Skip to content

Instantly share code, notes, and snippets.

@danmactough
danmactough / localport.sh
Created December 17, 2013 15:21
Block port except via localhost. Optionally, pass `-D` as second argument to remove the block.
#/bin/bash
PORT=$1
ACTION=${2:-"-A"}
iptables $ACTION INPUT -p tcp -s localhost --dport $PORT -j ACCEPT
iptables $ACTION INPUT -p tcp --dport $PORT -j DROP
@danmactough
danmactough / comment.md
Created December 31, 2013 00:22
Isaac's description of process.nextTick vs. setImmediate

I agree the point you’re making here, 100%. However, a slight correction about Node’s APIs.

First of all, process.nextTick is actually first in, first out. Proof:

$ node -e 'process.nextTick(console.log.bind(console, 1)); process.nextTick(console.log.bind(console, 2))'
1
2
@danmactough
danmactough / ip-addresses
Last active January 3, 2016 22:39
ThrustVPS hacked VPS postmortem. These are the unique, failed login attempts *AFTER* the hacker reinstalled the OS. Also, the running processes (note dropbear).
Count Address
----- -------
12856 117.239.9.229
390 117.21.127.215
301 216.126.110.116
169 1.93.37.231
136 119.90.37.14
80 115.68.22.162
56 bb220-255-26-152
50 60-199-196-144.s

On your EC2 server:

sudo apt-get update
sudo apt-get install ubuntu-desktop

Reboot your server

On your EC2 server:

@danmactough
danmactough / .bash_aliases
Created February 26, 2014 18:23
some git aliases
alias psm='ps axo pid,pcpu,pmem,rss,vsz,command'
# ^^ Not git, but awesome
alias ga="git add"
alias gb="git branch"
alias gba="git branch -a"
alias gbd="git branch -D"
alias gca="git commit -a -m"

Keybase proof

I hereby claim:

  • I am danmactough on github.
  • I am danmactough (https://keybase.io/danmactough) on keybase.
  • I have a public key whose fingerprint is 30E1 D7AF E3AE E6FF BDD3 FAC5 EC34 D42B 9B94 EEF8

To claim this, I am signing this object:

Install Dnsmasq on OSX

This will allow any url having the non-existant TLD .dev to resolve to your locale machine.

Install dnsmasq and run as a service

$ brew update
var vm = require('vm');
var boss = 'Mr. Trump'
, condition = 'bald';
var script = [
'boss = name;',
'condition = type;',
'result = boss + " is " + condition;'
].join('\n');
@danmactough
danmactough / flushdns
Created September 9, 2014 04:25
Supposedly, this will flush your dns cache on Mac OS X Mountain Lion and greater
#!/bin/bash
if [[ $OSTYPE == darwin* ]]; then
sudo killall -HUP mDNSResponder
fi

How to enable multiple stars in Gmail

What?

Gmail has a setting to enable multiple types of stars. Not "give this email 2 stars and this other email 1 star," but "give this email a gold star and this other email a blue star." YMMV as to whether this is helpful.

How?

  1. Open up your Gmail settings. Under the "General" tab, find the "Stars" section and click on "4 stars".