Skip to content

Instantly share code, notes, and snippets.

@muddana
muddana / do.m
Created September 16, 2011 16:16
An attempt at Ruby type conditional expression support in MATLAB
%/
% Developer : Srinivas Muddana (srinivas.muddana@gmail.com)
% All code (c)2012 Srinivas Muddana. all rights reserved
%
% do a = a*-1 if(a<0);
% can add a ternary operator too.??
function do(varargin)
%expr = size(2*length(varargin) -1) ;
expr = '';
for(ii = 1:length(varargin))
@muddana
muddana / python_global_keyword.py
Created March 15, 2010 22:18
test with python global keyword
WORD_FEATURES = []
def overwrite_word_features():
WORD_FEATURES = [1, 3, 5 ]
overwrite_word_features()
print WORD_FEATURES # prints []
#This took me a while to guess what could have been happening and was confirmed upon googling. the correct way to do is
WORD_FEATURES = []
@muddana
muddana / twitter_streaming.rb
Created March 15, 2010 22:16
twitter streaming script
require 'rubygems'
require 'mongo'
require 'tweetstream'
USER = "<username>"
PASS = "<password>"
conn = Mongo::Connection.new
db = conn.db("dbname")
tweets = db.collection("collname")
@muddana
muddana / sentiment_classifier.py
Created March 14, 2010 00:38
sentiment analysis of twitter data.
# down the test/train data : http://www.stanford.edu/~alecmgo/cs224n/twitterdata.2009.05.25.c.zip
#into a folder "corpus" at the level of this file (else u need to change inside the code for now)
import nltk
import random
import re
import gc
from pymongo import Connection
#method defs
class Collection
def initialize
@map = Hash.new
end
def inc_frequency(word)
@map[word] = @map[word] ? (@map[word]+1) : 1
end
def add(word)
#include <iostream>
#include <list>
#include <vector>
#include <stack>
#include <string>
// basic file operations
#include <iostream>
#include <sstream>
#include <fstream>
#include <time.h>
% Neural Netowrks Project
% srinivas muddana
% 9561 - 2909
% self organizing maps
function [initMap, map, elapsedTime, winNeurons] = testsomap(mapSize,ipData,epoochs)
initTime = clock;
filename = "test_mail.rb"
file = File.new("./"+filename, "r")
filecontent = ""
file.each do |line|
filecontent << line
end
encodedcontent = [filecontent].pack("m") # base64
marker = "TESTBOUNDARY"
body = <<MESSAGE_BODY
require 'rubygems'
require 'ruby2ruby'
require 'ruby_parser'
require 'pp'
code_str = File.read('./test.rb')
parser = RubyParser.new
sexp = parser.process code_str
#puts sexp.inspect
#some script for loading models and other stuff
require 'rubygems'
require 'active_record'
require 'yaml'
#require 'app/helpers/application_helper'
MODEL_PATH = './app/models/'
LIB_PATH = './app/lib/'