Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@MichaelCurrin
MichaelCurrin / README.md
Last active April 6, 2025 18:23
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@thuhak
thuhak / elastic_dup_remove.py
Created April 26, 2020 06:06
remove duplicated records in elasticsearch
#!/usr/bin/env python3.6
# A description and analysis of this code can be found at
# https://alexmarquardt.com/2018/07/23/deduplicating-documents-in-elasticsearch/
from argparse import ArgumentParser
import hashlib
from elasticsearch import Elasticsearch
@ohld
ohld / update_metabase_docker.sh
Last active February 19, 2022 17:43
How to safely update Metabase if you use docker deployments WITHOUT ANY DATA LOSS
# check the name of metabase container
docker ps
# make a backup
docker cp metabase:/metabase.db /root/
# get updated version
docker pull metabase/metabase
# remove old running container

Postgres - Simple Master-Slave Replication

This is insecure, fast-to-setup setup of simple master-slave replication with dockerized PostgreSQL installation. Note, that below works with version postgres version 12.2: postgres (PostgreSQL) 12.2 (Debian 12.2-1.pgdg100+1).

Preparation:

# This is where your primary database files will be stored
@JeremyBernier
JeremyBernier / typeorm-upsert.ts
Created February 5, 2020 23:39
TypeORM upsert
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>}
*/
@adowning
adowning / monstache
Last active September 14, 2021 08:51
apt update
apt install build-essentials git
sudo apt-get install -y zsh
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sudo apt install -y default-jdk default-jre
sudo echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' > /etc/environment
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
@franciscojsc
franciscojsc / k8s-ubuntu.md
Created October 20, 2019 05:22
Ubuntu com Kubernetes

Ubuntu com k8s

O cluster Kubernetes que criaremos, utilizará três Droplets da DigitalOcean com Sistema Operacional Ubuntu 18.04. A criação dos Droplets foi realizada utilizando o utilitário de linha de comando doclt, mais informações de uso do doctl acesse o link.

Geralmente a VPS da DigitalOcean é chamada de Droplet.

Caso não tenha uma conta na DigitalOcean, utilize este link para fazer sua conta, assim você receberá 50 dólares em crédito para utilizar na DigitalOcean, durante 30 dias, a partir do momento que adicionar um método de pagamanto válido na sua conta.

Instalação do Tmux

time="2019-10-09T13:27:29Z" level=fatal msg="cannot create an instance of proxy: cannot create CA: invalid certificates: tls: private key does not match public key"
# String I used on the command line is: docker run -p 3128:3128 scrapinghub/crawlera-headless-proxy -d -a $crawleraAPIKey -z "(.*cdn.*)|(.*digicert.*)|(.*google.*)|(.*firefox.*)|(.*services.*)|(.*doubleclick.*)|(.*\.(css|jpg|png|woff|ttf|wof|jpeg|bmp|wav|mp4|ogg|webp))$" --tls-ca-certificate=/etc/ssl/certs/ca-certificates.crt
docker run -p 3128:3128 scrapinghub/crawlera-headless-proxy -d -a $APIKey -z ^((?!httpbin).)*$
@gfguthrie
gfguthrie / .zshrc
Created September 27, 2019 22:02
Lazy Load Homebrew NVM but still have default aliased Node in PATH
# normal brew nvm shell config lines minus the 2nd one
# lazy loading the bash completions does not save us meaningful shell startup time, so we won't do it
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
# add our default nvm node (`nvm alias default 10.16.0`) to path without loading nvm
export PATH="$NVM_DIR/versions/node/v$(<$NVM_DIR/alias/default)/bin:$PATH"
# alias `nvm` to this one liner lazy load of the normal nvm script
alias nvm="unalias nvm; [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"; nvm $@"