Skip to content

Instantly share code, notes, and snippets.

View nirlanka's full-sized avatar

Nir Lanka nirlanka

  • SGX
  • Singapore
View GitHub Profile
@ryanflorence
ryanflorence / static_server.js
Last active April 26, 2024 16:18
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@zeuxisoo
zeuxisoo / gist:980174
Created May 19, 2011 04:15
How to use git diff to patch file

Create patch file

git diff --no-prefix > [path file name]

Apply path file

patch -p0 < [path file name]

@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active May 14, 2024 18:19
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@fredrikw
fredrikw / mediakeys.py
Created November 15, 2012 11:07
Python script to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys. Easiest used in combination with a launcher/trigger software such as Quicksilver.
#!/usr/bin/python
# CLI program to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys.
# Easiest used in combination with a launcher/trigger software such as Quicksilver.
# Main part taken from http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
# Glue to make it into cli program by Fredrik Wallner http://www.wallner.nu/fredrik/
import Quartz
import sys
@sdiehl
sdiehl / kaleidoscope.py
Created March 9, 2013 19:09
LLVMpy Tutorial
import sys
import re
from llvm.core import Module, Constant, Type, Function, Builder
from llvm.ee import ExecutionEngine, TargetData
from llvm.passes import FunctionPassManager
from llvm.core import FCMP_ULT, FCMP_ONE
from llvm.passes import (#PASS_PROMOTE_MEMORY_TO_REGISTER,
PASS_INSTCOMBINE,
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git

Moved

Now located at https://github.com/JeffPaine/beautiful_idiomatic_python.

Why it was moved

Github gists don't support Pull Requests or any notifications, which made it impossible for me to maintain this (surprisingly popular) gist with fixes, respond to comments and so on. In the interest of maintaining the quality of this resource for others, I've moved it to a proper repo. Cheers!

@staltz
staltz / introrx.md
Last active May 22, 2024 13:59
The introduction to Reactive Programming you've been missing
@stefanocoding
stefanocoding / huawei_e397b.md
Created February 24, 2018 03:43
Make modem Huawei E397B work on Mac OS X
  1. Install the Connection Manager that is launched when you connect the modem to the Mac
  2. Download the source of usb_modeswitch from here http://www.draisberghof.de/usb_modeswitch/ (at the moment of writing this the file appears with the name usb-modeswitch-2.5.2.tar.bz2)
  3. Run make in the directory of the source you downloaded
  4. Run sudo ./usb_modeswitch -v12d1 -p1505 -X in the same directory

If the last step returns an error (I don't remember the error now, but I was getting an error related to usb_modeswitch not being able to take control of the modem to perfom changes):

  1. Unplug the modem and plug it again
  2. As soon as you plug the modem again, run sudo ./usb_modeswitch -v12d1 -p1505 -X repatedly until you get a successful result
  3. Open Connection Manager and your modem is going to be detected
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active May 23, 2024 02:58
crack activate Office on mac with license file