Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar
💭
Amazed at Microsoft's poor UX.

Cees Timmerman CTimmerman

💭
Amazed at Microsoft's poor UX.
View GitHub Profile
@Kartones
Kartones / postgres-cheatsheet.md
Last active July 11, 2025 19:43
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@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 / 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 / PowerShell oneliners.ps1
Last active May 30, 2025 08:21
Oneliners, single line scripts.
# Ugly way to update Windows Store apps from PowerShell instead of the GUI. Only works in Admin-level PowerShell while Microsoft Store, profile, Settings, App updates, is set to "On"!
Get-CimInstance -Namespace "Root\cimv2\mdm\dmmap" -ClassName "MDM_EnterpriseModernAppManagement_AppManagement01" | Invoke-CimMethod -MethodName UpdateScanMethod
@drgarcia1986
drgarcia1986 / bottle_hello.py
Last active January 20, 2025 21:50
Python HelloWorld (WebFrameworks) Collection
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/')
def index():
return '<h1>Hello World/h1>'
run(host='localhost', port=8000)
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@CTimmerman
CTimmerman / Chrome_lazy_tabs.md
Last active January 30, 2017 17:51
Chrome lazy tab loading extensions test

Chrome + Session Buddy test of extensions that lazy load tabs

  1. Open two windows with two YouTube tabs per window.
  2. Pause all videos.
  3. Open extensions tab and enable none or one lazy tab extension.
  4. Save test session in Session Buddy.
  5. Focus extensions tab and close Chrome.
  6. Open Chrome.
  7. If videos don't all play at the same time, OK, else FAIL.
  8. Close all but Session Buddy tab and restore test session.
@revolunet
revolunet / python-es6-comparison.md
Last active April 11, 2025 10:54
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@CTimmerman
CTimmerman / SVG_to_PNG.js
Last active April 5, 2024 12:26
Convert SVG to PNG / save SVG as PNG
// SVG2PNG
// By Cees Timmerman, 2024-04-05.
// Paste into console and adjust indices as needed.
let im = document.getElementsByTagName('img')
let fname = location.href
if (im.length < 1) {
let svg = document.getElementsByTagName('svg')[0]
let bb = svg.getBBox()
im = new Image(bb.width, bb.height)
im.src = 'data:image/svg+xml;charset=utf-8;base64,' + btoa(document.getElementsByTagName('svg')[0].outerHTML)