Skip to content

Instantly share code, notes, and snippets.

View meritozh's full-sized avatar
:octocat:
5 plan, finish 0/5

gaowanqiu meritozh

:octocat:
5 plan, finish 0/5
View GitHub Profile
function get(uri) {
return http(uri,'GET');
}
function post(uri,data) {
if(typeof data === 'object' && !(data instanceof String || (FormData && data instanceof FormData))) {
var params = [];
for(var p in data) {
if(data[p] instanceof Array) {
for(var i = 0; i < data[p].length; i++) {
params.push( encodeURIComponenet(p) + '[]=' + encodeURIComponenet(data[p][i]);
@meritozh
meritozh / score_rank.cc
Last active April 8, 2016 02:04 — forked from chenshuo/score_rank.cc
Update score and get rank in real time
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef int32_t Score;
typedef int32_t UserId;
typedef int32_t Rank;
const Score kInvalidScore = -1;
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
using System;
using System.Globalization;
using System.IO;
namespace TestStringFormatPerformance
{
public class CorrectnessTester<T> where T : ITextWriterUtils, new()
{
public void Test()
@meritozh
meritozh / JSON.swift
Last active September 13, 2015 11:57 — forked from dorentus/JSON.swift
//
// JSON.swift
//
//
// Created by ZHANG Yi on 2015-9-1.
//
// The MIT License (MIT)
//
// Copyright (c) 2015 ZHANG Yi <zhangyi.cn@gmail.com>
//
@meritozh
meritozh / curl.md
Created December 22, 2015 11:14 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@meritozh
meritozh / xhyve-freebsd-tutorial-1.md
Created April 9, 2016 12:36 — forked from tanb/xhyve-freebsd-tutorial-1.md
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites

@meritozh
meritozh / isqrt.cpp
Created April 10, 2016 09:32 — forked from miloyip/isqrt.cpp
Big integer square root
#include <cassert>
#include <iostream>
#include <vector>
#include <type_traits>
// http://www.embedded.com/electronics-blogs/programmer-s-toolbox/4219659/Integer-Square-Roots
uint32_t isqrt0(uint32_t n) {
uint32_t delta = 3;
for (uint32_t square = 1; square <= n; square += delta)