Skip to content

Instantly share code, notes, and snippets.

@mrowe
mrowe / gist:e7ef918461a57e66a7ec
Created August 21, 2014 22:26
Installing npm on a new Ubuntu box
vagrant@ubuntu-14:~$ sudo apt-get install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
build-essential g++ g++-4.8 gyp javascript-common libc-ares-dev libc-ares2 libjs-node-uuid libssl-dev libssl-doc libstdc++-4.8-dev
libv8-3.14-dev libv8-3.14.5 node-abbrev node-ansi node-archy node-async node-block-stream node-combined-stream node-cookie-jar
node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs
node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json node-request
@mrowe
mrowe / muttrc
Created October 9, 2014 03:39
Viewing GitHub pull request diffs
folder-hook REA 'macro pager \Cd '<pipe-message>~/dotfiles/mutt/view_git_patch.sh^M'
@mrowe
mrowe / robots.java
Created January 8, 2015 04:05
Toy Robot in Java 8
package com.mikerowecode.robot8;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.function.Function;
public class Robots {
public static void main(String[] args) {
Robot robot = new Robot(-1, -1, Direction.WEST);
Scanner in = new Scanner(System.in);
@mrowe
mrowe / robots.java
Last active August 29, 2015 14:13
Toy Robot in Java 7
package com.mikerowecode.robot;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Robots {
public static void main(String[] args) {
Robot robot = new Robot(-1, -1, Direction.WEST);
@mrowe
mrowe / unused-security-groups.rb
Last active August 29, 2015 14:14
Find unused security groups
#!/usr/bin/env ruby
require 'aws-sdk'
ec2 = AWS::EC2.new
elb = AWS::ELB.new
rds = AWS::RDS.new.client # shrug
security_groups = ec2.security_groups.map { |sg| sg.id }.sort
instance_sgs = ec2.instances.map { |i| i.security_groups.map { |sg| sg.id } }.flatten.sort
;;
;; Read a CSV file and look up the product ids it contains in a
;; database. Report all the products in the CSV that do not exist in
;; the database.
;;
;; Usage: $0 <path-to-csv-file>
;;
(import 'java.io.FileReader 'au.com.bytecode.opencsv.CSVReader)
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
require 'yaml'
environment = YAML.load_file(".rea-env.yml")
connection_details = {
:provider => "AWS",
:endpoint => environment["ec2"]["url"],
@mrowe
mrowe / gist:1494680
Created December 18, 2011 22:31
iiNet DNS problems
$ dig PTR 169.41.170.124.in-addr.arpa.
; <<>> DiG 9.7.3-P3 <<>> PTR 169.41.170.124.in-addr.arpa.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43719
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;169.41.170.124.in-addr.arpa. IN PTR
@mrowe
mrowe / gist:1927654
Created February 27, 2012 22:43
a simple gradient
background: #f1dec2;
background: url("edge.png") repeat-x; /* fallback */
background: url("edge.png") repeat-x, -webkit-gradient(linear, left top, left bottom, from(#ebc17f), to(#f1dec2)); /* Saf4+, Chrome */
background: url("edge.png") repeat-x, -webkit-linear-gradient(left, #ebc17f, #f1dec1); /* Chrome 10+, Saf5.1+ */
background: url("edge.png") repeat-x, -moz-linear-gradient(left, #ebc17f, #f1dec1); /* FF3.6+ */
background: url("edge.png") repeat-x, -ms-linear-gradient(left, #ebc17f, #f1dec1); /* IE10 */
background: url("edge.png") repeat-x, -o-linear-gradient(left, #ebc17f, #f1dec1); /* Opera 11.10+ */
background: url("edge.png") repeat-x, linear-gradient(left, #ebc17f, #f1dec1); /* W3C */
@mrowe
mrowe / anything-git-project-files.el
Created August 2, 2012 01:17
Anything source to search files in current GIT project (http://www.emacswiki.org/emacs/AnythingSources#toc64)
(defvar anything-c-source-git-project-files-cache nil "(path signature cached-buffer)")
(defvar anything-c-source-git-project-files
'((name . "Files from Current GIT Project")
(init . (lambda ()
(let* ((git-top-dir (magit-get-top-dir (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory)))
(top-dir (if git-top-dir
(file-truename git-top-dir)
default-directory))