Skip to content

Instantly share code, notes, and snippets.

View remoharsono's full-sized avatar

Remo Harsono remoharsono

View GitHub Profile
@huyz
huyz / main_decompiled.js
Created September 6, 2011 12:32
Google+ Translate extension main.js decompiled
/* Copyright 2011 Google */
(function() {
var injectionScript = fillInTemplate("(function(){({{$code}})();})();", {
code: window.injection.toString()
}),
injectorScript = fillInTemplate("(function(){({{$code}})();})();", {
code: window.injector.toString()
});
delete window.injector;
delete window.injection;
@remoharsono
remoharsono / shape2mysql
Created May 4, 2016 17:46 — forked from rugbyprof/shape2mysql
Add shapefile to MySQL
ogr2ogr -f MySQL MySQL:DATABASENAME,host=localhost,user=USER,password=PASSWORD SHAPEFILE.shp -nln TABLENAME -update -overwrite -lco engine=MYISAM
@harrisj
harrisj / gist:b652f80fb55b6301b4ed
Last active July 21, 2016 05:23
Slack notification for election_results
class SlackNotifier
def self.notify(load_id)
notify_first_votes(load_id)
notify_calls(load_id)
notify_runoffs(load_id)
notify_uncalls(load_id)
notify_ap_uncalls(load_id)
end
def self.notify_first_votes(load_id)
from pyrabbit.api import Client
username = 'guest'
password = 'guest'
cl = Client('localhost:15672', username, password)
queues = [q['name'] for q in cl.get_queues()]
for q in queues:
#if q.startswith('Dispatch.259'):
print ('deleting...' + q)
cl.delete_queue('/', q)
@tinvaan
tinvaan / models.py
Created June 3, 2018 14:12
Code snippet to demonstrate how a Django model can be made immutable on certain condition. Hint : Override the save() method for the model in question.
from django.db import models
from django.utils import timezone
class Bank(models.Model):
bank_ifsc = models.CharField(max_length=200, blank=False, primary_key=True)
bank_name = models.CharField(max_length=200, blank=False)
bank_addr = models.CharField(max_length=400, blank=True)
def __str__(self):
@donrokzon
donrokzon / django.py
Last active June 3, 2018 14:36
Django
mkdir tutorial
cd tutorial
# Create a virtualenv to isolate our package dependencies locally
virtualenv env
source env/bin/activate # On Windows use `env\Scripts\activate`
# Install Django and Django REST framework into the virtualenv
pip install django
pip install djangorestframework
@RaphaelAslanian
RaphaelAslanian / KMP_algo.py
Last active November 26, 2018 02:19
Implementation of the Knuth-Morris-Pratt algorithm
"""
This module contains an implementation of the Knuth-Morris-Pratt algorithm allowing to look for sequence matching.
For example if you want to find the sequence [1, 2, 3] in [2, 3, 1, 2, 3, 5, 6], you could do:
find_sequence([2, 3, 1, 2, 3, 5, 6], [1, 2, 3])
This algorithm is especially interesting in case of many partial matches. Otherwise, you could simply use a brute
force search with correct performances.
The main function to use here is find_sequence which actually performs the KMP algorithm.
Julia likes to study KMP algorithm again using lecture note. What she likes to do is to go over the lecture
notes word by word, and then focus on thinking process.
She started to review KMP using Chinese blog, but she found out that the blog is not clear, so she likes to
follow up with more detail lecture note.
She likes to write and also she likes to read good writing of the KMP algorithm.
https://www.ics.uci.edu/~eppstein/161/960227.html
@blagoeres
blagoeres / Enable HTTP2 (h2) in NGINX.md
Last active March 3, 2019 05:30
🌟 Hypertext Transfer Protocol Version 2 (HTTP/2) in NGINX ⭐
@blagoeres
blagoeres / .md
Last active March 3, 2019 05:31
⭐ Frontend tooling & development environment for OS X

Setup your development environment for OS X

I bought new Macbook Pro 15 Retina. These are tools I like to install on macOS operating system.

Checklist

Prep OS X

  • Download and install latest version of Xcode from the Mac App Store.
  • Download and install Apple's Command Line Tools by issuing this command xcode-select --install