Skip to content

Instantly share code, notes, and snippets.

string clientID = "<Your ClientID>";
string clientSecret = "<Your Client Secret>";
String strTranslatorAccessURI =
"https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
String strRequestDetails =
string.Format("grant_type=client_credentials&client_id={0}&client_secret={1} &scope=http://api.microsofttranslator.com", HttpUtility.UrlEncode(clientID),
HttpUtility.UrlEncode(clientSecret));
System.Net.WebRequest webRequest = System.Net.WebRequest.Create(strTranslatorAccessURI);
webRequest.ContentType = "application/x-www-form-urlencoded";
def isSame(a, b):
return a==b
last = None
def f(sum, b):
global last
first = b[0]
if isSame(last, first):
sum[-1].extend(b[1:])
else:
package main
import (
"bytes"
"crypto/cipher"
"crypto/des"
"crypto/rand"
"crypto/rsa"
"encoding/base64"
"flag"
f, err := os.OpenFile("Registry", os.O_RDWR, 0644)
if err != nil {
log.Fatal(err)
}
defer f.Close()
enc := unicode.UTF16(unicode.LittleEndian, unicode.ExpectBOM)
tf := enc.NewDecoder()
tr := transform.NewReader(f, tf)
import urllib2
import urllib
headers = {
"X-Auth-Token": "xxxx",
"Content-Type": "application/json"
}
data = {
"id": "alert",
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
#include <string>
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <cerrno>
#include <stdexcept>
#include <sys/wait.h>
import time
def test():
key = list(map(str, range(10000000)))
t = time.time()
d=dict()
for i in xrange(10000000):
d[key[i]] = i
for i in xrange(10000000):
del d[key[i]]
package main
import (
"net"
"fmt"
"io"
"os"
)
func handle(source net.Conn) {
@hongruiqi
hongruiqi / test.go
Created November 29, 2015 14:07
funny
package main
import "sync"
func main() {
for {
x := 0
y := 0
a := 0
b := 0