Skip to content

Instantly share code, notes, and snippets.

@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."
#!/bin/sh
if [ $UID -ne 0 ]; then
echo "\033[31mSuperuser privileges are required to run this script.\033[0m"
echo "e.g. \"\033[33msudo\033[0m $0\""
exit 1
fi
driver=AX88179_178A.kext
driver_path=/Library/Extensions/$driver
http://devstreaming.apple.com/videos/wwdc/2014/403xxksrj0qs8c0/403/403_hd_intermediate_swift.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/419xxli6f60a6bs/419/419_hd_advanced_graphics_and_animation_performance.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/101xx36lr6smzjo/101/101_hd.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/236xxwk3fv82sx2/236/236_hd_building_interruptible_and_responsive_interactions.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/306xxjtg7uz13v0/306/306_hd_javascript_for_automation.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/404xxdxsstkaqjb/404/404_hd_advanced_swift.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/701xx8n8ca3aq4j/701/701_hd_designing_accessories_for_ios_and_os_x.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/224xxxlsvigdoc0/224/224_hd_core_os_ios_application_architectural_patterns.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/717xxux5eg6f9v4/717/717_hd_kids_and_apps.mov?dl=1
http://devstreaming.ap
@venj
venj / down.rb
Last active August 29, 2015 14:03
#!/usr/bin/env ruby
# Will download to Files in current directory.
# To download:
# ruby down.rb
require "open-uri"
require "fileutils"
include FileUtils
USER = "data_public"
@venj
venj / UIColorExtra.swift
Last active August 29, 2015 14:04
A UIColor Extension to parse Hex string(for CSS and for KML) to color. Code works for Xcode 6 Beta 5. Based on https://github.com/yeahdongcn/UIColor-Hex-Swift/blob/master/UIColorExtension.swift
import UIKit
extension UIColor {
convenience init(kmlColorString:String) {
var scanner = NSScanner(string:kmlColorString)
var color:UInt32 = 0;
scanner.scanHexInt(&color)
let mask:UInt32 = 0x000000FF
var a = color >> 24 & mask
#!/usr/bin/env xcrun swift
import Foundation
if NSFoundationVersionNumber < 1139.1 {
println("You need Xcode6-DP5 and up to run this script")
exit(1)
}
let args = Process.arguments