Skip to content

Instantly share code, notes, and snippets.

View nbomberger's full-sized avatar

Nathaniel Bomberger nbomberger

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@ekarulf
ekarulf / barcode_type.py
Created August 21, 2010 06:01
Common barcode formats
#!/usr/bin/env python
# -*- coding: ascii -*-
##############################################################################
# Copyright (c) 2010, Erik Karulf (erik@karulf.com)
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@zwaldowski
zwaldowski / NSObject+Blocks.h
Created May 4, 2011 12:08
Perform blocks with delays and cancellation
//
// NSObject+Blocks.h
// Filemator
//
// Created by Zachary Waldowski on 4/12/11.
// Copyright 2011 Dizzy Technology. All rights reserved.
//
@interface NSObject (Blocks)
anonymous
anonymous / gist:980468
Created May 19, 2011 09:23
Special password validation for devise
class AdminToolUser < ActiveRecord::Base
# Setup accessible (or protected) attributes for the model
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name
validates_presence_of :first_name, :last_name
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :registerable, :lockable and :timeoutable
devise :database_authenticatable, :recoverable, :rememberable, :trackable
@haxorjim
haxorjim / gist:1371323
Created November 16, 2011 20:45
Validate Tracking Numbers in PL/SQL
function fedex12(p_tracking_number varchar2) return boolean is
trk varchar2(12);
tot number:=0;
mult number:=1;
chr varchar2(1);
begin
--if the data passed is 12 digits then strip everything but valid FedEx tracking number characters.
if length(p_tracking_number) = 12 then
for x in 1..length(p_tracking_number) loop
chr := upper(substr(p_tracking_number,x,1));
@olivierlacan
olivierlacan / .pryrc
Created January 5, 2012 01:16 — forked from renz45/.pryrc
Pry configuraton
# switch default editor for pry to sublime text
Pry.config.editor = "sublime"
# format prompt to be <Rails version>@<ruby version>(<object>)>
Pry.config.prompt = proc do |obj, level, _|
prompt = "\e[1;30m"
prompt << "#{Rails.version} @ " if defined?(Rails)
prompt << "#{RUBY_VERSION}"
"#{prompt} (#{obj})>\e[0m"
end
@hcrub
hcrub / appledoc_aggregate.sh
Created November 6, 2013 20:02
Aggregate Target for Xcode 5+ for creating clean AppleDoc documentation.
/usr/local/bin/appledoc \
--project-name "${PROJECT_NAME}" \
--project-company "HCRUB" \
--company-id "com.hcrub" \
--output "${PROJECT_DIR}/Documentation" \
--install-docset \
--logformat xcode \
--keep-undocumented-objects \
--keep-undocumented-members \
--keep-intermediate-files \
<% if options.orientation == :vertical %>{<% end %>
<table border="0" align="center" cellspacing="0.5" cellpadding="0" width="<%= NODE_WIDTH + 4 %>">
<tr><td align="center" valign="bottom" width="<%= NODE_WIDTH %>"><font face="Arial-BoldMT" point-size="11"><%= entity.name %></font></td></tr>
</table>
<% if attributes.any? %>
|
<table border="0" align="left" cellspacing="2" cellpadding="0" width="<%= NODE_WIDTH + 4 %>">
<% attributes.each do |attribute| %>
<tr><td align="left" width="<%= NODE_WIDTH %>" port="<%= attribute %>"><%= attribute %> <font face="Arial-ItalicMT" color="grey60"><%= attribute.type_description %></font></td></tr>
<% end %>
# encoding: utf-8
require "rails_erd/diagram"
require "graphviz"
require "erb"
# Fix bad RegEx test in Ruby-Graphviz.
GraphViz::Types::LblString.class_eval do
def output # @private :nodoc:
if /^<.*>$/m =~ @data
@data
@chriseidhof
chriseidhof / sample.swift
Last active December 6, 2019 22:52
Observable References
import Foundation
// A lens is a getter and a setter combined
struct Lens<Whole, Part> {
let get: (Whole) -> Part
let set: (inout Whole, Part) -> ()
}
// We can create a lens from a key path
extension Lens {