Skip to content

Instantly share code, notes, and snippets.

View happypeter's full-sized avatar
🐶
Wait for U

Peter Wang happypeter

🐶
Wait for U
View GitHub Profile
@happypeter
happypeter / list.sh
Created August 10, 2017 08:08
当前文件夹下的所有 .mp4 文件,转换成一个 js 的 object
echo '[' > output.js
for item in `ls *.mp4`
do
if [ "$item" = "list.sh" ]
then
continue
fi
echo """ {
title: 'xxx',

现在来实现表单提交事件的相应,添加 handleSubmit 如下

<form onSubmit={this.handleSubmit} className="comment-form">
  <input type="text"  className="input" />
  <button type="submit" className="submit-btn" >提交</button>
</form>

名称注释:

@happypeter
happypeter / book.html
Created February 22, 2015 08:17
3d book
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>book</title>
<style>
/* Libro 3D */
* {margin:0; padding:0; border: 0 none; position: relative;}
.libro {
width: 276px;
@happypeter
happypeter / fff
Created October 27, 2014 12:43
byebye GFW
cleanup()
# example cleanup function
{
networksetup -setsocksfirewallproxystate wi-fi off
}
control_c()
# run if user hits control-c
{
echo -en "\n*** Ouch! Closing proxy ***\n"
@happypeter
happypeter / ffmpeg_compress.sh
Created May 15, 2013 03:36
compress videos and transcode
# http://ruby-china.org/topics/10987
# ffmpeg_compress.sh
# $1是源文件,$2是码率,网络传输建议码率是1024k~2048k,$3是分辨率,720p是-1:720,-1表示根据高720保持比例缩放,$4是视频比例,看源视频了,比如4:3, 3:2, 16:9等,$5是输出文件名
# 1st pass:
ffmpeg -i $1 -vcodec libx264 -vprofile high -preset slow -b:v $2 -maxrate $2 -bufsize 4000k -vf scale=$3 -aspect $4 -threads 0 -pass 1 -an -f mp4 /dev/null
# 2nd pass:
@happypeter
happypeter / ffmpeg_install.sh
Last active December 17, 2015 08:39
install the ffmpeg that actually works
# tested on ubuntu1204
# http://askubuntu.com/questions/148554/installingffmpeg-libx264-and-libavfilter
# remove the packages in the repo
sudo apt-get remove ffmpeg x264 libx264-dev
sudo apt-get update
# make sure this is successfully installed
@happypeter
happypeter / gitconfig
Created May 6, 2013 08:56
my ~/.gitconfig
[user]
name = Peter Wang
email = happypeter1983@gmail.com
[core]
editor = vim
[alias]
ci = commit -a -v
co = checkout
st = status
br = branch
@happypeter
happypeter / upyun_backup.sh
Last active July 13, 2021 06:57
backup upyun files to local dir
#!/bin/bash
HOST='v0.ftp.upyun.com'
USER='the_worker_name/the_bucket_name'
PASS='password_of_this_worker'
LCD='~/backup/'
RCD='uploads/'
lftp -c "open $HOST;
user $USER $PASS;
@happypeter
happypeter / get_linode_ready_for_rails.sh
Last active June 16, 2020 07:42
everything needed to install a rails project on linode ubuntu1204, happycasts as an example
#################################
#
# 本清单基于 ubuntu 12.04,
#
# 只是一个清单,不是一个可以安全执行的脚本
#
#################################
# create a linode,login as root, and create a common user for all the tasks
ssh root@the_ip_of_this_linode
@happypeter
happypeter / happycasts_sync.sh
Last active July 3, 2020 07:54
upload my assets to the server
#!/usr/bin/env bash
sync_dryrun()
{
echo
echo -e "\033[1m ...dryrun...\033[0m"
rsync -av --delete ~/happycasts/episodes/ peter@linode:~/media/assets/episodes/ --dry-run
echo -e "\033[1m ...dryrun...\033[0m"
echo
}