Skip to content

Instantly share code, notes, and snippets.

@venj
venj / server.rb
Last active December 17, 2015 18:59
Simple sinatra server for stream video to iOS. Now, more ruby style. :)
require "rubygems"
require "sinatra"
require "json"
set :public_folder, Dir.pwd
get "/" do
content_type 'application/json'
Dir["**/*"].select { |f| ["mp4", "m4v"].include? f.split(".").last.downcase }.to_json
end
@venj
venj / obf-ssh.sh
Created July 1, 2013 05:43
obf-ssh changed from ssh start up script for debian 7.0
#! /bin/sh
### BEGIN INIT INFO
# Provides: sshd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: OpenBSD Secure Shell server
### END INIT INFO
@venj
venj / obf-ssh.sh
Last active December 19, 2015 04:39
Another version of obf-ssh startup script for debian. via: http://blog.slpo.net/?p=1234
#! /bin/sh
### BEGIN INIT INFO
# Provides: sshd_ofc
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: OpenBSD Secure Shell server (ofc)
### END INIT INFO
@venj
venj / videos
Created December 24, 2013 01:06
Apple iOS 7 Tech Talk videos
http://devstreaming.apple.com/videos/techtalks/2013/11_App_Developer_Day_Kickoff/App_Developer_Day_Kickoff-hd.mov?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/11_App_Developer_Day_Kickoff/App_Developer_Day_Kickoff-sd.mov?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/11_App_Developer_Day_Kickoff/App_Developer_Day_Kickoff.pdf?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/12_User_Interface_Design_for_iOS_7_Apps/User_Interface_Design_for_iOS_7_Apps-hd.mov?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/12_User_Interface_Design_for_iOS_7_Apps/User_Interface_Design_for_iOS_7_Apps-sd.mov?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/12_User_Interface_Design_for_iOS_7_Apps/User_Interface_Design_for_iOS_7_Apps.pdf?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/13_Architecting_Modern_Apps_Part_1/Architecting_Modern_Apps_Part_1-hd.mov?dl=1
http://devstreaming.apple.com/videos/techtalks/2013/13_Architecting_Modern_Apps_Part_1/Architecting_Modern_Apps_Part_1-
diff --git a/Gemfile b/Gemfile
index cd8ce57..2296549 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,4 +1,4 @@
-source "https://rubygems.org"
+source "http://ruby.taobao.org"
group :development do
gem 'rake', '~> 0.9'
@venj
venj / dat2kml.rb
Created March 13, 2014 05:50
Dat to KML
#!/usr/bin/env ruby
require "FileUtils"
include FileUtils
exit if ARGV.size != 1
cd ARGV[0] do
Dir["*.dat"].each do |dat|
basename = File.basename(dat, ".dat")
@venj
venj / ua_test.rb
Created March 13, 2014 05:51
UPai Cloud UA Test
#!/usr/bin/env ruby
require "open-uri"
pic = "http://xxxx.b0.upaiyun.com/1/attachments/ZWg3nr1E.jpg"
open("test_no_ua.jpg", "w+") do |f|
begin
f.write(open(pic).read)
rescue Exception => e
@venj
venj / process.rb
Created March 31, 2014 07:14
Files for process csv files to make kml.
#!/usr/bin/env ruby
require "FileUtils"
require "csv"
include FileUtils
Dir["*.csv"].each do |dat|
basename = File.basename(dat, ".csv")
outfile_name = "#{basename}.kml"
open(outfile_name, "w+") do |out|
#!/usr/bin/env ruby
# encoding = UTF-8
# 模拟导航数据转换GPS坐标算法
# 接受一个参数,指定模拟导航数据文件的名字
path = ARGV[0]
open("result.txt", "w+") do |f|
open(path).each_line do |line|
x, y = line.sub("[", "").sub("]", "").split(",").map {|i|
#!/usr/bin/env ruby
# Rotate video files.
require 'shellwords'
require 'colorize'
TMPFILE = "/tmp/ffprobe_out.txt"
IMAGES = ["mjpeg", "jpg", "jpeg", "png", "gif"]
if (`which ffmpeg` == "")
puts "You need ffmpeg to use this command."