Skip to content

Instantly share code, notes, and snippets.

View criccomini's full-sized avatar

Chris criccomini

View GitHub Profile
@criccomini
criccomini / gist:3779255
Created September 25, 2012 00:20
Simple Login Screen - LoginViewController.h
#import <UIKit/UIKit.h>
@interface LoginViewController : UIViewController {
}
- (IBAction) login: (id) sender;
@end
@criccomini
criccomini / gist:3775978
Created September 24, 2012 13:34
App Engine and Facebook Connect - index.html
<html>
<body>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script>
<script type="text/javascript">FB.init("{{ apikey }}", '/static/xd_receiver.html');</script>
Hello, {{ name }}!
<br/><br/>
<a href="#" onclick="javascript:FB.Connect.logoutAndRedirect('/')">Logout</a>
@criccomini
criccomini / gist:3775976
Created September 24, 2012 13:33
App Engine and Facebook Connect - login.html
<html>
<body>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"><script>
<script type="text/javascript">FB.init("{{ apikey }}", "/static/xd_receiver.html");</script>
<fb:login-button v="2" onlogin='window.location="/";' size="large">Connect with Facebook</fb:login-button>
</body>
</html>
@criccomini
criccomini / gist:3775970
Created September 24, 2012 13:32
App Engine and Facebook Connect - main.py
#!/usr/bin/env python
import wsgiref.handlers
import os
import facebook
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext import db
class BaseHandler(webapp.RequestHandler):
@criccomini
criccomini / gist:3775967
Created September 24, 2012 13:31
App Engine and Facebook Connect - Install PyFacebook
def check_connect_session(self, request):
"""
For use in a facebook Connect application running in Google App Engine
Takes a Google App Engine Request
http://code.google.com/appengine/docs/webapp/requestclass.html
and determines if the current user has a valid session
"""
# our session is stored in cookies - validate them
params = self.validate_cookie(request.cookies)
@criccomini
criccomini / gist:3775858
Created September 24, 2012 13:06
Sort Reducer Input Values in Hadoop
public class SortReducerByValues {
public static final String INPUT = "/tmp/data_in";
public static final String OUTPUT = "/tmp/data_out";
public static void main(String[] args) throws IOException {
new SortReducerByValues().run();
}
public void run() throws IOException {
JobConf conf = new JobConf();
@criccomini
criccomini / gist:3773353
Created September 23, 2012 22:58
Hadoop, Pig, and SQL (TABLES)
CREATE TABLE newtable AS SELECT * FROM mytable;
STORE mytable INTO '/some_hdfs_folder/newtable' USING PigStorage(',');
DROP TABLE newtable;
RMF /some_hdfs_folder/newtable;
@criccomini
criccomini / gist:3773351
Created September 23, 2012 22:58
Hadoop, Pig, and SQL (GROUP BY)
SELECT COUNT(*) FROM mytable;
mytable = GROUP mytable ALL;
mytable = FOREACH mytable GENERATE COUNT(mytable);
DUMP mytable;
SELECT COUNT(DISTINCT col1) FROM mytable;
mytable = FOREACH mytable GENERATE col1;
mytable = DISTINCT col1;
mytable = GROUP mytable BY col1;
@criccomini
criccomini / gist:3773349
Created September 23, 2012 22:57
Hadoop, Pig, and SQL (JOIN)
SELECT * FROM mytable INNER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable LEFT OUTER JOIN othertable ON mytable.col1 = othertable.col1;
mytable = JOIN mytable BY col1 LEFT OUTER, othertable BY col1;
DUMP mytable;
SELECT * FROM mytable RIGHT OUTER JOIN othertable ON mytable.col1 = othertable.col1;
@criccomini
criccomini / gist:3773348
Created September 23, 2012 22:57
Hadoop, Pig, and SQL (SELECT)
SELECT * FROM mytable;
DUMP mytable;
SELECT col1, col2 FROM mytable;
mytable = FOREACH mytable GENERATE col1, col2;
DUMP mytable;
SELECT col1 AS new_col1, col2 AS new_col2 FROM mytable;
mytable = FOREACH mytable GENERATE col1 AS new_col1, col2 AS new_col2;