Skip to content

Instantly share code, notes, and snippets.

View okaram's full-sized avatar

Orlando Karam okaram

View GitHub Profile
@okaram
okaram / another.cpp
Created March 23, 2012 17:21
Recursion Examples (public)
#include <iostream>
using namespace std;
int fac(int n) {
if(n<=0)
return 1;
else
return n*fac(n-1)
}
@okaram
okaram / data2.py
Created September 11, 2012 21:33
models for join django example
ph2=Phone.objects.create(person=p1,area_code='770',number='1234567');
@okaram
okaram / include.html
Created September 13, 2012 16:51
django templates, include, with
{% include "table_frag.html" %}
@okaram
okaram / 1_typedefs.cpp
Created October 4, 2012 14:18
Functional sets in C++
typedef std::function<bool(int)> Set;
typedef std::function<bool(int)> Predicate;
@okaram
okaram / 1_ConsNode.cpp
Created October 13, 2012 04:42
cons lists in C++
template<typename T>
struct ConsNode {
public:
ConsNode(T car=T(), ConsList<T> cdr=ConsList<T>()):_car(car),_cdr(cdr) {}
private:
T _car;
ConsList<T> _cdr;
friend T car<>(const ConsList<T> &l);
friend const ConsList<T>& cdr<>(const ConsList<T> &l);
@okaram
okaram / 1_connect.py
Created October 14, 2012 04:50
dynamodb examples
conn=boto.connect_dynamodb() # if set in ~/.boto
# or
conn = boto.connect_dynamodb(aws_access_key_id='...',aws_secret_access_key='...')
@okaram
okaram / blogroll.py
Created November 16, 2012 01:27
Python Blogroll
import feedparser
f=open('blogroll.html','w')
f.write("<html>\n<head>\n<title>Blogroll</title>\n</head>\n<body>");
blogs=["http://programminggenin.blogspot.com/feeds/posts/default","http://djangolearner.blogspot.com/feeds/posts/default"];
for blog in blogs :
feed=feedparser.parse(blog)
f.write('<a href="%s">%s</a>\n'% (feed.feed.link,feed.feed.title));
f.write('<ul>\n');
for e in feed.entries:
@okaram
okaram / add.cs
Created November 17, 2012 15:47
LinQ basics
protected void AddBlog_Click(object sender, EventArgs e)
{
SimpleBlogDataContext ctx = new SimpleBlogDataContext();
Blog b = new Blog();
b.Title = BlogTitle.Text;
ctx.Blogs.InsertOnSubmit(b);
try
{
ctx.SubmitChanges();
}
@okaram
okaram / factorial.cpp
Last active October 13, 2015 10:08
Recursion and memoization
unsigned factorial(unsigned n)
{
if(n==0)
return 1;
else
return n*factorial(n-1);
}
hadoop dfs -copyFromLocal texts /user/hduser/texts
hadoop dfs -ls /user/hduser/texts