This file contains hidden or 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 hex2dec(hex) { | |
hex = hex.toLowerCase(hex).split(''); | |
var dec = 0; | |
while(h = hex.shift()) { | |
var code = h.charCodeAt(0); | |
dec = dec << 4; | |
dec += code < 58 ? code - 48 : code - 87; | |
} | |
return dec; | |
} |
This file contains hidden or 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 hsv2hex(hsv) { | |
return rgb2hex(hsv2rgb(hsv)); | |
} | |
function hex2hsv(hex) { | |
var dec = hex2dec(hex); | |
var rgb = dec2rgb(dec); | |
var hsv = rgb2hsv(rgb); | |
return hsv; | |
} |
This file contains hidden or 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 Foo = Class.extend(function() { | |
this.var1 = "var1 foo"; | |
}); | |
var Bar = Foo.extend(function() { | |
this.var1 = "var1 bar" | |
console.log(this.super.var1); // access var1 from the base class | |
}); |
This file contains hidden or 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
- Create EC2 instance - you should have your file.pem public key file saved somewhere. | |
- Assign Elastic IP. | |
- Configure security groups for ports 80, 20, pasv ftp range and if you want to enable ping: custom IMCP rule 'echo request' | |
ssh -i file.pem ubuntu@YOUR_IP | |
- INSTALL VSFTPD | |
sudo apt-get install vsftpd | |
to restart: |
This file contains hidden or 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
{ | |
"AED": { | |
"code": "AED", | |
"number": "784", | |
"symbol": "AED", | |
"decimals": "2" | |
}, | |
"AFN": { | |
"code": "AFN", | |
"number": "971", |
This file contains hidden or 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
/** | |
* Recursivelly find the first object with the given key | |
* @param {object} obj Object to search for key | |
* @param {string} key Key to find | |
* @return {object} Value if found, undefined if not found | |
*/ | |
findValueForKey: function(obj, key) { | |
var value = undefined; | |
function find(obj, key) { | |
for(var k in obj) { |
This file contains hidden or 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 split(arr) { | |
var l = arr.length, | |
m = Math.round(l / 2); | |
return { | |
left: arr.slice(0, m), | |
right: arr.slice(m, l) | |
} | |
} | |
function find(arr, el) { |
This file contains hidden or 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
// is it a monad? | |
var x = 1, | |
fn = x => x + 1, | |
gn = x => x * 2 | |
var law1 = new Maybe(x).bind(fn).return() == new Maybe(fn(x)).return() | |
console.log(law1) | |
var law2 = new Maybe(x).bind(x => x).return() == new Maybe(x).return() | |
console.log(law2) |
This file contains hidden or 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 initialData = [] | |
// These can be converted from other events | |
var add_ = new Rx.Subject() | |
var remove_ = new Rx.Subject() | |
var addF_ = add_.map(R.unary(R.curry(R.union))) | |
var removeF_ = remove_.map(R.unary(R.flip(R.difference))) | |
var update = (data, updateF) => updateF(data) |
This file contains hidden or 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 groupTransform = (stream$, f, keySelector, selector) => { | |
return Rx.Observable.create(observer => { | |
var disposable = new Rx.CompositeDisposable() | |
disposable.add(stream$.groupBy(keySelector, selector) | |
.subscribe(groupObservable => { | |
disposable.add(f(groupObservable, groupObservable.key).subscribe(observer)) | |
})) |
OlderNewer