Skip to content

Instantly share code, notes, and snippets.

<?php
$input = '[Hoten: Tran văn A -tuổi: 20-địa chỉ: Cần Thơ][Hoten: Tran văn c-tuổi: 40-địa chỉ: Hậu Giang][Hoten: Tran văn g-tuổi: 80-địa chỉ: An Giang]';
$regex = '/\[Hoten:\s([^-]+)-tuổi:\s(\d+)-địa chỉ:\s([^\]]+)/i';
preg_match_all($regex, $input, $matches);
$len = count($matches[1]);
$output = [];
for ($i = 0; $i < $len; $i++) {
$output[] = array(
'Hoten' => $matches[1][$i],
@tonythere
tonythere / HLS_dvr.sh
Created January 23, 2016 10:30 — forked from John07/HLS_dvr.sh
A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.
# required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier
# you can schedule this with launchd to run e.g. weekly
# Specify in seconds how long the script should record (default here is 1 hour).
seconds=3600
# Date format for the recording file name
DATE=`date "+%d-%m-%y_%H-%M"`
# start ffmpeg recording
@tonythere
tonythere / tmux.cheat
Created January 20, 2016 06:57 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
global
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
maxconn 4096
#!/bin/sh
#
# Init Script to run HaProxy in daemon mode at boot time.
#
# Author: Riccardo Riva - RPM S.r.l.
# Revision 1.0 - 2011 November, 18</pre>
#====================================================================
# Run level information:
#
@tonythere
tonythere / tor_ip_renew.py
Created December 28, 2015 16:49 — forked from arulrajnet/tor_ip_renew.py
TOR ip renew script using pytorctl https://github.com/aaronsw/pytorctl which is a python based module to interact with the Tor Controller.
from TorCtl import TorCtl
import urllib2
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
headers={'User-Agent':user_agent}
def request(url):
def _set_urlproxy():
proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"})
opener = urllib2.build_opener(proxy_support)
@tonythere
tonythere / gist:43003e650edcafeae180
Last active September 9, 2015 03:30 — forked from gobijan/gist:1568fb2b35c517f36369
Golang HTTP Handler to Upload Image => Resize => Convert to JPEG => Save to Disk.
func UploadHandler(w http.ResponseWriter, r *http.Request) {
file, _, err := r.FormFile("file")
if err != nil {
log.Println(err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
img, _, err := image.Decode(file)

200 – OK – Eyerything is working

201 – OK – New resource has been created

204 – OK – The resource was successfully deleted

304 – Not Modified – The client can use cached data

[XDebug]
zend_extension = xdebug.so
; ?XDEBUG_PROFILE=1
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
Licensed to The Apache Software Foundation, http://www.apache Licensed to The Apache Software Foundation, http://www.apache
Benchmarking auth.tts.dev (be patient) Benchmarking auth.tts.dev (be patient)
Server Software: nginx Server Software: nginx
Server Hostname: auth.tts.dev Server Hostname: auth.tts.dev
Server Port: 80 Server Port: 80
Document Path: /test/auth/rpc | Document Path: /test/auth/restful