Skip to content

Instantly share code, notes, and snippets.

*** Date: Sunday, September 28, 2014 at 3:21:13 PM Central European Summer Time
*** Platform Details:
*** System properties:
applicationXMI=org.eclipse.ui.workbench/LegacyIDE.e4xmi
awt.toolkit=sun.lwawt.macosx.LWCToolkit
derby.system.home=/Users/kaiyin/personal_config_bin_files/workspace/.metadata/.plugins/de.walware.ecommons.edb
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=4.4.0.I20140606-1215
@kindlychung
kindlychung / check_endian.c
Last active August 29, 2015 14:08
check whether the system is little or big endian
#include <stdio.h>
int main(int argc, const char *argv[])
{
int x = 1;
char *y = (char*)&x;
printf("If next line prints 1, then it's little-endian.\n")
printf("%c\n", (*y)+48);
return 0;
}
@kindlychung
kindlychung / collect_links.py
Last active August 29, 2015 14:11
master object oriented programming in python
@kindlychung
kindlychung / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kindlychung
kindlychung / abstract_class.py
Last active August 29, 2015 14:11
python oop, object oriented
class Animal:
__metaclass__ = ABCMeta
@abstractmethod
def say_something(self):
return "I'm an animal!"
class Cat(Animal):
def say_something(self):
s = super(Cat, self).say_something()
@kindlychung
kindlychung / 1.hs
Last active August 29, 2015 14:12
learn you a haskell
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
f `on` g = \x y -> f (g x) (g y)
Blog china kids music yahoo want wrong service tech saying lots had address working following years didn internet wants photos former technology being traffic small past full november experience door company learn paper research sell self sometimes couple video makes next process books could stuff audio web become problem details worth provide feeds another john away hand thanks night test update guy cost product still non drop year tried america amp start podcast month advertising ask almost systems american culture close pictures smart showing popular application e dvd camera links including during university special times party home display star likely room before personal digg yes yet save deal magazine down weekend international box visit making interesting morning enough sound images released again u hour days needs coming through services point cut source though planet entire access turn happens development school however news conference n gave level posts goes sure later case director without list ver
@kindlychung
kindlychung / 1.clj
Last active August 29, 2015 14:13
clojure for the true and brave
(ns clojure-noob.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
(println "hi there")
(defn sum [xs] (reduce + xs))
(defn avg [xs] (/ (sum xs) (count xs)))
(sum [1 2 3])
(avg [1 2 3])
(defn stats [numbers]
(map #(% numbers) [count sum avg])
)
(stats [1 2 3 4])
(defn even-numbers
([] (even-numbers 0))
([n] (cons n
(lazy-seq (even-numbers (+ n 2)))))
)
(take 10 (even-numbers 1))