Programming

I have it working now. I think the collection of headers I have works everywhere.

I was kind of wondering if they have tech that knows whether user-agent is spoofed, because a real user-agent was definitely one of the headers that is required, and if I say I’m Chrome of a certain version but don’t send sec-ch-ua headers, for instance, then I’m presumably lying. The configuration I have now sends a Firefox user-agent. I am definitely not messing around with it any more to figure out what the minimum requirements are, I hope to never have to touch it again.

So when you say you have it working, it’s also working on AWS? Or did you have to spoof? This problem has been rattling around in my head for a day now and I’m really curious. Blocking an entire cloud provider just seems so absolute nuts from my perspective that I couldn’t imagine that was actually what was going on. But maybe I was wrong.

Nah I don’t think there were ever actually any IP bans. It seems that requests on certain IP ranges get served by different architecture than others. Australian IPs generally seemed to work with very basic headers, I didn’t need to send CORS headers or anything. Other IPs generally seem to require not only CORS headers but a raft of other finicky demands.

One interesting thing I found is that a CORS request with origin specified as www.nba.com (as opposed to stats.nba.com) got a 405 Method Not Available to CORS’s preflight OPTIONS call, while a CORS request from any other domain simply resulted in the request being ignored. I ran into that by accident and it made me figure out that I was missing the Origin header. I hadn’t been very careful with my CORS headers before that as I didn’t think that could possibly be the issue, since locally I was having requests succeed with no CORS information whatsoever.

Edit: Complicating figuring this out about IP ranges was the fact that my friend claimed to have tried an Australian VPN IP on the server and had it fail. I’m not sure if he screwed it up or whether he happened to use an IP which didn’t geolocate to Australia. For example Google’s cloud servers physically located in Australia are resolved to a US location by some DNS providers; I’ve run into this before when consuming Pinnacle’s API.

now that makes a lot more sense to me. Great job figuring that out, you might be one of the only people to have done it! I was running into a lot of dead ends when researching this and all conclusions led to the IP block explanation which just wasn’t sitting right with me. Thanks for satisfying my curiosity.

This must either be a real passion project or you’re getting paid a lot more than I do, that just sounds like the biggest nightmare ever. But I guess when you’re basically hacking a website to do something it doesn’t want to or wasn’t designed to do, it comes with the territory. Do not envy you at all

Yeah I do a bunch of trying to pull data off websites where it’s not designed for it. This one was annoying but at least what I’m ultimately consuming is JSON with sensible values. Probably the absolute worst is this odds provider called DonBest. Consuming their data I was constantly having my mind blown by how horrifying their backend must be. Like they output total lines as things like “210.5u05” which means that the under odds is -105. What’s the over odds? Well, it’s up to you to know how much juice that site generally charges; could be -105 or -115. Not only that but they routinely output total nonsense like “210.5u1187”, your guess is as good as mine how data like that ends up in their database and how it’s being stored. They output timestamps with no timezone information; I worked out that they were Pacific time, only when daylight saving rolled around I discovered that nope, they are actually output with a static offset of UTC-8. Etc etc.

1 Like

I have read this thread and most of it is Greek to me. Is this thread also for noob questions?

Go nuts

CLIFFS: How do I create a list of mixed variables in C#?


My programming experience after computer science class in school adds up to about a week. Last year I thought it might be fun to learn some programming. With the help of google, youtube and stackoverflow.com I was able to make a word jumble game over the easter weekend in C# using Visual Studio. There is a lot that I did that I didn’t really understand. It just worked.

This is all picture boxes and labels.

When I got the basic functionality done I lost interested. Fast forward to about 2 weeks ago I wanted to try again. I thought of a turn-based game inspired by Heroes of Might & Magic - Chess Royale:

Now the problem I have run into:

Once there is more than one hero and one monster I needed some kind of pathfinding. Luckily others have solved this for me. I found good explanations of A* and Dijkstra. I opted for the latter because there might be more than one destination/targets (=the hero characters).

To implement this I need to store four variables for each node: two points (the node’s and the parent node’s x/y coordinates) and two integers (the G and H cost). I could create an array with mixed variables or convert the points to integers and back every time I need them.
Then add those arrays to the lists.

Now Microsoft says

This is the example code:

        // Create a list of parts.
        List<Part> parts = new List<Part>();

        // Add parts to the list.
        parts.Add(new Part() {PartName="crank arm", PartId=1234});
        parts.Add(new Part() { PartName = "chain ring", PartId = 1334 });
        parts.Add(new Part() { PartName = "regular seat", PartId = 1434 });

How do I adapt this for my purposes?
Something like…?

        // Create a list of nodes.
        List<Node> nodes = new List<Node>();

        // Add nodes to the list.
        parts.Add(new Part() {nodeCoordinates=(0,0), parent=(1,1), g=0, h=0});

(Sorry for the long post)

For those not following the weekly expenses thread, I bit the bullet and got a brand new macbook pro instead of rolling the dice on another 2015 model off ebay (last one crapped out after less than a year and the intervening years are shite).

I finally understand how sites like USA Today and salon.com can be so horrible. They load tolerably well on a brand new quad-core mac - which is probably what all the developers, testers, and other stakeholders have. Or similar PC. It’s not like that 2015 mac pro I had was slow or memory challenged.

https://twitter.com/DudeWhoCode/status/1306153292221669376

Not familiar with C#, wish I could be more helpful. If I’m understanding you correctly you want a list of some object that represents all those fields? Your method looks fine to me, but if it’s a small project I wouldnt worry too much about being “correct” if it works for you. It doesnt have to be production quality.

1 Like

I have a 2015 macbook and I have also found that some sites are horrifically slow for me. hsreplay.net being the biggest offender.

Facebook and stuff is fine. Anything that tries to load a lot of ads tends to be sluggish.

This is exactly how me and ggoreo run Unstuck.

I’m the guy eating the sandwich while my team frantically puts out fires.

    // Create a list of nodes.
    List<Node> nodes = new List<Node>();

    // Add nodes to the list.
    parts.Add(new Part() {nodeCoordinates=(0,0), parent=(1,1), g=0, h=0

In C#, Java, or C++, the answer is very similar: you create a class. I don’t understand your problem, but from the description you want a class. Start like this:
class Node {
public:
Point location;
Point parent_location;
int g_cost;
int h_cost;
};
Now to create an instance:
Node node = new Node();
node.g_cost = 32;

Setting each field in a new line is clumsy so you can add an initialization function called a constructor.
class Node {
public:
Node(Point locate, Point parent, int g, int h) {
location = locate;
parent_location = parent;
g_cost = g;
h_cost = h;
}
Point location;
Point parent_location;
int g_cost;
int h_cost;
};
Now you can initialize as you make it:
Node node = new Node(new Point(0, 0), new Point(1, 1), 3, 5);

A class is a container for related variables. Use new to make an instance of a class. Use variable name dot member name to access a variable.

This solves your immediate problems. In the future you can do more with your class. You can add functions inside the class which can act on the variables. Then a class is a container for related variables, and methods to act on the variables.

1 Like

Thank you. I will try this and report back.

Chips beat me to the punch by a few minutes. I would keep a reference to the parent node instead of having a parent Point. Also Point in C# is a built-in class but it has floating-point coordinates rather than integers, so I wouldn’t use it.

You don’t need to do this in C#, you can use an object initializer as below. They’re very readable for anyone following the code, as it’s explicit what is being assigned to which property without having to look up the constructor syntax.

public class Node() {

	public Node Parent {get; set;}
	public int X {get; set;}
	public int Y {get; set;}
	public int G {get; set;}
	public int H {get; set;}
	
}

.

var nodes = new List<Node>();
nodes.add(new Node() { Parent = someNode; X = 0; Y = 0; G = 0; H = 0; });
2 Likes

You don’t need to do this in C#, you can use an object initializer as below.

Oh yes, use this!
I miss C#.

Tell me about it. I spend my days at the moment writing Java, it sucks. I miss object initializers. And auto-properties. And extension methods.