Skip to content

Instantly share code, notes, and snippets.

def create
@img = Img.new(img_params.except("pic"))
@img.pic = img_params.delete("pic")
@ianchen06
ianchen06 / phantomjs_install.sh
Last active April 13, 2019 09:26
How to install PhantomJS on CentOS/RHEL
yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
tar -xjvf ~/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 --strip-components 1 /opt/phantomjs/
sudo yum install libffi-devel openssl-devel
pip install pyopenssl pyasn1
pip install requests[security]
@ianchen06
ianchen06 / install_mp4box.sh
Last active May 11, 2017 14:10
Install MP4Box on CentOS 6
# Install MP4Box on Centos 6
git clone https://github.com/gpac/gpac
git checkout 97eaffd
./configure
make all
sudo make install-lib install
echo "/usr/local/lib" >> /etc/ld.so.conf.d/gpac.conf
sudo /sbin/ldconfig
@ianchen06
ianchen06 / config.sh
Created July 17, 2015 01:40
Configure SSH via public IP when an OpenVPN connection is present
#Hi,
#(First, I assume you've tested the VPN and verified that it's actually working, i.e. you can make connections from your Linode and they're routed over the VPN.)
#This is a classic problem: when you connect to the Linode by its public IP address, the return packets get routed over the VPN. You need to force these packets to be routed over the public eth interface. These route commands should do the trick:
#Code:
ip rule add from x.x.x.x table 128
ip route add table 128 to y.y.y.y/y dev ethX
ip route add table 128 default via z.z.z.z
#!/bin/sh -x
# ==================================
# iptables default configuration script
#
# - this locks down our servers port access
# ==================================
# install fail2ban
sudo apt-get update
@ianchen06
ianchen06 / nginx.conf
Last active August 29, 2015 14:26 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your location block(s):
#
# include cors_support;
#
# A limitation to this method is that Nginx doesn't currently send headers
@ianchen06
ianchen06 / ufw_centos.md
Created August 5, 2015 08:28
Setting up ufw on Centos
@ianchen06
ianchen06 / vim_lua_install.sh
Created August 21, 2015 14:23
Install Vim with Lua on Ubuntu 14.04
sudo apt-get remove vim vim-runtime vim-tiny vim-common
# Install dependencies
sudo apt-get install libncurses5-dev python-dev libperl-dev ruby-dev liblua5.2-dev
# Fix liblua paths
sudo ln -s /usr/include/lua5.2 /usr/include/lua
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.2.so /usr/local/lib/liblua.so
# Clone vim sources
@ianchen06
ianchen06 / remap.sh
Created September 1, 2015 00:07
Remap capslock key to ctrl
sudo apt-get install xcape
Then configure it in the following way:
# make CapsLock behave like Ctrl:
setxkbmap -option ctrl:nocaps
# make short-pressed Ctrl behave like Escape:
xcape -e 'Control_L=Escape'
@ianchen06
ianchen06 / video-fix-videos-for-pseudo-streaming.md
Last active September 14, 2015 04:51 — forked from alienresident/video-fix-videos-for-pseudo-streaming.md
How to: Fix pseudo-streaming videos by moving Moov Atom
How to:

Fix pseudo-streaming videos by moving Moov Atom

Relies on some *nix CLI utilities: mediainfo; and qt-faststart (part of ffmpeg). I used homebrew to install them on OS X.

What is pseudo-streaming?

Pseudo streaming is simply a video that can start playing before it's fully dowmloaded. The videos are not streaming but rather progressively downloaded. What's important is that the file metadata (the Moov Atom) is at the start of the file rather than at the end. Usually this is an option set when encoding the file (called quick start or web start). If the files have not been encoded this way you can either re-encode or use a utility to move the Moov Atom. Re-encoding takes much longer than using a utility to move the Moov Atom so here's how to do it.

Steps

First check with mediainfo to see if video 'is streamable':