Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile
Copied from http://www.programmierecke.net/howto/gpg-ssh.html
Saved here for posterity.
Tested with Yubikey NEO in 0x82 mode.
with smartcard (openpgp)
Some Links
Using Smartcard with Windows (Putty): Pageant for Putty with smartcard support
step by step
@dschep
dschep / bootlocal.sh
Last active March 4, 2016 21:41
Workaround bug in Linux boot2docker hosts not mounting home dirs (boot2docker/boot2docker#1085)
#!/bin/sh
# Work around for boot2docker/boot2docker#1085
# Extracted from boot2docker/boot2docker#1086
mkdir -p /hosthome
mount | grep -q /hosthome || mount -t vboxsf hosthome /hosthome \
-o defaults,uid=$(id -u docker),gid=$(id -g docker)
ls -1 /hosthome | while read d
do
@dschep
dschep / fix-apple-kbd.sh
Created November 25, 2015 15:23
Swap Alt & Meta and default to Fkeys not media keys
#!/bin/bash
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode
echo 1 | sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd
javascript: function runDownloadThing(howManyToDownload) {
if (!howManyToDownload) {
howManyToDownload = 3;
}
if (window['downloadSome']) {
window.downloadSome();
return;
}
var iter = $('div.download a.a:not([download])').toArray();
iter = iter.concat($('div.row a[download]').toArray());
@dschep
dschep / swc
Created March 24, 2016 01:29
Streaming version of wc -l
#!/bin/bash
exec awk '{printf "\r%lu", NR}'
@rsvp
rsvp / netspeed.sh
Last active May 13, 2020 15:08
netspeed.sh : check download speed rate via command line | Linux bash script
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2013-07-11
#
# _______________| netspeed : check download speed via command line.
#
# Usage: netspeed [tokyo, london, usw, use, east, west, URL]
# ^default U.S. west coast.
# [ -speed_KB/sec ]
# ^negation activates the Mbps converter.
#
import { useState } from "react";
const useLocalStorageState = (storageKey, defaultValue) => {
const [value, setValue] = useState(
JSON.parse(localStorage.getItem(storageKey) || "null") || defaultValue
);
const wrappedSetValue = (newValue) => {
localStorage.setItem(storageKey, JSON.stringify(newValue));
setValue(newValue);
@dschep
dschep / ST_TileEnvelope.sql
Last active January 9, 2021 18:41
ST_TileEnvelope backport
-- ported from https://github.com/pramsey/minimal-mvt/blob/58f3e695a305f42024dcf0ba395590bf39b0b573/minimal-mvt.py#L63-L81
CREATE OR REPLACE FUNCTION ST_TileEnvelope(tileZoom integer, tileX integer, tileY integer) RETURNS geometry AS $$
-- Width of world in EPSG:3857
DECLARE worldMercMax float = 20037508.3427892;
DECLARE worldMercMin float = -1 * worldMercMax;
DECLARE worldMercSize float = worldMercMax - worldMercMin;
-- Width in tiles
DECLARE worldTileSize float = power(2, tileZoom);
-- Tile width in EPSG:3857
DECLARE tileMercSize float = worldMercSize / worldTileSize;
@dschep
dschep / ST_LineChunk.sql
Last active January 10, 2021 02:43
Line chunking implementations for PostGIS
CREATE OR REPLACE FUNCTION ST_LineChunk(geom geometry, max_length float8) RETURNS SETOF geometry AS $$
WITH
points AS (
SELECT generate_series(0, CEIL(ST_Length(geom) / max_length)::int)
/ CEIL(ST_Length(geom) / max_length) "end"
),
line_points AS (SELECT LAG("end", 1) OVER (ORDER BY "end") "start", "end" FROM points)
SELECT ST_LineSubstring(geom, "start", "end")
FROM line_points
WHERE "start" IS NOT NULL AND "start" <> 1
@shovon
shovon / increase_swap.sh
Created April 10, 2015 15:18
Increasing swap size. Only tested on the ubuntu/trusty64 Vagrant box. CREDIT GOES TO ---> http://jeqo.github.io/blog/devops/vagrant-quickstart/
#!/bin/sh
# size of swapfile in megabytes
swapsize=8000
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then