Skip to content

Instantly share code, notes, and snippets.

View dreampuf's full-sized avatar

Dreampuf dreampuf

View GitHub Profile
@dreampuf
dreampuf / sh.py
Created September 18, 2013 07:10
Integrate sh into fabric. Let fabric invoke more suitable.
#vi: fileencoding=utf-8
import os
import sys
import warnings
from functools import partial
from types import ModuleType
from fabric.operations import run, sudo, local
@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' ;;
#!/bin/bash
#
#
#
# Start on runlevels 3, 4 and 5. Start late, kill early.
# chkconfig: 345 95 05
#
#
#!/bin/bash
@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 / merge_subtitle.py
Last active September 2, 2017 07:16
Convert the Youtube captions to SRT file Usage : python merge_subtitle.py ~/Downloads/timedtext.xml ~/Downloads/timedtext_en.xml > ~/Downloads/James-Coplien---The-DCI-Architecture--Supporting-the-Agile-Agenda-\(hd-8235574\).Mix.srt
#!/usr/bin/env python
# -*- conding:utf-8 -*-
__author__ = "Dreampuf<soddyque@gmail.com>"
""" Convert the Youtube captions to SRT file
feature :
this script could able to merge some Youtube captions to one STR (like chinse, english mix SRT file)
@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 / 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 / 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 / Dockerfile
Created August 21, 2018 20:00
Pingfederate Container
from nimmis/java-centos:oracle-8-jre
ENV JAVA_HOME /usr/java/default
WORKDIR /opt
RUN yum install -y which tar nmap-ncat
ADD pf-install-9.1.2.sh /opt/pf-install.sh
RUN chmod +x /opt/pf-install.sh
RUN /opt/pf-install.sh // You need to run it manually
ENTRYPOINT ["sh", "-c", "/usr/local/pingfederate-1/bin/run.sh"]
@dreampuf
dreampuf / remote_ingest.sh
Created September 28, 2018 16:30
Docker Image Repository Ingest
token=$(curl -s -H "Authorization: Basic $(echo -n "USERNAME:PASSWORD" | base64)" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:sebp/elk:pull" | jq -r ".token")
configsha=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer ${token}" https://registry-1.docker.io/v2/sebp/elk/manifests/latest | jq -r .config.digest)
curl -sL -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer ${token}" https://registry-1.docker.io/v2/sebp/elk/blobs/sha256:4b52312ebe8d44f438eeecf08da2b4460250bd574642cc124bc5eaac4f1ebfc5 | jq