Skip to content

Instantly share code, notes, and snippets.

View mutoo's full-sized avatar

Lingjia Liu mutoo

View GitHub Profile
@mutoo
mutoo / svnaddall.sh
Last active December 18, 2015 04:38
SVN add all unversioned files to SVN ...
alias svnaddall="svn st | grep ^? | awk '{print$2}' | xargs svn add"
class AVLIterator {
AVLTree tree;
Node begin;
Node end;
Node current;
AVLIterator(AVLTree t) {
this.tree = t;
current = begin = t.findMin(t.root);
end = t.findMax(t.root);
float[] x = {
88, 431, 431, 124
};
float[] y = {
115, 367, 188, 331
};
void setup() {
size(640, 480);
}
// Returns 1 if the lines intersect, otherwise 0. In addition, if the lines
// intersect the intersection point may be stored in the floats i_x and i_y.
char get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y,
float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y)
{
float s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x; s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x; s2_y = p3_y - p2_y;
float s, t;
function Random(initialValue) {
var A = 48271;
var M = 2147483647; // 2^31-1
var Q = (M / A) >> 0;
var R = M % A;
initialValue %= M;
if (initialValue < 0)
initialValue += M;
@mutoo
mutoo / safeNumber.js
Last active December 18, 2015 14:09
a simple way to avoid memory locator detecting a number's address;
var addProperty = function(obj, property, value) {
var salt = Math.random(), saltValue;
var saltGetter = function() {
return saltValue * salt;
};
var saltSetter = function(value) {
saltValue = value / salt;
};
//<script type="text/javascript">
var guess = (function() {
var code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var randomize = function(a, b) {
return Math.random() < 0.5 ? -1 : 1;
};
var total = 10;
var remain;
return {
@mutoo
mutoo / better_shuffle.js
Last active December 19, 2015 10:29
By counting the distribution of numbers after simple shuffle, statistics indicate that the probability of distribution of numbers is inequality;
var numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var total = [];
var testCount = 10000;
for (var i = 0; i < numbers.length; i++) {
total[i] = [];
for (var j = 0; j < numbers.length; j++) {
total[i][j] = 0;
}
};
@mutoo
mutoo / RPS.c
Created July 8, 2013 05:57
A simple Rock-paper-scissors Game implement with Table-Driven Approach
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(int argc, char **argv) {
/*
U\C R P S
R 1 0 2
P 2 1 0
@mutoo
mutoo / ELO_demo.pde
Created July 18, 2013 02:50
a simple simulator of ELO
import java.util.*;
static int count = 0;
class Player implements Comparable<Player> {
int id;
float score;
int win;
int lose;
Player() {