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
jQuery('body').on('click', '[data-method="delete"]', function(event) { | |
event.preventDefault(); | |
var confirm_msg = jQuery(this).data('confirm'); | |
var form = jQuery('<form />').attr({ | |
method : 'POST', | |
action : jQuery(this).attr('href') | |
}); | |
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
(function($) { | |
$.each_slice = function(num, things, iterator) { | |
var tmp = []; | |
$.each(things, function(index, thing) { | |
tmp.push(thing); | |
if (tmp.length >= num || (index + 1) >= things.length) { | |
iterator(tmp); | |
tmp = []; | |
} | |
}); |
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
require 'digest/md5' | |
class String | |
def to_md5 | |
Digest::MD5.hexdigest(self) | |
end | |
end | |
# "Hello World!".to_md5 |
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
alias coda='open -a /Applications/Coda\ 2.app .' |
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
(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]', |
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
$.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] |
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..3].map{[*1..6].sample}).sort.join(', ') |
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
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 |
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
# 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 |
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
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; |
OlderNewer