Skip to content

Instantly share code, notes, and snippets.

def create
@img = Img.new(img_params.except("pic"))
@img.pic = img_params.delete("pic")
#!/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 / 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':

@ianchen06
ianchen06 / qtfaststart.BAT
Created September 15, 2015 02:35
BAT script for running python qtfaststart on the current directory
@echo off
echo Preparing video for Fast Start...
IF EXIST "Output" (
echo Output directory is present
) else (
echo Writing Output directory
mkdir "Output"
)
@ianchen06
ianchen06 / locate.md
Last active September 16, 2015 10:36
Custom mlocate(locate) database for locate searching

You can use the -U option (--database-root PATH)

updatedb -l 0 -U /home/user/music -o /home/user/databasefile

-o writes to the output file

-l 0 makes that you can read it, otherwise it is only accessible for locate

Then you can then use it like:

@ianchen06
ianchen06 / Readme.md
Created October 23, 2015 01:50 — forked from makevoid/Readme.md
use Mechanize persisting the cookie jar

EptiMecha

example on how to use mechanize with cookie jars, basically:

agent.cookie_jar.save_as "cookies.yml"
agent.cookie_jar.load "cookies.yml"

to try it:

  • download this zip
########################################
#
# Nginx 1.8.0
# Pagespeed v.1.9.32.6
# OpenSSL 1.0.2d
# - Tested on Ubuntu 14.4.2
#
########################################