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
#!/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' |
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 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()]); |
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 PalindromeNumber { | |
public static boolean checkifPalindrome(int num) { | |
if (num < 0) { | |
return false; | |
} | |
int div = 1; | |
while (num / div >= 10) { | |
div = div * 10; | |
} |
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
// use case sample | |
this.$(this.selectItemsTag).select2({ | |
placeholder:"Enter an items", | |
multiple:true, | |
minimumInputLength:1, | |
maximumSelectionSize:200, | |
initSelection : function (element, callback) { | |
var data = []; |
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
# 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. |
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
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 |
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 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 |
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
### 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: |