Skip to content

Instantly share code, notes, and snippets.

@mazuhl
mazuhl / odd-even.sh
Last active October 21, 2015 13:42
Command line bash functions to list odd/even lines form input file
# 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 February 9, 2016 22:30
Get screenshots and resize/crop them
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 August 29, 2015 14:02
Get MODx version number from GitHub Master branch and paste into Google Spreadsheet
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 07:59
Check URL status from input file list
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 August 29, 2015 13:57
Javascript - modified scoping example from p. 36 of Javascript: The Good Parts
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 December 23, 2015 23:39
Scan website and save all URLs to text file
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 November 10, 2021 16:37
Bookmarklet to give you a simple browser-based text editor
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 October 24, 2012 14:31
Diff all files in a folder
diff -rq folder1 folder2
# show summary of differences
diff -r folder1 folder2
# show full differences
@mazuhl
mazuhl / gist:3097044
Created July 12, 2012 09:38
Regex to find line without an @ sign
^[^@]*$
@mazuhl
mazuhl / gist:3096899
Created July 12, 2012 09:08
Use ImageMagick to identify image compression level
identify -verbose filename.jpg | grep "Quality"