Skip to content

Instantly share code, notes, and snippets.

Tim Weber scy

View GitHub Profile
@scy
scy / gw2-golang-poc.go
Last active Jan 2, 2019
Example on how to access the Guild Wars 2 Mumble Link API on Windows using Go. Not supposed to be good Go code, but it works.
View gw2-golang-poc.go
package main
import (
"fmt"
"log"
"syscall"
"time"
"unsafe"
"unicode/utf16"
"unicode/utf8"
@scy
scy / login-notify
Created Dec 7, 2017
Only allow SSH logins after a push notification to your phone has been sent
View login-notify
#!/bin/sh
# Only allow SSH logins after a push notification to your phone has been sent.
# Also sends a notification after logging out.
# This uses the Pushover service (pushover.net).
# If Pushover cannot be reached, the login will be denied!
# Add something like this to /etc/pam.d/sshd:
# session required pam_exec.so /usr/local/bin/login-notify
# For Debian, a good place is after "@include common-account".
@scy
scy / install-phantomjs.sh
Created May 21, 2014
Simple PhantomJS installer for Linux
View install-phantomjs.sh
#!/bin/sh
set -e
if [ "$(id -u)" -ne 0 ]; then
printf 'WARNING: You will most likely need to be root, but continuing anyway ...\n' >&2
fi
url="$1"
if [ -z "$url" ]; then
printf 'Please go to <http://phantomjs.org/download.html> and find the\n'
@scy
scy / utc.py
Created Apr 30, 2014
How to parse a string as UTC in Python
View utc.py
import datetime
class UTC(datetime.tzinfo):
ZERO = datetime.timedelta(0)
def utcoffset(self, dt):
return self.ZERO
def tzname(self, dt):
return 'UTC'
def dst(self, dt):
return self.ZERO
@scy
scy / keybase.md
Last active Feb 4, 2018
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am scy on github.
  • I am scy (https://keybase.io/scy) on keybase.
  • I have a public key ASAdsSlXz8yCDiWmbQDYVCO2FiNRysGf4rIxRieOYynBIgo

To claim this, I am signing this object:

@scy
scy / btrsnap
Last active Aug 29, 2015
a btrfs-based local snapshotting script (for timemachine-like fuckup recovery)
View btrsnap
Please see https://github.com/scy/scybtr/blob/master/btrsnap instead.
@scy
scy / README.md
Last active Jan 10, 2019
My OSX PF config for #30C3.
View README.md

My OS X “VPN only” Setup For #30C3

You should never let passwords or private data be transmitted over an untrusted network (your neighbor’s, the one at Starbucks or the company) anyway, but on a hacker congress like the #30C3, this rule is almost vital.

Hackers get bored easily, and when they’re bored, they’re starting to look for things to play with. And a network with several thousand connected users is certainly an interesting thing to play with. Some of them might start intercepting the data on the network or do other nasty things with the packets that they can get.

If these packets are encrypted, messing with them is much harder (but not impossible! – see the end of this article). So you want your packets to be always encrypted. And the best way to do that is by using a VPN.

Target audience

@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active Apr 18, 2019
Opening and closing an SSH tunnel in a shell script the smart way
View opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost
@scy
scy / delete-from-repo.md
Created Sep 20, 2013
How to delete a file from a Git repository, but not other users' working copies
View delete-from-repo.md

How to delete a file from a Git repository, but not other users' working copies

Suppose you have, by mistake, added your IDE's project folder (you know, these .idea folders with all kinds of local paths and configuration data and settings in it) to the Git repository of your project. (We're talking about a whole folder here, but the same rules apply to individual files as well.)

Of course, you only realize that two days after the fact and have already pushed it, and your colleagues have already pulled it. They use the same IDE as you do, so whenever they change a setting or fix paths, they can either

  • commit that, causing nasty merge conflicts for you and others or
  • ignore the changes and carry around a modified file until the end of time without ever committing it.

Why .gitignore won't help

@scy
scy / jquery.pseudo.data.js
Last active Dec 21, 2015
A simple :data(key) selector for jQuery
View jquery.pseudo.data.js
// jQuery UI has a :data selector. I wanted to have it without including jQuery UI.
// To find out how all of this works, read the Sizzle documentation:
// https://github.com/jquery/sizzle/wiki/Sizzle-Documentation
// Thanks to @_Tomalak for inspiring me to check this out.
jQuery.expr.pseudos.data = jQuery.expr.createPseudo(function (key) {
return function (el) {
return !!jQuery.data(el, key);
};
});
You can’t perform that action at this time.