Skip to content

Instantly share code, notes, and snippets.

Avatar
🐶
Wait for U

Peter Wang happypeter

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

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

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

名称注释:

View book.html
<!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;
View fff
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
compress videos and transcode
View ffmpeg_compress.sh
# 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 Dec 17, 2015
install the ffmpeg that actually works
View ffmpeg_install.sh
# 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
View 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 Jul 13, 2021
backup upyun files to local dir
View upyun_backup.sh
#!/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 Jun 16, 2020
everything needed to install a rails project on linode ubuntu1204, happycasts as an example
View get_linode_ready_for_rails.sh
#################################
#
# 本清单基于 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 Jul 3, 2020
upload my assets to the server
View happycasts_sync.sh
#!/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
}