Skip to content

Instantly share code, notes, and snippets.

DanBradbury / 0_reuse_code.js
Created Sep 2, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
DanBradbury / spec_helper.rb
Last active Feb 12, 2016
Replacing simplecov
View spec_helper.rb
# add to the top of your spec_helper.rb
require 'yardcov'
# require files
# ...
Rspec.configure do |config|
# ...
config.after(:suite) do
View Resize Images with HTML5

This is old news by now for most but I had quite a bit of fun implementing it for myself and figured I'd share my code and some learnings that came along with it. The basic idea is to use canvas to render an uploaded image and then utilize the toDataURL method on canvas to retrieve a Base64 encoded version of the image. In the example included here we will just direct link to the newly scaled image but you could imagine that we kick off an ajax request and actually process the image (in PHP base64_decode FTW). Without any more tangential delay let's take a look at the code.

<input type="file" accept="image/*" id="imageFile" />
		<td>Width: <input type="text" id="width" value="200" style="width:30; margin-left: 20px;" /></td>
		<td>Height: <input type="text" id="height" value="200" style="width:30; margin-left: 20px;" /></td>
DanBradbury / blank_template.rb
Created Apr 25, 2015
Ruby sprite template creator
View blank_template.rb
# brew install imagemagick
# sudo gem install rmagick
# ruby blank_template.rb 200 200 50 50
# For more information on ImageMagick:
require 'rubygems'
require 'rmagick'
if ARGV.length != 4
DanBradbury / vimrc
Last active Aug 29, 2015
minmal vimrc
View vimrc
" Mandatory Vim Config (passed down from da masta..)
set nocompatible " be iMproved, required
filetype off " required
filetype plugin indent on
filetype plugin on
autocmd filetype c,asm,python setlocal shiftwidth=4 tabstop=4 softtabstop=4
set hidden " don't unload buffer when switching away
set modeline " allow per-file settings via modeline
DanBradbury /
Last active Aug 29, 2015
Rebase -i without fear

Do this in your own branches and not on master

~/Documents/Invoca/web on ⭠ 81/eb/STORY-2324_add_failover_node_ui ⌚ 17:28:16
$ git rebase -i ac28fc8~1                                                                                                                  
# will open up your configd editor of choice and you will be presented with a menu.

DanBradbury / gist:8fb221815161ef6b8286
Last active Aug 29, 2015
Automatic Slack Emoticons
View gist:8fb221815161ef6b8286
# USAGE: ruby emote.rb "fingers crossed" & roll the dice!
1require 'rubygems'
require 'google-search'
require 'ImageResize'
raise "query gone wrong" if !ARGV[0]
puts ARGV[0]
options_found = false
image_count = 0
View .vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" " let Vundle manage Vundle, required
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'tpope/vim-dispatch'
Plugin 'neilagabriel/vim-geeknote'
Plugin 'vim-scripts/TeTrIs.vim'

Pegasus Route


10/28/14 09:09:23.718 INFO Started GET "/pegasus/signup" for at 2014-10-28 09:09:23 -0700
10/28/14 09:09:23.751 INFO Processing by Pegasus::SignupController#index as HTML
10/28/14 09:09:23.753 DEBUG   OrganizationMembership Load (0.2ms) rows: 1  SELECT `organization_memberships`.* FROM `organization_memberships` WHERE `organization_memberships`.`id` = 57 LIMIT 1
10/28/14 09:09:23.760 INFO   Rendered pegasus/views/pegasus/signup/index.html.slim within pegasus/layouts/setup (2.1ms)
10/28/14 09:09:23.768 DEBUG   User Load (0.2ms) rows: 1  SELECT `users`.* FROM `users` WHERE `users`.`id` = 64 LIMIT 1
10/28/14 09:09:23.770 DEBUG   Network Load (0.3ms) rows: 0  SELECT `networks`.* FROM `networks` WHERE `networks`.`vanity_domain` IN ('.localhost') LIMIT 1