Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@WooodHead
WooodHead / serverless-deploy.yml
Created December 29, 2020 15:12 — forked from hadynz/serverless-deploy.yml
Serverless deploy with state management in S3
name: Continuous deploy
on:
push:
branches: [master]
jobs:
serverless-deploy:
runs-on: ubuntu-latest
@WooodHead
WooodHead / background.js
Created December 8, 2020 04:13 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@WooodHead
WooodHead / background.js
Created December 8, 2020 04:13 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at [email protected] or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

@WooodHead
WooodHead / psql_useful_stat_queries.sql
Created October 18, 2020 06:30 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@WooodHead
WooodHead / settings.jsonc
Created October 9, 2020 04:36 — forked from anton-dudarev/settings.jsonc
Microsoft Terminal Settings
// This file was initially generated by Windows Terminal 0.11.1191.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@WooodHead
WooodHead / hyper.js
Created October 9, 2020 03:43 — forked from coco-napky/hyper.js
Hyper config for git bash in Windows
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
@WooodHead
WooodHead / parallel.sh
Created October 8, 2020 12:27 — forked from gmolveau/parallel.sh
todo parallel commands
cat urls.txt | xargs youtube-mp4 {}
cat urls.txt | xargs zsh -c 'youtube-mp4 {}'
cat urls.txt | xargs $functions[youtube-mp4] {}
cat urls.txt | xargs zsh -c '$functions[youtube-mp4] {}'
cat urls.txt | parallel curl http://example.com/item/{}.tar ">" {}.tar
@WooodHead
WooodHead / README.md
Created October 8, 2020 06:28 — forked from gousiosg/README.md
Restoring the GHTorrent MongoDB database

This is a collection of scripts to restore a full GHTorrent MongoDB database from the dumps available at http://ghtorrent-downloads.ewi.tudelft.nl.

To do the restore:

  1. Open a MongoDB terminal and run the createCollections.js script to create the necessary collections. You can block_compressor to either snappy or zlib to make your databases compressed. I am using none here, as I am using compression at the filesystem level.

  2. Run restore-cummulative-dumps.sh to restore the cummulative dumps. Wait 3-4 days.

import { getRepository, InsertResult } from "typeorm";
/**
* Upsert for TypeORM on PostgreSQL
* Returns InsertResult object (contains ID)
* @param repo Repository
* @param {object | object[]} data Data to upsert. Can be object or array
* @param {string} primaryKey Name of column that is primary key
* @returns {Promise<InsertResult>}
*/