Skip to content

Instantly share code, notes, and snippets.

View ravikiranj's full-sized avatar

Ravikiran Janardhana ravikiranj

View GitHub Profile
@ravikiranj
ravikiranj / infinte_scroll_3.php
Last active September 26, 2015 07:07
infinite_scroll_final_touch
<?php
function init(){
$offset = 0;
$xhr = false;
if(!empty($_GET['offset'])){
$offset = $_GET['offset'];
$xhr = true;
}
$limit = 15;
$data = getRSSFeedItems($limit, $offset);
@ravikiranj
ravikiranj / infinte_scroll_4.js
Last active September 26, 2015 07:07
Instantiating YUI3 and calling _handleScroll function
YUI().use('node', 'event', 'io-base', function(Y){
var updateInitiated;
var page;
var retries;
var maxRetries;
var allStoriesFetched;
function init(){
var self = this;
//Initialize updateInitiated flag and pagination unit
@ravikiranj
ravikiranj / infinte_scroll_5.js
Last active September 26, 2015 07:07
Checking the condition and initiating an AJAX update followed by page update
function handleScroll(){
var self = this;
var scrollPos;
if(this.updateInitiated){
return;
}
//Find the pageHeight and clientHeight(the no. of pixels to scroll to make the scrollbar reach max pos)
var pageHeight = document.documentElement.scrollHeight;
var clientHeight = document.documentElement.clientHeight;
//Handle scroll position in case of IE differently
@ravikiranj
ravikiranj / tw-1.py
Last active December 9, 2020 02:57
preprocess tweets
#import regex
import re
#start process_tweet
def processTweet(tweet):
# process the tweets
#Convert to lower case
tweet = tweet.lower()
#Convert www.* or https?://* to URL
@ravikiranj
ravikiranj / tw-2.py
Created May 8, 2012 20:43
preprocess tweet words
#initialize stopWords
stopWords = []
#start replaceTwoOrMore
def replaceTwoOrMore(s):
#look for 2 or more repetitions of character and replace with the character itself
pattern = re.compile(r"(.)\1{1,}", re.DOTALL)
return pattern.sub(r"\1\1", s)
#end
@ravikiranj
ravikiranj / tw-4.py
Created May 8, 2012 21:10
Feature extractor code
#Read the tweets one by one and process it
inpTweets = csv.reader(open('data/sampleTweets.csv', 'rb'), delimiter=',', quotechar='|')
tweets = []
for row in inpTweets:
sentiment = row[0]
tweet = row[1]
processedTweet = processTweet(tweet)
featureVector = getFeatureVector(processedTweet, stopWords)
tweets.append((featureVector, sentiment));
#end loop
@ravikiranj
ravikiranj / tw-5.csv
Created May 8, 2012 21:13
Sample Tweets
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 6.
|positive|,|@PrincessSuperC Hey Cici sweetheart! Just wanted to let u know I luv u! OH! and will the mixtape drop soon? FANTASY RIDE MAY 5TH!!!!|
|positive|,|@Msdebramaye I heard about that contest! Congrats girl!!|
|positive|,|UNC!!! NCAA Champs!! Franklin St.: I WAS THERE!! WILD AND CRAZY!!!!!! Nothing like it...EVER http://tinyurl.com/49955t3|
|neutral|,|Do you Share More #jokes #quotes #music #photos or #news #articles on #Facebook or #Twitter?|
|neutral|,|Good night #Twitter and #TheLegionoftheFallen. 5:45am cimes awfully early!|
|neutral|,|I just finished a 2.66 mi run with a pace of 11'14"/mi with Nike+ GPS. #nikeplus #makeitcount|
|negative|,|Disappointing day. Attended a car boot sale to raise some funds for the sanctuary, made a total of 88p after the entry fee - sigh|
|negative|,|no more taking Irish car bombs with strange Australian women who can drink like rockstars...my head hurts.|
|negative|,|Just had some bloodwork done. My arm hurts|
@ravikiranj
ravikiranj / tw-6.py
Created May 8, 2012 21:13
tweets Variable
tweets = [(['hey', 'cici', 'luv', 'mixtape', 'drop', 'soon', 'fantasy', 'ride'], 'positive'),
(['heard', 'congrats'], 'positive'),
(['ncaa', 'franklin', 'wild'], 'positive'),
(['share', 'jokes', 'quotes', 'music', 'photos', 'news', 'articles', 'facebook', 'twitter'], 'neutral'),
(['night', 'twitter', 'thelegionofthefallen', 'cimes', 'awfully'], 'neutral'),
(['finished', 'mi', 'run', 'pace', 'gps', 'nikeplus', 'makeitcount'], 'neutral'),
(['disappointing', 'day', 'attended', 'car', 'boot', 'sale', 'raise', 'funds', 'sanctuary',
'total', 'entry', 'fee', 'sigh'], 'negative'),
(['taking', 'irish', 'car', 'bombs', 'strange', 'australian', 'women', 'drink', 'head',
'hurts'], 'negative'),
@ravikiranj
ravikiranj / tw-7.py
Created May 8, 2012 21:30
Feature List
featureList = ['hey', 'cici', 'luv', 'mixtape', 'drop', 'soon', 'fantasy', 'ride', 'heard',
'congrats', 'ncaa', 'franklin', 'wild', 'share', 'jokes', 'quotes', 'music', 'photos', 'news',
'articles', 'facebook', 'twitter', 'night', 'twitter', 'thelegionofthefallen', 'cimes', 'awfully',
'finished', 'mi', 'run', 'pace', 'gps', 'nikeplus', 'makeitcount', 'disappointing', 'day', 'attended',
'car', 'boot', 'sale', 'raise', 'funds', 'sanctuary', 'total', 'entry', 'fee', 'sigh', 'taking',
'irish', 'car', 'bombs', 'strange', 'australian', 'women', 'drink', 'head', 'hurts', 'bloodwork',
'arm', 'hurts']
@ravikiranj
ravikiranj / tw-9.py
Created May 8, 2012 21:43
Sample Feature Vector
{
'contains(arm)': True, #notice this
'contains(articles)': False,
'contains(attended)': False,
'contains(australian)': False,
'contains(awfully)': False,
'contains(bloodwork)': True, #notice this
'contains(bombs)': False,
'contains(cici)': False,
.....