Skip to content

Instantly share code, notes, and snippets.

func TestSha1(t *testing.T) {
v := map[string]string{"name": "Felix", "age": "18"}
e := &v
//e := &[]string{"hi"}
sh1 := sha1.New()
io.WriteString(sh1, "q3244214")
ge := gob.NewEncoder(sh1)
ge.Encode(e)
fmt.Println(".........!")
//$('.qor-notify-number').hide(); //红色通知,还是留着吧...
$('.qor-notify-num-grey').hide(); //灰色未读数不要
$('.new-stream-bar').remove(); //不要主动推送消息
@athom
athom / gist:6009124
Created July 16, 2013 14:17
牛顿迭代闭包版
package main
import (
"fmt"
"math"
"math/cmplx"
)
func equal(x, y complex128) bool {
delta := 0.000001
@athom
athom / gist:6008849
Created July 16, 2013 13:48
cube root iterate
package main
import (
"fmt"
"math/cmplx"
"math"
)
func equal(x, y complex128) bool {
delta := 0.0001
@athom
athom / onLocalSearchResult.js
Created September 6, 2012 05:18
tokeninput callback example
onLocalSearchResult: function(items, q){
var newItems = new Array();
$.each(items, function(index, item){
names = item.Name.split(" ");
$.each(names, function(i, name){
if(name.toLowerCase().slice(0,q.length) == q){
newItems.push(item);
return false
}
})
@athom
athom / pat_example.go
Created July 27, 2012 05:12
an example of pat usage
package main
import (
"github.com/bmizerany/pat"
"io"
"log"
"net/http"
)
// hello world, the web server
@athom
athom / simple_fiber_concurrency.rb
Created March 14, 2012 08:49 — forked from aprescott/simple_fiber_concurrency.rb
Simple example of concurrency in Ruby with Fiber.
require "fiber"
f1 = Fiber.new { |f2| f2.resume Fiber.current;loop{puts "A"; f2.transfer} }
f2 = Fiber.new { |f1| f1.transfer; loop{puts "B"; f1.transfer} }
f1.resume f2
class Proxy
def initialize(target_object)
@object = target_object
# ADD MORE CODE HERE
@call_count = {}
end
attr_accessor :channel
def proxy_call(m, *args)
@athom
athom / player.rb
Created July 11, 2011 09:50
rubywarrior-step-by-step
require "readline"
class Player
def play_turn(w)
# add your code here
buf = Readline.readline("> ", true )
action=buf[0]
direction=buf[1]
abilities = {'w' => 'w.walk!', 'a' => 'w.attack!', 'r' => 'w.rest!', 'c' => 'w.rescue!', 's' => 'w.shoot!', 'b' => 'w.bind!', 'd' => 'w.detonate!'}
directions = {'l' => ':forward', 'h' => ':backward', 'j' => ':right', 'k' => ':left'}
@athom
athom / acm_bot.rb
Created July 7, 2011 07:05 — forked from JulesWang/acm_bot.rb
A acm bot do some boring work
# Ruby 1.9.2
# Home: https://gist.github.com/856219
# My CPP template: template_cpp.rb
# OJ Support:
# Online Judge of Zhejiang University
# Author: w.jq0722@gmail.com
require 'uri'
require 'net/http'
#require 'hpricot'