Skip to content

Instantly share code, notes, and snippets.

@jemygraw
jemygraw / MergeFileContent.go
Created May 16, 2014 13:32
Merge File Content
package main
import (
"bufio"
"fmt"
"io"
"os"
"path/filepath"
"strings"
)
@jemygraw
jemygraw / gist:7e8efb113ba0eb157d12
Created October 15, 2014 06:07
Print QByteArray to console
QString str=UrlSafeBase64Encode(sha1Data);
std::cout<<str.toLocal8Bit().data()<<std::endl;
@jemygraw
jemygraw / golang_rsa_oaep.go
Created November 13, 2014 02:24
Golang RSA-OAEP Encrypt&Decrypt
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"fmt"
@jemygraw
jemygraw / csharp_rsa_oaep_encrypt.cs
Created November 13, 2014 02:29
C# RSA-OAEP Encrypt
using System;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace Qiniu.Util
{
public static class Base64URLSafe
{
public static string Encode (string text)
@jemygraw
jemygraw / golang_rsa_oaep_decrypt.go
Created November 13, 2014 02:31
Golang RSA OAEP Decrypt
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"fmt"
@jemygraw
jemygraw / callback_token_check.py
Created November 13, 2014 05:42
Qiniu Cloud Callback Upload Token Check Code
#回调验签代码
__author__ = 'jemy'
from qiniu.auth import digest
import urllib
path = '/~jemy/qiniu-lab-php/demos/service/callback_upload_service.php'
body = 'fname=jemygraw_999.png&etag=FkbO_BZF_49z0j63-2i1C25QGdT3&key=FkbO_BZF_49z0j63-2i1C25QGdT3&exParam1=w&exParam2=h&exParam3=h'
access_key = 'pObK-5uirmOAtYGM705oxIco1m9xlqwONnYyLOoX'
secret_key = 'wXIqwPbClstEew5vibPkUJPv-bJojiVe4aapNmYW'
@jemygraw
jemygraw / php5_post_raw_to_urlencoded.php
Created November 13, 2014 06:30
php5 unicode convert raw post data to urlencoded
<?php
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
function unicode_decode($str) {
return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
}
$data="fname=jemygraw_999.png\u0026etag=FkbO_BZF_49z0j63-2i1C25QGdT3\u0026key=FkbO_BZF_49z0j63-2i1C25QGdT3\u0026exParam1=w\u0026exParam2=h\u0026exParam3=h";
@jemygraw
jemygraw / all_in_one_batch_upload_mac.sh
Created January 24, 2015 08:59
curl&qbox upload test script
gecho -e "curl\tqboxrsctl"
#set variables
uploadFile="/Users/jemy/Documents/qiniu.png"
uploadHost="up.qiniu.com"
uploadToken="ELUs327kxVPJrGCXqWae9yioc0xYZyrIpbM6Wh6o:YEZCdEInhP2a-4Whb_D23nPl6b4=:eyJzY29wZSI6ImlmLXBibCIsImRlYWRsaW5lIjoxNDIyMDkxOTk3fQ=="
uploadBucket="if-pbl"
uploadTimes=1000
curlPrefix="curl_1277431"
@jemygraw
jemygraw / all_in_one_batch_upload_linux.sh
Created January 24, 2015 09:00
curl&qbox upload test script
echo -e "curl\tqboxrsctl"
#set variables
uploadFile="/home/jemy/Documents/qiniu.png"
uploadHost="upload.qiniu.com"
uploadToken="ELUs327kxVPJrGCXqWae9yioc0xYZyrIpbM6Wh6o:YEZCdEInhP2a-4Whb_D23nPl6b4=:eyJzY29wZSI6ImlmLXBibCIsImRlYWRsaW5lIjoxNDIyMDkxOTk3fQ=="
uploadBucket="if-pbl"
uploadTimes=1000
curlPrefix="curl_pic"
package main
//Usage: vsina http://video.weibo.com/show?fid=1034:0e906d53094c5d231bf09028af8ba9b1
import (
"bufio"
"fmt"
"github.com/astaxie/beego/httplib"
"io"
"io/ioutil"
"net/url"