Skip to content

Instantly share code, notes, and snippets.

View kimsterv's full-sized avatar

Kim Lewandowski kimsterv

View GitHub Profile
@kimsterv
kimsterv / timezone.js
Created August 9, 2012 18:11
timezone detection
/*
* Original script by Josh Fraser (http://www.onlineaspect.com)
* Continued and maintained by Jon Nylander at https://bitbucket.org/pellepim/jstimezonedetect
*
* Provided under the Do Whatever You Want With This Code License.
*/
/**
* Namespace to hold all the code for timezone detection.
*/
@kimsterv
kimsterv / tz.js
Created August 9, 2012 18:11
looking for user's timezone
var cookie_tz = $.cookie('tz');
if (user_tz == null) {
if (cookie_tz == null) {
try {
var tmp_tz = jstz.determine_timezone();
if (tmp_tz) {
user_tz = tmp_tz.name();
$.cookie('tz', user_tz);
}
} catch(err) {
@kimsterv
kimsterv / gist:1297195
Created October 19, 2011 00:42
django comment signals
from django.contrib.comments.signals import comment_was_posted
@receiver(comment_was_posted)
def my_callback(sender, **kwargs):
comment = kwargs.get('comment')
request = kwargs.get('request')
@kimsterv
kimsterv / gist:1251689
Created September 29, 2011 19:30
First Post
*******************************************************
A pirate walks into a bar. The bartender notices that the pirate
has a steering wheel in his pants, and promptly inquires, "Sir,
I can't help but ask, why do you have a steering wheel in your
pants?"
With this the pirate replies, "Yaaar! Its driving me nuts!"
*******************************************************
@kimsterv
kimsterv / parse.py
Created August 11, 2011 16:55
Split out lat/lon
import simplejson as json
import sys
import re
load = open('/dev/stdin', 'r')
buf = ''
for line in load:
buf += line
if line.strip().endswith('}'):
try:
@kimsterv
kimsterv / gist:1040741
Created June 22, 2011 18:23
Clean bad gzips
#!/bin/bash
for i in `hadoop fs -lsr /flume/incoming/2011/04 | awk '{print $8}'`; do
echo $i; hadoop fs -cat $i | gzip -t
if [ $? -ne 0 ] && [ -n "`echo \"$i\" | grep 'gz$'`" ]; then
`echo hadoop fs -rmr -skipTrash $i`
fi
done
@kimsterv
kimsterv / gist:1033242
Created June 18, 2011 16:23
Pig TOBAG
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@kimsterv
kimsterv / mapping.py
Created June 8, 2011 22:22
imposm mapping file
# Copyright 2011 Omniscale (http://omniscale.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@kimsterv
kimsterv / CSVLoaderWithFilename.java
Created May 4, 2011 17:09
CSVLoader for Pig that includes path of file being processed
package com.simplegeo.elephantgeo.pig.load;
/*
* Licensed under the Apache License, Version 2.0 (the "License");
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@kimsterv
kimsterv / coworkersrock
Created March 30, 2011 23:54
Melissa's talk got accepted to Joint Statistical Meetings in Miami Beach, co-workers are giving advice
Melissa S. yay fun
it's almost worse to spend the whole day in super air conditioned convention center. but JSM is statistician mecca. 5k+ go every year
4:05 PM
Casey C. sounds like your odds will be pretty good
*rimshot*
4:10 PM
Jon R. casey: it may be a *integral* part of her career
Casey C. especially if her talk is a real outlier
Jon R. She'll prob need to lim n->30 her talk, or she wont have any time for questions at the end
Casey C. I bet they'll give her a 5% margin of error