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 / 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 / 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
}
@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 / Traps.markdown
Created September 12, 2012 07:33 — forked from billie66/nginx.conf
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mysql
  1. the default index.html does not work well in prodution mode, so do not borther to config that, just delete it and go on.

  2. To put things in production mode, do

     rails g scaffold items name:string
     rake db:migrate RAILS_ENV=production
     rm public/index.html
     #change route.rb point root to items#index
     rake assets:precompile
     sudo service nginx restart
    

./config/unicorn_init.sh stop

@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 / mac_fuck_gfw.sh
Last active July 3, 2016 06:03
FUCK GWF apple script
#!/user/bin/env bash
on_die() {
echo
echo byebye proxy
echo
networksetup -setsocksfirewallproxystate "Ethernet 2" off #close the proxy
# the name can be "wifi" or "Ethernet 1", just see what is listed in "network preference"
}
@happypeter
happypeter / db_backup.sh
Created June 27, 2012 12:04
db backup with git
#!/usr/bin/env bash
ssh linode 'cd local_clone; cd happynewsdb; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot authlove_development>authlove_development.sql; \
git commit -a -m"i"; \
git push;\
cd ../happyecdb/ ; \
mysqldump --extended-insert=FALSE --complete-insert=TRUE -uroot ec_development>ec_development.sql; \
git commit -a -m"i"; \
git push;\
@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