Skip to content

Instantly share code, notes, and snippets.

@venj
venj / com.yourcompany.autossh.plist
Created May 30, 2012 14:39
Put following gist to ~/Library/LaunchAgents, and then run: launchctl load /Users/your_name/Library/LaunchAgents/com.yourcompany.autossh.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OnDemand</key>
<false/>
<key>KeepAlive</key>
<true/>
@venj
venj / calc.vb
Created May 29, 2012 00:43
old code for the lab
Attribute VB_Name = "包合常数自动计算脚本"
'
' 作者: venj
' 日期: 2007年01月06日
' 版本: 0.2.0 Update 1
'
' 用途: 环糊精包合常数自动计算脚本
'
' ChangeLog:
@venj
venj / preprocess.rb
Created May 21, 2012 05:38
batch convert images for appstore for my project.
#!/usr/bin/env ruby
require "fileutils"
include FileUtils
p = "processed"
mkdir "processed" unless File.exists?(p)
Dir["*.png"].each do |f|
puts "Processing #{f}."
name = File.basename(f).split('.')[0]
@venj
venj / remux.rb
Created May 20, 2012 06:56
The real deal remux script that can remux videos with M4V compatible video stream. Audio stream will be encoded to 192kbps aac if it is not m4v compatible audio.
#!/usr/bin/env ruby
# Remux MP4/H264 videos (mkv, avi, etc.) to m4v.
TMPFILE = "/tmp/ffprobe_out.txt"
VIDEO_CONTAINER = ["mkv", "f4v", "avi", "divx", "ts"]
VCODECS = ["mpeg4", "h264"]
ACODECS = ["aac"]
if (`which ffmpeg` == "")
puts "You need ffmpeg to use this command."
@venj
venj / color.sh
Created May 14, 2012 07:25
Color in terminal
#!/bin/bash
# colors.sh - Print out all the different ECMA color-mod combos
#
# 2008 - Mike Golvach - [email protected]
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#
declare -a color_array
@venj
venj / f4v_to_m4v.rb
Created May 14, 2012 05:22
Remux f4v to m4v.
#!/usr/bin/env ruby
Dir["*.f4v"].each do |file|
name = File.basename file, ".f4v"
system("ffmpeg -i '#{file}' -acodec copy -vcodec copy '#{name}.m4v'")
end
@venj
venj / anyduplicate.rb
Created May 11, 2012 06:25
find duplicate city name for me.
#!/usr/bin/ruby
#encoding=utf8
cities = {}
open("/Users/venj/Desktop/city.txt").each_line do |l|
city = l.split("=").last
if cities[city].nil?
cities[city] = 0
else
cities[city] += 1
@venj
venj / apod.sh
Created May 10, 2012 01:59
Download NASA Astronomy Picture Of Day media. (Bash version)
#!/bin/bash
# Constants
TMPDIR=/tmp/apod
LISTFILE=$TMPDIR/list.html
REMOTEPREFIX=http://antwrp.gsfc.nasa.gov/apod/
# Functions
function parse_page() {
printf "Downloading photo page %s...\n" $1
@venj
venj / apod.rb
Created May 10, 2012 01:58
Download NASA Astronomy Picture Of Day media. (Ruby version)
#!/usr/bin/env ruby
##
# This script will grab NASA's Astronomy Picture of the Day Archive
#
# It will create 2 directories in current directory: big and small
# to save pictures.
#
# Requirements:
# 1. Ruby 1.8.x with Rubygems
# 2. nokogiri gem: (sudo) gem install nokogiri
@venj
venj / settings.txt
Created May 8, 2012 01:59
List of currently known URLs in the Settings app
# Via: http://stackoverflow.com/questions/8246070/ios-launching-settings-restrictions-url-scheme
List of currently known URLs in the Settings app:
prefs:root=General&path=About
prefs:root=General&path=ACCESSIBILITY
prefs:root=AIRPLANE_MODE
prefs:root=General&path=AUTOLOCK
prefs:root=General&path=USAGE/CELLULAR_USAGE
prefs:root=Brightness
prefs:root=General&path=Bluetooth