Skip to content

Instantly share code, notes, and snippets.

@stfnhh
stfnhh / prototypes.js
Last active December 20, 2015 09:19
Useful Prototypes
/* Arrays */
Array.prototype.each = function(callback) {
for (i=0; i < this.length; i++) {
callback(i, this[i])
}
}
Array.prototype.first = function() {
@stfnhh
stfnhh / Simple Server
Last active April 27, 2016 13:21
Creates a simple httpd server in your current directory
#!/bin/bash
P=5000;
if [ -n "$1" ]; then
P=$1
fi
ruby -run -e httpd . -p $P;
@stfnhh
stfnhh / template.html
Created May 5, 2014 14:55
Basic HTML File
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
@stfnhh
stfnhh / distance.sql
Created May 14, 2014 14:31
MySQL find distance from latitude and longitude
SELECT
`locations`.`id`
SQRT(
POW(69.1 * (
41.7600 - `locations`.`latitude`
), 2) +
POW(69.1 * (
`locations`.`longitude` - 70.0833) * COS(41.7600 / 57.3), 2)
) AS `distance`
FROM
@stfnhh
stfnhh / spider
Created August 15, 2014 14:30
simple bash http spider
#!/bin/bash
url=$1
if [[ $1 != *http:\/\/* ]]; then
url="http://$1"
fi
wget --spider -r -nv -nd -np $1 2>&1 | ack -o '(?<=URL:)\S+'
We can't make this file beautiful and searchable because it's too large.
zipcode,city,state
00501,Holtsville,NY
00544,Holtsville,NY
00601,Adjuntas,PR
00602,Aguada,PR
00603,Aguadilla,PR
00604,Aguadilla,PR
00605,Aguadilla,PR
00606,Maricao,PR
00610,Anasco,PR
@stfnhh
stfnhh / iam.sh
Created July 27, 2015 13:33
IAM SSL Upload
aws iam upload-server-certificate --server-certificate-name X --certificate-body file://cert.crt --private-key file://key.key --certificate-chain file://chain.crt --path /cloudfront/X/
@stfnhh
stfnhh / share.sh
Last active November 1, 2022 02:20
Command line interface for file.io
#!/bin/bash
WEEKS=0
ENCRYPTION=false
FILE=$1
usage() {
cat <<EOF
Usage: $0 FILE [options]
#!/bin/bash
# Takes one parameter: a remote git repository URL.
#
# This is the stuff this script does:
#
# 1. Clones the repository
# 2. Fetches all remote branches
# 3. Compresses the folder
# 4. Deletes the cloned folder.
#!/bin/bash
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $1