Skip to content

Instantly share code, notes, and snippets.

View pingzh's full-sized avatar

Ping Zhang pingzh

View GitHub Profile
# ==================
# Top-level metadata
# ==================
%global pybasever 3.9
# pybasever without the dot:
%global pyshortver 39
Name: python%{pybasever}
version: "2.1"
services:
wireguard:
image: linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
- PUID=1000
@pingzh
pingzh / run_alembic_command_with_code.py
Created February 10, 2021 06:54
Run alembic command with code
from alembic.config import Config
from alembic import command
def run_db_migrations(dsn: str) -> None:
LOGGER.info('Running DB migrations on %r', dsn)
alembic_cfg = Config('alembic.ini')
alembic_cfg.set_main_option('sqlalchemy.url', dsn)
command.upgrade(alembic_cfg, 'head')
import time
from airflow.configuration import conf
from airflow.utils.log.logging_mixin import LoggingMixin
class JobDispatcherExecutor(LoggingMixin):
def __init__(self, celery_executor, kubernetes_executor):
"""
"""
@pingzh
pingzh / provision_docker_in_aws.sh
Created January 11, 2020 05:12
Provision aws with docker
### ubuntu ###
sudo apt update -y
sudo apt install -y docker docker.io git net-tools vim tmux
sudo usermod -aG docker ubuntu
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo systemctl start docker
sudo systemctl enable docker
@pingzh
pingzh / headless.md
Created November 20, 2017 01:49 — forked from addyosmani/headless.md
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.

###rbenv, rbenv-rehash, rebenv-bundler http://dan.carley.co/blog/2012/02/07/rbenv-and-bundler/
###install ruby-build
###rbenv specifies local version, .ruby-version
###create .ruby-gemset, this will install those gems into this ruby version, and this gemset, under this ruby version.
#install rbenv
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
@pingzh
pingzh / js-crypto-libraries.md
Last active July 17, 2017 23:56 — forked from jo/js-crypto-libraries.md
List of JavaScript Crypto libraries.

JavaScript Crypto Libraries

I start with a list and plan to create a comparison table.

WebCryptoAPI

http://www.w3.org/TR/WebCryptoAPI/

This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.

shell -$SHELL
hardstatus alwayslastline '%{= kg}[ %{G}%H %{g}][%= %{= kB}%?%-Lw%?%{+b r}(%{G}%n*%f %t%?(%u)%?%{r})%{-b B}%?%+Lw%?%?%= %{g}%]'
@pingzh
pingzh / chrome.md
Last active June 3, 2016 05:00 — forked from 0xjjpa/chrome.md
Understanding Google Chrome Extensions

#Introduction

Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.

Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.

Table of Contents

  1. Understand the Chrome Architecture
  2. Understand the Tabs-Extension Relationship
  3. Picking the right interface for the job