Skip to content

Instantly share code, notes, and snippets.

@amomin
amomin / .gitignore
Last active March 15, 2016 03:43
Monty Hall
.ipynb_checkpoints/*
@amomin
amomin / README.markdown
Last active December 5, 2015 01:19
Conditional 302 redirect

Conditional redirect based on use case from work.

Page a.php is moving to b.php, and b.php is not yet ready, but for some reason (well, we'll assume there is a reason) it is necessary to direct users to b.php to tell them that the new content will be hosted there, and then send them back to the original content at a.php without redirecting them again to b.php.

This is one way to do it in php. We introduce a query string parameter on the request to a.php that - if present - will force the content to load with 200 response; otherwise it 302 redirects to b.php. When b.php is completely ready it will be turned into a permanent 301 redirect.

(In reality a.php and b.php live on different domains but this example adapts easily to that case - and you could replace the query string condition with something else, like a referal domain check or other.)

@amomin
amomin / README.markdown
Last active November 25, 2015 02:11
Slanted Rows

Example of slanted row layout.

Two examples are given - the first only works if the width is fixed, the second is responsive.

@amomin
amomin / README.markdown
Last active July 11, 2024 14:39
Converting a folder into a git submodule
@amomin
amomin / README.markdown
Last active November 1, 2015 16:47
Notes on an error in building a meanjs project for production

Building production on a mean.js stack application

By mean.js I mean specifically an application based on the meanjs framework hosted here.

For reference, the following posts helped me identify and fix my problem.

It works mostly like how you would expect. From a vanilla working development environment, the following should work:

@amomin
amomin / README.md
Last active October 17, 2015 03:27
Building 64-bit emacs on Windows

Building 64-bit emacs on Windows

Licensed under CC BY 4.0.

This was actually reasonably straightforward....

Installing msys2

I installed msys2 for performing the build. This was pretty straightforward:

@amomin
amomin / scripts.markdown
Last active September 23, 2015 00:05
Things I forget

Firewalls

Add rule to open port 3000 for nodejs on line 2001 (which must be before the DROP rule)

First get the line numbers

$ sudo iptables -nL --line-numbers
@amomin
amomin / cygwin.markdown
Last active October 19, 2022 18:52
Cygwin notes

Notes on making cygwin work

  • See this so answer using mkpasswd for one way to change your default home directory
  • You can always add packages after install by re-running setup.

Packages to add

  • wget (Web)
  • curl (PHP, Net)
  • ssh (Net)
@amomin
amomin / README.markdown
Created September 22, 2015 15:45
Git log pretty

Git log alias

This short but sweet post shows how to create a simple command to create an alias to a suped-up git log.

It's just a one-liner

$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@amomin
amomin / gist:09ebffc5ca25c7822c07
Last active August 29, 2015 14:17
instructions.md

A very basic Apache set-up to host python apps with mod WSGI

This is almost all taken from (https://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide) - I'm adding something here because I did not realize that I had port 81 blockked on my firewall and lost a bit of time figuring that out (was able to wget the expected url but could not navigate in a browser). Anyway, here are the basic steps. See the link google code link though.

In my case, I have an already running php server where I just want to test out some python web apps and don't particularly care about performance or anything like that. In reality, it might make sense to have a separate instance of apache running for the python apps. But that's beyond the scope of what I'm trying to accomplish today, which is just to get a hello world python app up and running.

  1. Install mod_wsgi: sudo apt-get install libapache2-mod-wsgi
  2. For this installation we will run python apps on a different port, namely port 88. It is not necessary to do