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 generator(pfunc){ | |
return function(){ // Generator object closure | |
var i = 0; //state keeps track number of calls | |
return { | |
next: function(){ // iterator next() method | |
var val = pfunc(i); //pfunc is the parameter function | |
i++; | |
return val; | |
} |
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 yfunc(prev, index, array, callback){ | |
var newValue = callback(prev, index, array); | |
console.log(newValue); | |
return function(){ | |
return yfunc(newValue, index++, array.push(newValue), callback) | |
}; | |
} | |
function yield(callback){ | |
return yfunc(null, 0, [], callback); |
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 id="disqus_thread"></div> | |
<script type="text/javascript"> | |
if(typeof DISQUS === "undefined"){ | |
var disqus_shortname = 'your_shortname'; // required: replace example with your forum shortname | |
(function() { | |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); |
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
$(document).on("page:change", function() { | |
$("#sheet_sort_order").change(function () { | |
data = { | |
"sort_order": this.value | |
}; | |
$.get("/sheets", data, undefined, "script"); | |
}); | |
}); |
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
# FriendlyId Global Configuration | |
# | |
# Use this to set up shared configuration options for your entire application. | |
# Any of the configuration options shown here can also be applied to single | |
# models by passing arguments to the `friendly_id` class method or defining | |
# methods in your model. | |
# | |
# To learn more, check out the guide: | |
# | |
# http://norman.github.io/friendly_id/file.Guide.html |
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
module Paperclip | |
# Handles generating preview images of Sheet PDFs | |
class Preview < Processor | |
def initialize(file, options = {}, attachment = nil) | |
super | |
@file = file | |
@instance = options[:instance] | |
@current_format = File.extname(@file.path) | |
@basename = File.basename(@file.path, @current_format) |
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
class Sheet < ActiveRecord::Base | |
bitmask :instruments, :as => [:guitar, :piano, :bass, :mandolin, :banjo, :ukulele, :violin, :flute, :harmonica, :trombone, :trumpet, :clarinet, :saxophone, :others], :null => false | |
def self.instruments_to_bitmask(instruments) | |
(instruments & Sheet.values_for_instruments).map { |r| 2**Sheet.values_for_instruments.index(r) }.inject(0, :+) | |
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
(**********************************) | |
(* Lab 2 : Higher-Order Functions *) | |
(**********************************) | |
(* We will discuss the initial part of this Lab as Tutorial | |
for the Week of 8 Sept *) | |
(* This lab assignment must be submitted by 16Sept14 6pm *) | |
(* | |
Q1: Last via List.fold_Left |
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
def max(*values) | |
values.max | |
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
require 'net/https' | |
require 'json' | |
uri = URI('https://api.clever.com/v1.1/districts/4fd43cc56d11340000000005/sections?limit=1000000000') | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request.add_field 'Authorization', 'Bearer DEMO_TOKEN' |
OlderNewer