Skip to content

Instantly share code, notes, and snippets.

View scy's full-sized avatar

Tim Weber scy

View GitHub Profile
@scy
scy / README.md
Last active July 7, 2023 09:27
My OSX PF config for #30C3.

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 March 15, 2024 11:26
Opening and closing an SSH tunnel in a shell script the smart way

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 September 20, 2013 11:54
How to delete a file from a Git repository, but not other users' working copies

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 December 21, 2015 02:08
A simple :data(key) selector for jQuery
// 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);
};
});
@scy
scy / fix-expanded-svn-id.sh
Created September 12, 2012 10:28
Un-expand $Id$ in a git-svn repository, with some special powers
#!/bin/sh
# The problem:
#
# You have a clean git-svn working copy and, for example, rsync the files from
# the production server into it in order to find out whether some files have
# been changed directly on the server, without committing.
#
# However, the files on the production server possibly have $Id$ expanded, and
# now you're seeing a _lot_ of changed files which contain no differences except
@scy
scy / _edit.html.erb
Created September 11, 2011 13:41
Initializing a jQuery UI autocomplete with data from a Rails array
<script type="text/javascript">
// Trying to help @gedankenstuecke here. A bit hard because I don’t speak Rails (neither Ruby) and can’t try live what the output looks like.
$(function () {
$("#<%=p.object.phenotype_id.to_json%>").autocomplete({
source: <%=Phenotype.find_by_id(p.object.phenotype_id).known_phenotypes.to_json%>
});
});
</script>
@scy
scy / gist:944031
Created April 27, 2011 10:31
Automatically close netzpolitik.org tabs with Linus Neumann posts
" Add this to your .pentadactylrc:
autocmd -js DOMLoad netzpolitik.org if (doc.querySelectorAll('body.single-post .entry-meta a[href="http://www.netzpolitik.org/author/linus/"]').length) { content.window.close(); }