Skip to content

Instantly share code, notes, and snippets.

View robert-claypool's full-sized avatar
💥
Breaking Things

Robert Claypool robert-claypool

💥
Breaking Things
View GitHub Profile
@robert-claypool
robert-claypool / web.config
Created November 13, 2015 03:28
IIS configuration for HTTP to HTTPS redirects behind an AWS Electric Load Balancer; IIS URL Rewrite must be installed.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTPS rewrite behind AWS Electric Load Balancer rule" enabled="true" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" />
</conditions>
@robert-claypool
robert-claypool / us-states-and-territoties.csv
Created November 11, 2015 19:47
States and Territories of the United States
ID State_FIPS State_Name State_Postal
0 08 Colorado CO
1 48 Texas TX
2 31 Nebraska NE
3 56 Wyoming WY
4 06 California CA
5 04 Arizona AZ
6 32 Nevada NV
7 27 Minnesota MN
8 28 Mississippi MS
@robert-claypool
robert-claypool / xy.truth
Last active March 29, 2023 11:53
Longitude is X, Latitude is Y
Longitude is X,
Latitude is Y.
That is all.
@robert-claypool
robert-claypool / putty-ssh-to-amazon-linux.md
Created August 3, 2015 04:55
Troubleshooting PuTTY SSH to an Amazon Linux instance in a VPC

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectingPuTTY

  • Check the instance security group rules. Allow incoming SSH, port 22.
  • Are DNS resolution & hostnames enabled for the VPC?
  • Does the VPC have an Internet gateway?
  • Check the route table for the VPC subnet. Add 0.0.0.0/0 --> Internet gateway
  • Check the network access control list (ACL) for the subnet. Allow incoming SSH, port 22.
  • Use the right private key, duh. Look it up under the instance details, https://console.aws.amazon.com/ec2/v2/home

Login as the right user:

@robert-claypool
robert-claypool / app_offline.htm
Created July 21, 2015 20:11
A simple "app offline" template for ASP.NET
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Offline</title>
</head>
<body style="margin:3em;font-family:sans-serif">
<h2>Offline</h2>
<p>This site is offline for maintenance.</p>
<!--
@robert-claypool
robert-claypool / notes-on-Vim.md
Last active January 15, 2016 07:12
My notes on Vim

My notes on Vim

  • Where is this Vim installed? Within Vim, run :echo $VIM
  • The home directory is $HOME. Within Vim, enter :echo $HOME or :echo ~
  • A history of Vim commands is in $HOME/_viminfo. Within Vim, enter : and then and to cycle through history
  • :scriptnames lists files that Vim loaded for you, including your .vimrc file
  • .vimrc is not created for you by most installations. Create one and save it in $HOME
  • To edit your configuration in Vim, enter :e $HOME/.vimrc or :e ~/.vimrc (tilde is an alias of HOME)
  • The Vim installed as part of msysgit does not have syntax files for most languages. To fix this, install Vim for Windows (gvim) and copy syntax files over from one installation to the other, e.g. ~\Program Files (x86)\Vim\vim74\syntax -- to --> ~\Program Files (x86)\Git\share\vim\vim74\syntax. Another option is to go into ~\Program Files (x86)\Git\bin\ and edit the vim and vi files to run your gvim installation of Vim instead.
  • Git for Windows (msysgit
@robert-claypool
robert-claypool / dd2webmercator.py
Last active September 27, 2022 16:02
Convert bounding box values from decimal degrees to Web Mercator (Auxiliary Sphere) EPSG:3857
# This script converts bounding box values from decimal degrees to
# WGS 1984 Web Mercator (Auxiliary Sphere) EPSG:3857. Note that Web Mercator
# was originally assigned wkid 102100, but was later changed to 3857.
# See http://resources.arcgis.com/en/help/rest/apiref/geometry.html
# Arguments and Output
# With flags, arguments can be given in any order, but the output will always
# be ordered like a GeoJSON bbox: "xmin, ymin, xmax, ymax". In both the GeoJSON and
# Esri JSON specs, a bounding box (or envelope) is defined with the lowest
# values for all axes followed by the highest values, e.g. "xmin, ymin, xmax, ymax".
@robert-claypool
robert-claypool / file-size-in-bytes.py
Last active June 13, 2018 03:11
File size calculation in Python
import os
print os.path.getsize("c:\\temp\\my.file") # returns the size in bytes
@robert-claypool
robert-claypool / sha1-digest-calculation.py
Last active August 23, 2020 21:28
SHA1 digest calculation using Python's hashlib
import hashlib
print hashlib.sha1(open("c:\\temp\\my.file", "rb").read()).hexdigest()
@robert-claypool
robert-claypool / ssh-keys-management-advice
Last active August 29, 2015 14:23
SSH keys management advice
Use separate private keys *per origin* (e.g. one from your work computer and a separate one for your personal laptop).
The same is not true of destinations: One private key on your personal laptop can serve to access multiple destinations;
if that key is compromised, all other private keys stored on in the same directory will surely be compromised as well.
-- http://superuser.com/a/189485/13481