Skip to content

Instantly share code, notes, and snippets.

View wangwenchao's full-sized avatar
🎯
Focusing

wwc wangwenchao

🎯
Focusing
View GitHub Profile
@wangwenchao
wangwenchao / salt-formula-setup.sh
Last active May 28, 2019 10:20 — forked from mortn/formula-setup.sh
Saltstack formula setup and updating
#!/bin/bash
formulas="sudoers timezone ntp openssh resolver iptables salt systemd users vim rsyslog logrotate vsftpd apt locale epel firewalld golang snmp iscsi lvm rsyncd sysctl zabbix dnsmasq haproxy keepalived docker nginx php postfix chrony letsencrypt libvirt nfs powerdns varnish redmine zookeeper postgres mysql kibana openvpn collectd apache tomcat etcd consul memcached django openvswitch bind ufw mongodb elasticsearch fail2ban vault prometheus node"
BASE_DIR=/srv
formula_root=$BASE_DIR/formulas
state_root=$BASE_DIR/states
pillar_root=$BASE_DIR/pillars
# git use git/https
git_url=git@github.com:saltstack-formulas
@wangwenchao
wangwenchao / get_esxi_guest_ip_address.sh
Created June 12, 2018 07:52 — forked from alexclifford/get_esxi_guest_ip_address.sh
ESXi: get the IP address of a host running VMware tools
#!/bin/bash
vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1 | xargs vim-cmd vmsvc/get.guest | grep ipAddress | sed -n 1p | cut -d '"' -f 2
# or
ssh esxi.example.com /bin/vim-cmd vmsvc/get.guest $(ssh esxi.example.com /bin/vim-cmd vmsvc/getallvms | grep -i hostname | cut -d ' ' -f 1) | grep ipAddress | sed -n 1p | cut -d '"' -f 2
@wangwenchao
wangwenchao / ca.md
Created March 20, 2018 09:18 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@wangwenchao
wangwenchao / ffprobe.help.txt
Created January 30, 2018 03:13 — forked from davinkevin/ffprobe.help.txt
ffprobe.help.txt
Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]
Main options:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
@wangwenchao
wangwenchao / Redmine installation
Created January 21, 2018 05:20 — forked from thanhhh/Redmine installation
How to configuration Redmine with puma and running on nginx (based on Gitlab's installation)
Add config/puma.ruby
--------------------
cd /home/redmine/redmine
sudo -u redmine -H curl --output config/puma.rb https://gist.github.com/thanhhh/5610668/raw/fdfe2a865c3a0afe912c8784c971ea7ca3e64cfd/puma.rb
Install Init Script
--------------------
Download the init script (will be /etc/init.d/redmine):
@wangwenchao
wangwenchao / RNN.md
Created December 15, 2017 13:41 — forked from rushilgupta/wip-RNN.md
Recurrent Neural Nets and Tensorflow

Intro

There is a lot of buzz around neural-nets and how cool they are for image-recognition and text-recognition. There are a lot of sources out there to learn tensorflow and their application to solve these set of problems.

I'd reommend a course offered by Google on Udacity which teaches all about this stuff: https://classroom.udacity.com/courses/ud730.

This course doesn't cover the details of mathematics behind neural-nets and so doesn't this gist. However, the instructors do go into the intuition, breaking down a complex problem like visual recognition into abstract concepts and writing a program to predict some tensors and ultimately those concepts.

Through this gist I've tried to cover a very basic introduction to the tensorflow framework, the data structures it uses and it's application in a predictive-text model.

What is a tensor?

@wangwenchao
wangwenchao / python-ffmpeg.py
Created November 20, 2017 10:18 — forked from hiwonjoon/python-ffmpeg.py
ffmpeg and ffprobe subprocess call in python; extract specific frame at some timepoint, extract duration of a video
import subprocess
import datetime
import numpy as np
THREAD_NUM=4
def get_video_info(fileloc) :
command = ['ffprobe',
'-v', 'fatal',
'-show_entries', 'stream=width,height,r_frame_rate,duration',
@wangwenchao
wangwenchao / GoConcurrency.md
Last active October 18, 2017 02:48 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@wangwenchao
wangwenchao / delete_es_index.sh
Created July 28, 2017 09:21
delete old es index
#!/bin/sh
# example: sh  delete_es_by_day.sh logstash-kettle-log logsdate 30
 
index_name=$1
daycolumn=$2
savedays=$3
format_day=$4
 
if [ ! -n "$savedays" ]; then
  echo "the args is not right,please input again...."
@wangwenchao
wangwenchao / 1) Install
Last active October 10, 2023 09:02 — forked from nghuuphuoc/1) Install
Install Redis and php-redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm