This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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); }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2 | |
gem 'bootstrap-sass', '~> 3.1.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval (-> | |
Quota.get().then (quotas) -> $scope.quotas = quotas | |
), 20000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer