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 data1 = { | |
| attributes: { | |
| domain: 'from.attributes.com' | |
| } | |
| } | |
| const data2 = { | |
| attributes: { | |
| unknownAttributes: { | |
| domain: 'from.unknownAttributes.com' |
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
| -- find biggest database | |
| SELECT *, pg_size_pretty(total_bytes) AS total | |
| , pg_size_pretty(index_bytes) AS INDEX | |
| , pg_size_pretty(toast_bytes) AS toast | |
| , pg_size_pretty(table_bytes) AS TABLE | |
| FROM ( | |
| SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM ( | |
| SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME | |
| , c.reltuples AS row_estimate | |
| , pg_total_relation_size(c.oid) AS total_bytes |
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
| brew doctor | |
| brew update | |
| brew services list | |
| brew services stop postgres | |
| brew uninstall postgres | |
| rm -rf /usr/local/var/postgres | |
| rm -rf /usr/local/opt/postgresql | |
| rm -rf .psql_history .psqlrc .psql.local .pgpass .psqlrc.local | |
| # then use docker to start local postgres to avoid all these issues with running postgres on your local |
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 fs = require('mz/fs'); | |
| const read = async() => { | |
| const root = '/Users/testing-s3-2/' | |
| let html = `<html><table style="width:100%" border="1">` | |
| const folders = await fs.readdir(root); | |
| for (const folder of folders) { | |
| if (!fs.lstatSync(folder).isDirectory()) continue; | |
| if (folder.startsWith('.') || folder.startsWith('node_modules')) continue; | |
| html += '<tr>' |
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
| #! /bin/sh - | |
| # that also works in any sh, so you don't even need to have or use bash | |
| file_pattern="/Users/ondrej/Downloads/emails/*.dms" | |
| # all uppercase variables should be reserved for environment variables | |
| IFS='' # disable splitting | |
| for f in $file_pattern # here we're not quoting the variable so | |
| # we're invoking the split+glob operator. |
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
| #!/bin/bash | |
| CUR_DIR=$(pwd) | |
| echo "\n\033[1mPulling in latest changes for all repositories in $CUR_DIR directory\033[0m\n" | |
| for i in $(find . -name ".git" | cut -c 3-); do | |
| echo ""; | |
| echo "\033[33m"+$i+"\033[0m"; | |
| cd "$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
| /** | |
| * Copyright 2017, Google, Inc. | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, |
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
| async function doSomething() { | |
| return 'some result' | |
| } | |
| async function doSomethingAndFail() { | |
| throw new Error() | |
| } | |
| describe('promise testing', () => { |
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 base64 | |
| payload = 'VKlNGb4mCR/5BBunW4d7jpwp/KI1pRcsW/DeuMzXThh+nz8HRMI54bmWLKjC3haJuBGZQmX/SfNIACU=' | |
| payloadEncoded = payload.encode("UTF-8") | |
| payloadArray = base64.b64decode(payload) | |
| nonceArray = payloadArray[0:24] | |
| msgArray = payloadArray[24:len(payloadArray)] | |
| from nacl.secret import SecretBox |
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 input = 'hi:ha:ho'; | |
| const matches = input.match(/(.*):(.*):(.*)/); | |
| const firstGroup = matches[1]; | |
| const secondGroup = matches[2]; | |
| const thirdGroup = matches[3]; | |
| console.log(firstGroup, secondGroup, thirdGroup); | |
| // prints out: hi ha ho |