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
| // Similar to Ruby array `last` method | |
| Object.defineProperty(Array.prototype, "last", { | |
| get: function(){ | |
| return this.length && this[this.length-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
| // Adapted from: https://nodejs.org/docs/latest/api/cluster.html | |
| const cluster = require('cluster'); | |
| const http = require('http'); | |
| const numCPUs = require('os').cpus().length; | |
| if (cluster.isMaster) { | |
| console.log(`Master ${process.pid} is running on ${numCPUs} numCPUs`); | |
| // Fork workers. |
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
| const LOG_LEVELS = { | |
| DEBUG: 1000, | |
| INFO: 2000, | |
| WARN: 3000, | |
| ERROR: 4000, | |
| NONE: 5000 | |
| } | |
| export function makeFakeLogger (log_level_override) { |
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
| import requests | |
| import time | |
| THRESHOLD = 1000000 | |
| packages = ["babel-core","babel-loader","babel-plugin-transform-flow-strip-types","babel-plugin-transform-object-rest-spread","babel-preset-es2015","babel-preset-react","babel-register","chai","chai-enzyme","cheerio","codecov","css-loader","enzyme","expect","file-loader","flow-bin","json-loader","mocha","node-sass","nyc","react-addons-test-utils","sass-loader","style-loader","url-loader"] | |
| for package in packages: | |
| url = "https://api.npmjs.org/downloads/range/2018-11-12:2018-12-09/" + package | |
| resp = requests.get(url) | |
| data = resp.json() |
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 wrap_selectors (selectors, state_path) { | |
| const wrapped_selectors = {} | |
| Object.keys(selectors).forEach(selector_key => { | |
| wrappedSelectors[selectorKey] = (state, ...args) => selectors[selectorKey](state[statePath], ...args) | |
| }) | |
| return wrapped_selectors | |
| } |
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
| // Based off: https://gist.github.com/jasonleonhard/177b67f135c443719fe8 | |
| function removeElement (element) { | |
| element.parentNode.removeChild(element); | |
| } | |
| function removeElements (elements) { | |
| for (var i = 0; i < elements.length; ++i) { | |
| removeElement(elements[i]); | |
| } |
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
| // state/reducers/schema.ts or spread through sub reducers/schema.ts files. | |
| interface SettingsState { | |
| favouriteColor: string | |
| } | |
| interface UsersState { | |
| count: number | |
| settings: SettingsState | |
| } |
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
| # Your database is probably in: ~/Library/Application Support/Google/Chrome/Default/History | |
| # Copy it to ./chrome_history | |
| import sqlite3 | |
| conn = sqlite3.connect("./chrome_history") | |
| # Manually exploring the db and foreign keys etc | |
| # print(conn.execute("SELECT name FROM sqlite_master WHERE type='table';").fetchall()) |
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
| using System; | |
| //using System.Web.Extensions; | |
| //using System.Web.Script.Serialization; | |
| /************************************************ | |
| * State | |
| ***********************************************/ | |
| public abstract class State<SubClassState> | |
| { |
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
| # Takes text with the format: | |
| # | |
| # 00:05 | |
| # Some subtitles | |
| # 00:12 | |
| # Some more text | |
| # ... | |
| # | |
| # 61:20 | |
| # More subtitle at 61 minutes, 20 seconds |