Skip to content

Instantly share code, notes, and snippets.

View Fingel's full-sized avatar
🏠

Austin Riba Fingel

🏠
View GitHub Profile
@Fingel
Fingel / gist:5227736f6a9679c21387
Created November 21, 2014 18:24
CacheFactory for Angular
.factory('CacheFactory', ['$injector', function($injector){
var cache = {};
var cacheFactory;
cacheFactory = {
get: function(type, callback){
if(!cache[type] || cache[type].length < 1){
console.log("no cache");
var factory = $injector.get(type);
factory.query({}, function(data, headers){
cache[type] = data.results;
@Fingel
Fingel / accuratelocation.js
Last active August 29, 2015 14:11
Getting an Accurate location in javascript
getAccurateCurrentPosition = function (geolocationSuccess, geolocationError, geoprogress, options) {
var lastCheckedPosition,
locationEventCount = 0,
watchID,
timerID;
options = options || {};
var checkLocation = function (position) {
lastCheckedPosition = position;
@Fingel
Fingel / config.fish
Last active August 29, 2015 14:14
config.fish
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_char_stagedstate "●"
@Fingel
Fingel / PGBoxDjangoField.py
Last active October 13, 2015 16:40
A django model field for the postgresql box geometric type
from django.db import models
from ast import literal_eval as make_tuple
from django.core.exceptions import ValidationError
import collections
def parse_tuple(box_tuple):
if len(box_tuple) != 2:
raise ValidationError("Box has exactly two points (NE, SW)")
if not all(isinstance(i, tuple) for i in box_tuple):
@Fingel
Fingel / Dripping-WD-42.markdown
Created September 19, 2013 08:25
A Pen by Austin Riba.

Dripping WD-42

My first pen. Just playing around with canvas and TweenMax. This is my first real foray into animation like stuff but I came up with what might be a pretty cool loading screen for a website.

A Pen by Austin Riba on CodePen.

License.

@Fingel
Fingel / TocComparator.java
Created September 19, 2013 23:56
A comparator for String representing numbers, where 1.10 is greater than 1.1 and 1.2, like a table of contents.
private static class TocComparator implements Comparator<String>{
public int compare(String s1, String s2){
Integer s1front = Integer.parseInt(s1.substring(0, s1.indexOf('.')));
Integer s2front = Integer.parseInt(s2.substring(0, s2.indexOf('.')));
if(s1front.equals(s2front)){
Integer f1ass = Integer.parseInt(s1.substring(s1.indexOf('.')+1));
Integer f2ass = Integer.parseInt(s2.substring(s2.indexOf('.')+1));
return f1ass.compareTo(f2ass);
}
else{
@Fingel
Fingel / pyswear.py
Created November 11, 2013 02:33
Python script to determine if a song has dirty language
#!/usr/bin/python
import urllib2
import urllib
import re
import getopt, sys, argparse
def getSongLyrics(artist, song):
songUrl = 'http://api.chartlyrics.com/apiv1.asmx/SearchLyricDirect?artist=%s&song=%s' % (urllib.quote_plus(artist), urllib.quote_plus(song))
data = urllib2.urlopen(songUrl).read();
p = re.compile('<Lyric>[a-zA-z].*?<\/Lyric>', re.DOTALL)
@Fingel
Fingel / img2txt.sh
Created November 22, 2013 05:43
Script for converting images to text (ocr) for the Noisebridge Archivists group. Requires tesseract. Ubuntu packages: tesseract-ocr and tesseract-ocr-eng
#!/bin/bash
#Converts images to text using tesseract (package tesseract-ocr & tesseract-ocr-eng)
function usage
{
echo "img2txt -i <input directory> -o <output directory> --concat"
}
function concat
{
@Fingel
Fingel / httpscheck.py
Created November 13, 2013 02:41
Check Alexa top sites to see who uses https
import urllib, urllib2, subprocess, re, csv, pickle
from collections import OrderedDict
urls = []
usessl = 0
sites = OrderedDict()
CHECK = 1000
with open('top-1m.csv', 'rb') as csvfile:
i = 0
reader = csv.reader(csvfile)
@Fingel
Fingel / pony.py
Last active August 26, 2016 20:29
A really simple ponysort implementation
import random
"""
My 'probably good enough' implementation of the ponysort.
Create enough buckets (rakes) for each rider. Iterate over the
riders and only add a rider to a rake if it is not already
there. Does not attempt to optimize spacing.
There is a case where the callup can not be created: if a rider
appears more than NUM_RIDERS/RAKE_SIZE times.