This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model style guide | |
class ModelX < ActiveRecord::Base | |
# 1. include mixins here | |
include BT::Token | |
# 2. constants | |
Timeout = 1.day | |
Status = OpenStruct.new(active: 0, disabled: -1).freeze | |
# 3. associations | |
# 3a. belongs_to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// manipulating values and attributes | |
$("div.foo").html(); // getter | |
$("div.foo").html("<h1>Hello World</h1>"); // setter | |
$("div.foo").text(); // getter, strips html | |
$("div.foo").text("hello world"); // setter | |
$("a.foo").attr("class"); // getter | |
$("a.foo").attr("href", "foo.html"); // setter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StringBuilder sb = new StringBuilder(); | |
String msg = sb.append("Error in: ").append(getClass().getSimpleName()).append(" -- ").append(e.getMessage()).toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String temp1 = "Error in: " + getClass().getSimpleName(); | |
String temp2 = temp1 + " -- "; | |
String msg = temp2 + e.getMessage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String msg = "Error in: " + getClass().getSimpleName() + " -- " + e.getMessage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bluetornadosf.microbench; | |
import java.util.HashMap; | |
import org.apache.commons.lang3.RandomStringUtils; | |
import com.google.caliper.Runner; | |
import com.google.caliper.SimpleBenchmark; | |
public class StringConcat extends SimpleBenchmark { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import org.apache.commons.lang3.RandomStringUtils; | |
import com.google.caliper.Runner; | |
import com.google.caliper.SimpleBenchmark; | |
public class StringConcat extends SimpleBenchmark { | |
private final static int CONCATENATIONS = 5; |