Skip to content

Instantly share code, notes, and snippets.

@sidazhou
sidazhou / temp.java
Created November 29, 2019 12:27
Oh god this works
public class Temp {
public static int myf(int i, int j, Function<List<Integer>,Integer> fn) {
System.out.println("start");
List<Integer> myi= new ArrayList<>();
myi.add(i);
myi.add(j);
int retval = fn.apply(myi);
System.out.println(retval);
System.out.println("end");
import pickle
class Dummy:
def __init__(self,num):
self.num = num
dummy = Dummy(666)
print(dummy) # this is object pointer, not the object
stored = pickle.dumps({'my_object': dummy})
'''
Get a overview of the structure of a variable that is nested dict of list of dict ...
Usage:
recur_get_keys_print(dictlist)
'''
def recur_get_keys(dict_or_list, count=1):
if type(dict_or_list) is dict:
for key, value in dict_or_list.items():
yield {
@sidazhou
sidazhou / twoPGame.rb
Created October 3, 2014 02:41
adding 2 numbers correctly and in 5 seconds GAME
require 'colorize'
# # "Player 1: What does 5 plus 3 equal?"
# # Both players start with 3 lives. They lose a life if they mis-answer a question. If a player gets a question wrong, the game should output the new scores for both players, so players know where they stand.
# # The game doesn’t end until one of the players loses all their lives. At this point, the game should announce who won and what the other player’s score is.
def getRandNums
# [ (rand*10-5).round(1), (rand*10-5).round(1) ] # rounding errs
@sidazhou
sidazhou / dummyfile
Created October 8, 2014 00:44
war3 headache
this is dum
@sidazhou
sidazhou / sdtest
Created September 3, 2014 23:39
testin1234
puts 3+4