Skip to content

Instantly share code, notes, and snippets.

@ismyrnow
ismyrnow / _README.md
Last active May 24, 2016 23:15
PhantomJS script for rendering a webpage to an image

Run with phantomjs rasterize.js URL FILENAME.

@ismyrnow
ismyrnow / backup_postgres.bat
Created May 18, 2016 15:34
Command for backing up a postgres database to a file
"C:\Program Files (x86)\pgAdmin III\1.18\pg_dump.exe" --host DBHOST --port 5432 --username "DBUSER" --format custom --blobs --verbose --file "OUTFILE.backup" "DBNAME"
@ismyrnow
ismyrnow / index.js
Last active April 11, 2016 16:08
Hello world web server written for Node.JS
var http = require('http');
var port = process.env.PORT || 3000;
var server = http.createServer(function(req, res) {
res.end('Hello, world!');
});
server.listen(port, function () {
console.log('Hello world web server running on port %s', port);
@ismyrnow
ismyrnow / directory_csv.bat
Created March 28, 2016 17:35
Create a csv from a directory of files
REM create a csv from a directory of files
forfiles /p "C:\myfolder" /s /m *.jpg /c "cmd /c if @isdir==FALSE echo @path,@file,@fsize" > myfolder_jpg.csv
@ismyrnow
ismyrnow / hackathon-resources.md
Created February 11, 2016 20:23
Resources for rapid prototype development or hackathons
@ismyrnow
ismyrnow / psql-copy.txt
Created February 1, 2016 18:05
Selective data migration between databases
# Open a database connection
psql -h myserver -U myuser mydatabase
# Use `\copy` to copy data to a local file, not one on the server.
\copy (select * from mytable where ...) to 'C:\output.copy`
# Copy the data into the new database
\copy mytable from 'C:\output.copy'
@ismyrnow
ismyrnow / query-multiple-dbs.bat
Created December 17, 2015 19:10
Query multiple postgres databases, outputting results as CSV
@echo off
for %%a in (DB1,DB2,DB3) do call psql -h DBHOST -c "SQL" -t -A -F , %%a DBUSER
@ismyrnow
ismyrnow / database_size.sql
Created December 16, 2015 19:27
Database sizes in postgres
select t1.datname AS db_name,
pg_size_pretty(pg_database_size(t1.datname)) as db_size
from pg_database t1
order by pg_database_size(t1.datname) desc;
-- credit to http://stackoverflow.com/a/18907188/192217
@ismyrnow
ismyrnow / docker-machine.cmd
Last active January 15, 2016 21:06
Instructions for using docker-machine on Windows
docker-machine start dev
# Make note of the IP address (typically 192.168.99.100)
docker-machine env dev --shell cmd
# Copy/paste commands
docker build -t ismyrnow/my-container:1.0.0 .
docker run -di -p 8080:8080 ismyrnow/my-container:1.0.0
# To access the shell of the container:
docker exec -it -u root *hash* bash
@ismyrnow
ismyrnow / README.md
Last active December 17, 2015 19:15
Node web server redirecting all requests

A Node.js web server, with zero dependencies, which redirects all requests to a URL provided at runtime.

Useful for redirecting Elastic Beanstalk apps to a new location. Just deploy this as a new version, then set the REDIRECT variable.

Run with node server http://google.com or set REDIRECT=http://google.com && node server