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
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@czyang
czyang / gist:c2672eed208a7b0b99c9
Last active August 29, 2015 14:08
This bash script use ImageMagick trim the transparent part of the images in a directory.
#!/bin/bash
# This script need ImageMagick
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for file in *.png
do
echo "trim: $file"
convert $file -trim $file
done
@czyang
czyang / ss-install.md
Last active May 22, 2016 08:21 — forked from aa65535/ss-install.md
shadowsocks-libev install at Debian or CentOS

Debian

cd /tmp
# 下载源码
git clone https://github.com/shadowsocks/shadowsocks-libev.git
# 开始编译
cd shadowsocks-libev
./autogen.sh
./configure --prefix=/usr && make
make install
@czyang
czyang / downloads.js
Created November 11, 2016 10:11 — forked from xd547/downloads.js
ASUS DownloadMaster batch downloads
// 1. open DownloadMaster in chrome
// 2. use the code in chrome console
urls = ["", ""] //urls array
addDownload = function(url) {
showPanel();
document.getElementById("HTTP_usb_dm_url").value = url;
dm_add_status();
}
@czyang
czyang / README.md
Created February 10, 2017 11:05 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {

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:

@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
@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.
// #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 / .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() {