Skip to content

Instantly share code, notes, and snippets.

View CoryFoy's full-sized avatar

Cory Foy CoryFoy

View GitHub Profile
@CoryFoy
CoryFoy / analytics.rb
Last active July 18, 2023 21:01
An example of calling the Analytics API using machine creds and the V4 API from Ruby
require 'google/apis/analyticsreporting_v4'
require 'googleauth'
include Google::Apis::AnalyticsreportingV4
include Google::Auth
VIEW_ID = "12345678" #your profile ID from your Analytics Profile
SCOPE = 'https://www.googleapis.com/auth/analytics.readonly'
@client = AnalyticsReportingService.new
;;core-test.clj
(ns gol.core-test
(:require [midje.sweet :refer :all]
[gol.core :refer :all]))
(facts "coin changer"
(fact "returns a penny for a penny"
(make-change-for 1) => [1])
(fact "returns 2 pennies for 2 cents"
(make-change-for 2) => [1,1])
I’m a constituent calling about the recent caucus vote by the GOP to reduce the impact of the Office of Congressional Ethics. This is something even the President Elect has come out against as of this morning, and I would like Congressman Walker to take a stand against this move and side with the president elect, as well as simply doing the right thing.
@CoryFoy
CoryFoy / sample.rb
Created November 28, 2016 21:12
TDD no Expectations
# TODO: Write sample implementation
@CoryFoy
CoryFoy / railsbug.sh
Last active January 12, 2016 04:17
Rails Bug(?) where an object served through the controller as json modifies the URL parameter
This is a bug where a model with a `url` attribute gets it modified when a controller is returning a JSON response
as_json response: [{"id"=>1, "title"=>"Hello 1", "url"=>"http://www.hello.com", "created_at"=>Tue, 12 Jan 2016 04:12:22 UTC +00:00, "updated_at"=>Tue, 12 Jan 2016 04:12:22 UTC +00:00}, {"id"=>2, "title"=>"Hello 2", "url"=>"http://www.hello.com", "created_at"=>Tue, 12 Jan 2016 04:12:29 UTC +00:00, "updated_at"=>Tue, 12 Jan 2016 04:12:29 UTC +00:00}]
JSON response in browser: [{"id":1,"title":"Hello 1","url":"http://localhost:3000/stories/1.json"},{"id":2,"title":"Hello 2","url":"http://localhost:3000/stories/2.json"}]
Corys-MacBook-Pro-2:Workspace foyc$ rails --version
Rails 4.2.5
Corys-MacBook-Pro-2:Workspace foyc$ rails new rails-bug
create
create README.rdoc
it "has already checked this" do
"We have checked this elsewhere and don't need to do anything"
end
~> Console extensions: wirble hirb ap rails2 rails3 pm interactive_editor
>> a = ["{\"email\":[\"You must fill in Email\",\"The email entered is not valid\"],\"first_name\":[\"You must fill in First Name\"],\"last_name\":[\"You must fill in Last Name\"]}"]
=> ["{\"email\":[\"You must fill in Email\",\"The email entered is not valid\"],\"first_name\":[\"You must fill in First Name\"],\"last_name\":[\"You must fill in Last Name\"]}"]
>> b = ["{\"email\":[\"translation missing: xx_YY.activerecord.errors.models.user.attributes.email.blank\",\"translation missing: xx_YY.errors.email_is_not_valid\"],\"first_name\":[\"translation missing: xx_YY.activerecord.errors.models.user.attributes.first_name.blank\"],\"last_name\":[\"translation missing: xx_YY.activerecord.errors.models.user.attributes.last_name.blank\"]}"]
=> ["{\"email\":[\"translation missing: xx_YY.activerecord.errors.models.user.attributes.email.blank\",\"translation missing: xx_YY.errors.email_is_not_valid\"],\"first_name\":[\"translation missing: xx_YY.
# create a file on the remote computer called set_volume.sh with the following
osascript -e "set Volume $1"
# create a local file to set the volume (I named mine ~/v)
ssh username@192.168.0.3 /Users/user/set_volume.sh $1
# make it executable
chmod +x ~/v
# Add your user to the remote computer via sshkeys
@CoryFoy
CoryFoy / gist:5434811
Created April 22, 2013 13:17
Speed vs Quality vs Feedback

(From this thread: https://twitter.com/unclebobmartin/status/326189060311891970)

Abby is talking about speed of feedback. Why would we invest in something high quality if we have no idea if it is going to work? In the Agile world, Fast in exchange for Quality certainly does appear - we just call it "Prototypes" or "Spikes". Those are specifically designed to eliicit feedback without spending a ton of time on a solution we may or may not need.

Lean Startup principles take that a bit further - build something quickly to get feeback so that you know if the direction you are going in is the right one. That gives you customer feedback - and dollars - to be able to build a high quality solution. If something has bugs or doesn't work correctly for all cases, who cares if we are directing people only down one path to see how they respond to the system?

Like spikes, it has the danger of turning into the final product, at which point quality is a big concern. But I see no problem with advising customers who are tryi

Feature: Capybara
Scenario: Finds hidden elemenets
Given we are on the home page
Then we should be able to find the hidden text
Given /^we are on the home page$/ do
visit '/'
end