Skip to content

Instantly share code, notes, and snippets.

@austinhappel
austinhappel / cross-origin-images-with-canvas-and-toDataUrl.md
Created April 16, 2013 17:53
You're creating a `<canvas>` app and you're pulling images from external sources (e.g. http://notyourdomain.com/image/foo.jpg) and you want to create a bitmap of the new image via the canvas **toDataUrl**. You will get a **DOM security error 18** most likely. Here is a workaround.

Cross origin images with canvas and toDataUrl()

Problem:

You're creating a <canvas> app and you're pulling images from external sources (e.g. http://notyourdomain.com/image/foo.jpg) and you want to create a bitmap of the new image via the canvas toDataUrl. You will get a DOM security error 18 most likely.

Solution:

You must have control over what headers the image source sends.

png optimization and filesize comparison

4 pngs were created, each 1000x1000 pixels in dimension 1 png, 80x80 pixels in dimension. It uses the same image as the one used in png-transparent-tinyimage.png

Images can be found here: https://dl.dropbox.com/u/416403/png-test/png-test.zip

  • png-image.png
    • full size photo
  • png-one-color.png
@austinhappel
austinhappel / remove_svn.py
Last active July 12, 2016 14:41
A few different ways to delete all .svn files from a git repository's history.
#!/bin/python
# USAGE:
# 1) cd /path/to/git/repository
# 2) execute the script with: `python /path/to/remove_svn.py`
# NOTE: By default this code does a dry-run. To actually delete files from history, remove the
# "n" flag from the 'git rm -rfn' around line 20.
import subprocess
p = subprocess.Popen(['find', '.', '-name', '*.svn'], stdout=subprocess.PIPE)
@austinhappel
austinhappel / installing_npm_locally.md
Last active December 11, 2015 16:58
Installing NPM (node package manager) into your home folder. For mac/*nix.

Installing NPM locally (to ~/local instead of /usr/local)

Install npm into ~/local instead of usr/local:

`curl https://npmjs.org/install.sh | npm_config_prefix=~/local sh`

Add this to your ~/.npmrc file:

prefix = ~/local
@austinhappel
austinhappel / app.js
Last active December 10, 2015 18:58
Example bbb build contents re: https://github.com/tbranyen/backbone-boilerplate/issues/185. See readme for more information.
define([
"modules/testing",
"backbone.layoutmanager"
], function() {
// Provide a global location to place configuration settings and module
// creation.
var app = {
// The root path to run the application.
root: "/"
@austinhappel
austinhappel / ssh-pubkey-commands.md
Created December 12, 2012 04:45
Simple commands for managing ssh keys on servers.

Overview

This is a basic walk through of how to generate an ssh key and how to set it up on a server so you can log in without having to type your password every time you want to log in.

Steps

  1. Generate ssh key
  2. Add your key to the authorized_keys file on your server.
@austinhappel
austinhappel / Monokai-AH.tmTheme
Created June 6, 2012 05:13
Sublime Text 2 Mononkai theme that supports MarkDown
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>