Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import z3
import pprint
# 9x9 matrix of integer variables
X = [ [ z3.Int("x_%s_%s" % (i+1, j+1)) for j in range(9) ]
for i in range(9) ]
# each cell contains a value in {1, ..., 9}
cells_c = [ z3.And(1 <= X[i][j], X[i][j] <= 9)
@krackers
krackers / gist:a72fd7709b5b1b9a7b4e765fdbc017a1
Created May 17, 2020 02:08 — forked from ingramchen/gist:e2af352bf8b40bb88890fba4f47eccd0
ffmpeg convert gif to mp4, for best cross browser compatibility
### Full command line options
```
ffmpeg -f gif -i FOO.gif -pix_fmt yuv420p -c:v libx264 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' BAR.mp4
```
### Notie
* output mp4 is encoded with h264, support Firefox/Chrome/Safari in Windows, Mac OSX, Android, and iOS.
@krackers
krackers / userChrome.css
Created February 19, 2020 00:03 — forked from tjespe/userChrome.css
Make Firefox Quantum look like Chrome
/* Should be put at
* `$FIREFOX_PROFILE/chrome/userChrome.css`
* e.g.:
* `/Users/tordjohanespe/Library/Application%20Support/Firefox/Profiles/l2hbvytn.dev-edition-default-1510516302187/chrome/userChrome.css`
*/
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
@-moz-document url(chrome://browser/content/browser.xul) {
#TabsToolbar {
margin-top: -3px !important;
margin-bottom: -2px !important
#!/bin/sh
# -*- mode:R -*-
#PBS -l nodes=1:ppn=8,mem=30gb
'\' >/dev/null 2>&1 || true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
@krackers
krackers / python-bash-wrapper.py
Created January 26, 2020 04:24 — forked from DarwinAwardWinner/python-bash-wrapper.py
Put bash cluster setup code and python script in a single file
#!/bin/bash
# -*- mode:python -*-
#PBS -l nodes=1:ppn=8,mem=30gb
''''/bin/true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
# Bash setup code ends here
python - "$@" <<EOF
''' # Python starts here '''
var BVT = function(width, depth, init, elems) {
this._width = width;
this._depth = depth;
this._leaf = depth === 1;
this._shift = (this._depth - 1) * Math.round(Math.log(width) / Math.log(2));
this._himask = this._width - 1;
this._lomask = Math.pow(2, this._shift) - 1;
this._elems = elems;
@krackers
krackers / easysql.js
Created October 26, 2019 01:24 — forked from konsumer/easysql.js
HTML5 Promise-based WebSQL query convenience-function
// https://github.com/Philzen/WebSQL-Polyfill
// https://github.com/jakearchibald/es6-promise
/**
* Usage:
* var db = new DB('demo', '1.0', 'Demo', 2 * 1024 * 1024);
* db.query('SELECT * FROM mytable')
* .then(function(res){
* console.log(res.rows);
* }, function(err){
@krackers
krackers / lmutracker.mm
Created October 17, 2019 07:02 — forked from Glavin001/lmutracker.mm
Read lux measurement using MBP ambient light sensor.
// lmutracker.mm -- Provides lux measurement using MacBook Ambient Light Sensor
//
// clang -o lmutracker lmutracker.mm -framework IOKit -framework CoreFoundation
//
// Adaptation of code originally posted at https://bugzilla.mozilla.org/show_bug.cgi?id=793728
// by Reuben Morais. Modified by Ken Keiter <[email protected]> to output a single *lux* value
// and exit, rather than repeating measurements on the sensor's arbitrary scale.
#include <mach/mach.h>
#include <math.h>
@krackers
krackers / howto_nat_traversal.md
Created December 22, 2018 08:07 — forked from mildred/howto_nat_traversal.md
How To TCP NAT Traversal using Node.js and a STUN Server

How To TCP NAT Traversal using Node.js and a STUN Server

With the scarecity of IPv4 addresses, and IPv6 still not available at large, NAT traversal is becoming a necessity. Especially with the generalisation of Carrier-grade NATs that you can find on mobile connections. Even with IPv6 you may suffer NAT66. Imagine your mobile device that gets only a single Ipv6 address, and you want to share it on your computer.

The solution might be in a decentralized protocol for address attribution such

# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.