Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / bench.py
Last active March 6, 2024 14:57 — forked from marians/bench.py
Python serialization benchmark
"""
Python serialization benchmark
Based on https://gist.github.com/marians/f1314446b8bf4d34e782
2014-11-11 v1.0
2014-11-12 v1.1 Added compression and output size.
"""
try: import cPickle
except: import pickle as cPickle # don't break in Python 3
import json, marshal, pickle, random
from hashlib import md5
@CTimmerman
CTimmerman / Like-o-matic.js
Last active January 6, 2019 16:37
Like-o-matic bookmarklet based on http://marklets.com/Like-o-matic.aspx
javascript:(function(){try{var url='https://www.facebook.com/plugins/like.php?href='+encodeURIComponent(location.href);eval('');var ifr=document.createElement('iframe');ifr.style.cssText='border:0px;z-index:9000;position:fixed;top:100px;left:10px;width:200px;height:70px';ifr.src=url;document.getElementsByTagName('body')[0].appendChild(ifr)}catch(e){window.open(url)}})()
@CTimmerman
CTimmerman / test_email.php
Created November 26, 2014 10:14
Testing WordPress email settings
<?php
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
CTimmerman / share_clipboard.py
Last active July 5, 2023 15:15
Share clipboard
# -*- coding: utf-8 -*-
"""
Share clipboard
by Cees Timmerman
01-12-2014 v0.1 Works fine except Tk.clipboard_append()
02-12-2014 v0.9 Nonblocking sockets (didn't help Tk) and clipboard module instead of tkinter.
02-12-2014 v0.99 Bidirectional clipboard sharing. clipboard/pyperclip fails on Unicode like “, though.
08-12-2014 v1.0 pyperclip 1.5.7 supports Unicode (with emoji: 📋) on Windows.
"""
import socket, struct, sys, threading
@CTimmerman
CTimmerman / Notepad++ IDE setup.md
Last active July 30, 2021 10:42
Notepad++ IDE setup
  1. Install Notepad++ (check "set as default HTML editor" to replace Notepad in IE).
  2. Download Plugin Manager zip, open it, and copy the two folders into your Notepad++ program folder, e.g. C:\Program Files\Notepad++ for the 64-bit version.
  3. Run Notepad++, update its plugins, and install "NppExec" via Plugins, Plugin Manager.
  4. Enter these scripts for Python debugging:

Press F6 to create a NppExec Execute script, save as "Python 3.4":

NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
@CTimmerman
CTimmerman / Windows_clipboard_test.py
Last active June 8, 2018 12:22
Windows clipboard test
#coding=utf-8
"""
Test various clipboard solutions (for Windows).
by Cees Timmerman
2014-12-04 v1.1 use locale.getpreferredencoding()
2014-12-05 v1.2 Test emoji. pyperclip (1.5.5) now uses the ctypes code.
2014-12-05 v1.3 ctypes code now uses proper CF_UNICODETEXT encoding according to http://bugs.python.org/issue22999#msg232191 - Emoji 📋 (\U0001f4cb) was copied as 🐀 (\U0001f400) in Python 3.3+.
"""
try: from tkinter import Tk
@CTimmerman
CTimmerman / romaji.js
Last active August 29, 2015 14:13
Romaji
// Bookmarklet to convert hiragana and katatana to romanji (Latin characters)
// Based on Hiragana, Katakana, Hepburn, Nihon-shiki, Kunrei-shiki table of http://en.wikipedia.org/wiki/Romanization_of_Japanese
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","ぐ:グ:
@CTimmerman
CTimmerman / Windows_oneliners.bat
Last active April 4, 2024 07:42
Oneliners, single line scripts.
rem Show WiFi password
netsh wlan show profile name="MyNetwork" key=clear
rem Fix software BSOD as Administrator. Problems not already fixed by DISM SFC will log in %windir%\logs\cbs\cbs.log
dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow
rem Fix hardware sectors as Administrator (takes hours so run overnight)
chkdsk C: /r
substr(preg_replace_callback('/(.*?), /', function($matches){
return '<a href="user_mod.php?frole='.rawurlencode($matches[1]).'">'.$matches[1].'</a>, ';
}, $row['froles'].', '), 0, -2)
@CTimmerman
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
</IfModule>
</FilesMatch>