Skip to content

Instantly share code, notes, and snippets.

View benzittlau's full-sized avatar

Ben Zittlau benzittlau

View GitHub Profile
@benzittlau
benzittlau / gist:e628488f7c5e6ee48d61
Created September 13, 2014 19:59
Vim Writing Settings
set formatoptions+=a # auto reformat paragraphs
set formatoptions+=t # enable auto line wraping
set tw=100
@benzittlau
benzittlau / gist:37163482be834ea995f0
Created September 15, 2014 18:08
Copy file name to clipboard in vim
:let @* = @%
@benzittlau
benzittlau / .vimrc.talk
Created November 16, 2014 21:59
Basic .vimrc example
" Highlight searches
set hlsearch
" Case sensitivity
set ignorecase
set smartcase
" Automatic Indenting
set autoindent
@benzittlau
benzittlau / hard_click.js
Created May 29, 2015 21:33
Programatically Accept Suggestions in Google Docs
function hardClick(node) {
triggerMouseEvent (node, "mouseover");
triggerMouseEvent (node, "mousedown");
triggerMouseEvent (node, "mouseup");
triggerMouseEvent (node, "click");
}
function triggerMouseEvent (node, eventType) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent (eventType, true, true);
@benzittlau
benzittlau / .gitignore
Created April 7, 2011 20:38
My default .gitignore
.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.DS_Store
.rvmrc*
@benzittlau
benzittlau / gist:909162
Created April 8, 2011 02:22
Create a new rails project with Jquery/Mongoid
rails new APP_NAME -m http://railswizard.org/48c15b50eff428bc421f.rb
rails generate mongoid:config
rails generate jquery:install
@benzittlau
benzittlau / application.html.erb
Created April 8, 2011 03:02
Sample application layout file from a typical rails projecst
<!DOCTYPE html>
<html>
<head>
<title>Spike</title>
<%= csrf_meta_tag %>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %>
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %>
@benzittlau
benzittlau / Mongoid Hierarchy Excerpt
Created May 4, 2011 21:45
Why you have to be careful using versions in Mongoid
Mongoid/Hierarchy
# Get all child +Documents+ to this +Document+, going n levels deep if
# necessary. This is used when calling update persistence operations from
# the root document, where changes in the entire tree need to be
# determined. Note that persistence from the embedded documents will
# always be preferred, since they are optimized calls... This operation
# can get expensive in domains with large hierarchies.
#
# @example Get all the document's children.
@benzittlau
benzittlau / ORM Option Generate Migration
Created May 11, 2011 18:21
Explicitly specify which ORM to use when generating a migration in Rails
macbook:bs_portal Ben$ rails g migration add_translations_table --orm=active_record
@benzittlau
benzittlau / Button.css
Created May 16, 2011 04:13
Good button css
/*http://www.zurb.com/playground/google-buttons*/
button.g-button, a.g-button, input[type=submit].g-button {
padding: 6px 10px;
-webkit-border-radius: 2px 2px;
border: solid 1px rgb(153, 153, 153);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(255, 255, 255)), to(rgb(221, 221, 221)));
color: #333;
text-decoration: none;
cursor: pointer;
display: inline-block;