Skip to content

Instantly share code, notes, and snippets.

View kn007's full-sized avatar
:octocat:
I may be slow to respond.

Karl Chen kn007

:octocat:
I may be slow to respond.
View GitHub Profile
@rashidi
rashidi / android-masking-network-operator.sh
Created October 20, 2011 11:23
Android - Masking Network Operator
# Settings -> Applications -> Manage Applications -> Market -> Clear Cache -> Force Stop (this button will be enabled if your Market is still running) -> OK
# Open a console and type the following command (for *nix user, remember to use sudo to avoid permission error):
adb shell setprop gsm.sim.operator.numeric 310260
adb shell setprop gsm.operator.numeric 310260
adb shell getprop gsm.sim.operator.iso-country us
adb shell getprop gsm.operator.iso-country us
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
@davidnknight
davidnknight / send_email.php
Created July 20, 2012 12:01
PHP Send Mail (Plaintext and HTML)
<?php
/**
* Send email
* @param string|array $email
* @param object $from
* @param string $subject
* @param string $message
* @param string $headers optional
*/
function send_email($email, $from, $subject, $message, $headers = null)
@xdstack
xdstack / gist:3713539
Created September 13, 2012 10:49
php查询IP地理位置(dat数据库)
header("content-type:text/html;charset=utf-8");
//*
//文件头 [第一条索引的偏移量 (4byte)] + [最后一条索引的偏移地址 (4byte)] 8字节
//记录区 [结束ip (4byte)] + [地区1] + [地区2] 4字节+不定长
//索引区 [开始ip (4byte)] + [指向记录区的偏移地址 (3byte)] 7字节
//注意:使用之前请去网上下载纯真IP数据库,并改名为 "CoralWry.dat" 放到当前目录下即可.
//by 查询吧 www.query8.com
//*
class ipLocation {
@ck-on
ck-on / ocp.php
Last active May 18, 2024 22:35
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
@kitelife
kitelife / segmentfault-1010000000174213.py
Created March 5, 2013 09:06
Python验证用户输入IP的合法性,有什么好方法吗? 如:<input type="text" name="ip" id="ip" /> 在text里表单输入的字符串
#!/usr/bin/python
#-*- coding: utf-8 -*-
'''
http://segmentfault.com/q/1010000000174213
Python验证用户输入IP的合法性,有什么好方法吗?
如:<input type="text" name="ip" id="ip" /> 在text里表单输入的字符串
'''
@cypreess
cypreess / periodic_thread.py
Last active February 28, 2024 02:59
Python periodic thread using timer. You can cancel this thread any time. Thread will live at maximum to the end of one single processing run, otherwise it will end in the same time (especially during a wait time for next run). This code avoids the problem of waiting very long for thread exiting, because it does not uses time.sleep(). Please be a…
import logging
import threading
class PeriodicThread(object):
"""
Python periodic Thread using Timer with instant cancellation
"""
def __init__(self, callback=None, period=1, name=None, *args, **kwargs):
@bradleyboy
bradleyboy / nginx.conf
Last active March 22, 2022 19:46
nginx rewrite setup for Koken
# Enable gzip. Highly recommending for best peformance
gzip on;
gzip_comp_level 6;
gzip_types text/html text/css text/javascript application/json application/javascript application/x-javascript;
# By default, do not set expire headers
expires 0;
# Set expires header for console CSS and JS.
# These files are timestamped with each new release, so it is safe to cache them agressively.
@bbrochier
bbrochier / gotop.css
Last active May 27, 2018 19:00
Go Top Sticky button
/* Go Top */
.go-top {
position: fixed;
bottom: 2em;
right: 2em;
text-decoration: none;
color: white;
background-color: #f6f6f6;
background-color: rgba(0, 0, 0, 0.3);
font-size: 12px;
@jackielii
jackielii / OpenWithSublimeText3.bat
Last active March 13, 2024 17:38 — forked from mrchief/LICENSE.md
Add "Open with Sublime Text 3" to Windows Explorer Context Menu (including folders)
@echo off
SET st2Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f