Skip to content

Instantly share code, notes, and snippets.

View consatan's full-sized avatar

Chopin Ngo consatan

  • Amoy, Fujian, China
View GitHub Profile

Uploading Large Files

Note This is preliminary documentation and is subject to change as we evolve the OneDrive API.

OneDrive handles uploading large files by supporting the BITS protocol. BITS is a simple extension to HTTP that enables resumable file uploads to OneDrive.

Where the standard PUT method for uploading a file has a 100 MB limit, using

@consatan
consatan / arrayToXML.php
Last active April 20, 2020 08:20
php 数组转换为 SimpleXML, php array conver to SimpleXML
<?php
/**
* 转换数组为 SimpleXMLElement
*
* 数组键名转换为 nodeName(value为数组时) 或 attributeName(value非array时)
* 数组键名为 _ 时转换为 innerText
*
* 数组值转换为 nodeValue或attribute
* 数组值为数组时转换为子节点
* 数组值为 null 时转换为空节点
@consatan
consatan / checkChinaID.js
Last active November 19, 2015 15:10
验证所给的身份证号码是否符合中国大陆二代身份证号码规则
/**
* 验证所给的身份证号是否符合中国大陆二代身份证号码规则
*
* @param string id 身份证号码
* @return boolean 符合二代身份证号码规则返回 true,否则返回false
*/
function checkChinaID(id) {
var n = 0,
i = 0,
a = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
@consatan
consatan / insertPrefixMaxID.sql
Created November 30, 2015 05:05
通过子查询更新或插入固定前缀的递增字段
# 如果前缀要使用年份加月份,第7行需要增加判断条件
UPDATE `table` SET `no`=
(
SELECT `no`
FROM (
SELECT IF(
(SELECT 1 FROM `table` WHERE `no` IS NOT NULL AND `no` <> "") IS NULL,
"NO1000",
(
SELECT CONCAT("NO", SUBSTRING(`no`, 3) + 1)
@consatan
consatan / redis_push_1m.php
Created July 5, 2016 14:03
Redis 插入100万数据到 List
<?php
$time = microtime(true);
ini_set('memory_limit', -1);
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$arr = range(1, 1000000);
array_unshift($arr, 'test');
<?php
class Item
{
private $cost = 100;
public function getTotal($discount = 7) {
return $this->cost *(100+$discount)/100;
}
}
@consatan
consatan / gist:009f505c436d58fd48a7c2ea414b0996
Created August 3, 2016 05:19 — forked from samsamm777/gist:7230159
PHP set private property value using reflection. This allows you to set a private property value from outside the object, great for PHPUnit testing.
<?php
$a = new A();
$reflection = new \ReflectionClass($a);
$property = $reflection->getProperty('privateProperty');
$property->setAccessible(true);
$property->setValue($a, 'new-value');
echo $a->getPrivateProperty();
//outputs:
@consatan
consatan / keybase.md
Created August 4, 2016 09:29
keybase

Keybase proof

I hereby claim:

  • I am consatan on github.
  • I am consatan (https://keybase.io/consatan) on keybase.
  • I have a public key whose fingerprint is A302 1325 1326 8B2C 778F 32E1 F894 C16B 91D6 C019

To claim this, I am signing this object:

@consatan
consatan / .cvimrc
Last active May 3, 2018 17:00
cvimrc
let searchalias g = "google"
let barposition = "bottom"
let scrollstep = 70
let searchengine php = ["http://php.net", "http://php.net/manual-lookup.php?scope=quickref&pattern=%s"]
let searchengine fy = "https://translate.google.com/#zh-CN/en/"
let completionengines = ["google", "php", "fy"]
unmap E R K J d x b B u e D f F
map h previousTab
map l nextTab
map d closeTab
$.fn.select2.amd.define('select2/data/extended-ajax',['./ajax', './tags', '../utils', 'module', 'jquery'], function(AjaxAdapter, Tags, Utils, module, $) {
function ExtendedAjaxAdapter ($element,options) {
//we need explicitly process minimumInputLength value
//to decide should we use AjaxAdapter or return defaultResults,
//so it is impossible to use MinimumLength decorator here
this.minimumInputLength = options.get('minimumInputLength');
this.defaultResults = options.get('defaultResults');
ExtendedAjaxAdapter.__super__.constructor.call(this,$element,options);
}