Skip to content

Instantly share code, notes, and snippets.

@stim371
stim371 / update_hash_benchmark.rb
Created July 22, 2012 07:49
Trying out a few different ways of updating a hash
# user system total real
# each clean 0.280000 0.000000 0.280000 ( 0.278609)
# inject clean 0.460000 0.000000 0.460000 ( 0.460230)
# update clean 0.230000 0.000000 0.230000 ( 0.230860)
# collect clean 0.540000 0.000000 0.540000 ( 0.537933)
require 'benchmark'
require 'date'
@stim371
stim371 / observing_plan.md
Created April 25, 2012 01:34
class project to create own DSL

##Creating a DSL for stellar observation plans

###Why? This is a project for the advanced Ruby class at University of Washington.

###What would you use this for? Astronomers typically create an observation plan for the night so they have an idea for what they want to look at. This DSL could allow them to simplify interacting with telescope automation programs by moving the interaction closer to natural language.

###Criteria

  • Time to view
@stim371
stim371 / search and highlight dynamic.vba
Created March 6, 2012 01:10
a quick function to search for and highlight specific strings in a range of cells.
Sub highlighttext()
Dim cell As Range
Dim cellRange As Range
Dim textStart As Integer
Dim wordToFind As String
Set cellRange = Selection
Application.ScreenUpdating = False
@stim371
stim371 / subquery basic example.sql
Created March 2, 2012 02:00
Examples of a subquery in SQL as well as a slightly different implementation
-- Here's a very basic one that could really be a regular join as well
-- Instead of being in the SELECT section it is in WHERE
-- This could also be thought of as a INNER JOIN with DISTINCT
-- The downside is you can't call columns, so it's more of an EXISTS than a way to pull in aggregated info like the COUNT example
SELECT c.ID, c.Name
FROM Company c
WHERE c.ID in
@stim371
stim371 / inner_join.sql
Created March 2, 2012 00:32
examples of different types of joins
-- This example shows the use of an INNER JOIN between two tables
-- You would use it when you want to find records that exist in both tables
SELECT c.CompanyName, l.SiteName
FROM company c INNER JOIN location l ON c.ID = l.CompanyID
/*
Company table
@stim371
stim371 / installing_uncoil.rb
Created February 12, 2012 06:12
example usage of the new uncoil gem
gem install uncoil
@stim371
stim371 / string_split_benchmark.rb
Created February 11, 2012 10:03
benchmarking different ways of splitting up a string
sentence = "rake routes --help this last part"
def with_split sentence
a = sentence.split('--')
@build_args = "--" << a[1]
@args = a[0]
end
def with_slice sentence
dash_ind = sentence.index("--")
@stim371
stim371 / creating_repositories.feature
Created January 24, 2012 09:56
cucumber feature for testing site
Feature: Creating Repositories
In order to have repositories to solicit help on
As a user
I want to add my repositories
Background:
Given I am on the homepage
When I follow "New Repository"
Scenario: Creating a repository
@stim371
stim371 / gist:1533180
Created December 29, 2011 09:25
list of git cleanup commands
git ls-files --deleted | xargs git rm
ps
lsof -i tcp:3000
kill -int {pid}
@stim371
stim371 / js-rubygame-wk3.rb
Created December 28, 2011 06:24
Solutions to therubygame.com week 3 problems
# times are based on 25,000 iterations
# solution 1 / time: 1.47936483s
def capitalize(time)
string.split.each{|n| n.capitalize!}.join ' '
end
# solution 2 / time: 2.32211853s
def capitalize(string)