Skip to content

Instantly share code, notes, and snippets.

@vicramon
vicramon / twitter_edit_code.rb
Last active September 2, 2020 19:52
I wrote the code for you Twitter!
class TweetsController < ApplicationController
def update
tweet = Tweet.find(tweet_params[:id])
if tweet.editable_by?(current_user)
tweet.update!(body: tweet_params[:body])
end
end
private
@vicramon
vicramon / projections.json
Created July 7, 2014 13:41
Javascript Vim Projections for Ember JS
{
"app/assets/javascripts/router.js": {
"command": "jini"
},
"app/controllers/api/v1/*_controller.rb": {
"command": "apicontroller",
"alternate": "spec/controllers/api/v1/%s_controller_spec.rb",
"template": "class Api::V1::%SController < ApplicationController\n respond_to :json\nend"
},
"app/assets/javascripts/models/*.js": {
@vicramon
vicramon / application.css
Created June 6, 2014 18:20
Stylesheet for Vic Ramon's Ember Tutorial
@import url(http://fonts.googleapis.com/css?family=Roboto:400,700,300,400italic);
@import url(http://fonts.googleapis.com/css?family=Maven+Pro:400,500,700);
ul, ol {
list-style: none;
}
h1, h2, h3, h4, h5, h6, pre, code {
font-size: 1em;
}
@vicramon
vicramon / mux-init
Last active January 4, 2016 15:39
Initialize tmux with rails console and server
# ~/hashrocket/hr/share/mux-init
tmux \
split-window -h -t $name \; \
split-window -d -h -t $name \; \
select-layout -t $name main-horizontal &>/dev/null \; \
new-window -a -d -n server -t $name:0 \; \
split-window -d -h -t $name:server \; \
send-keys -t $name:0.2 'vim .' C-m \; \
send-keys -t $name:1.1 'rails s' C-m \; \
@vicramon
vicramon / gist:7696084
Created November 28, 2013 18:08
Vimium Detection
// Detect the Vimium Chrome extension by Evan Hahn (evanhahn.com)
;(function(doc) {
doc.hasVimium = function() {
return doc.getElementsByClassName('vimiumReset').length > 0;
};
doc.onDetectVimium = function(callback, scope) {
@vicramon
vicramon / projections
Last active May 26, 2016 09:58
CoffeeScript Vim Projections for Ember JS
{
"app/assets/javascripts/router.js.coffee": {
"command": "jini"
},
"app/controllers/api/v1/*_controller.rb": {
"command": "apicontroller",
"alternate": "spec/controllers/api/v1/%s_controller_spec.rb",
"template": "class Api::V1::%SController < ApplicationController\n respond_to :json\nend"
},
"app/assets/javascripts/models/*.js.coffee": {
@vicramon
vicramon / .vimrc
Created April 29, 2013 16:12
Handy vimrc options
set shiftwidth=2
set number
colorscheme molokai
set ignorecase
if version >= 700
au InsertEnter * hi StatusLine ctermfg=28 ctermbg=white