Skip to content

Instantly share code, notes, and snippets.

@lkptrzk
lkptrzk / 404-check.sh
Last active April 29, 2022 22:18
Script to test for 404s
#!/bin/sh
# 404-check.sh - Script to test for 404s
# author: lkptrzk
# Usage:
# Assuming a file named 'input' with one URL per line
# the following command will output which files were 404s:
# cat input | xargs 404-check.sh
@lkptrzk
lkptrzk / get-http-status-codes.sh
Created August 24, 2012 14:15
Gets HTTP status codes for a list of URLs
#!/bin/sh
# get-http-status-codes.sh - Gets HTTP status codes for a list of URLs
# Usage:
# Assuming a file named 'input' with one URL per line
# the following command will output the HTTP status code,
# a space, and the URL for each line of input
# cat input | xargs get-http-status-codes.sh
@lkptrzk
lkptrzk / start-database-research.sql
Created August 24, 2012 14:18
T-SQL script to generate pretty SELECTs to start researching an undocumented SQL Server database
/*
|| T-SQL script to generate pretty SELECTs to start researching an undocumented SQL Server database
*/
declare @crlf varchar(2);
set @crlf = CHAR(13); /* crlf is really CHAR(10)+CHAR(13) but doesn't print right in messages window */
declare @query_catalog nvarchar(50),
@query_schema nvarchar(50),
@query_table nvarchar(50),
@lkptrzk
lkptrzk / gist:3452103
Created August 24, 2012 15:39
Use number of characters to set textbox width
function setWidthInChars(selector, numChars) {
$('body').append('<div id="testwidth"><span>&nbsp;</span></div>');
var w = $('#testwidth span').width();
alert(w);
$('#testwidth').remove();
$(selector).css('width', (w * numChars + 1) + 'px'); /* +1 is for rounding problems */
}
@lkptrzk
lkptrzk / man.sh
Created September 6, 2012 15:16
`man` replacement for git bash on windows
#!/bin/sh
# man.sh - `man` replacement for git bash on windows
# Dependencies (outside of git bash):
# wget (http://users.ugent.be/~bpuype/wget/)
# TODO:
# use sed to remove <head> & tags, convert HTML entities
@lkptrzk
lkptrzk / binary-search.js
Created September 19, 2012 14:43
javascript binary search
function binary_search(arr, search_term, min, max) {
if (max < min) return -1;
var i = Math.floor((min + max) / 2),
curr_term = arr[i];
if (curr_term === search_term) {
return i;
} else if (curr_term < search_term) {
return binary_search(arr, search_term, min, i - 1);
} else if (curr_term > search_term) {
return binary_search(arr, search_term, i + 1, max);
@lkptrzk
lkptrzk / minimal-server.js
Created October 30, 2012 03:18
minimal nodejs server
var http = require('http'),
util = require('util'),
url = require('url');
var handlers = {};
handlers.homepage = function (request, response) {
response.writeHead(200, { 'Content-type': 'text/plain' });
response.write('homepage goes here.');
};
@lkptrzk
lkptrzk / gist:5462714
Created April 25, 2013 20:07
jQuery events
$._data($('#someid')[0]).events
@lkptrzk
lkptrzk / cuss.sh
Created October 5, 2013 06:30
cuss.sh
#!/bin/bash
COUNT=$1
EXPLETIVE=$2
yes $EXPLETIVE | tr -d '\n' | head -c $COUNT
@lkptrzk
lkptrzk / rando.sh
Last active December 24, 2015 17:39
rando.sh
#!/bin/bash
COUNT=$1
cat /dev/urandom | head -c $COUNT