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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
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
module Mongoid | |
module CounterCache | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Use Case: | |
# | |
# keep a cached count of embedded collections in the parent collection(s) | |
# | |
# for example, if a Post embeds many Comments, and there have been 2 |
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
require 'rubygems' | |
require 'bundler' | |
Bundler.require | |
require './application' | |
namespace :assets do | |
desc 'compile assets' | |
task :compile => [:compile_js, :compile_css] do | |
end |
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
/** | |
* normalizeEvent | |
* | |
* Firefox does not implement offsetX, OffsetY, so we have to detect for this an | |
* manually calculate it ourselves using the pageX, pageY less the event | |
* target's left offset and right offset | |
* | |
* If using a browser that supports offsetX, OffsetY, just return the event, | |
* don't need to do anything | |
*/ |
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
library(ggplot2) | |
library(reshape2) | |
df <- data.frame(grp = 1:25, start = rnorm(25, 10, 5), end = rnorm(25, 5, 3)) | |
df$end_higher <- df$start < df$end | |
mdf <- melt(df, id.vars = c("grp", "end_higher")) | |
names(mdf) <- c("grp", "end_higher", "category", "value") | |
mdf$grp <- factor(mdf$grp) |
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
library(ggplot2) | |
library(reshape2) | |
# data setup | |
df <- data.frame(grp = 1:25, start = rnorm(25, 100, 10), end = rnorm(25, 10, 5)) | |
# ** plotting using base plot functions | |
par(mfrow = c(1, 1)) | |
rng <- range(df$start, df$end) | |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
options(repos = c(CRAN = "http://cran.rstudio.com")) | |
install.packages("ggplot2") | |
install.packages("dplyr") | |
require(ggplot2) | |
require(dplyr) | |
points <- 10000 | |
buckets <- 20 |
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
x = -10:0.1:10; | |
plot(x, 1 ./ (1 + e .^ -x)) |
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
for b in `git branch --merged | grep -v \*`; do git branch -D $b; done |
NewerOlder