Skip to content

Instantly share code, notes, and snippets.

@asmedrano
asmedrano / gist:4708675
Created February 4, 2013 18:49
Get the location of the bash script you are running. Great for making alias..ssss
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd)
echo SCRIPTPATH
@asmedrano
asmedrano / gist:4627261
Last active December 11, 2015 16:19
Simple script to download a list of files with wget
Give a list like so...
Lets call it list.txt
jquery|http://code.jquery.com/jquery-1.8.3.min.js
modernizr|http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js
pydocs|http://docs.python.org/2/archives/python-2.7.3-docs-html.zip
djangodocs|https://www.djangoproject.com/m/docs/django-docs-1.4-en.zip
leaflet|http://cdn.leafletjs.com/leaflet-0.5/leaflet.js
leafletdocs|http://leafletjs.com/reference.html
@asmedrano
asmedrano / setGOPATH.sh
Created November 8, 2015 18:48
Small GOPATH setter 2015
#!/bin/bash
export GOPATH=$(pwd):$(pwd)/vendor # make GOPATH both the local src dir and also if using GB the 'vendor' dir
export PATH=$PATH:$(pwd)/bin # add the current GOPATH bin directory to the path for convinience
@asmedrano
asmedrano / fips.sh
Created November 16, 2012 01:24 — forked from forkandwait/fips.sh
Reworked script for loading tiger data
declare -A FIPS
declare -A STNAME
FIPS[AK]=02; STNAME[AK]=Alaska
FIPS[AL]=01; STNAME[AL]=Alabama
FIPS[AR]=05; STNAME[AR]=Arkansas
FIPS[AS]=60; STNAME[AS]=American Samoa
FIPS[AZ]=04; STNAME[AZ]=Arizona
FIPS[CA]=06; STNAME[CA]=California
FIPS[CO]=08; STNAME[CO]=Colorado
FIPS[CT]=09; STNAME[CT]=Connecticut
@asmedrano
asmedrano / gist:3947679
Created October 24, 2012 17:52
prettifythis
class ScruffySpider(BaseSpider):
name = "scruffy"
allowed_domains = ['constantcontact.com']
start_urls = [
'http://www.constantcontact.com/index.jsp'
]
domain_pattern = re.compile('constantcontact\.com')
mailto_pattern = re.compile('mailto\:')
@asmedrano
asmedrano / gist:3853932
Created October 8, 2012 17:58
Setting up a WebView for Ubuntu App Dev
import gettext
import os
from gettext import gettext as _
gettext.textdomain('html5test')
from gi.repository import Gtk, WebKit # pylint: disable=E0611
import logging
logger = logging.getLogger('html5test')
from html5test_lib import Window
@asmedrano
asmedrano / index.html
Created October 3, 2012 19:28 — forked from enjalot/index.html
Simple Pie Chart example with D3.js
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Testing Pie Chart</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?2.1.3"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?2.1.3"></script>
<style type="text/css">
// a simple addition function
function add_these(num1, num2){
$result = $num1 + $num2;
return $result;
}
@asmedrano
asmedrano / acs2010_sumlev.py
Created April 26, 2012 19:49
ACS2010 Census Summary Levels as a Dict
"""
Summary Level Definitions
Defined as:
SUMLEV: (Geographies, Hierarchy(when avail))
"""
SUMLEV = {
'010':('United States', 'United States'),
'020':('Region'),
'030':('Division'),
'040':('State','State'),
@asmedrano
asmedrano / gist:2466271
Created April 22, 2012 19:17
New Twitter Bootstrap row every Nth item.
{%for item in items%}
{% if forloop.first or forloop.counter0|divisibleby:3 %}
<div class = "row">
{%endif%}
{# We need to add a new Bootstrap row every after every third item item#}
<div class = "span4">
<h3><a href ="">{{title}}</a></h3>
<span>Posted on {{created_on}} </span>
</div>