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;
@meritozh
meritozh / remove_CLI_tools.sh
Created May 19, 2015 08:56
Remove CLT via lsbom and rm in OS X yosemite
#!/bin/bash
DEV_SDK_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.DevSDK_OSX1010.bom
DEV_SDK_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.DevSDK_OSX1010.plist
DEV_TOOLS_RECEIPT_FILE=/var/db/receipts/com.apple.pkg.CLTools_Executables.bom
DEV_TOOLS_RECEIPT_PLIST=/var/db/receipts/com.apple.pkg.CLTools_Executables.plist
if [ ! -f "$DEV_TOOLS_RECEIPT_FILE" ]
then
#!/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 / exec.cpp
Created April 5, 2016 07:12
use c++ to execute a command and get the output of command. It only grab stdout. Use perror or add "2>&1" for grabbing stderr.
#include <iostream>
#include <cstdarg>
#include <string>
#include <fstream>
#include <memory>
#include <cstdio>
std::string exec(const char* cmd) {
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
if (!pipe) return "ERROR";
@meritozh
meritozh / split_number.cpp
Last active April 8, 2016 02:01
read numbers from a file stream, split them to evens and odds then print to other two file streams. C++ Primer 5th 10.33
#include <fstream>
int main(int argc, char const *argv[])
{
std::ifstream input(argv[1]);
std::ofstream output_odd_number(argv[2]);
std::ofstream output_even_number(argv[3]);
std::istream_iterator<int> in_iter(input), eof;
std::ostream_iterator<int> output_odd_number_iter(output_odd_number, " ");
@meritozh
meritozh / fstream_to_fstream.cpp
Created April 8, 2016 02:00
file stream to file stream
#include <fstream>
int main(int argc, char const *argv[])
{
std::ifstream input(argv[1], std::ios::binary);
std::ofstream output(argv[2], std::ios::binary);
output << input.rdbuf();
input.close();