Skip to content

Instantly share code, notes, and snippets.

View qhwa's full-sized avatar

Qiu Hua qhwa

View GitHub Profile
@qhwa
qhwa / linksprite_jpeg_camera.rb
Created March 18, 2014 15:28
ruby script that grab pictures from LinkSprite TTL JPEG camera
require 'serialport'
require 'colored'
require 'ruby-progressbar'
class Y201Grab
def self.a2s(*arr)
arr.pack 'c*'
end
@qhwa
qhwa / from-now-filter.coffee
Created May 8, 2014 02:06
angularjs filter of display time as 'xxx ago'
angular.module('fromNowFilter',[]).filter 'from_now', () ->
(date) ->
moment(date).fromNow()
@qhwa
qhwa / Main.as
Created May 27, 2014 08:16
VAST SDK Usage Example
/**
* Basic AS3 VAST OVA Video Player Example
* Released as open source under the BSD License
* http://www.opensource.org/licenses/bsd-license.php
*
* hua.qiuh copied from dehash.com
*/
package {
import com.apdevblog.events.video.VideoControlsEvent;
package com.alibaba.ad.vas.example
{
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import flash.system.*;
import com.alibaba.ad.vas.toolkit.AdManager;
import com.alibaba.ad.vas.vast.model.AdUnit;
@qhwa
qhwa / .vimrc
Created February 2, 2015 02:36
my vim config
fun! MySys()
return "mac"
endfun
set runtimepath=~/.vim_runtime,~/.vim_runtime/after,\$VIMRUNTIME
source ~/.vim_runtime/vimrc
"helptags ~/.vim_runtime/doc
set guifont=Lucida\ Sans\ Typewriter\ Regular:h13
if has("gui_running")
set guioptions-=T
set t_Co=256
@qhwa
qhwa / auto_dnspod.rb
Created May 26, 2015 06:49
automatically update DNSPod record with internal IP address
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
require 'net/https'
require 'open-uri'
require 'logger'
class AutoDNS
PARAMS = {
@qhwa
qhwa / buid-wd-server.sh
Created December 23, 2011 12:42
Build a web developer collaboration server in RedHat
#!/bin/sh
#****************************************************************#
# ScriptName: build-wd-server.sh
# Author: hua.qiuh
# Create Date: 2011-12-02
# Modify Author:
# Modify Date: 2011-12-02
# Function:
#***************************************************************#
@qhwa
qhwa / string-utf8.rb
Created February 1, 2012 07:52
turn string encoding into utf-8 from any charset
class String
def utf8!
%w(ascii-8bit utf-8 ucs-bom shift-jis gb18030 gbk gb2312 cp936).any? do |c|
begin
if self.respond_to? :encode
self.encode!('utf-8', c).force_encoding('utf-8')
else
require 'iconv'
text = Iconv.new('UTF-8', c).iconv(self)
@qhwa
qhwa / dabblet.css
Created April 18, 2012 15:38
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@qhwa
qhwa / dabblet.css
Created April 21, 2012 14:23
CSS3 progress bar
/**
* CSS3 progress bar
* desgin: http://dribbble.com/shots/522214-Progress-Bar
*/
body {
background-image: repeating-linear-gradient(0, #3C3540 0, #3C3540 50%, #38313B 50%, #38313B 100%);
background-size: 3px 1px;
}
.prog-bar {