Skip to content

Instantly share code, notes, and snippets.

@border
border / mgoExample.go
Created August 27, 2012 15:33
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@border
border / long_polling.go
Created September 25, 2012 09:58
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@border
border / turnutils_uclient.md
Created November 20, 2021 02:37 — forked from cameronelliott/turnutils_uclient.md
Tutorial for turnutils_uclient and Coturn server

Tutorial for turnutils_uclient and Coturn server

@border
border / get_sn.c
Created September 19, 2014 11:49
Get Disk Serial Number For Linux
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>
#define SCSI_TIMEOUT 5000 /* ms */
static char *device = "/dev/sda";
@border
border / Signature.java
Last active April 16, 2021 03:41
Signature for php and java
static String generateSignature () {
String encoded = "";
String type = "HmacSHA1";
try {
byte[] key = ("KEY").getBytes("UTF-8");
byte[] Sequence = ("hello").getBytes("UTF-8");
Mac HMAC = Mac.getInstance(type);
SecretKeySpec secretKey = new SecretKeySpec(key, type);
@border
border / gocookies.go
Created December 7, 2013 07:27
go cookiejar demo
package main
import (
"io/ioutil"
"log"
"net/http"
"net/http/cookiejar"
)
var gCurCookies []*http.Cookie
@border
border / fetchv1.go
Created September 6, 2012 01:25
启动100个goroutines去抓取URL,这100个抓取完后再继续下一组, v2版本更简洁明了,
package main
import (
"fmt"
"runtime"
"sync"
"time"
)
const MAX = 100
@border
border / Makefile
Created January 12, 2011 01:36
json example in golang
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char** tokenize(const char* input)
{
printf("%s\n", input);
char* str = strdup(input);
int count = 0;
int capacity = 10;
@border
border / unzip.py
Created May 19, 2015 08:45
unzip from GBK To UTF-8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import zipfile
print "Processing File " + sys.argv[1]
file=zipfile.ZipFile(sys.argv[1],"r");