Skip to content

Instantly share code, notes, and snippets.

@ndelage
ndelage / gist:3185891
Created July 27, 2012 02:35
svm example
require 'lib/svm'
data = [
[5, {:year => 1987, :campy => 1}],
[3, {:year => 1978, :man_eating_monsters => 1, :horror => 1}],
[2, {:year => 1988, :teens => 1}]
]
predictor = SvmPrediction.from_svm_problem( data )
puts predictor.predict(:year => 1988)
@ndelage
ndelage / testing with rspec.md
Last active February 21, 2017 16:11
Testing with RSpec

Definitions

General Testing

  • TDD Test Driven Development. Write examples before implementation.
  • BDD Behaviour-Driven Development is about implementing an application by describing its behavior from the perspective of its stakeholders. (The Rspec Book)
  • RSpec (mention alternatives, write a simple hand sewn test)

Testing Terms

@ndelage
ndelage / testing tips.md
Last active December 17, 2015 09:09
Testing Tips & Tricks

Testing Tips & Tricks

Run a single test

In a large application, running all the tests at once using rake spec can make it difficult to check the output of the test you're working on. Especially if you have many failing or pending tests. Run a single test by running rspec:

rspec spec/models/account.rb

You can be even more specific and run a specific example from a test file. For example, given the following tests:

11: describe "#deposit!" do
@ndelage
ndelage / continuous integration.md
Last active December 17, 2015 10:19
Continuous Integration Intro

Continuous Integration for Fun and Profit

Continu-what?

Definition: the practice of frequently integrating one's new or changed code with the existing code repository -Wikipedia

Merging new code into master often sounds awesome, but we've been learning the value of testing and the importance of a passing test suite.

But, as your projects grow, your test suite should grow as well. We're all lazy and forget to run the entire test suite everytime we create a new commit. For large projects, running the entire test suite can take hours. So we do what all lazy people do, make a computer to the work for us.

@ndelage
ndelage / web_perf.md
Last active February 7, 2019 06:50
Web Performance

Web Preformance

Sources of slow

Database

  • n+1 queries (try :includes or join)
  • Complex joins (is there another way to find the data?)
  • Missing indexes
  • Useless indexes
  • Schema (prossibly denormalize)
@ndelage
ndelage / 00 - Entrepreneurial Notes.md
Last active November 16, 2016 06:43
Entrepreneurial Notes

Entrepreneurial Notes

I've begun taking detailed notes for the entrepruneral presentations, articles and books I find most valuable. For now, these notes live here as a collection of Gists.

@ndelage
ndelage / secret_keys_open_source.md
Last active December 25, 2015 19:09
Managing Secret Data in Open Source Applications

Managing Secret Data in Open source Applications

If you're working on an open source project, committing API keys or secrets to your repo is a big no-no. You wouldn't want anyone else making request with your keys, right?

So instead of putting those keys in app/config/initializers set then as environment variables in your shell. Here's an example for a Facebook API key:

export FB_API_KEY=3629346238763284623874623
@ndelage
ndelage / Tips for a #WINNING Github Profile.md
Last active November 9, 2021 03:11
Tips for a #WINNING Github Profile

Tips for a #WINNING Github Profile

The basics

As a new developer some potential employers are going to review your Github profile as part of the interview process. This doc covers some tips that should help you make a good impression. What this doc won't do is polish a turd.

README

Think of your experiences reviewing a Gem or other JS library on Github. Where do you look first? The README of course. What makes for a frustrating repo? One that doesn't:

  • include a README.
  • include install instructions (if applicable)
@ndelage
ndelage / unix_challenge.md
Last active December 29, 2015 13:48
Unix Challenge

Unix Challenge

Background

In this challenge you'll become familiar with a number of standard Unix command utilities and then implement a subset of their functionality in Ruby. You'll gain a better understanding of:

  • files/descriptors in unix
  • pipes
  • sockets
  • STDIN, STDERR, STDOUT
@ndelage
ndelage / command_line_fu.md
Created December 4, 2013 15:34
Command Line Fu

Unix Command Line Fu

Basics

tab completion

Nearly all shells have support for tab completion. At a minimum for completing file & directory names, though some even tab-complete based on which commands you're running. Some examples:

$ ls [TAB]
Gemfile app/ connectors.rb public/