Skip to content

Instantly share code, notes, and snippets.

View jagd's full-sized avatar

C. Wu jagd

  • Germany
View GitHub Profile
@Speedy37
Speedy37 / gpg-agent-relay.sh
Created July 10, 2020 11:02
WSL2 gpg agent relay (Yubikey)
#!/bin/bash
# Launches socat+npiperelay to relay the gpg-agent socket file for use in WSL
# See https://justyn.io/blog/using-a-yubikey-for-gpg-in-windows-10-wsl-windows-subsystem-for-linux/ for details
GPGDIR="${HOME}/.gnupg"
USERNAME=Vincent
# I use the same username for wsl and windows, but feel free to modify the paths below if that isn't the case
WIN_GPGDIR="C:/Users/${USERNAME}/AppData/Roaming/gnupg"
NPIPERELAY="${HOME}/npiperelay.exe"
@detunized
detunized / run.sh
Created September 4, 2017 11:02
Mount a read-only folder inside a Docker container with OverlayFS on top
# On the host to run the container
docker run --privileged -i -t -v ~/host-folder-to-mount:/root/folder-ro:ro ubuntu
# Inside the container
# Need to create the upper and work dirs inside a tmpfs.
# Otherwise OverlayFS complains about AUFS folders.
mkdir -p /tmp/overlay && \
mount -t tmpfs tmpfs /tmp/overlay && \
mkdir -p /tmp/overlay/{upper,work} && \
mkdir -p /root/folder && \
@avafloww
avafloww / PhpJava.java
Last active August 12, 2025 13:33
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@johnramsden
johnramsden / openvpn-pia.bash
Last active February 3, 2025 16:02
Freebsd openvpn bash script. Used to automate setup of OpenVPN on Private Internet Access.
#!/usr/local/bin/bash
###############################
# Created by John Ramsden
# Github Ramsdenj
###############################
# Used script by jedediahfrey@github and post by Tango@FreeNAS forums as reference
# https://forums.freenas.org/index.php?threads/guide-setting-up-transmission-with-openvpn-and-pia.24566/
@NoUsername
NoUsername / imageViewer.html
Created March 2, 2014 15:38
Simple image viewer, which loads all images from an html directory listing.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<img id="viewer" src="" width="800px"/>
<div id="info"> </div>
<script>
$(function() {
@jagd
jagd / feko.vim
Created April 4, 2011 12:16
.vimrc patch for editfeko / prefeko (*.pre) syntax highlight
"" feko
autocmd BufNewFile,BufRead *.pre set filetype=feko
autocmd filetype feko call Feko()
function! Feko()
"" Syntax Highlight
set syntax=feko
@jagd
jagd / gist:805782
Created February 1, 2011 12:13
Miller-Rabin in Haskell
{-
x^(n-1) % n == 1
k == n-1 == d*(2^m)
und
a^d % n == (1 || n-1)
oder irgendeine
a^(d * (2^i)) % n == n-1
davon, i = 1, 2, 3 ... m
-}
@jagd
jagd / gist:804850
Created January 31, 2011 21:29
Miller-Rabin in C for uint32_t
int MillerRabin(uint32_t a, int n)
{
/* x^(n-1) % n == 1 */
/* k == n-1 == d*(2^m) */
/* davon :
* a^d % n == 1
* oder
* a^(d * (2^i)) % n == n-1
* davon, i = 1, 2, 3 ...