Skip to content

Instantly share code, notes, and snippets.

@jwage
jwage / SplClassLoader.php
Last active July 23, 2024 18:42
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@flisky
flisky / goroutine by example
Created November 5, 2013 03:25
Goroutine By Example
Goroutine By Example
====================
尹吉峰 2013/11/05
Python Thread
-------------
```python
import time
import threading
@cgwxyz
cgwxyz / urldecode_encode.lua
Last active June 23, 2020 14:09
lua urlencode/urldecode
function encodeURI(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
@cgwxyz
cgwxyz / urllib2_post.py
Last active August 29, 2015 14:02
Python urllib2 post sample
config = {
'api_host':'github.com',
'api_script':'test.php'
}
params = {
'code':1,
'file_id':123454,
'file_name':"v/test.mp4",
'file_size':3653.32
}
@cgwxyz
cgwxyz / python-proc-name.py
Last active June 13, 2019 06:59
python设置当前进程名称(linux ps时显示)
try:
import dl
libc = dl.open('/lib/libc.so.6')
libc.call('prctl', 15, 'myproc', 0, 0, 0) #执行后ps -A,显示为myproc的进程
#参数2:15 /linux/prctl.h定义 #define PR_SET_NAME 15
except:
pass