Skip to content

Instantly share code, notes, and snippets.

@fwolf
fwolf / Choose betwen PHP ORM
Last active August 29, 2015 14:14
Choose betwen PHP ORM
Propel
http://propelorm.org/
第一印象感觉不错
Propel2 需要 PHP 5.4
CRUD 正合我意
Relationships 也不错,就是 useXxx() 和 endUse() 缩进有点奇怪,IDE 那儿也许会有点小问题
缺点:初始化比较复杂
Doctrine
主要是觉得笨重,另外不喜欢它的特殊注释
@fwolf
fwolf / export
Last active August 29, 2015 14:15
Swarm Simulator save
MS4wLjE4|Q2hlYXRlciA6KAoKN4IglgJiBcIG4AYB0AmEAaEALApgQwCcAXAI3yIEkpZFUBaAawHsA7AcwJzbyJ2l0KlyGEAFcWYIkQCeABxwBnGKDAs4YBWBIAbHFh4BjXAWkwQARhEBbYbACsqOwBYAzAhR2UCBC4AcTnABqFAA2EW1CODwzXz8PB3MAdl8ATl9fBCdEu1TMkQMmAtYzBBFeAgJJJhMzcyQ/d0SnFHN3JySXFCcndyCWkRwWHAI2U1hfO2QUlxmRTgV5AwBRIZGxkFLMIYAPUSVYNEwrUSI8NkGSkVlOY9PzlkvMPAUDQc1i2E2QADNOHAAlRSLMxOEQQAisHBmFBIOwhLpOEKpFx2ZLOLIpELmPouEQAR1EOAusHMEycOQmSJQoXccKcKSQYS2iiI0MSiQQKXa5hCiRSdgZqURoMwHHIwwJRIeB0SXRyyBCuMwWDAcChJNJspEKrVkuJGwGVmuin2Bsw1yYslwrM+IjYTAgEBNjxAsjwLCIuA+Ztd7s9OFYaFt5r9XpYuODvo9YdBkbd0YDLDsLqYaoIVlU1B9qeGGZYECD2bTeYgEaLuczsfL6czycjOZr+bCkYUAHdCFZtKo2GYckieSkRAoiN3hrV0gg7J4h7JIGPYOSUnyUL5rEwFASqiDUYlFYcQNpCnsbSBeS4Um05kw8EYQa4kaiUiu7WA/Qs5wQQRymq5Ol9Xh6YDyE6tTmDM1JdCI7YLCCIQIBMYI4HATCiJwn4kvCmKWKKTDeokIgSGwWCkKIPaRlYTCei6JA8C6tyhoYxjrF89EejRJ4sScfoGIeQx0VxHpth27YELI/GnB6BB7Fg4l+vgt7kQJRC/DgeKyR6Ox7Oppzpsx1hKTYtG2gAvpgEA8OqoDDoIOBZl45h2HQ7h0C0AAqCCJNArjQOYdQuHBABacwsjZdkIA5TkoC55juZ53m+fUgVDngaphRFzkoC47koNA3i5U4SDTAgQWYJwYDfGAtnQuFjkZVl7i5Qg+VIHyTgl
@fwolf
fwolf / MockContainer.php
Created February 27, 2015 10:52
MockContainer, not used, system function mock need create in per test case.
<?php
namespace Fwlib\Test;
use Fwlib\Base\AbstractServiceContainer;
use malkusch\phpmock\Mock;
/**
* Container of system function mocks
*
* @copyright Copyright 2015 Fwolf
@fwolf
fwolf / flotr2-example.html
Created February 28, 2015 05:17
Stuff when learning flotr2
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="utf-8" />
<meta name="Author" content="Fwolf &lt;fwolf.aide+fwolflib.class.flotr2@gmail.com&gt;, http://www.fwolf.com/" />
<link rel="stylesheet" href="../../css/reset.css" type="text/css" media="screen, print" />
@fwolf
fwolf / highcharts-example.html
Created February 28, 2015 05:18
Stuff when learning HighCharts, 2012
<?php
$s_title = 'Highcharts JS Example';
echo<<<EOF
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@fwolf
fwolf / base36-timestamp-trimmed.php
Created March 5, 2015 16:14
Compute if trim timestamp to start from not 1970, the max year same length base 36 zzz... can present to.
<?php
// Compute if trim timestamp to start from not 1970, the max year same length
// base 36 zzz... can present to.
$startYear = 2000;
$currentYear = date('Y');
$currentTimestamp = time();
for ($year = $startYear; $year <= $currentYear; $year ++) {
$startDate = "$year-01-01";
@fwolf
fwolf / find-best-start-date.php
Last active August 29, 2015 14:16
Given length of second and microsecond, use base36, from current time, which start date will fill the full length ?
<?php
// @see http://3v4l.org/YPTHo
$lengthOfSecond = 6;
$lengthOfMicroSecond = 4;
$length = $lengthOfSecond + $lengthOfMicroSecond;
// From start date to now, the encoded value need fill length
$minTimestamp36 = '1' . str_repeat('0', $length - 1);
$minTimestamp10 = base_convert($minTimestamp36, 36, 10);
@fwolf
fwolf / lifetime-compute.php
Last active August 29, 2015 14:16
With given timestamp start date, compute same length base36 encoded string can be start from or end to which date.
<?php
/**
* Compute of lifetime range for base36 encoded timestamp string
*
* Notice: Need to run in 64-bit environment
*
* @see http://3v4l.org/qDkDE
*/
$lengthOfSecond = 6;
@fwolf
fwolf / tg.sh
Last active August 29, 2015 14:21
Send message with telegram-cli
#!/bin/bash
# Usage:
# Only first line of output
# ./tg.sh 用户昵称或群组名称(空格用_替代) "$(w)"
# Or combile multiple line to one
# ./tg.sh 昵称 $(w)
#
# 要求对方用户在联系人目录中,或者 group 有对话记录(空的也行)
@fwolf
fwolf / gist:464533
Created July 5, 2010 17:14
Find and recover un-continous id of WordPress post.
<?php
/**
* Find and recover un-continous id of WordPress post.
*
* Will make empty draft using these id for edit them later.
* Also change revision or auto-draft to draft.
*
* @package fwolfweb
* @subpackage wordpress
* @copyright Copyright 2010, Fwolf