Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am bamthomas on github.
* I am bamthomas (https://keybase.io/bamthomas) on keybase.
* I have a public key whose fingerprint is 3BD1 A1EE 2615 82ED 1CC8 60CE 1E58 68FD 1070 09A2
To claim this, I am signing this object:
@bamthomas
bamthomas / filesystem_tree.js
Last active December 7, 2016 19:52
js migration ES6
export class Node {
constructor(name, data, children = undefined) {
this.name = name;
this.data = data;
this.children = children;
}
is_dir() {
return this.children !== undefined;
};
# -*- coding: utf-8 -*-
import logging
from sqlalchemy import Column
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, relationship
@bamthomas
bamthomas / gist:a826ab04377c78f0de63316fc1b61ba3
Last active February 3, 2018 13:53
capture FP2 on openwrt router
tcpdump -i br-lan host android-25ac02f8e4ea5f61
13:47:46.547385 IP dune.io.imaps > android-25ac02f8e4ea5f61.lan.36478: Flags [P.], seq 1966813352:1966813398, ack 521680810, win 261, options [nop,nop,TS val 3655118434 ecr 23066180], length 46
13:47:46.670093 IP dune.io.imaps > android-25ac02f8e4ea5f61.lan.48402: Flags [P.], seq 1986507477:1986507523, ack 632287404, win 243, options [nop,nop,TS val 3655118464 ecr 23066192], length 46
13:47:46.735749 IP android-25ac02f8e4ea5f61.lan.36478 > dune.io.imaps: Flags [.], ack 46, win 1822, options [nop,nop,TS val 23075340 ecr 3655118434], length 0
13:47:46.736316 IP android-25ac02f8e4ea5f61.lan.48402 > dune.io.imaps: Flags [.], ack 46, win 1550, options [nop,nop,TS val 23075340 ecr 3655118464], length 0
13:47:51.550928 ARP, Request who-has android-25ac02f8e4ea5f61.lan tell OpenWrt.lan, length 28
13:47:51.648474 ARP, Reply android-25ac02f8e4ea5f61.lan is-at 84:cf:bf:8b:32:e4 (oui Unknown), length 28
13:47:58.244076 ARP, Request who-has OpenWrt.lan tell android-25ac02f8
curl -i --request PROPFIND --insecure --digest -u user:password --header "Content-Type: text/xml" --header "Brief:t" \
https://dav.url/card.php/addressbooks/user/default/
curl -i --request PROPFIND --insecure --digest -u user:password --header "Content-Type: text/xml" --header "Brief:t" \
https://dav.url/cal.php/principals/user/
sudo ngrep '' -d lo udp port 514 &
logger -n localhost -p local7.info log by udp
@bamthomas
bamthomas / gist:49dde34877e7010b6487cbeddd7eef1b
Created January 31, 2019 13:50
Create bootable windows USB key
sudo woeusb --target-filesystem NTFS --device Downloads/Win10_1809Oct_English_x64.iso /dev/sda
@bamthomas
bamthomas / FileExtension.java
Created April 30, 2019 12:11
Class to get a file extension with its mime type
package org.icij.datashare;
import java.util.HashMap;
import java.util.Map;
import static java.util.Arrays.stream;
import static java.util.Collections.unmodifiableMap;
public class FileExtension {
@bamthomas
bamthomas / MemoryDataBus.java
Created January 13, 2020 11:53
A tiny multithreaded memory databus
package org.icij.datashare;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Supplier;
@bamthomas
bamthomas / gist:17c3e3086620b7ef58d10d7bf8d64f8d
Created January 18, 2020 10:35
redis CLI : transform a set into a map
EVAL "local vals = redis.call('SMEMBERS', KEYS[1]); local len = redis.call('SCARD', KEYS[1]); for k, v in pairs(vals) do redis.call('HSET', KEYS[2], v, '0'); end; return len;" 2 setkey mapkey