Skip to content

Instantly share code, notes, and snippets.

View pingzh's full-sized avatar

Ping Zhang pingzh

View GitHub Profile
@pingzh
pingzh / b.rb
Last active August 23, 2016 02:03
add :
def hi
puts "try"
puts "vim w"
puts "change"
puts "hi"
en
###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 / 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.

@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
{
"documents": [
{
"id": "1",
"language": "en",
"text": "I had a wonderful experience! The rooms were wonderful and the staff was helpful."
},
{
"id": "2",
"language": "en",
@pingzh
pingzh / stream_pod.py
Created August 24, 2020 06:30
An example of streaming pod events from k8s for a namespace
from datetime import datetime
from kubernetes import client, config, watch
config.load_kube_config()
# Create a configuration object
with_ssl_disabled_config = client.Configuration()
with_ssl_disabled_config.verify_ssl = False
api_client = client.ApiClient(with_ssl_disabled_config)
v1 = client.CoreV1Api(api_client)
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 / 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')
version: "2.1"
services:
wireguard:
image: linuxserver/wireguard
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE
environment:
- PUID=1000
# ==================
# Top-level metadata
# ==================
%global pybasever 3.9
# pybasever without the dot:
%global pyshortver 39
Name: python%{pybasever}