Skip to content

Instantly share code, notes, and snippets.

🔊


Duncan Beevers duncanbeevers

🔊

Block or report user

Report or block duncanbeevers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View users_app.js.coffee
App.setupWithOptions
orange: "very"
fragrant: "barely"
@duncanbeevers
duncanbeevers / fisheryates.coffee
Created Oct 22, 2012 — forked from ddgromit/fisheryates.coffee
CoffeeScript Implementation of the Fisher-Yates array sorting algorithm
View fisheryates.coffee
fisherYates = (array) ->
cap = array.length
for e, i in array
j = Math.floor(Math.random() * (cap - i)) + i
[ array[i], array[j] ] = [ array[j], e ] unless i == j
array
@duncanbeevers
duncanbeevers / sc-dl-min.js
Created Mar 22, 2012 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
View sc-dl-min.js
(function(window){var i,$sound,$buttonGroup;var $sounds=$(".sound");var clientId=require("config").get("client_id");var oauthToken=require("lib/connect").getAuthToken();var conversionHelper=require("lib/helpers/conversion-helper");var $downloadButton,size;var params,downloadUrl,onSuccess;for(i=$sounds.length-1;i>=0;i--){$sound=$($sounds[i]);var soundcloudUrl="https://soundcloud.com"+($sound.find(".soundTitle__title").attr("href")||window.location.pathname);params={url:soundcloudUrl,client_id:clientId};onSuccess=function($sound){return function(data){var params={client_id:clientId};downloadUrl=require("lib/url").stringify({query:params},data.stream_url+".mp3");$buttonGroup=$($sound.find(".sound__soundActions .sc-button-group")[0]);size=$buttonGroup.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1];$downloadButton=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+conversionHelper.bytesToMB(data.origi
View populate.rake
namespace :db do
desc "Populate Users Table with images from /public/feedimg"
task :populate => :environment do
require "populator"
require "faker"
image_filenames = Dir.glob(File.join(Rails.root, '/public/feedimg', '*'))
User.populate 1 do |user|
user.username = Faker::Name.first_name.downcase
user.email = Faker::Internet.user_name + "@myhost.com".downcase
View gist:1503770
module SessionsHelper
def sign_in(user)
cookies.permanent.signed[:remember_token] = [user.id, user.salt]
self.current_user = user
end
def current_user=(user)
@current_user = user
end
View recursively_symbolize_keys.rb
class Hash
def recursively_stringify_keys
recursively_xify_keys(:to_s, :recursively_stringify_keys)
end
def recursively_symbolize_keys
recursively_xify_keys(:to_sym, :recursively_symbolize_keys)
end
private
You can’t perform that action at this time.