Skip to content

Instantly share code, notes, and snippets.

@stephenjtong
stephenjtong / tk.php
Last active November 25, 2020 03:22
<?php
$file = $argv[1];
$ffmpeg = './ffmpeg';
if(empty($file)){
die('no file provide');
}
$length = shell_exec("$ffmpeg -i $file 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//");
@stephenjtong
stephenjtong / .sh
Last active May 8, 2021 09:29
git sync repo1 to repo2
for dir in ams-backend ams-frontend ams-pop ams-crm-android qrscan
do
cd /root/git_sync/$dir
sudo git fetch --all
for a in $(git branch -a | grep remotes|grep gerrit | sed 's/remotes\/gerrit\///'); do git push -f origin gerrit/$a:refs/heads/$a; done
done
@stephenjtong
stephenjtong / pre-receive
Last active April 29, 2016 08:17 — forked from proofek/pre-receive
two git pre-receive for php
#!/usr/bin/php
<?php
echo "\nRunning php linter...\n";
$params = explode(' ', file_get_contents('php://stdin'));
$ref = trim($params[1]);
$diff = array();
$return = 0;
@stephenjtong
stephenjtong / rename.php
Last active August 29, 2015 14:24
random add num prefix to file
<?php
$files = scandir('.');
shuffle($files);
$i = 1;
foreach($files as $file){
if(preg_match('/^\./', $file)){
continue;
}
if(!preg_match('/(mp3|wav)$/', $file)){
continue;
@stephenjtong
stephenjtong / gist:be73da209b6e8b208d41
Last active August 29, 2015 14:01
小木屋游戏存档
eyJ2ZXJzaW9uIjoxLjMsImZlYXR1cmVzIjp7ImxvY2F0aW9uIjp7InJvb20iOnRydWUsIm91dHNpZGUiOnRydWUsIndvcmxkIjp0cnVlLCJzcGFjZVNoaXAiOnRydWV9fSwic3RvcmVzIjp7IuacqOWktCI6ODMyOTgsIuiCiSI6OTkwNTAsIuavm+eariI6Mzk0Miwi6K+x6aW1IjoyNDIsIueJmem9vyI6MTgwMTUsIuearumdqSI6MzQwNCwi6IWM6IKJIjo0NDU5LCLps57niYciOjU2MDAwLCLluIPljLkiOjkwLCLmiqTouqvnrKYiOjIsIue9l+ebmCI6MSwi5rC06KKLIjoxMDAsIumqqOaeqiI6Miwi54Gr54KsIjo5OSwi5peF6KGM5YyFIjoxLCLnmq7nlLIiOjEsIuWtkOW8uSI6OTk5OTk0OSwi5Yy755aX6I2v5YmCIjo5OTg4LCLpk4EiOjE1Mzk5LCLnhaQiOjIxNDQsIumSoiI6MjIxNjMwLCLmsLTmobYiOjEwMCwi6LSn6L2mIjoxMCwi6ZOB55SyIjoxLCLpk4HliZEiOjEsIuWkp+i0p+i9piI6MTAwMCwi6ZO+55CDIjowLCLpkqLnlLIiOjEsIumSouWJkSI6MSwi5aSW5pif5ZCI6YeRIjoxNTk2NCwi5rC0566xIjoxMDAwLCLmraXmnqoiOjMwMSwi6ZWt5bCE5p6qIjoxMDAwLCLnh4PmlpnnlLXmsaAiOjk1MCwi5omL6Zu3Ijo5OTgyLCLnoavno7oiOjk1MH0sImNoYXJhY3RlciI6eyJwdW5jaGVzIjoxMjQsInN0YXJ2ZWQiOjMsInBlcmtzIjp7IumZjem+meWNgeWFq+aOjCI6dHJ1ZSwi6YCa6IeC5ouzIjp0cnVlLCLlh4zms6Llvq7mraUiOnRydWV9LCJkZWh5ZHJhdGVkIjoyfSwiaW5jb21lIjp7ImdhdGhlcmVyIjp7ImRlbGF5IjoxMCwic3RvcmVzIjp7
#!/usr/bin/env python2
"""
Author: takeshix <[email protected]>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford ([email protected]).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@stephenjtong
stephenjtong / max-profit-of-an-interval.php
Created December 5, 2013 16:19
get the max profit of a certain interval
<?php
$data = array();
for($i = 0; $i <= 50; $i++){
if(0 == $i){
$data[] = mt_rand(1,20);
}else{
$data[] = max(0, mt_rand($data[$i-1] - 1, $data[$i-1] +1));
}
@stephenjtong
stephenjtong / multi_db_query.php
Created September 24, 2013 10:34
多组db query轮查,给出统一结果
<?php
$db_conf = array(
array(
'host' => '1',
'port' => '',
'db' => '1',
'user' => '1',
'pwd' => '1',
),
array(
# encoding: utf-8
require 'rubygems'
require 'haml'
require 'erb'
require 'erubis'
notes = []
20.times { notes << {:title => "标题标题", :content => "内容,内容"} }
obj = {
@stephenjtong
stephenjtong / GoogleAuthenticator.php
Created March 10, 2013 14:28
google 2 步验证 PHP 算法
<?php
// https://github.com/fuchaoqun/colaphp/blob/2.0/Cola/Ext/GoogleAuthenticator.php
class Cola_Ext_GoogleAuthenticator
{
public static $ttl = 30;
public static $limit = 6;
// Lookup needed for Base32 encoding
private static $map = array(