I hereby claim:
- I am jeffreyiacono on github.
- I am jfi (https://keybase.io/jfi) on keybase.
- I have a public key whose fingerprint is 9313 2A1C 7607 9701 D3EF B96F 28F3 F2D8 4DE7 2229
To claim this, I am signing this object:
library(ISLR) | |
library(ggplot2) | |
library(caret) | |
data(Wage) | |
# remove logwag as predicting wage, so this would be a pretty good predictor :) | |
Wage <- subset(Wage, select = -c(logwage)) | |
# cross-validation data |
library(UsingR) | |
library(ggplot2) | |
library(reshape) | |
data(galton) | |
freqData <- as.data.frame(table(galton$child, galton$parent)) | |
names(freqData) <- c("child", "parent", "freq") | |
freqData$child <- as.numeric(as.character(freqData$child)) | |
freqData$parent <- as.numeric(as.character(freqData$parent)) |
def something a, b, &block | |
sum = a + b | |
another_private_thing = "only something can see this" | |
puts "I'm in something, executing code." | |
puts "I added #{a} + #{b} and got #{sum}" | |
puts "and I can access my local vars: another_private_thing = #{another_private_thing}" | |
yield sum, another_private_thing |
d <- rnorm(1000) | |
df <- data.frame(x = seq(1, length(d), by = 1), y = d) | |
df$zscore <- (df$y - mean(df$y, na.rm = TRUE)) / sd(df$y, na.rm = TRUE) | |
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95)) | |
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95)) + scale_color_manual(values = c("FALSE" = "grey", "TRUE" = "red")) |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/ruby | |
# get file name arg from command line | |
File.open(ARGV[0], 'r') do | f | | |
# read the first line containing the integer | |
(1..f.readline.strip.to_i).each do | i | | |
# div by 3? | |
if ( i % 3 ) == 0 then | |
# and by 5? | |
if ( i % 5 ) == 0 then |
#! /usr/bin/ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
DIRECTORY_QUERY_URL_FOR = "https://web.middlebury.edu/database/directory/?cn=" | |
"A".upto("Z") do |letter| | |
url = "#{DIRECTORY_QUERY_URL_FOR}#{letter}" |
$.ajax({ | |
url: this.href, | |
type: 'POST', | |
dataType: 'script', | |
data: {_method: 'delete'}, | |
beforeSend: function() { console.log("in before send ...") }, | |
complete: function() { console.log("in complete ...") } | |
}); |
class WidgetsController < ApplicationController | |
def destroy | |
@widget = Widget.find(params[:id]) | |
respond_to do |format| | |
if @widget.delete | |
format.html { flash[:notice] = "Item Removed"; redirect_to widgets_path } | |
# change format.json to format.js and it works properly | |
format.js { render :status => :ok } | |
else | |
format.html { flash[:alert] = "Something went terribly wrong"; redirect_to widgets_path } |
# Given that I have a model Item that inherits from ActiveRecord::Base and it has an attribute #locked_at, | |
# I want to be able to select T/F from a select in UI to set #locked_at's timestamp | |
# === VIEW === | |
# app/views/items/edit.html.haml, using formtastic | |
# Attempt #1: | |
# I could set locked_at => Time.now by setting it in the select's collection, | |
# but revisiting this form will not show the properly selected option, unless you do :selected => Time.now, | |
# which seems kludgy. Worse, if unlocked (locked_at => nil), this select option will not be |