Skip to content

Instantly share code, notes, and snippets.

View dreampuf's full-sized avatar

Dreampuf dreampuf

View GitHub Profile
@dreampuf
dreampuf / tutorial.md
Created July 25, 2018 18:24 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@dreampuf
dreampuf / buildrpm.sh
Created May 23, 2018 18:28
Promethues RPM package generator
#!/bin/bash
# Automatic generate a rpm package for prometheus component
# Author: dreampuf <soddyque@gmail.com>
# Usage: buildrpm.sh package_url
# Example: buildrpm.sh https://github.com/prometheus/mysqld_exporter/releases/download/v0.10.0/mysqld_exporter-0.10.0.linux-amd64.tar.gz
URL=${1}
FILENAME=${URL##*/}
PACKAGEFOLDERNAME=${FILENAME%%.tar*}
APPNAME=${FILENAME%%-*}
@dreampuf
dreampuf / build.sh
Created May 4, 2018 02:51
Build gvisor from centos:latest container
git clone --depth 1 https://github.com/google/gvisor.git
cd gvisor
docker --rm -it "$PWD":/opt/gvisor -w /opt/gvisor centos bash
curl -O /etc/yum.repos.d/vbatts-bazel-epel-7.repo https://copr.fedorainfracloud.org/coprs/vbatts/bazel/repo/epel-7/vbatts-bazel-epel-7.repo
yum install -y epel-release bazel gcc gcc-c++ git protobuf-devel protobuf-lite-devel
env CC=/usr/bin/gcc bazel build runsc
@dreampuf
dreampuf / bootstrap_develop_environment.sh
Last active October 9, 2021 10:04
Bootstrap_develop_environment.sh
#!/usr/bin/env bash
# Install Homebrew first
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# If you need a mirror repo (in case you are in China)
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git clone https://mirrors.ustc.edu.cn/homebrew-core.git "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git "$(brew --repo homebrew/cask)"
git clone https://mirrors.ustc.edu.cn/homebrew-cask-versions.git "$(brew --repo)/Library/Taps/homebrew/homebrew-cask-versions"
#!/bin/bash
#
#
#
# Start on runlevels 3, 4 and 5. Start late, kill early.
# chkconfig: 345 95 05
#
#
#!/bin/bash
@dreampuf
dreampuf / .profile.sh
Created February 1, 2016 07:08
JetBrains downloader
function jetbrains_downloader() {
pkg=$1
if [[ -z $pkg ]]; then
echo "Please execute with these project name to download it";
echo "=============";
fi
ostype='linux'
case `uname` in
Linux)
ostype='linux' ;;
@dreampuf
dreampuf / remote_salt_ssh.sh
Last active July 18, 2017 08:34
Salt-master/Python2.6 execute salt-ssh/Python2.7
# Replace the HAS_XML assign in thin.py
$ sed -i 's#HAS_XML = True#HAS_XML = False#' $(python2.6 -c "import salt; print salt.__path__[0];")/utils/thin.py
# clean up the local thin package cache
rm /var/cache/salt/master/thin/thin.tgz
# addition `-w` and `-W` options in your command
salt-ssh -w -W -i --roster-file ROSTER_FILE 'HOSTNAME' state.sls minion-setup
@dreampuf
dreampuf / marathon.yml
Last active December 14, 2015 01:35
Marathon single compose yml
# Zookeeper: -p 2181:2181 -p 2888:2888 -p 3888:3888
zookeeper:
image: jplock/zookeeper
ports:
- "2181"
- "2888"
- "3888"
master:
image: mesosphere/mesos-master:0.25.0-0.2.70.ubuntu1404
@dreampuf
dreampuf / build_python_rpm_package.sh
Created November 25, 2015 09:04
Build yourself Python 2.7 rpm package in RHEL5/CENTOS5
# 1. install pyenv and with it download python 2.7.10
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
exec $SHELL
pyenv install 2.7.10
pyenv rehash
# 2. install rvm and fpm gem package
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
@dreampuf
dreampuf / sqlite3_wal_test.py
Created November 11, 2015 06:06
Sqlite WAL test
import time
from playhouse.sqlite_ext import SqliteExtDatabase
sqlite_db = SqliteExtDatabase('my_app.db', journal_mode="WAL", autocommit=False)
with sqlite_db.transaction() as cursor:
cursor = sqlite_db.execute_sql("""CREATE TABLE server_status (
id INTEGER PRIMARY KEY,
time_created INT);""")
assert cursor.rowcount == -1