Skip to content

Instantly share code, notes, and snippets.

View kenchangh's full-sized avatar
🎀

Ken Chan kenchangh

🎀
  • World
View GitHub Profile
@kenchangh
kenchangh / facebook.com.js
Created August 16, 2014 13:20
Dotjs for Facebook
/*
Thanks, Facebook.
*/
var adsDiv = $('#pagelet_ego_pane');
adsDiv.remove();
@kenchangh
kenchangh / google.com.my.js
Created August 16, 2014 13:16
Dotjs file for Google
/*
Thanks, Google.
*/
var adsDiv = $('div#taw');
adsDiv.remove();
$('button#gbqfb').click(function() {
adsDiv.remove();
@kenchangh
kenchangh / plkn-hack.js
Last active August 29, 2015 14:05
"Changing" the results of PLKN
var resultBox = $('#result-box');
function makeBox(details) {
var success = details.success;
var participantName = details.name;
var icNumber = details.ic;
var newResults;
@kenchangh
kenchangh / ic_generator.py
Last active August 29, 2015 14:05
Generates random I.C. numbers, well... for fun.
##########
from random import randrange, choice
##########
def generate_ic(times=10):
YEAR = 97
PLACE = 10
@kenchangh
kenchangh / organize_django
Created August 11, 2014 04:03
Organizing big projects in Django
Organizing in Django
------------------
This is just an example of a project setup. See [this link](http://zacharyvoase.com/2010/02/03/django-project-conventions/).
```
PROJECT_ROOT/
|-- app/ # Site-specific Django apps
|-- etc/ # A symlink to an `etcs/` sub-directory
|-- etcs/ # Assorted plain-text configuration files
@kenchangh
kenchangh / practice.jl
Last active August 29, 2015 14:04
A practice on Julia.
# This is just for practice!
# Single line comment
#=
This is a multiline comment
=#
# Function syntax
function name(x, args...)
# do something
@kenchangh
kenchangh / variable_styles.md
Last active August 29, 2015 14:04
Julia's style conventions for variables.

Stylistic Conventions

While Julia imposes few restrictions on valid names, it has become useful to adopt the following conventions:

  • Names of variables are in lower case.
  • Word separation can be indicated by underscores ('_'), but use of underscores is discouraged unless the name would be hard to read otherwise.
  • Names of Types begin with a capital letter and word separation is shown with CamelCase instead of underscores.
  • Names of functions and macros are in lower case, without underscores.
  • Functions that modify their inputs have names that end in !. These functions are sometimes called mutating functions or in-place functions.
@kenchangh
kenchangh / hot_score.jl
Last active August 29, 2015 14:04
A rewrite of the hot score algorithm in Julia
# The epoch seconds when the algorithm is implemented
const SET_TIME = 1403975999.39
function hot(score, created, comments, user_rep)
# To make the score scale smaller
score = log10(abs(score))
if score > 0
sign = 1
elseif score < 0
sign = -1
@kenchangh
kenchangh / prom_vote.py
Created July 4, 2014 17:41
A script that automates Prom King / Queen voting for SMK Damansara Jaya
import requests
import thread
def make_vote(gender):
if gender == 'f':
url = 'https://docs.google.com/forms/d/1RBXC6SrZ9D86qksVVlfybfNBi-zEG9npsIHWWNas8JM/formResponse'
form_data = {
'entry.1739159996': 'Karina Lee&nbsp;-5 Bal'
}
@kenchangh
kenchangh / validate.py
Created June 30, 2014 09:29
Validation methods in Google App Engine
##########
import re
import hmac
import random
from hashlib import sha256
from base_handler import BaseHandler
from google.appengine.ext import db