Skip to content

Instantly share code, notes, and snippets.

View jordanhudgens's full-sized avatar

Jordan Hudgens jordanhudgens

View GitHub Profile
#python2.6 <
from math import log
def getDigit(num, base, digit_num):
# pulls the selected digit
return (num // base ** digit_num) % base
def makeBlanks(size):
# create a list of empty lists to hold the split by digit
return [[] for _ in xrange(size)]
#!/usr/bin/env python
def counting_sort(array, maxval):
"""in-place counting sort"""
m = maxval + 1
count = [0] * m # init with zeros
for a in array:
count[a] += 1 # count occurences
i = 0
for a in range(m): # emit
@jordanhudgens
jordanhudgens / merge_sort.py
Created May 29, 2014 17:23
Merge sort implementation
# Python version 2.6+
from heapq import merge
def merge_sort(m):
if len(m) <= 1:
return m
middle = len(m) / 2
left = m[:middle]
@jordanhudgens
jordanhudgens / gist:d4f4a9e6c5744886ad49
Created August 7, 2014 21:25
Instagram Follower Counter
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
$.ajax({
type: "GET",
dataType: "jsonp",
cache: true,
error: function(data) { console.log(data); },
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
gem 'bootstrap-sass', '~> 3.1.1'
<div class="row">
<%= form_for @invoice, html: { class: 'form-horizontal' } do |f| %>
<% if @invoice.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@invoice.errors.count, "error") %> prohibited this invoice from being saved:</h2>
<ul>
<% @invoice.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
@jordanhudgens
jordanhudgens / map-lasso.js
Created February 27, 2015 03:11
Map Lasso Feature
var map;
var points=[];
var pointsrand=[];
var areaDiv=document.getElementById('area');
var areaDivkm=document.getElementById('areakm');
var randomMarkers=new Array(0);
var routeMarkers=new Array(0);
var lines=[];
var lineColor='#ff0000';
var fillColor='#00FF00';
# This is to be used as a process flow, not an executable implementation
## Dynamic Ruby View
# Situation: You have a very similar views that needs to be rendered, currently they are two separate models/views/controllers.
# This isn't an ideal setup since it means that anytime you want to make changes to one view you also need to make changes to the other view.
# And if they ever want more views created that are like this it will mean you need to change more, this can be bad from a time and
# code duplication perspective.
# To fix this:
setInterval (->
Quota.get().then (quotas) -> $scope.quotas = quotas
), 20000
# 1) Add to your root .js file (like application.js):
//= require ckeditor/override
//= require ckeditor/init
#2) Create new .rake task in this code to your "lib" folder:
namespace :ckeditor do
desc 'Create nondigest versions of some ckeditor assets (e.g. moono skin png)'
task :create_nondigest_assets do