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
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">
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>
@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',
);
<?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 / geo.php
Created November 5, 2014 07:09
世界各国首都经纬度
<?php
$country = array (
0 =>
array (
0 => 'Country',
1 => 'Capital',
2 => 'Latitude',
3 => 'Longitude',
),
1 =>
@picasso250
picasso250 / code_line.sh
Last active October 13, 2015 16:17
count how many lines you write in your project dir
#!/bin/sh
if [ x"$1" = x ]
then
code_dir="."
else
code_dir="$1"
fi
if [ x"$2" = x ]
@picasso250
picasso250 / .vimrc
Last active December 14, 2015 05:40
a lot of settings, .rc .etc. Sublime Text, Vim
set number
syntax on
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
<?php
// get all sub strings for a given string
// return an array whose count is O(n^2)
function all_substr($str)
{
$length = strlen($str);
$ret = array();
for ($i=0; $i < $length; $i++) {
$max_length = $length - $i;
<?php
// from file
function make_image2($imagefile, $opt = array())
{
// deault option
$opt = array_merge(array(
'crop' => 0,
'resize' => 0,
'width' => 50,