Skip to content

Instantly share code, notes, and snippets.

View msg7086's full-sized avatar

Xinyue Lu msg7086

  • Greater Portland, OR
  • 00:16 (UTC -07:00)
View GitHub Profile
<?php
require_once dirname ( __FILE__ ) . '/' . 'RequestCore.class.php';
class BaiduPCS {
public function uploadFile($fullFilename, $remoteFilename, $isTemp = FALSE)
{
$url = 'file?method=upload&access_token=' . $this->_accessToken . '&path=' . urlencode($remoteFilename) . ($isTemp?'&type=tmpfile':'');
if(PHP_VERSION_ID >= 50500 && class_exists('CURLFile'))
$post = ['file_contents' => new CURLFile($fullFilename)];
else
<?php
// 略
if($filesize > 262144)
{
echo 'Try rapid uploading...', PHP_EOL;
// Try rapid upload
$fp = fopen($fn, 'rb');
$data = fread($fp, 262144);
fclose($fp);
$md5s = md5($data);
@msg7086
msg7086 / myfilter.php
Last active December 29, 2015 03:48
t/90174
<?php
function myfilter($src, $limit = 5)
{
$ips = array_map(function ($entry) { return $entry['ip']; }, $src);
$ipcount = array_count_values($ips);
$filtered_data = array_filter($src, function ($entry) use ($ipcount, $limit) { return $ipcount[$entry['ip']] >= $limit; });
return $filtered_data;
}
@msg7086
msg7086 / fact.php
Last active December 31, 2015 05:29
t/92952
<?php
foreach(range(1, 10) as $i)
echo join(' * ', range($i, 1)), ' = ', array_product(range(1, $i)), "\n";
@msg7086
msg7086 / fact-fast.php
Created December 13, 2013 07:54
t/92952 fast
<?php
for($i = 2, $s = '1', $v = 1; $i <= 10; ++$i)
echo ($s = $i . ' * ' . $s), ' = ', ($v *= $i), "\n";
$ eac3to 陈妍希\ -\ 孩子气.m2ts 1:a.h264 2:a.wav
M2TS, 1 video track, 1 audio track, 0:04:13, 25p
1: h264/AVC, 1080p25 (16:9)
2: RAW/PCM, 2.0 channels, 16 bits, 48kHz
v01 Extracting video track number 1...
a02 Extracting audio track number 2...
a02 Reading RAW/PCM...
a02 Swapping endian...
a02 Writing WAV...
v01 Creating file "a.h264"...
@msg7086
msg7086 / parse.sh
Last active August 29, 2015 13:56
To parse python files in ROS project and see how many publishers and subscribers.
#!/bin/bash
IFS='
'
DIR=ros_catkin_ws/src/
SUB=0
PUB=0
SVC=0
SVP=0
ACC=0
$ sudo mtr --report --report-wide -c 10 mokfire.net
HOST:                                           Loss%   Snt   Last   Avg  Best  Wrst StDev
  1. 222.73.164.1                               0.0%    10    1.3   2.9   1.3  16.6   4.8
  2. 222.73.89.229                              0.0%    10    0.3   3.9   0.3  36.9  11.6
  3. 124.74.166.61                              0.0%    10    3.6   3.5   1.8   4.9   1.1
  4. 202.101.63.202                             0.0%    10    2.8   3.6   1.6   4.9   1.2
  5. 202.97.33.34                               0.0%    10    1.4   4.0   1.2  28.1   8.5
  6. 202.97.33.254                              0.0%    10    1.9   1.9   1.7   2.5   0.3
  7. 202.97.50.114                              0.0%    10  287.5 286.6 284.6 291.6   2.0

EXELION -> CRISSIC

$ mtr lg.crissic.net --report-wide -c 5
Start: Sat Apr 19 05:52:10 2014
HOST: host7086                                Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 198.52.214.206                           0.0%     5    0.6   0.6   0.6   0.6   0.0
  2.|-- 10.255.255.1                             0.0%     5    0.6   0.6   0.6   0.7   0.0
  3.|-- 172.16.9.2                               0.0%     5    4.1   3.5   0.9   4.6   1.3
  4.|-- 192.168.255.5                            0.0%     5    5.4   4.1   1.3   6.0   1.8