Skip to content

Instantly share code, notes, and snippets.

View chrisparnin's full-sized avatar

Chris Parnin chrisparnin

View GitHub Profile
@chrisparnin
chrisparnin / StackPromise.js
Created February 19, 2020 14:48
Trace stack traces when a promise resolves.
class StackPromise extends Promise {
constructor(args) {
super((myresolve, myreject) =>
{
let fn = function(result) {
console.log(new Error("Promise resolved").stack);
myresolve(result);
}
args.call(null, fn, myreject );
from z3 import *
n = 10
vars = []
def getConstraint(v, x, y):
if x < 0 or x >= n or y < 0 or y >= n:
return False
return v == (1 + vars[x][y])

In a terminal start a server.

$ python -m SimpleHTTPServer 8000

In another terminal set up the cgroups freezer.

@jawn
jawn / Ideal onboarding braindump.md
Last active July 29, 2023 19:56
Ideal onboarding braindump
import imaplib
HOST = "imap.gmail.com"
USER = "[email protected]"
PASSWORD = "---"
BATCH_FOLDER = "Batch"
INBOX_FOLDER = "\\Inbox"
@tzmartin
tzmartin / Info.plist
Created June 24, 2017 19:31 — forked from nathankerr/Info.plist
Registering a Go app as a protocol handler under Mac OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>myapp</string>
<key>CFBundleIdentifier</key>
<string>com.pocketgophers.myapp</string>
<key>CFBundleURLTypes</key>
<array>
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active May 25, 2023 03:55
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"
@alexnederlof
alexnederlof / deploy.sh
Last active December 21, 2015 21:48
Automatic deployment of your latest Latex (or other) PDF to Amazon S3. The script adds the latest git describe output to the title so that if someone reviews and annotates it, you know which version it was.
#!/bin/bash
#####
#
# Deploy a PDF file annotated with the latest git version
# to your Amazon S3 bucket.
#
# This script requires you are running on a Mac with
# homebrew installed and a S3 bucket setup.
#