Skip to content

Instantly share code, notes, and snippets.

View littleq0903's full-sized avatar
🎱
Wanna see some magic?

Colin Su littleq0903

🎱
Wanna see some magic?
View GitHub Profile
@littleq0903
littleq0903 / gist:521e0bc6c9284117cf91
Created April 2, 2015 08:44
Random Number Generator
float rng(float a, float b, int m, int x0, int n) {
float temp;
if (n == 1) {
temp = x0;
} else {
temp = rng(a, b, m, x0, n-1);
}
return ((int)(a * temp + b) % M) / (float)M;
}
@littleq0903
littleq0903 / login.py
Created April 1, 2015 14:16
How to authenticate NCCU student accounts
# use cgi entry point
https://github.com/littleq0903/FacemapNCCU-Server/blob/master/src/utilities.py#L44
Notice: this code uses `urlfetch` module of Google App Engine, you have to replace it with `urllib` to make it working.
# use POP3 entry point
# here's a pop3 authentication backend for Django. set it to "nccu.edu.tw" (NCCU's POP3 server)
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
The auth via trust pop3 server for Django http://www.djangoproject.com
set up the trust pop3 server domain in AUTH_POP_SERVERS, you could have one or many
trusted pop3 server
require python package python-dnspython, http://www.dnspython.org/
for smart MX record lookup
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@littleq0903
littleq0903 / README.md
Last active August 29, 2015 14:11
My Squirrel Settings

clone command: git clone [email protected]:/0cc95cc4e122f000c2f9.git my-squirrel-settings

@littleq0903
littleq0903 / gcloud-bigquery-proposal.md
Last active August 29, 2015 14:10
gcloud BigQuery Proposal

gcloud bigquery proposal

Abstract

This is the proposal of gcloud BigQuery API which is being implemented by Colin Su.

Basically the design follows the structure of both gcloud.storage and gcloud.datastore, so they may look familiar.

Classes

cd path/to/tagtoo-open-bidder
cd tagtoo-openbidder-utils/scripts/deployer
# editing config file, set the ip to bidder
vim open-bidder-material/metadata/tanx-bidder-metadata.json
# editing ssh key location, username
vim fabfile.py
# deploy ssh keys
@littleq0903
littleq0903 / rock.js
Created July 30, 2014 02:17
code of Build "Rock, Paper, Scissors"
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
console.log(computerChoice);
# Just like its CoffeeScript cousin, LiveScript uses number symbols for
# single-line comments.
/*
Multi-line comments are written C-style. Use them if you want comments
to be preserved in the JavaScript output.
*/
# As far as syntax goes, LiveScript uses indentation to delimit blocks,