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 Jimp = require('jimp'); | |
const fileName = process.argv[2]; | |
const width = process.argv[3]; | |
const height = process.argv[4]; | |
Jimp.read(fileName) | |
.then(photo => { | |
let colours = {}; | |
for (let x = 0; x < width; x++) { |
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 wordList = { | |
sacrilege: {popularity: 0.5207411547}, | |
sarcasm: {popularity: 0.1913595276}, | |
said: {popularity: 0.736293578}, | |
sardine: {popularity: 0.2439570583}, | |
sars: {popularity: 0.6371759558}, | |
saw: {popularity: 0.1695272778}, | |
say: {popularity: 0.8312312658}, | |
scare: {popularity: 0.3623531581}, |
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 TOKEN_PATH = 'token.json'; | |
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets']; | |
const gapi = require('googleapis'); | |
const clientSecret = process.env.GOOGLE_CLIENT_SECRET; | |
const clientId = process.env.GOOGLE_CLIENT_ID; | |
const redirectUri = process.env.GOOGLE_REDIRECT_URI; | |
const oAuth2Client = new gapi.google.auth.OAuth2(clientId, clientSecret, redirectUri); | |
const fs = require('fs').promises; | |
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
2020-02-05 14:08:14.431 [apm-server-healthcheck] DEBUG co.elastic.apm.agent.report.ApmServerHealthChecker - Starting healthcheck to http://172.24.102.69:8200/ | |
2020-02-05 14:08:14.442 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 10:memory:/ | |
2020-02-05 14:08:14.442 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 9:hugetlb:/ | |
2020-02-05 14:08:14.442 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 8:devices:/ | |
2020-02-05 14:08:14.443 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 7:blkio:/ | |
2020-02-05 14:08:14.443 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 6:cpuacct,cpu:/ | |
2020-02-05 14:08:14.443 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - |
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
2020-02-05 11:20:19.512 [apm-server-healthcheck] DEBUG co.elastic.apm.agent.report.ApmServerHealthChecker - Starting healthcheck to http://172.24.102.69:8200/ | |
2020-02-05 11:20:19.522 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 10:net_cls:/ | |
2020-02-05 11:20:19.522 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 9:memory:/ | |
2020-02-05 11:20:19.523 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 8:hugetlb:/ | |
2020-02-05 11:20:19.523 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 7:perf_event:/ | |
2020-02-05 11:20:19.523 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Could not parse container ID from '/proc/self/cgroup' line: 6:devices:/ | |
2020-02-05 11:20:19.524 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo |
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
module.exports = { | |
"env": { | |
"commonjs": true, | |
"es2021": true | |
}, | |
"extends": "eslint:recommended", | |
"parserOptions": { | |
"ecmaVersion": 13 | |
}, | |
"rules": { |
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
// without event sourcing | |
function transferMoneyBetweenAccounts(amount, fromAccount, toAccount) { | |
BankAccount.where({ id: fromAccount.id }) | |
.decrement({ amount }); | |
BankAccount.where({ id: toAccount.id }) | |
.increment({ amount }); | |
} | |
function makeOnlinePayment(account, amount) { | |
BankAccount.where({ id: account.id }) |
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
// the base command class or interface | |
class Command { | |
handle() { | |
} | |
} | |
class CreateUserCommand extends Command { | |
constructor(user) { | |
super(); | |
this.user = user; |
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 { createStore } from 'redux'; | |
// our reducer | |
const tweets = (state = {tweets: []}, action) => { | |
switch (action.type) { | |
// we'll handle only one action: when new tweets arrive | |
case 'SHOW_NEW_TWEETS': | |
state.numberOfNewTweets = action.count; | |
return state.tweets.concat([action.tweets]); | |
default: |
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 debounce(f, t) { | |
return function (args) { | |
let previousCall = this.lastCall; | |
this.lastCall = Date.now(); | |
if (previousCall && ((this.lastCall - previousCall) <= t)) { | |
clearTimeout(this.lastCallTimer); | |
} | |
this.lastCallTimer = setTimeout(() => f(args), t); | |
} | |
} |