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 thing({ a = 1, b }) { | |
console.log(`a: ${a} b: ${b}`) | |
} | |
const options = { | |
b: 2 | |
} | |
thing(options) |
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
// Original | |
if (url) { | |
window.location.href = url; | |
} else { | |
window.location.href = noApp; | |
} | |
// Better | |
window.location.href = url || noApp; |
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 parallel(tasks, max, done) { | |
let running = 0 | |
let completed = 0 | |
next() | |
function taskCompleted() { | |
completed++ | |
console.log(`finished task #${completed}`) |
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
/* | |
* Initial steps of the mateogianolio/vectorious library | |
* https://github.com/mateogianolio/gravity/blob/master/js/vector.js | |
*/ | |
function Vector(x, y) { | |
this.x = x; | |
this.y = y; | |
} |
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
{"data": [ | |
"Psycho-Pass", | |
"No Game No Life", | |
"Steins;Gate", | |
"Fullmetal Alchemist: Brotherhood", | |
"Katekyo Hitman Reborn!", | |
"Ano Hana", | |
"Commando, Infantry, or Police. Who are you?", | |
"Superhero.js", | |
"What every programmer needs to know about game networking", |
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
// Nightmare patch for weird Chrome bug | |
Array.prototype.slice.call(document.querySelectorAll('md-input-container label')).forEach(function(label) { | |
label.style.direction = 'rtl'; | |
setTimeout(function() { | |
label.style.direction =' ltr'; | |
}, 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
import UIKit | |
extension UIColor { | |
func isLightColor() -> Bool { | |
var red : CGFloat = 0 | |
var green : CGFloat = 0 | |
var blue : CGFloat = 0 | |
self.getRed(&red, green: nil, blue: nil, alpha: nil) |
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
func generateRandomColor() -> UIColor { | |
let hue : CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0 | |
let saturation : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white | |
let brightness : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black | |
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1) | |
} |