Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
@dvliman
dvliman / gym.py
Created September 28, 2021 23:32 — forked from Alir3z4/gym.py
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@dvliman
dvliman / screen-gif.sh
Created August 23, 2020 05:10 — forked from julesjans/screen-gif.sh
Capture iOS Simulator to animated gif
# Turn on the simulator screen capture
xcrun simctl io booted recordVideo ~/simulator.mov
# Convert the iPhone 6s screen shot into a gif:
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif
@dvliman
dvliman / spike-day-02-03-20.md
Created February 9, 2020 20:46 — forked from cldwalker/spike-day-02-03-20.md
GraalVM dive in Clojure at work

Spike

I looked into the state of GraalVM and Clojure and wrote some small work-related scripts.

GraalVM Build Tools

@dvliman
dvliman / gist:921ca48137d134e0152d494d9aa54c73
Created November 14, 2019 18:23 — forked from chanks/gist:7585810
Turning PostgreSQL into a queue serving 10,000 jobs per second

Turning PostgreSQL into a queue serving 10,000 jobs per second

RDBMS-based job queues have been criticized recently for being unable to handle heavy loads. And they deserve it, to some extent, because the queries used to safely lock a job have been pretty hairy. SELECT FOR UPDATE followed by an UPDATE works fine at first, but then you add more workers, and each is trying to SELECT FOR UPDATE the same row (and maybe throwing NOWAIT in there, then catching the errors and retrying), and things slow down.

On top of that, they have to actually update the row to mark it as locked, so the rest of your workers are sitting there waiting while one of them propagates its lock to disk (and the disks of however many servers you're replicating to). QueueClassic got some mileage out of the novel idea of randomly picking a row near the front of the queue to lock, but I can't still seem to get more than an an extra few hundred jobs per second out of it under heavy load.

So, many developers have started going straight t

@dvliman
dvliman / gist:372de58943f2534fafe9803bc8fb8893
Created June 12, 2019 03:01 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@dvliman
dvliman / _reader-macros.md
Created June 10, 2019 04:38 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@dvliman
dvliman / spacemacs-cheshe.md
Created March 29, 2019 20:18 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@dvliman
dvliman / async_util.clj
Created July 2, 2018 06:52 — forked from echeran/async_util.clj
Utility functions for core.async 0.1.346.0-17112a-alpha to create a linear pipeline of go-routines in a Storm-esque way.
(ns your.namespace.async-util
(:require
[clojure.core.async :as a :refer [>! <! >!! <!! go chan buffer
close! thread alts! alts!! timeout]]
[clojure.core.match :as match :refer [match]]))
;;
;; core.async util fns
;;
@dvliman
dvliman / main.go
Created January 7, 2018 19:22 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@dvliman
dvliman / postgres_queries_and_commands.sql
Created September 6, 2017 00:12 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'