Skip to content

Instantly share code, notes, and snippets.

@smj10j
smj10j / installedPackagesPossiblyTouchingSSH.sh
Last active August 29, 2015 14:02
List all packages installed with apt-get that have anything to do with "ssh"
#!/bin/bash
dpkg-query --search ssh* | awk '{print $1}' | tr -d ':,' | sort -u | xargs -n 1 apt-cache search | sort -u
@smj10j
smj10j / downloadAirbnbListingImages.sh
Created June 1, 2014 14:04
Download all images of an Airbnb listing
#!/bin/bash
PROJECT_DIR=~/httrack/airbnb
LISTING_URL='https://www.airbnb.com/rooms/1300067?s=9Xmw'
brew install httrack
echo "Using httrack to download all images"
echo "Update cookies.txt within $PROJECT_DIR if login needed"
echo ""
@smj10j
smj10j / go-go-gadget-docker-on-osx
Last active August 29, 2015 14:05
One-stop Docker Install for OSX
set -e
echo "Get homebrew in order..."
if [[ -z $(which brew) ]]; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
else
brew update
brew upgrade
fi
# reversed and limited to last 100 rows
sudo awk '{print $8" "$5}' /mnt/log/nginx/www.extrabux.com.access_log | uniq -w 4 -c | grep -v " [1-5] " | tac | head -n 100
6 /password/reset [14/Nov/2014:01:27:53
6 /password/reset [14/Nov/2014:01:27:16
7 /password/reset [14/Nov/2014:01:27:02
6 /password/reset [14/Nov/2014:01:26:53
@smj10j
smj10j / Airbnb Availability Printed on DOM from JSON Response
Last active August 29, 2015 14:10
Airbnb Availability Printed on DOM from JSON Response
// Requires jQuery
// Running from https://www.airbnb.com/rooms/4469705 works
// JSFiddle example of installing as a bookmarklet: http://jsfiddle.net/smj10j/sjwko4bp/
var listingId = window.location.pathname.replace('/rooms/','');
var calData = {};
$.getJSON('https://www.airbnb.com/api/v1/listings/'+listingId+'/calendar?key=d306zoyjsyarp7ifhu67rjxn52tv0t20', function(data) {
calData = data.calendar;
@smj10j
smj10j / trello-get-oauth-url-wizard.sh
Last active August 29, 2015 14:10
Guided Wizard to Generate URL To Request Authorization from Trello Users
#!/bin/bash
#
# Used by and included in https://github.com/smj10j/git_notified_on_trello
#
echo -n "Press any key to open Trello. Log in if prompted, copy your developer API key, and return to this window."
read -e < /dev/tty
open https://trello.com/1/appKey/generate
@smj10j
smj10j / create-2gb-swap-on-ubuntu
Created December 7, 2014 07:07
Create a 2GB swap file on Ubuntu
#!/bin/bash
#
# https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880
#
install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
@smj10j
smj10j / find-error-occurences.sh
Created December 8, 2014 15:35
Bash one-liners to find first and last occurences of errors in server logs
# find the first occurrence of each Fatal error
grep "Fatal" combined | awk '{FS="(error: )|( in \/mnt)|( - \/mnt)"} {errors[$2]=$0} END {for(i in errors) print errors[i]}'
# find the last occurrence of each fatal error
grep "Fatal" <(tac combined) | awk '{FS="(error: )|( in \/mnt)|( - \/mnt)"} {errors[$2]=$0} END {for(i in errors) print errors[i]}'
# find the first occurence of each fatal error, sorted by date
grep "Fatal" combined | awk '{FS="(error: )|( in \/mnt)|( - \/mnt)"} {errors[$2]=$0} END {for(i in errors) print errors[i]}' | sort -k1 | egrep "^2014[^a-z]+ "
@smj10j
smj10j / Install-zsh-and-oh-my-zsh.sh
Last active August 29, 2015 14:12
Uses Homebrew to install zsh and Oh My Zsh plugins on OSX
#!/bin/bash
brew install zsh
curl -L http://install.ohmyz.sh | sh