Skip to content

Instantly share code, notes, and snippets.

View p53ud0k0d3's full-sized avatar

Vishnu Ashok p53ud0k0d3

View GitHub Profile
from trello import TrelloClient
import requests
API_KEY = ""
API_SECRET = ""
TOKEN = ""
BOARD_NO = 0
LIST_NO = 10
@p53ud0k0d3
p53ud0k0d3 / Cleanup Tweet
Created April 6, 2017 14:11
How to cleanup tweets
#tweet is a single tweet
def clean_tweet(tweet):
tweet = re.sub("https?\:\/\/", "", tweet) #links
tweet = re.sub("#\S+", "", tweet) #hashtags
tweet = re.sub("\.?@", "", tweet) #at mentions
tweet = re.sub("RT.+", "", tweet) #Retweets
tweet = re.sub("Video\:", "", tweet) #Videos
tweet = re.sub("\n", "", tweet) #new lines
tweet = re.sub("^\.\s.", "", tweet) #leading whitespace
tweet = re.sub("\s+", " ", tweet) #extra whitespace
@p53ud0k0d3
p53ud0k0d3 / maximizing-xor.py
Created March 19, 2015 15:56
HackerRank Maximizing XOR
#!/bin/python
# Complete the function below.
def maxXor( l, r):
largest = 0
for i in xrange(l, r+1):
for j in xrange(l, r+1):
if (i^j) > largest:
@p53ud0k0d3
p53ud0k0d3 / utopian-tree.py
Created March 19, 2015 15:49
HackerRank Utopian Tree
height = 1
N = []
for _ in xrange(int(raw_input())):
N.append(int(raw_input()))
for item in N:
if item == 0:
print 1
else :
s = raw_input()
s = s.lower()
is_pangram = lambda s: not set('abcdefghijklmnopqrstuvwxyz') - set(s.lower())
if is_pangram(s) == True:
print "pangram"
else:
print "not pangram"
@p53ud0k0d3
p53ud0k0d3 / remove-the-first-capital-letter-from-each-array-element.sh
Created March 19, 2015 14:35
Remove the first capital letter from each element
i=1
while read word
do
words[i]=$word
i=$(( $i + 1 ))
done
echo ${words[@]/[A-Z]/.}
@p53ud0k0d3
p53ud0k0d3 / display-the-third-element-of-an-array.sh
Created March 19, 2015 14:20
Display an element of an array
i=0
while read x
do
arr[i]=$x
i=$i+1
done
echo ${arr[3]}
@p53ud0k0d3
p53ud0k0d3 / concatenate-an-array-with-itself.sh
Created March 19, 2015 14:17
HackerRank Concatenate an array with itself
i=0
while read x
do
arr[$i]=$x
i=$i+1
done
arr=(${arr[@]} ${arr[@]} ${arr[@]})
echo ${arr[@]}
@p53ud0k0d3
p53ud0k0d3 / filter-an-array-with-patterns.sh
Created March 19, 2015 13:57
HackerRank Filter An Array With Patterns
i=0
while read x
do
arr[$i]=$x
i=$i+1
done
arr=(${arr[@]//*a*})
arr=(${arr[@]//*A*})
if [ ${#arr[@]} -eq 0 ]
then
@p53ud0k0d3
p53ud0k0d3 / slice-an-array.sh
Created March 19, 2015 13:39
HackerRank Slice An Array
i=0
while read x
do
arr[$i]=$x
i=$i+1
done
echo ${arr[@]:3:5}