Skip to content

Instantly share code, notes, and snippets.

View larzconwell's full-sized avatar

Larz Conwell larzconwell

View GitHub Profile
content_tag('input', 'Where would you like to go?', { data: {goTo: 'www.google.com'} })
=> <input value="Where would you like to go?" data-go-to="www.google.com" />
Desktop% ruby -v (~/Desktop)
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Desktop% cat benchmark_quotes.rb (~/Desktop)
require 'benchmark'
n = 1000000
Benchmark.bm do |x|
x.report('assign single') { n.times do; c = 'a string'; end }
x.report('assign double') { n.times do; c = "a string"; end }
x.report('assign interp') { n.times do; c = "a string #{'b string'}"; end }
If I use the hotkeys ctrl+alt+up/down/left/right then it always makes the keys stick.
The s key sticks, but if I press ctrl+s it fixes it.
The o key sticks and I can only fix that if I frantically press alt, ctrl or shift keys with the o key.
$the_cow = <<EOC;
$thoughts
$thoughts
/\\__/\\
/` '\\
=== 0 0 ===
\\ -- /
/ \\
/ \\
| |
<ul>
<% for (var p in params) { %>
<li><%= p + ': ' + params[p]; %></li>
<% } %>
</ul>
#!/bin/bash
PREFIX=${PREFIX-/usr/local}
NVM_DIR="$PREFIX/lib/nvm"
VERSIONS_DIR="$NVM_DIR/versions"
CURRENT_NVM="$NVM_DIR/current"
LOGPATH="/tmp/nvm.log"
# Exit with message
abort() {
<div class="hero-unit">
<h2>All <%= names.constructor.plural %></h2>
<%%- linkTo('Create a new <%= names.constructor.singular %>'), {controller: '<%= names.property.plural %>', action: 'add'}, {class: 'btn pull-right'}) %>
</div>
OUTPUT:
<div class="hero-unit">
<h2>All Users</h2>
<%- linkTo('Create a new User'), {controller: 'users', action: 'add'}, {class: 'btn pull-right'})
package main
import "fmt"
func swap(x, y, string) (string, string) {
return y, x
}
func main() {
a, b := swap("world", "Hello")
package main
import (
"fmt"
"time"
)
type MyError struct {
When time.Time
Type, Message string
package main
import (
"fmt"
"time"
"errors"
)
func run() (str string, err error) {
time := time.Now()