Skip to content

Instantly share code, notes, and snippets.

View changemewtf's full-sized avatar

Max C changemewtf

View GitHub Profile
@changemewtf
changemewtf / log_bash.sh
Last active August 29, 2015 14:03
source this script to log all of your shell output to a file... it'll make vim mad because output is not to terminal though
# Redirect stdout ( > ) into a named pipe ( >() ) running "tee"
exec > >(tee logfile.txt)
# Without this, only stdout would be captured - i.e. your
# log file would not contain any error messages.
exec 2>&1
function Animal(name) {
this.name = name;
}
Animal.prototype = {
eat: function() { return this.name + " consumes vital sustenance."; }
};
function Dog(name, breed) {
this.name = name;
class Person
class << self
attr_accessor :personalities
# Normally we would do this with 'def self.whatever', but because
# of the class << self idiom above, we're already in the scope of
# the Person class
def whatever
"Hey man"
@changemewtf
changemewtf / gist:255cbac73ba21d93c43e
Created May 14, 2014 21:05
How to improve the Rails guides

The Rails Guides are static HTML, so it's incredibly easy to generate and preview them locally.

To get started:

git clone [email protected]:rails/rails.git
cd rails
bundle install --without db
cd guides
bundle exec rake guides:generate:html
mcantor@cottlebook ~/src/ext/rails/guides (master): bundle exec redcarpet --version
Redcarpet 3.1.2
mcantor@cottlebook ~/src/ext/rails/guides (master): bundle exec rake guides:generate:html
/Users/mcantor/.rbenv/versions/2.1.0/bin/ruby rails_guides.rb
Generating active_model_basics.md as active_model_basics.html
/Users/mcantor/src/ext/rails/guides/rails_guides/markdown/renderer.rb:18:in `header': wrong number of arguments (2 for 3) (ArgumentError)
from /Users/mcantor/src/ext/rails/guides/rails_guides/markdown.rb:76:in `render'
from /Users/mcantor/src/ext/rails/guides/rails_guides/markdown.rb:76:in `generate_header'
from /Users/mcantor/src/ext/rails/guides/rails_guides/markdown.rb:20:in `render'
### ~/.tmux.conf ###
set-option -g default-command "tmux rename-window bash; reattach-to-user-namespace -l bash"
### ~/bin/tmux-project ###
#!/bin/bash
export SESSION=$(basename $PWD)
# set window title
echo -ne "\033]0;${SESSION}\007"
@changemewtf
changemewtf / backboneFetch.js
Created May 8, 2014 19:03
Some pseudocode representing part of what Backbone.Collection.fetch() does.
Backbone.Collection = {
fetch: function() {
var requestUrl;
if (isAFunction(this.url)) {
requestUrl = this.url();
} else {
requestUrl = this.url;
}
<!doctype html>
<html lang="en">
<head>
<title></title>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
<script type="text/javascript">
var postDefaults = {
def fake_method(whateveR)
puts "lol"
end
this is ridicalous