Skip to content

Instantly share code, notes, and snippets.

View kyledecot's full-sized avatar
🤘

Kyle Decot kyledecot

🤘
View GitHub Profile
### Keybase proof
I hereby claim:
* I am kyledecot on github.
* I am kyledecot (https://keybase.io/kyledecot) on keybase.
* I have a public key whose fingerprint is E0B5 BDBD C4F5 75AF 40C4 7F3A DE47 DFC1 9E16 712A
To claim this, I am signing this object:
require "benchmark"
require "securerandom"
Benchmark.bm do |bm|
15.times do |t|
n = t * 10_000
a = [].tap do |array|
n.times { array << SecureRandom.uuid }
end
bm.report("#{n} uniq") { a.uniq }
setTimeout(function() {
$.getJSON('http://example.com/sdlfjkflkjsadklj.json', function(results) {
var newCheckins = [];
for (result in results) {
newCheckins.push('...');
}
$('#checkins').replaceWith(newCheckins);
});

Keybase proof

I hereby claim:

  • I am kyledecot on github.
  • I am kyledecot (https://keybase.io/kyledecot) on keybase.
  • I have a public key whose fingerprint is 5109 3108 F6D9 6ED6 96E3 015D 2FAA 6252 D000 FCC7

To claim this, I am signing this object:

import java.util.Random;
import java.util.Scanner;
public class Project {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = input.nextLine();
int number_of_questions = 4;
# Given a CSV of people, display them grouped together by their favorite colors
require 'csv'
# Gather the data...
results = Array.new.tap do |a|
CSV.foreach File.expand_path('../people.csv', __FILE__), headers: true do |row|
a << row.to_hash
end
Resource::POSSIBLE_CLASSES.each do |klass|
define_method klass.name.tableize do
resource_ids = group_memberships.pluck(:resource_id)
klass.where(klass.arel_table[:id].in(resource_ids))
end
define_method "has_#{klass.name.underscore}?" do |object|
object.resource_id.in? send(klass.name.tableize.to_sym).pluck(:id)
end
end
@kyledecot
kyledecot / gist:5512014
Created May 3, 2013 17:57
CLow Dice Roller in Ruby
([*1..3].map{[*1..6].sample}).sort.join(', ')
@kyledecot
kyledecot / gist:2954926
Created June 19, 2012 15:49
jQuery.without
$.without = function(first, second) {
return $.grep(first, function(n, i){
return $.inArray(n, second) == -1;
});
};
// Usage...
console.log($.without([1,2,3,4,5], [4,5]));​​ // [1,2,3]
@kyledecot
kyledecot / laravel-ujs.js
Created June 19, 2012 14:40
laravel UJS
(function($, undefined) {
// Shorthand to make it a little easier to call public laravel functions from within laravel.js
var laravel;
$.laravel = laravel = {
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',