Skip to content

Instantly share code, notes, and snippets.

Max Mitchell mazuhl

View GitHub Profile
@mazuhl
mazuhl / odd-even.sh
Last active Oct 21, 2015
Command line bash functions to list odd/even lines form input file
View odd-even.sh
# usage: odd numbers.txt
function odd() {
# print odd lines from file
awk 'NR%2==1 {print}' $1
}
function even() {
# print even lines from file
awk 'NR%2==0 {print}' $1
@mazuhl
mazuhl / pageres-mogrify.sh
Last active Feb 9, 2016
Get screenshots and resize/crop them
View pageres-mogrify.sh
pageres 1024x768 < urls.txt ; mogrify -resize 474 -crop 474x501+0+0 *.png
# Go get screenshots from list in clipboard
# Once that's done, resize all the images
# and crop them
# And then optimise them: /Applications/ImageOptim.app/Contents/MacOS/ImageOptim *.png
@mazuhl
mazuhl / Code.gs
Last active Aug 29, 2015
Get MODx version number from GitHub Master branch and paste into Google Spreadsheet
View Code.gs
function myFunction() {
var response = UrlFetchApp.fetch("http://www.example.com/get-modx-latest-version.php");
SpreadsheetApp.getActiveSheet().getRange('A1').setValue(response.getContentText());
}
@mazuhl
mazuhl / check-url-status.rb
Created May 12, 2014
Check URL status from input file list
View check-url-status.rb
File.foreach('URLS.txt') { |l|
system("curl -sL -w '%{http_code} %{url_effective}\\n' '#{l.chomp}' -o /dev/null")
}
@mazuhl
mazuhl / gist:9366311
Last active Aug 29, 2015
Javascript - modified scoping example from p. 36 of Javascript: The Good Parts
View gist:9366311
var foo = function() {
var a = 3, b = 5;
console.log("a: " + a + ", b: " + b);
if (typeof c === "undefined") { console.log("c is undefined"); }
console.log("---");
var bar = function() {
var b = 7, c = 11;
@mazuhl
mazuhl / url-grabber.rb
Last active Dec 23, 2015
Scan website and save all URLs to text file
View url-grabber.rb
require 'rubygems'
require 'spidr'
links = []
wesite = "http://www.website.com"
puts "Scanning #{website} for links"
puts ""
f = File.open("urls.txt","w");
@mazuhl
mazuhl / bookmarklet
Last active Dec 23, 2015
Bookmarklet to give you a simple browser-based text editor
View bookmarklet
data:text/html,%20%3Ctitle%3EText%20Editor%3C/title%3E%3Cbody%20contenteditable%20style=%22font-size:2rem;line-height:1.4;max-width:60rem;%20font-family:%20Consolas;%20margin:0%20auto;padding:4rem;%22%3E
@mazuhl
mazuhl / gist:3946402
Created Oct 24, 2012
Diff all files in a folder
View gist:3946402
diff -rq folder1 folder2
# show summary of differences
diff -r folder1 folder2
# show full differences
@mazuhl
mazuhl / gist:3097044
Created Jul 12, 2012
Regex to find line without an @ sign
@mazuhl
mazuhl / gist:3096899
Created Jul 12, 2012
Use ImageMagick to identify image compression level
View gist:3096899
identify -verbose filename.jpg | grep "Quality"
You can’t perform that action at this time.