Skip to content

Instantly share code, notes, and snippets.

@cnruby
cnruby / install imagemagick and rmagick on macosx
Created June 4, 2011 12:47
How TO INSTALL ImageMagick and RMagick on MacOSX
# mkdir download
# cd download
# 仅仅在MacOSX上安装软件ImageMagick
# 需要运行一段时间
sudo bash < <( curl -L http://lycom.de/bash/magick-installer.sh )
# 每当出现“Password: ”,请输入密码
# 或者
@cnruby
cnruby / gist:893798
Created March 30, 2011 03:15
How To Use Rails The Function gsub_file
gsub_file 'config/environments/production.rb', /config.i18n.fallbacks = true/ do <<-'RUBY'
config.i18n.fallbacks = true
config.action_mailer.default_url_options = { :host => 'yourhost.com' }
RUBY
end
gsub_file 'config/environments/production.rb', /config.i18n.fallbacks = true/, "\
config.i18n.fallbacks = true
config.action_mailer.default_url_options = { :host => 'yourhost.com' }"
@cnruby
cnruby / install ncurses on macosx
Created May 7, 2011 09:05
HOW TO INSTALL ncurses on MacOSX
$ curl -O ftp://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
$ tar -xzvf ncurses-5.9.tar.gz
$ cd ./ncurses-5.9
$ ./configure --prefix=/usr/local \
--without-cxx --without-cxx-binding --without-ada --without-progs --without-curses-h \
--with-shared --without-debug \
--enable-widec --enable-const --enable-ext-colors --enable-sigwinch --enable-wgetch-events \
&& make
$ sudo make install
@cnruby
cnruby / install sqlite3 on debian
Created May 8, 2011 21:02
HOW TO INSTALL SQLITE3 ON DEBIAN
$ aptitude install sqlite3 libsqlite3-dev
$ wget http://www.sqlite.org/sqlite-autoconf-3070400.tar.gz
$ apt-get build-dep sqlite3
$ tar vvvvvxzf sqli*
$ cd sqli* && ./configure
$ make && make install
$ cp /usr/local/lib/libsqlite3.* /usr/lib/
$ ldconfig
@cnruby
cnruby / add_passwor_ssh_config.md
Last active July 1, 2020 19:26
adding password to .ssh/config

using ssh-forever

# need to install ruby
# install ssh-forever on macos or linux
gem install ssh-forever
# adding password to .ssh/config
@cnruby
cnruby / ls-recursively-wildcards.md
Created June 13, 2020 09:18
Run `ls` recursively with wildcards
@cnruby
cnruby / bfg.md
Last active June 13, 2020 08:39
BFG Repo-Cleaner: Remove files and folders from git history permanently(代码库历史文件和目录删除软件)
  • Remove files and folders from git history permanently(代码库历史文件和目录删除软件)
  • Removes large or troublesome blobs like git-filter-branch does, but faster, simpler, better and easier

Step 0: Get tool: BFG Repo-Cleaner

wget https://repo1.maven.org/maven2/com/madgag/bfg/1.13.0/bfg-1.13.0.jar

Step 1: download your Repo

@cnruby
cnruby / cut_video.sh
Last active March 28, 2020 01:04
Cutting the videos based on start and end time using ffmpeg
// https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg
INPUT_VIDEO=input
CUT_OUTPUT_VIDEO=cut_output
BEGIN_TIME="00:00:03"
END_TIME="00:00:08"
ffmpeg -ss $BEGIN_TIME -t $END_TIME -i $INPUT_VIDEO.mp4 -acodec copy -vcodec copy -async 1 $CUT_OUTPUT_VIDEO.mp4
@cnruby
cnruby / merging-mp4.sh
Last active March 26, 2020 21:24
ffpmeg-merging-mp4-video-files
# install ffmpeg on MacOS
brew install ffmpeg
brew cask install vlc
# merge two vidoes into one video
ls
INPUT_VIDEO_1=input_01
INPUT_VIDEO_2=input_02
OUTPUT_VIDEO=output
ffmpeg -i $INPUT_VIDEO_1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts $INPUT_VIDEO_1.ts
@cnruby
cnruby / fix_permissions.sh
Created March 26, 2020 18:59
how to fix Homebrew permissions?
# fix my permissions for OSX Homebrew
# https://github.com/Homebrew/legacy-homebrew/issues/43301
sudo chown -R "$USER":admin /usr/local