Skip to content

Instantly share code, notes, and snippets.

@keturn
keturn / MethodHandleAdapters.java
Last active May 18, 2022 03:01
Java MethodHandle from SerializedLambda
import com.google.common.base.Throwables;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleInfo;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.SerializedLambda;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@keturn
keturn / SpyingOutputObjectStream.java
Last active May 18, 2022 03:01
Java: Get a lambda's parameter types
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.invoke.MethodType;
import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@keturn
keturn / pr-only-fork.sh
Created December 29, 2019 01:52
Document git fork as "Pull-Request Only"
#!/bin/bash
# Replace the repo's default branch with a README explaining this fork is only for its submitted pull requests.
set -e -x -o pipefail
REMOTE=origin
GH_USERNAME="${GH_USERNAME:-$USER}"
TRUNK="$(git symbolic-ref --short refs/remotes/$REMOTE/HEAD | sed "s:${REMOTE}/::")"
REMOTE_URL="$(git remote get-url $REMOTE)"
;; Adapted from https://github.com/rurban/picat-lang/blob/master/picat-mode.el
;; mostly the same but this one works..
;;
(eval-when-compile
(require 'generic)
(require 'font-lock)
(require 'regexp-opt))
(defmacro picat-match-symbol (&rest symbols)
@mzizzi
mzizzi / x11_events.py
Created November 12, 2015 01:15
Subscribe to X11 PropertyChange events
"""
Subscribe to X11 PropertyChange events and print "Window Changed!" when a
_NET_ACTIVE_WINDOW property has been changed.
Unfortunately no event is received events when _NET_WM_NAME is changed so this
would only partially solve https://github.com/dictation-toolbox/aenea/issues/103
You'll have to `pip install python-xlib` to run this script.
(Tested with the Cinnamon 2.2.16 desktop)
@eestrada
eestrada / sqlite_regex.py
Last active December 21, 2023 13:46
How to do regular expressions in sqlite3 (using python).
#!/usr/bin/env python
"""How to do regular expressions in sqlite3 (using python)."""
from __future__ import division, absolute_import, print_function, unicode_literals
import re
import sys
import time
import datetime
import sqlite3
@iconara
iconara / queries.sql
Last active November 13, 2023 22:26
Low level Redshift cheat sheet
-- Table information like sortkeys, unsorted percentage
-- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html
SELECT * FROM svv_table_info;
-- Table sizes in GB
SELECT t.name, COUNT(tbl) / 1000.0 AS gb
FROM (
SELECT DISTINCT datname, id, name
FROM stv_tbl_perm
JOIN pg_database ON pg_database.oid = db_id