Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
CTimmerman / test_email.php
Created November 26, 2014 10:14
Testing WordPress email settings
require_once('wp-load.php'); // Required by all WordPress functions.
wp_mail("email", "subject", "message"); // Sends message to email address.
phpinfo(); // Shows all PHP settings, including SMTP server.
CTimmerman / romaji.js
Last active August 29, 2015 14:13
// Bookmarklet to convert hiragana and katatana to romanji (Latin characters)
// Based on Hiragana, Katakana, Hepburn, Nihon-shiki, Kunrei-shiki table of
javascript:(function(){function t(s){var n="";var i=-1;while(++i<s.length){var c=s[i];c=d[c]||c;n+=d2[c]||c};return n}function A2L(e){if(e.nodeType==3&&e.nodeValue.trim()!=""){e.nodeValue=t(e.nodeValue)}else{var i=e.childNodes.length;while(i--){A2L(e.childNodes[i])}}}var HKH=["あ:ア:a","い:イ:i","う:ウ:u","え:エ:e","お:オ:o","や:ャ:ya","ゆ:ュ:yu","よ:ョ:yo","か:カ:ka","き:キ:ki","く:ク:ku","け:ケ:ke","こ:コ:ko","ゃ:ャ:a","ゅ:ュ:u","ょ:ョ:o","さ:サ:sa","し:シ:shi:si","す:ス:su","せ:セ:se","そ:ソ:so","た:タ:ta","ち:チ:chi:ti","つ:ツ:tsu:tu","て:テ:te","と:ト:to","な:ナ:na","に:ニ:ni","ぬ:ヌ:nu","ね:ネ:ne","の:ノ:no","は:ハ:ha","ひ:ヒ:hi","ふ:フ:fu:hu","へ:ヘ:he","ほ:ホ:ho","ま:マ:ma","み:ミ:mi","む:ム:mu","め:メ:me","も:モ:mo","や:ヤ:ya","ゆ:ユ:yu","よ:ヨ:yo","ら:ラ:ra","り:リ:ri","る:ル:ru","れ:レ:re","ろ:ロ:ro","わ:ワ:wa","ゐ:ヰ:i:wi:i","ゑ:ヱ:e:we:e","を:ヲ:o:wo:o","ん:ン:n-n'(-m):n-n'","が:ガ:ga","ぎ:ギ:gi","ぐ:グ:
substr(preg_replace_callback('/(.*?), /', function($matches){
return '<a href="user_mod.php?frole='.rawurlencode($matches[1]).'">'.$matches[1].'</a>, ';
}, $row['froles'].', '), 0, -2)
CTimmerman / .htaccess
Last active August 29, 2015 14:14
jQuery 2 not working in IE11? It might be your old intranet policy.
<FilesMatch "\.(htm|html|php)$">
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
CTimmerman / Stop_POODLE.reg
Created February 2, 2015 19:55
If your IE is still vulnerable according to merge this registry setting.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
CTimmerman / VS2013_edit_during_run.txt
Last active August 29, 2015 14:14
Visual Studio 2013 error: "Changes are not allowed for this module as it was not built for changes while debugging or the target .NET runtime version does not support it."
Given the lack of comment permalinks, link looks, and the broken profile picture update link, i'll mirror my proposed answer at
To edit a C# program while you're running it in Visual Studio 2013:
1. Go to Project, Properties, Build.
2. Set Platform target: x86
2. Disable "Optimize code"
3. Set Advanced, Debug Info: Full
CTimmerman / filter.js
Last active August 29, 2015 14:15
jQuery table filter trigger for IE10.
$('#filter').on("keyup", filter)
// Too slow? Wait for enter:
//$('#filter').on('change', filter);
// Help IE10 because it doesn't trigger change until field loses focus.
//$('#filter').on('keydown', function(event){if(event.which == 13) $(this).change()})
$('#filter').on("mouseup", function(){setTimeout(filter, 50)}) // Wait for IE10 to clear input.
CTimmerman /
Last active August 29, 2015 14:17
import requests #
url = ''
post_data = {'email':'xxx', 'password':'xxx'}
response =, json=post_data)
json = response.json()
print("Key: " + json['access_key'])
CTimmerman /
Last active August 29, 2015 14:18
pypyodbc insert/update
import pypyodbc # C:\Python34\Scripts>pip install pypyodbc
def printu(s):
try: print(s)
except: print(str(s).encode('ascii', errors='xmlcharrefreplace'))
con = pypyodbc.connect('DRIVER={SQL Server};SERVER=xxx;DATABASE=xxx;UID=xxx;PWD=xxx')
cur = con.cursor()
table = "reports"
CTimmerman /
Last active August 29, 2015 14:18
batch replace / escape SQL previewer
def sql_escape(v):
return "'"+str(v).replace("'", "''")+"'"
def fill_sql(sql, values):
"Hacking around hard-to-reproduce pypyodbc bug. Also using tinyint for bools for easy counting."
unique = "%PARAMETER%"
sql = sql.replace("?", unique)
for v in values: sql = sql.replace(unique, "null" if repr(v)=="None" else str(int(v)) if type(v) == bool else repr(v) if type(v) in (int, float) else sql_escape(v), 1)
return sql