Skip to content

Instantly share code, notes, and snippets.

View picasso250's full-sized avatar
💭
I may be slow to respond.

pica picasso250

💭
I may be slow to respond.
View GitHub Profile
// from c++ version: https://gist.github.com/timshen91/f6a3f040e5b5b0685b2a
// author: wangxiaochi
function ConcatExpr (Left,Right) {this.Left = Left;this.Right=Right} // ab
function AltExpr(Left,Right) {this.Left = Left;this.Right=Right} // a|b
function RepeatExpr(SubExpr) {this.SubExpr= SubExpr;} // a*
function OptionalExpr(SubExpr) {this.SubExpr= SubExpr;} // a?
function MatchExpr(ch) {
this.ch= ch
}
@picasso250
picasso250 / fast_cygwin.php
Last active November 8, 2017 13:30
fast cygwin mirror
<?php
foreach (file('http://cygwin.com/mirrors.lst') as $line) {
echo $line;
if (preg_match('%^\w+://([\w.-]+)/%', $line, $matches)) {
$host = $matches[1];
if (!isset($table[$host])) {
$output = shell_exec("ping $matches[1]");
echo $output;
if (preg_match('/(\d+)ms/', $output, $matches)) {
@picasso250
picasso250 / geo.php
Created November 5, 2014 07:09
世界各国首都经纬度
<?php
$country = array (
0 =>
array (
0 => 'Country',
1 => 'Capital',
2 => 'Latitude',
3 => 'Longitude',
),
1 =>
<?php
$g_start_time = microtime(true);
register_shutdown_function(function () {
global $g_start_time;
$g_start_time = microtime(true) - $g_start_time;
UB_LOG_TRACE('%s (time %s ms)', $_SERVER['REQUEST_URI'], intval($g_start_time*1000));
});
@picasso250
picasso250 / router.php
Last active August 29, 2015 13:57
php -S 0.0.0.0:80 router.php
<?php
// php build in server vhost
// php -S 0.0.0.0:80 router.php
// on Windows, router.php must be absolute path, bug of php v5.4.26
$map = array(
'host.name' => '/file/path',
);
<style type="text/css">
canvas { border: 1px solid #000; position:absolute; top:0;left:0;
visibility: hidden; }
</style>
<canvas id="MainCanvas" width="480" height="640"></canvas>
<canvas id="SecondCanvas" width="480" height="640"></canvas>
<script type="text/javascript" src="bird.js"></script>
var request = require('request');
var cheerio = require('cheerio');
var Iconv = require('iconv').Iconv;
var iconv = require('iconv-lite');
var i = 10;
var url = 'http://www.esgweb.net/Html/Yxzcpstj/'+i+'.htm';
console.log(url);
request(url, function(err, resp, body) {
if (err)
<style type="text/css">
.cell{
width: 40px;
height: 40px;
display: inline-block;
border: 1px solid;
}
.c1 {
background-color: red;
}
<?php
// 1
TcpClient::api_name(array('key' => $value, 'key2' => $value));
// 2
TcpClient::api_name($value1, $value2);