Note to self…
Note to self…
'Authorization': 'Basic ' + btoa(username+':'+password), but in the proxy script, that header had vanished.
Turns out it was Apache stripping it away. Don’t know if it’s because of security or because Apache thinks that, hey, I’m the one dealing with this stuff so no point sending it to the script. Anyways, seems you can get it back by doing the following in an .htaccess file:
Now the header is passed through to the API successfully and I’m no longer getting 401 Unauthorized back
To cleanly redirect HTTP to HTTPS with IIS, first install the URL Rewrite module, and then add the following to your web.config. Also remember to have bindings defined for your site for both HTTPS(443) and HTTP(80).
I love the file search (ctrl+shift+f) and quick navigate (ctrl+p) in Sublime Text. What can be annoying however is when these present you with library code in your project, files related to source control, binary files or minified files.
Since I keep forgetting how to clean that up, here’s a note to self (and others) on how to clean that up. Easy peasy.
Below is an example from one of my current projects which excludes the git repo folder, a cache folder, minified files and some binary files.
.htaccess redirects all traffic to a different domain and preserves the path.
The following redirects non-www to www version, also preserving the path.
And hopefully I’ll remember I put this here the next time I’ve forgotten how to do this…
In a project at work we were going to merge a bunch of PDfs and Word documents into a single PDF. The ordering irrelevant except that certain files had to be before all the others. Solved it initially like this:
Found it a bit ugly though, and decided to ask a question about other ways on StackOverflow. Got several interesting answers and inspired by those and some further thinking I tried to make a generic solution myself, which I thought I could also blog here so I definitely know where to find it if I ever need it again…
One issue here might be that the predicates will be called several times per item, which could be bad if working on a huge list. Haven’t really benchmarked it though so could be fine for all I know. For smaller uses it shouldn’t matter much either way. Very curious to know about ways to optimize this though, so do let me know in the comments below if you have any good ideas!
The nice thing about it being an IComparer is that you could push this into both OrderBy and ThenBy, and also use it in for example ordered dictionaries, priority queues, etc, and since it uses a list of fully generic predicates you could order things by pretty much anything with a yes/no answer
To make the final code even cleaner the ordering could be encapsulated in a sublcass like following, which is what I did in my actual code too: