Skip to content

Instantly share code, notes, and snippets.

View czyang's full-sized avatar
🏠
Working from home

Chengzhi Yang czyang

🏠
Working from home
View GitHub Profile
# Count file number in a Zip file.
unzip -lqq test.zip | wc -l
@czyang
czyang / archive-commit-mac.sh
Created May 15, 2018 10:47 — forked from hereswhatidid/archive-commit-mac.sh
Custom file deployment actions for SourceTree. The zip archives generated retain directory structure so you can FTP them to a remote server in one shot. Actions are set up under Preferences -> Custom Actions and all have the Parameters set to "$REPO, $SHA"
#!/bin/sh
# creates a zip archive of the files modified in a merge.
args=("$@")
git archive -o deploy/deploy-${args[1]:0:7}.zip HEAD $(git diff-tree --no-commit-id --name-only -r ${args[1]})

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

@czyang
czyang / IDE-Atom.md
Created October 19, 2017 12:08 — forked from xiaobailong24/IDE-Atom.md
Atom 使用笔记

Atom 设置和取消代理

设置Shadowsocks代理

apm config set http-proxy socks5:127.0.0.1:1080
apm config set https-proxy socks5:127.0.0.1:1080

取消ssl

apm config set strict-ssl false
#!/bin/bash
# This script monitoring a web page, if get any error the error infomation will output to the log file.
# Usage: nohup ./monitoring_web_page.sh http://127.0.0.1 2>&1 >/tmp/monitoring_web_page.log &
SERVER=$1
PAUSE=10
while true
do
if curl -s --head $SERVER | grep "200 OK" > /dev/null
then
echo "The HTTP server on $SERVER is up! $(date)" > /dev/null
@czyang
czyang / .serverstatus.sh
Created October 18, 2017 09:18 — forked from seyDoggy/.serverstatus.sh
Shell script to monitor HTTP server status and email me when the server is not responding.
#!/bin/bash
NAME=Adam
TESTDATE=`date "+%B %e, %Y"`
TESTTIME=`date "+%H:%M:%S"`
auto_init() {
runTest
}
runTest() {
// #Warning! You Should Use this Code Carefully, and As Your Own Risk.
package main
import (
"fmt"
"net/url"
"strings"
)
/*
After hours searching, I can't find any method can get the result exact as the JS encodeURIComponent function.
@czyang
czyang / ctime.c
Created June 29, 2017 09:00 — forked from mmozeiko/ctime.c
ctime.c
/* ========================================================================
$File: tools/ctime/ctime.c $
$Date: 2016/05/08 04:16:55PM $
$Revision: 7 $
$Creator: Casey Muratori $
$Notice:
The author of this software MAKES NO WARRANTY as to the RELIABILITY,
SUITABILITY, or USABILITY of this software. USE IT AT YOUR OWN RISK.
@czyang
czyang / pimpl.cpp
Created June 14, 2017 10:06 — forked from cloudwu/pimpl.cpp
My version of pimpl
// My version of pimpl ([email protected])
// See http://en.cppreference.com/w/cpp/language/pimpl
#include <iostream>
// interface (widget.h)
class widget {
struct impl;
public:
static widget* create(int); // replacement of new

Keybase proof

I hereby claim:

  • I am czyang on github.
  • I am pixelbacter (https://keybase.io/pixelbacter) on keybase.
  • I have a public key whose fingerprint is AD8A AE85 DFD7 F43E 9CE3 34B9 3EF8 90CB 33BE 47D0

To claim this, I am signing this object: