This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"test" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dropzone Action Info | |
# Name: Qiniu | |
# Description: Upload images to qiniu.com | |
# Handles: Files | |
# Creator: Su Yan | |
# URL: http://yansu.org | |
# OptionsNIB: ExtendedLogin | |
# Events: Clicked, Dragged | |
# KeyModifiers: Command, Option, Control, Shift | |
# SkipConfig: No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
int strStr(const char *source, const char *target) { | |
// check if source or target is nullptr | |
if (source == nullptr || target == nullptr) { | |
return -1; | |
} | |
string s(source), t(target); | |
if (t.size() == 0) { | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$test_json = file_get_contents('/tmp/test_json'); | |
$byte_array = json_decode($test_json, true); | |
$byte_string = implode(array_map("chr", $byte_array['fieldInfo']['image'])); | |
$img_string = base64_encode($byte_string); | |
echo '<img src="data:image/jpg;base64,'.$img_string.'"/>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if inotifywait -e modify -e move -e create -r /var/www ; then | |
while inotifywait -e modify -e move -e create -t 30 -r /var/www ; do echo "waiting" ; done | |
supervisorctl reload | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch --commit-filter ' | |
if [ "$GIT_AUTHOR_EMAIL" = "test@test.com" ]; | |
then | |
GIT_AUTHOR_NAME="First Last"; | |
GIT_COMMITTER_NAME="First Last"; | |
GIT_AUTHOR_EMAIL="user@user.com"; | |
GIT_COMMITTER_EMAIL="user@user.com"; | |
git commit-tree "$@"; | |
else | |
git commit-tree "$@"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function closure_dump(Closure $c) { | |
$str = 'function ('; | |
$r = new ReflectionFunction($c); | |
$params = array(); | |
foreach($r->getParameters() as $p) { | |
$s = ''; | |
if($p->isArray()) { | |
$s .= 'array '; | |
} else if($p->getClass()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// server | |
$Server = D('Server'); | |
set_time_limit(0); | |
$host = C('DAEMON_HOST'); | |
$port = C('DAEMON_PORT'); | |
// 创建一个tcp流 | |
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) | |
or die("socket_create() failed:" . socket_strerror(socket_last_error())); | |
// 设置阻塞模式 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* @Author: Su Yan <http://yansu.org> | |
* @Date: 2014-04-16 09:26:21 | |
* @Last Modified by: Su Yan | |
* @Last Modified time: 2014-04-16 16:43:23 | |
*/ | |
$dsn = 'mysql:host=localhost;dbname=test'; | |
$db = new PDO($dsn,'root',''array(PDO::ATTR_PERSISTENT => true)); | |
//删除上次的插入数据 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once '/usr/local/Cellar/php55-xhprof/254eb24/xhprof_lib/utils/xhprof_lib.php'; | |
include_once '/usr/local/Cellar/php55-xhprof/254eb24/xhprof_lib/utils/xhprof_runs.php'; | |
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); | |
$app->run(); | |
$xhprof_data = xhprof_disable(); |
NewerOlder