This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is dum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts 3+4 | |