CSS minion from Despicable Me recreated in pure CSS. This was created with only CSS3 shapes using pseudo classes and box-shadows.
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
validGuess = (sudoku, x, y, value) -> | |
row = sudoku[y] | |
column = row[x] for row in sudoku | |
cube = (sudoku[~~(y/3) + i][~~(x/3) + j] for i in [0..2] for j in [0..2]).reduce (result, curr) -> result.concat(curr) | |
value not in [].concat row, column, cube | |
guess = (sudoku, x, y, value) -> | |
sudoku[y][x] = value if validGuess sudoku, x, y, value | |
# sudoku = genValidSudoku() |
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 format(num, fmt) { | |
if (isNaN(Number(num))) { | |
throw new TypeError('Not a number'); | |
} | |
if (typeof fmt.scale == 'number') { | |
num = Number(num).toFixed(fmt.scale); | |
} | |
num = String(num).replace('.', fmt.outDecSep||'.'); | |
var regexp = /(\d+)(\d{3})/; | |
while(regexp.test(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 mongoose = require('mongoose'); | |
var db; | |
var connect = module.exports = function () { | |
mongoose.connect('mongodb://localhost/events'); | |
db = mongoose.connection; | |
db.on('error', function(err) { | |
console.error('Error', err); | |
}); | |
db.once('open', function() { |
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* generatorFunction() { | |
// ... | |
} | |
let iterator = generatorFunction(); | |
// for-of loop | |
for (let k of iterator) { | |
// ... | |
} |
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
describe("isPrimitive", function() { | |
it("should return true for primitive values", function() { | |
expect(isPrimitive(0)).toBe(true); | |
expect(isPrimitive('')).toBe(true); | |
expect(isPrimitive(false)).toBe(true); | |
expect(isPrimitive(null)).toBe(true); | |
expect(isPrimitive(undefined)).toBe(true); | |
expect(isPrimitive(NaN)).toBe(true); | |
}); |
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
describe("toBoolean", function() { | |
var toBool = toBoolean; | |
it("should return true for all objects", function() { | |
expect(toBool({})).toBe(true); | |
expect(toBool([])).toBe(true); | |
}); | |
it("should return false for falsy values", function() { |
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
// `yield*`: yield delegation | |
function* gen1() { | |
yield gen2(); | |
yield* gen2(); | |
yield [3, 4]; | |
yield* [3, 4]; | |
} | |
function* gen2() { | |
yield 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
class YourConstruct { | |
constructor() {} | |
// implement iterable protocol | |
[Symbol.iterator]() { | |
// return an iterator | |
return { | |
// the iterator is iterable! | |
[Symbol.iterator]() { | |
return this; |
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 superhero(clazz) { | |
Object.defineProperty(clazz.prototype, 'isSuperHero', {value: true}); | |
return clazz; | |
} | |
@superhero | |
class MySuperHero { | |
constructor(first, last) { | |
this.name = `${first} ${last}`; | |
} |
OlderNewer