View gist:5748a9a262f5dd2e0b3d4b1102dfbeca
### Keybase proof | |
I hereby claim: | |
* I am ypxu on github. | |
* I am yingxu (https://keybase.io/yingxu) on keybase. | |
* I have a public key ASA5kc7FdnEa48Gn0Tb_gP7sDLO77quXivCdiuSaqHDELgo | |
To claim this, I am signing this object: |
View pingpong.scala
import akka.actor.{Actor, ActorRef, ActorSystem, Props} | |
case object PingMessage | |
case object PongMessage | |
case object StartMessage | |
case object StopMessage | |
class Ping(pongRef: ActorRef) extends Actor { | |
var count = 0 |
View zigzag_matrix.py
class Solution(object): | |
def flatten(self, matrix): | |
if not matrix: | |
return [] | |
m, n = len(matrix), len(matrix[0]) | |
delta_move = [(-1, 1), (1, -1)] # right_up, left_down | |
delta_pivot = [(1, 0), (0, 1)] # down, right | |
result = [] | |
i, j = 0, 0 |
View manifest.py
# a - j, Z, M,K,P,Q | |
""" | |
Thoughts | |
Consider the message a tree, walk the message until we meet the valid | |
considition which there's no more charactors. | |
When we encouter a - j, we substract one from the message. When we see | |
Z, we look for next valid message, when we counter M,K,P,Q, we look | |
for two valid message. |
View gist:4998881
// use case sample | |
this.$(this.selectItemsTag).select2({ | |
placeholder:"Enter an items", | |
multiple:true, | |
minimumInputLength:1, | |
maximumSelectionSize:200, | |
initSelection : function (element, callback) { | |
var data = []; |
View gist:2325452
public class PalindromeNumber { | |
public static boolean checkifPalindrome(int num) { | |
if (num < 0) { | |
return false; | |
} | |
int div = 1; | |
while (num / div >= 10) { | |
div = div * 10; | |
} |
View MajorityVoting.java
import java.math.BigDecimal; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class MajorityVoting { | |
public static String checkForWinner(List<String> votes) { | |
String winner = "Nobody"; | |
String[] votesArr = votes.toArray(new String[votes.size()]); |
View aws_usage.py
#!/usr/bin/env python | |
""" | |
A script to query the Amazon Web Services usage reports programmatically. | |
Ideally this wouldn't exist, and Amazon would provide an API we can use | |
instead, but hey - that's life. | |
Basically takes your AWS account username and password, logs into the | |
website as you, and grabs the data out. Always gets the 'All Usage Types' |