Skip to content

Instantly share code, notes, and snippets.

View sheerluck's full-sized avatar
💭
jobless

Andrew sheerluck

💭
jobless
View GitHub Profile
@sheerluck
sheerluck / convert.py
Created September 12, 2022 13:00 — forked from dogancelik/convert.py
(Python) Convert ShiftJIS to UTF-8
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Convert ShiftJIS to UTF-8
# Usage: cat ShiftJIS.txt | ./convert.py > UTF8.txt
# Alternative method: cat ShiftJIS.txt | iconv -f shift_jis -t utf8 > UTF8.txt
import sys
import codecs
@sheerluck
sheerluck / dplyr_pandas_comparison_to_nim.org
Created April 28, 2022 09:46 — forked from Vindaar/dplyr_pandas_comparison_to_nim.org
A comparison of dplyr, Pandas and data frames in Nim (using ggplotnim)

Dplyr (R), Pandas (Python) & Nim data frame comparison

This comparison is inspired by the comparison here: https://gist.github.com/conormm/fd8b1980c28dd21cfaf6975c86c74d07

The Nim data frame implementation we use here is the Datamancer data frame.

Note that due to UFCS in Nim we can write the commands we present either similar to the Python notation as if the function were a method of the

@sheerluck
sheerluck / docker_descendants.py
Created December 4, 2021 13:51 — forked from altaurog/docker_descendants.py
Python3 script to find descendants of one or more docker images
#!/usr/bin/python3
#
# usage: python3 docker_descendants.py <image_id> ...
import sys
from subprocess import check_output
def main(images):
image_ids = set(images)
class Maybe[A : Equatable[A] val] is Equatable[Maybe[A]]
let v : (A val | None)
new val create(thing: A) => v = thing
new val empty() => v = None
fun eq(that: box->Maybe[A]): Bool =>
match (this.v, that.v)
| (let v' : A, let v'' : A) => v' == v''
| (let n' : None, let n'' : None) => true
@sheerluck
sheerluck / gitbook_to_pdf.sh
Created May 9, 2018 19:12 — forked from clemsos/gitbook_to_pdf.sh
Build Gitbook PDF using Pandoc
# #!/bin/bash
GITBOOK_REP=$1
SUMMARY_FILE="SUMMARY.md"
echo $OUTPUT_FILE
if [ -d "$GITBOOK_REP" ]; then
echo "Entering directory '$GITBOOK_REP'..."
cd $GITBOOK_REP
from pyrabbit.api import Client
username = 'guest'
password = 'guest'
cl = Client('localhost:15672', username, password)
queues = [q['name'] for q in cl.get_queues()]
for q in queues:
#if q.startswith('Dispatch.259'):
print ('deleting...' + q)
cl.delete_queue('/', q)
@sheerluck
sheerluck / film-to-dvd-ffmpeg.md
Created November 12, 2017 13:41 — forked from arthurpizza/film-to-dvd-ffmpeg.md
FFMPEG Film DVD Cheat Sheet

FFMPEG to DVD

This is the default for most movies.

Scope Movies

ffmpeg -y -i {Input} -vf scale=720:352,pad=720:480:0:64 \
-target film-dvd -vb 4M -aspect 1.7777 -ac 2 -ab 192k {Output}
@sheerluck
sheerluck / latency.markdown
Created March 11, 2017 13:26 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@sheerluck
sheerluck / cli.md
Created October 1, 2016 19:47 — forked from phrawzty/2serv.py
simple http server to dump request headers
$ curl -s -H "X-Something: yeah" localhost:8000 > /dev/null
$ python serv.py
ERROR:root:User-Agent: curl/7.37.1
Host: localhost:8000
Accept: */*
X-Something: yeah