Skip to content

Instantly share code, notes, and snippets.

View tyraeltong's full-sized avatar

Tyrael Tong tyraeltong

  • Vancouver, Canada
View GitHub Profile
@tyraeltong
tyraeltong / save_frame_as_jpeg.c
Created March 29, 2017 18:22
Save an AVFrame as a JPEG file using FFmpeg
int save_frame_as_jpeg(AVCodecContext *pCodecCtx, AVFrame *pFrame, int FrameNo) {
AVCodec *jpegCodec = avcodec_find_encoder(AV_CODEC_ID_JPEG2000);
if (!jpegCodec) {
return -1;
}
AVCodecContext *jpegContext = avcodec_alloc_context3(jpegCodec);
if (!jpegContext) {
return -1;
}
#!/usr/bin/env bash
# Pre-requisites
sudo apt-get -y update
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev vim
# Download and compile Ruby 2.1.3
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.3.tar.gz
tar -xvzf ruby-2.1.3.tar.gz
# Install Git needed for Git based gems
packages:
yum:
git: []

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@tyraeltong
tyraeltong / Emacs.md
Created January 27, 2012 06:11
Setting up Emacs daemon on OS X

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Homebrew

First you'll need to install the [Homebrew package manager][brew] if yo haven't already. It is amazing.

@tyraeltong
tyraeltong / rails_env_setup.rb
Created October 14, 2011 13:26
setup rails development environment for a fresh mac
def write(text="")
puts text
end
def say(message, subitem=false)
write "#{subitem ? " ->" : "--"} #{message}"
end
def say_custom(tag, text)
say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}"
@tyraeltong
tyraeltong / config_wordpress_nginx.bash
Created October 4, 2011 15:34
setup wordpress on linode vps part 2
server{
listen 80; #or change this to your public IP address eg 1.1.1.1:80
server_name wordpress; #change this to the domain name, for example www.myblog.com
access_log /var/log/wordpress.access_log;
error_log /var/log/wordpress.error_log;
location / {
root /home/your-user-name/Sites/wordpress;
index index.php index.html index.htm;
@tyraeltong
tyraeltong / create_mysql_account.bash
Created October 4, 2011 15:29
setup wordpress on linode vps
mysql -u root -p
mysql> create user blog@localhost identified by 'password';
mysql> create database blog;
mysql> grant all on blog.* to blog@localhost;
mysql> exit;
@tyraeltong
tyraeltong / bundle.bash
Created October 4, 2011 15:09
Getting Passenger work with RVM gemset
bundle install