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 vi = new versalInterface(); | |
var Gadget = function() { | |
var createListeners = function() { | |
vi.on('attached', this.render()); | |
// I just want to set a general re-render listener when config changes | |
vi.on('attributesChanged', function(data) { | |
for (var key in data) { | |
this.config[key] = data[key]; |
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
counterVal = 4 | |
tick() -> | |
if counterVal !== 1 | |
# logic each countdown tick | |
counterVal-- | |
setTimeout tick, 1000 | |
else | |
# breaking case - callback on countdown completion |
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 style = document.createElement('style'); | |
style.textContent = '@import "' + url + '"'; | |
var fi = setInterval(function() { | |
try { | |
style.sheet.cssRules; // <--- MAGIC: only populated when file is loaded | |
CSSDone('listening to @import-ed cssRules'); | |
clearInterval(fi); | |
} catch (e){} | |
}, 10); |
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.exports = (app) -> | |
# request specific user | |
app.get '/users/:user', (req, res) -> | |
console.log req.params.user | |
# catch-all for allowing Backbone to handle routing | |
app.get '*', (req, res) -> | |
res.render 'app/index' |
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
'use strict'; | |
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet; | |
var mountFolder = function (connect, dir) { | |
return connect.static(require('path').resolve(dir)); | |
}; | |
var path = require('path'); | |
module.exports = function (grunt) { | |
// load all grunt tasks |
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
let rec factorial acc n = match n with | |
| 0 -> acc | |
| n -> factorial (n * acc) (n-1) | |
let factorial_res = factorial 1 6 |
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
# Write a method named get_squares that takes an array of numbers | |
# and returns a sorted array containing only the numbers whose square is also in the array | |
# | |
# get_squares [9] # => [] | |
# get_squares [9,3] # => [3] | |
# get_squares [9,3,81] # => [3, 9] | |
# get_squares [25, 4, 9, 6, 50, 16, 5] # => [4, 5] | |
def get_squares(array) | |
to_return = array.select do |square| |
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
print "Hello. Please enter a celsius value: " | |
celsius = gets | |
fahrenheit = (celsius.to_i * 9 / 5) + 32 | |
print "The fahrenheit equivalent is: " | |
print fahrenheit | |
puts "." | |
# REFACTORED METHOD (denser, but less readable) | |
# print "Hello. Please enter a celsius value: " | |
# print "The fahrenheit equivalent is: " gets.to_i * 9/5 + 32, ".\n" |
NewerOlder