Skip to content

Instantly share code, notes, and snippets.

View sforteln's full-sized avatar

Simon Fortelny sforteln

View GitHub Profile
@sforteln
sforteln / htaccess to redirect wordpress links
Created August 10, 2011 03:49
htaccess to redirect wordpress links to jekyll ones
@sforteln
sforteln / gist:1231203
Created September 21, 2011 03:51
Use interfaceChecker in object creation example
//create object that partly conforms to the interfaces contract
document.writeln('<b>Create checking_orange_juice</b> <br/>');
var checking_orange_juice = function() {
var that = {};
//implement some of the interface functions/methods
that.cup_size = function () {
return "small";
}();
interfaceCheckerWithThrow(coffee_interface,that);
return that;
@sforteln
sforteln / gist:2271491
Created April 1, 2012 04:44
hive-default.xml to connect to Oracle
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:oracle:thin:@localhost:1521:oracle</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
<description>Driver class name for a JDBC metastore</description>
@sforteln
sforteln / gist:3057704
Created July 6, 2012 02:32
Hadoop Pig's Batch Mode 1
customerData = LOAD 'CustomerData-020211'
USING PigStorage(',') AS (customerId:chararray, purchaseDate:long, itemId:long);
customersGroupByItem = GROUP customerData BY itemId;
numberOfCustomersWhoBoughtItem = FOREACH customersGroupByItem {
count = COUNT(customerData.customerId);
GENERATE group.itemId, count;
};
ps.openIterator('numberOfCustomersWhoBoughtItem');
customersGroupByPurchDate = GROUP customerData BY purchaseDate;
numberOfCustomersWhoBoughtDate = FOREACH customersGroupByPurchDate {
@sforteln
sforteln / gist:3057733
Created July 6, 2012 02:36
Hadoop Pig's Batch Mode 2
ps.openIterator('numberOfCustomersWhoBoughtItem');
ps.openIterator('numberOfCustomersWhoBoughtDate');
PigServer ps = getPigServer();
ps.setBatchOn();
. .
ps.openIterator("numberOfCustomersWhoBoughtItem");
ps.openIterator("numberOfCustomersWhoBoughtDate");
ps.executeBatch();
PigServer ps = getPigServer();
ps.setBatchOn();
. .
STORE numberOfCustomersWhoBoughtItem INTO 'numberOfCustomersWhoBoughtItemTmpFile'
USING BinStorage();
STORE numberOfCustomersWhoBoughtDate INTO 'numberOfCustomersWhoBoughtDateTmpFile'
USING BinStorage();
ps.executeBatch();
ps.openIterator("numberOfCustomersWhoBoughtItem");
ps.openIterator("numberOfCustomersWhoBoughtDate");
PigServer ps = getPigServer();
ps.setBatchOn();
ps.registerQuery("customerData = LOAD 'CustomerData-020211'
USING PigStorage(',') AS (customerId:chararray, purchaseDate:long, itemId:long);");
//count the number of times the item was bought
ps.registerQuery("customersGroupByItem = GROUP customerData BY itemId;");
ps.registerQuery("numberOfCustomersWhoBoughtItem = FOREACH customersGroupByItem { "+
" count = COUNT(customerData.customerId); "+
" GENERATE group.itemId, count;"+
"};");
PS1="[[33[1;34m]u[33[1;37m]@[33[1;32m]h[33[1;37m] ${BRANCH} [33[1;36m]W [33[0m]]${PROMPT_SYMBOL} "
try{
//do SQL stuff
}catch(Exception e){
if("-0955".equals(e.getSqlCode())){
//ORA-00955: name is already used by an existing object
//tried to make a table that already existed ignore exception
}else {
//got an unexpected exception don't ignore it throw e;
}
}