Skip to content

Instantly share code, notes, and snippets.

View chengdh's full-sized avatar

chengdh

  • 中国郑州
View GitHub Profile
@chengdh
chengdh / gist:07a30b75af658208550cdefc58906bb1
Created May 25, 2017 09:08 — forked from jcataluna/gist:1dc2f31694a1c301ab34dac9ccb385ea
Script to save all images from a docker-compose.yml file
#!/bin/bash
mkdir -p out
for img in `grep image $1| sed -e 's/^.*image\: //g'`;
do
cleanname=${img/\//-}
tag=`docker images | grep $img | awk '{print $2}'`
echo "Exporting image: $img, tag:$tag ($cleanname)..."
docker save $img -o out/$cleanname.tar
@chengdh
chengdh / percona-xtrabackup.sh
Created August 28, 2016 00:49 — forked from jaygooby/percona-xtrabackup.sh
Call via crontab on whatever schedule suits you; keep n full mysql Percona xtrabackups of your mysql database, with binary logs applied. Also does a full mysqldump that can then have the binary logs applied to restore to a point-in-time backup via the binlogs. Copy all of this (backup, mysqldump, binlogs) to S3.
#!/bin/bash
#
# Carries out a full mysqldump, calls percona-xtrabackup and then
# copies the sql dump, the percona backup and your mysql bin logs
# to S3 using s3cmd http://s3tools.org/s3cmd
#
# TODO: extract out the S3 backup stuff to make it optional, and so
# other s3 programs can replace the s3cmd call.
# TODO: the if [ $? == 0 ] alert blocks should be a function
# TODO: make the if [ $? == 0 ] if [ $? != 0 ] more consistent - test
@chengdh
chengdh / master.vim
Created March 3, 2014 15:01 — forked from gmccreight/master.vim
vim练习脚本
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
#!/bin/sh
#
# gunicorn_sr Startup script for gunicorn for sr
#
# chkconfig: - 86 14
# processname: gunicorn
# pidfile:
# description: Python application server in ubuntu
#
### BEGIN INIT INFO
@chengdh
chengdh / patch.sh
Created November 3, 2013 14:08 — forked from dlo/patch.sh
修正PIL的错误问题
#!/bin/sh
# Ref: http://ubuntuforums.org/showthread.php?t=1751455
# Uninstall PIL
# sudo pip uninstall PIL -q
# Install required libs
yes | apt-get install build-essential python-dev zlib1g-dev liblcms1-dev libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
# Link to correct location
@chengdh
chengdh / my.cnf.txt
Created August 29, 2012 09:58 — forked from sr75/my.cnf.txt
mysql-innodb-large-server-example-configuration
# *** Application-specific options follow here ***
#
# The MySQL server
#
[mysqld]
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
@chengdh
chengdh / demo.html
Created August 20, 2012 09:48 — forked from insin/index.html
Export a <table> to Excel
<!DOCTYPE html>
<html>
<head>
<title>tableToExcel Demo</title>
<script src="tableToExcel.js"></script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>
@chengdh
chengdh / unicorn.conf
Created August 13, 2012 06:23 — forked from pshima/unicorn.conf
Unicorn logrotate
/path/to/unicorn/log/unicorn.stderr.log
/path/to/production/log/production.log
{
daily
missingok
rotate 180
compress
dateext
# this is important if using "compress" since we need to call
@chengdh
chengdh / example_migration.rb
Created August 10, 2012 01:20 — forked from mmrwoods/example_migration.rb
Rails migration helper for dealing with large tables in MySQL
require "mysql_big_table_migration_helper"
class AddIndexOnSomeColumnToSomeTable < ActiveRecord::Migration
extend MySQLBigTableMigrationHelper
def self.up
add_index_using_tmp_table :some_table, :some_column
end
@chengdh
chengdh / ubuntu_rials_server_install
Created August 6, 2012 07:30 — forked from EricLondon/ubuntu_rials_server_install
Ubuntu Rails Server Install
# update installed packages
sudo apt-get update
sudo apt-get upgrade
# ssh server
sudo apt-get install openssh-server -y
# install curl
sudo apt-get install curl -y