Skip to content

Instantly share code, notes, and snippets.

View darrencauthon's full-sized avatar

Darren Cauthon darrencauthon

View GitHub Profile
@darrencauthon
darrencauthon / arg.txt
Created June 18, 2015 11:20
MLB voting, technical perspective
Faulty premise, lots of assumptions
I believe HookSlide is lacking the necessary facts to reach the conclusion that the voting is being hacked.
Let’s look at it from a technical perspective by pretending that we had to build the MLB voting website. I’m sure MLB would demand the following:
1) Voting must be valid and accurate. No hacking the vote!
2) The voting site must stand up to TONS of web traffic from around the world. No downtime!
3) It must be friendly for visitors to vote. Don’t scare people away!
Checking for valid votes is expensive, as it will require computation and many database lookups across millions of records. Combine that with making a real-time check as thousands of users from around the world are hitting your site… at the same time?!?!?! That’s a very hard problem.
@darrencauthon
darrencauthon / feature.feature
Created May 19, 2015 20:26
Save the table for later
Background:
Given I have a table named Test
| Field | Value |
| x | y |
Scenario:
When I look at the Test Table
@darrencauthon
darrencauthon / boardSteps.cs
Created March 20, 2015 13:19
Chess BDD with SpecFlow
[Binding]
class BoardSteps
{
[When("there is a chess board set up as")]
public void a(Table table)
{
rows = Table.ConvertToSet<BoardRow>();
board = Board.new();
@darrencauthon
darrencauthon / evil.cs
Created February 23, 2015 14:58
Good and Evil (?)
public class Product
{
public string Id { get; set; }
public string Name { get; set; }
// etc
public IQueryable<Product> All()
{
MyIoCContainer.Resolve<DbContext>().Products();
}
@darrencauthon
darrencauthon / run.rb
Last active August 29, 2015 14:12
hacking at camtasia
require 'nokogiri'
generic_track_id = '10'
xml = File.open('project.xml').read
doc = Nokogiri::XML xml
tracks = doc.xpath("//GenericTrack")
@darrencauthon
darrencauthon / controller_test.rb
Created November 17, 2014 15:39
Contact Us Form
describe ContactUsController do
let(:params) { {} }
let(:controller) do
c = ContactUsController
c.stubs(:params).returns params
c
end
@darrencauthon
darrencauthon / 1_old_worker.rb
Created September 29, 2014 18:24
Using a base class to simplify workers that subscribe to an event
class OldWorker
include Sidekiq::Worker
def perform user_event_id
user_event = UserEvent.find user_event_id
user = User.find user_event.user_id
user_application = user.find_application user_event.application_id
# do something
end
### Keybase proof
I hereby claim:
* I am darrencauthon on github.
* I am darrencauthon (https://keybase.io/darrencauthon) on keybase.
* I have a public key whose fingerprint is 3D4B 591E 675D 0B41 AE95 EA86 0A23 A070 4250 4AE2
To claim this, I am signing this object:
@darrencauthon
darrencauthon / caching_layer.rb
Created September 19, 2014 19:28
Surgical caching
module CachingLayer
class << self
def method_missing meth, *args, &block
action = meth.to_s.split('_')[0].to_sym
object_id = args[0].is_a?(ActiveRecord::Base) ? args[0].id : args[0]
object_type = meth.to_s.sub("#{action}_", '').to_sym
case action
public class ProductController : Controller
{
private IProductRepository _productRepository;
public ProductController(IProductRepository productRepository)
{
_productRepository = productRepository;
}
public ActionResult Index()