Skip to content

Instantly share code, notes, and snippets.

@csytan
csytan / keybase.md
Created September 22, 2015 16:46
keybase.md

Keybase proof

I hereby claim:

  • I am csytan on github.
  • I am csytan (https://keybase.io/csytan) on keybase.
  • I have a public key whose fingerprint is 25AC 27CE 8135 97E3 2BA5 AF1C 72AB B26C B7B4 8C6F

To claim this, I am signing this object:

@csytan
csytan / paths.py
Created August 5, 2015 20:33
Python Module Paths
import os
# Current working directory
print(os.getcwd())
# Module path (relative to cwd)
print(os.path.dirname(__file__))
# Abs path of the current module's directory
@csytan
csytan / crawl.py
Created October 14, 2014 17:27
Nigeria polling booths crawler
import csv
import json
import os
import time
import urllib
def load(**kwargs):
url = 'http://booths.nigeriaelections.org/getStuff.php'
@csytan
csytan / sequencer.html
Created July 11, 2014 15:32
sequencer.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0;
}
.node {
cursor: pointer;
fill: red;
@csytan
csytan / async_thread.py
Created April 18, 2014 21:19
Tornado async handler with threading
import time
# For python 2.7 use:
# pip install futures
import concurrent.futures
import tornado.ioloop
import tornado.web
import tornado.gen
@csytan
csytan / service.conf
Last active August 29, 2015 13:59
Tornado Upstart example
# Ubuntu upstart file at /etc/init/<service>.conf
# More info: http://upstart.ubuntu.com/cookbook/
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid <username>
@csytan
csytan / fims_proposal.md
Last active January 3, 2016 14:49
FIMS proposal. Feedback welcome.

With the possibility of a new NIMS project, FIMS (Future Information Management System), we have the opportunity to create something better by learning from the issues that have affected us in the past with NIMS.

Overview

Objective: To create an online facility inventory for Ethiopia

Goals:

  • Software Maintainability: "do one thing and do it well"
  • Offline & mobile data collection
@csytan
csytan / reddit.js
Created March 12, 2013 01:43
Reddit JS comment loading
function findRedditComments(query){
var url = 'http://www.reddit.com/search.json?syntax=plain&sort=top'+
'&q=' + query + '&jsonp=?';
$.getJSON(url, function(data){
var articles = data.data.children;
articles.sort(function(a, b){
return b.data.num_comments - a.data.num_comments;
});
var article = articles[0];
if (article && article.data.num_comments){
(function($){ // Module pattern, means vars defined here will not leak outside
// Global vars. Some people use CAPS for them -- it's your personal preference
var MAP = null;
var INFOWINDOW = null;
...
function setLocation() {
@csytan
csytan / lazy_video_loading.js
Created April 19, 2011 07:31
Lazy loads videos as you scroll. Place the iframe src in a "data-embed" attribute. Use with jQuery.
$(document).ready(function(){
var vid_links = $('a.video');
function showVideos(){
if (!vid_links.length) return;
var window_bottom = $(window).scrollTop() + $(window).height() + 500;
vid_links.each(function(){
var link = $(this);
if (link.offset().top < window_bottom){
link.replaceWith(
'<iframe src="' + link.attr('data-embed') + '" class="video" frameborder="0"></iframe>');