Skip to content

Instantly share code, notes, and snippets.

View anlai2's full-sized avatar

Andy Lai anlai2

  • Portland, OR
  • 09:53 (UTC -07:00)
View GitHub Profile
import tweepy;
consumer_key = 'CONSUMER KEY HERE'
consumer_key_secret = 'CONSUMER KEY SECRET HERE'
access_token = 'ACCESS TOKEN HERE'
access_token_secret = 'ACCESS TOKEN SECRET HERE'
key = tweepy.OAuthHandler(consumer_key, consumer_key_secret)
key.set_access_token(access_token , access_token_secret)
import tweepy;
consumer_key = 'CONSUMER KEY HERE'
consumer_key_secret = 'CONSUMER KEY SECRET HERE'
access_token = 'ACCESS TOKEN HERE'
access_token_secret = 'ACCESS TOKEN SECRET HERE'
class TweetListener(tweepy.StreamListener):
def on_status(self , status):
function nextPalindrome(num) {
let incrementSize = 1;
let incPalindrome = 0;
let decPalindrome = 0;
let sign = Math.sign(num);
while(incPalindrome === 0) {
if(sign === -1) {
var pal1 = ((num + incrementSize) * -1).toString().split('').reverse().join('');
} else {
@anlai2
anlai2 / CheckBalancedParen.js
Last active May 26, 2018 15:57
Check Balanced Parentheses/Bracket/Curly
/**
* @param {string} s
* @return {boolean}
*/
var isValid = function(s) {
let stack = new Stack();
for(let char of s) {
let top = stack.peek();
if(char === '}' && top === '{') {
@anlai2
anlai2 / ReverseInteger.js
Created May 23, 2018 03:12
Reverse Integer within Range
/**
* @param {number} x
* @return {number}
*/
var reverse = function(x) {
let sign = Math.sign(x);
let res = sign * parseInt(x.toString().split('').reverse().join(''))
if(res <= Math.pow(-2,31) || res >= Math.pow(2, 31) - 1) {
return 0;
@anlai2
anlai2 / DuplicateArray.js
Created May 23, 2018 03:03
Duplicates in an Array
/**
* @param {number[]} nums
* @return {number[]}
*/
var findDuplicates = function(nums) {
let duplicates = [];
let obj = {};
for(let num of nums) {
if(obj[num] && obj[num] !== 2){
@anlai2
anlai2 / BlackJack.py
Created October 28, 2017 17:46
BlackJack Python Project
from random import randint
import os
class Deck(object):
def __init__(self, values = ['nothing',1,2,3,4,5,6,7,8,9,10,11], cards = ['nothing','A', 'A', 'A', 'A', '2', '2', '2', '2', '3', '3', '3', '3', '4', '4', '4', '4',
'5', '5', '5', '5', '6', '6', '6', '6', '7', '7', '7', '7', '8', '8', '8', '8', '9', '9', '9', '9',
'10', '10', '10', '10', 'J', 'J', 'J', 'J', 'Q', 'Q', 'Q', 'Q', 'K', 'K', 'K', 'K', ]):
self.values = values
self.cards = cards
def totalCards(self):
@anlai2
anlai2 / TicTacToe.py
Created October 21, 2017 18:43
Tic Tac Toe Python Project
# 0 | 1 | 2
#---|---|---
# 3 | 4 | 5
#---|---|---
# 6 | 7 | 8
import os
class TicTacToe:
entries = "012345678";
usedEntries = [None] * 9;