Skip to content

Instantly share code, notes, and snippets.

View huzhifeng's full-sized avatar

Zhifeng Hu huzhifeng

View GitHub Profile
@huzhifeng
huzhifeng / thumbnailer.sh
Last active August 29, 2015 14:01
Create thumbnail for Images and Videos, depends on epeg and ffmpeg.
#!/bin/bash
photo_dir='.'
if test $# -gt 0; then
photo_dir=$1
fi
thumbnail_dir='_thumbnail'
# Create thumbnail for Images by epeg
for file in `find $photo_dir -type f -name "*.jpg"`
do
@huzhifeng
huzhifeng / thumbnail_cleanup.sh
Last active August 29, 2015 14:01
Cleanup thumbnail created by thumbnailer.sh
#!/bin/bash
photo_dir='.'
if test $# -gt 0; then
photo_dir=$1
fi
thumbnail_dir='_thumbnail'
find $photo_dir -type d -name $thumbnail_dir |xargs rm -rf
#!/bin/bash
full_path="/var/www/public/ch1.sec1.index.html"
dir=${full_path%/*}
filename=$(basename $full_path)
filename_with_ext=${full_path##*/}
filename_without_ext=${filename_with_ext%.*}
ext=${full_path##*.}
echo "Full path: $full_path" # /var/www/public/ch1.sec1.index.html
@huzhifeng
huzhifeng / smart_uncompress.sh
Created June 6, 2014 03:14
Smart uncompress
#!/bin/bash
smart_uncompress()
{
if [ $# -lt 1 ]; then
echo "At least one paramater required"
exit 1
fi
ftype="$(file $1)"
@huzhifeng
huzhifeng / forgifs.js
Last active August 29, 2015 14:03
Node.js crawler for http://forgifs.com
var request = require('request');
var cheerio = require('cheerio');
var util = require('util');
var baseUrl = 'http://forgifs.com';
function formatSrc(src) {
if (src.charAt(0) === '/') {
return util.format('%s%s', baseUrl, src);
} else if (src.indexOf('http://') === -1) {
var request = require('request');
var cheerio = require('cheerio');
//var Iconv = require('iconv').Iconv;
//var iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
var iconv = require('iconv-lite');
var util = require('util');
var baseUrl = 'http://www.gaoxiaogif.com';
var navItems = [
{
var request = require('request');
var cheerio = require('cheerio');
//var Iconv = require('iconv').Iconv;
//var iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
var iconv = require('iconv-lite');
var util = require('util');
var baseUrl = 'http://www.gifcool.com';
var options = {
'url': '',
var request = require('request');
var cheerio = require('cheerio');
//var Iconv = require('iconv').Iconv;
//var iconv = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
var iconv = require('iconv-lite');
var util = require('util');
var baseUrl = 'http://www.youqu5.com';
var navItems = [
{
var request = require('request');
var cheerio = require('cheerio');
var util = require('util');
var baseUrl = 'http://www.gifbin.com';
var options = {
'url': '',
'method': 'GET',
'headers': {
'User-Agent': 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36',
var request = require('request');
var cheerio = require('cheerio');
var util = require('util');
var baseUrl = 'http://www.tehcute.com';
var options = {
'url': '',
'method': 'GET',
'headers': {
'User-Agent': 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36',