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
<html> | |
<head> | |
<style> | |
.viewport { | |
position: relative; | |
width: 300px; | |
height: 300px; | |
} | |
.viewport:hover img { |
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
const Instagram = require('instagram-node-lib') | |
Instagram.set('client_id', 'xxx') | |
Instagram.set('client_secret', 'xxx') | |
// to get an access_token | |
let url = Instagram.oauth.authorization_url({ | |
redirect_uri: 'http://mysite.com' | |
}) |
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'; | |
function toDecimal(A) { | |
var sum = 0; | |
for (var i = 0; i < A.length; i++) { | |
sum += A[i] * Math.pow(-2, i); | |
} | |
return sum; | |
} |
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
// wrong for trailing 0s, ... | |
// 6, 328, n=16=2**4 and n=1024=2**10 | |
// n=51712=110010100000000_2 and n=20=10100_2 | |
function solution(N) { | |
var max = 0; | |
var currentLength = 0; | |
while (N > 0) { | |
var remainder = N % 2; | |
inGap = remainder === 0; |
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 ProjectForm = React.createClass({ | |
getInitialState: function() { | |
return { headerText: 'nothing' } | |
}, | |
handleToggleChange: function(value) { | |
this.setState({ headerText: value.toUpperCase() }) | |
}, | |
render: function() { | |
return ( | |
<form> |
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
w = require 'when' | |
w.all [ | |
w.resolve(1) | |
w.resolve(2) | |
] | |
.then console.log | |
w.all [ | |
w.resolve('a') |
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
w = require 'when' | |
# When using when, should you put the catch first or last in the promise chain? | |
# You should put it last if you want it to end the chain before your thens run. | |
doSomethingAndFail = (n) -> | |
console.log 'fail', n | |
w.reject(n) | |
doSomethingAndFail(1) |
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
#!/usr/bin/ruby | |
# Usage: compare-contacts.rb [file1] [file2] | |
require 'csv' | |
def find_email_column_indexes(row) | |
[ | |
row.index('E-mail Address'), | |
row.index('E-mail 2 Address'), | |
row.index('E-mail 3 Address'), | |
row.index('E-mail 1 - Value'), |
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 JavaScriptCore | |
let context = JSContext() | |
context.evaluateScript("var num = 5 + 5") | |
context.evaluateScript("var names = ['Grace', 'Ada', 'Margaret']") | |
context.evaluateScript("var triple = function(value) { return value * 3 }") | |
context.evaluateScript("names.sort()") | |
let tripleNum: JSValue = context.evaluateScript("triple(num)") |
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 count = 0; | |
when.iterate(function(args) { | |
var cursor = parseInt(args[0]); | |
return redis.whenZScan('mykey', cursor || 0); | |
}, function predicate(args) { | |
var cursor = parseInt(args[0]); | |
return cursor === 0; | |
}, function handler(args) { | |
if (args.length > 1) { |