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
| { | |
| "fileFormatTypes": [ | |
| { | |
| "desc": "An RGBA color", | |
| "props": [ | |
| { | |
| "name": "r", | |
| "type": "Number", | |
| "content": "Red channel value, between 0 and 1" | |
| }, |
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
| #!/usr/bin/env python | |
| '''Crop an image to just the portions containing text. | |
| Usage: | |
| ./crop_morphology.py path/to/image.jpg | |
| This will place the cropped image in path/to/image.crop.png. | |
| For details on the methodology, see |
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 clone(thing, opts) { | |
| var newObject = {}; | |
| if (thing instanceof Array) { | |
| return thing.map(function (i) { return clone(i, opts); }); | |
| } else if (thing instanceof Date) { | |
| return new Date(thing); | |
| } else if (thing instanceof RegExp) { | |
| return new RegExp(thing); | |
| } else if (thing instanceof Function) { | |
| return opts && opts.newFns ? new Function('return ' + thing.toString())() : thing; |
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
| // more minimal version of https://github.com/olahol/scrollparent.js/blob/master/scrollparent.js | |
| const regex = /(auto|scroll)/; | |
| const style = (node, prop) => | |
| getComputedStyle(node, null).getPropertyValue(prop); | |
| const scroll = (node) => | |
| regex.test( | |
| style(node, "overflow") + | |
| style(node, "overflow-y") + |
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
| // sending to sender-client only | |
| socket.emit('message', "this is a test"); | |
| // sending to all clients, include sender | |
| io.emit('message', "this is a test"); | |
| // sending to all clients except sender | |
| socket.broadcast.emit('message', "this is a test"); | |
| // sending to all clients in 'game' room(channel) except sender |
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
| /** | |
| * This code is licensed under the terms of the MIT license | |
| * | |
| * Deep diff between two object, using lodash | |
| * @param {Object} object Object compared | |
| * @param {Object} base Object to compare with | |
| * @return {Object} Return a new object who represent the diff | |
| */ | |
| function difference(object, base) { | |
| function changes(object, base) { |