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
//only handles integerValue, doubleValue, stringValue and booleanValue | |
const getType = (val) => { | |
if (val === null) return 'nullValue' | |
const t = typeof val | |
switch (t) { | |
case 'number': return n % 1 === 0 ? 'integerValue' : 'doubleValue' | |
case 'string': | |
case 'boolean': | |
return t + 'Value' | |
} |
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
curl -X GET http://localhost:9500 -H 'Content-Type: application/json' -d '{ | |
"jsonrpc":"2.0", | |
"method":"hmy_estimateGas", | |
"params":[{ | |
"from": "0x7c41e0668b551f4f902cfaec05b5bdca68b124ce", | |
"to": "0x7c41e0668b551f4f902cfaec05b5bdca68b124ce", | |
"value": "0x1" | |
}], | |
"id": 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
import { getReducer, getState } from '../util/redux-util' | |
//default state | |
const defaultState = { | |
toggle: false | |
} | |
//reducer | |
const type = 'appReducer' | |
export const appReducer = getReducer(type, defaultState) | |
export const appState = getState(type) | |
//actions |
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
{ | |
"AC": { | |
"unicode": "U+1F1E6 U+1F1E8", | |
"name": "Ascension Island", | |
"emoji": "🇦🇨" | |
}, | |
"AD": { | |
"unicode": "U+1F1E6 U+1F1E9", | |
"name": "Andorra", | |
"emoji": "🇦🇩" |
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 cheerio = require('cheerio') | |
const request = require('request'); | |
let query = process.env.QUERY | |
if (!query) { | |
console.log('Please define an ENV var for QUERY="..."') | |
return -1 | |
} | |
query = encodeURIComponent(query) |
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
a=1 | |
for i in *.jpg; do | |
new=$(printf "%04d.jpg" "$a") #04 pad to length of 4 | |
mv -i -- "$i" "$new" | |
let a=a+1 | |
done | |
# from https://stackoverflow.com/a/3211670/1060487 |
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
SELECT con.* | |
FROM pg_catalog.pg_constraint con | |
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid | |
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace | |
WHERE | |
nsp.nspname = '<schema name>' | |
AND rel.relname = '<table name>'; | |
/* from: https://dba.stackexchange.com/a/214877/187757 */ |
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
[ | |
{ | |
"key": "ctrl+]", | |
"command": "workbench.action.terminal.focusNext" | |
}, | |
{ | |
"key": "ctrl+[", | |
"command": "workbench.action.terminal.focusPrevious" | |
}, | |
{ |
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
# start docker manually | |
sudo rm -rf /var/run/docker.pid; sudo dockerd & | |
# kill all docker ps | |
ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh | |
# restart as service | |
sudo systemctl restart docker | |
# build docker |
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 { lock, unlock } from './mutex.js' | |
async function processCallsLikeQueue() { | |
// stop method calls here | |
await lock('processCallsLikeQueue()') | |
// ... | |
// code to protect from re-entry | |
// i.e. prevent multiple simultaneous calls to this part of the code | |
// ... | |
// let next method call in |