Skip to content

Instantly share code, notes, and snippets.

View subdigital's full-sized avatar

Ben Scheirman subdigital

View GitHub Profile

Keybase proof

I hereby claim:

  • I am subdigital on github.
  • I am subdigital (https://keybase.io/subdigital) on keybase.
  • I have a public key whose fingerprint is 21AB 9009 45D6 171D A19F 2B40 0654 48A1 4C7D AF2F

To claim this, I am signing this object:

@subdigital
subdigital / ASP.NET MVC rendering javascript templates
Created August 19, 2009 19:07
showing how to do a quick & dirty javascript template sort of like rails
//HomeController
public ActionResult Foo()
{
if(Request.IsAjaxRequest())
{
return View("_foo");
}
return View();
}
using(var db = new FooDataContext())
{
foreach(var row in table)
{
Car car = (from c in db.Cars
where c.Id = row["CAR_ID"]).SingleOrDefault();
if(car == null)
car = new Car();
<delete verbose="true">
<fileset>
<include name="**/bin"/>
<include name="**/obj"/>
</fileset>
</delete>
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.opaque = NO;
cell.textLabel.backgroundColor = [UIColor clearColor];
public static string Pluralize(this string str)
{
if(str.EndsWith("s"))
return str + "es";
return str + "s";
}
@subdigital
subdigital / Foo.hbm.xml
Created December 23, 2009 16:27
These are just so I can refer to them later.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="YOUR_ASSEMBLY"
namespace="YOUR_NAMESPACE">
<class name="Foo" table="foos">
<id name="id">
<generator class="identity"/>
</id>
<property name="Bar" not-null="true"/>
</class>
@subdigital
subdigital / Heroku + json_pure conflict
Created November 19, 2010 16:33
On a brand new Rails 3 app....
[~/cool-app (master)]$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using ZenTest (4.4.0)
Using abstract (1.0.0)
Using activesupport (3.0.1)
Using builder (2.1.2)
Using i18n (0.4.2)
Using activemodel (3.0.1)
Using erubis (2.6.6)
@subdigital
subdigital / savon_vcr.rb
Created January 27, 2011 20:06
Trying to get savon working with vcr, however it doesn't record the cassette file
VCR.config do |c|
c.cassette_library_dir = 'fixtures/cassettes'
c.stub_with :webmock
end
class VCRSavonTest < Test::Unit::TestCase
def setup
path = File.expand_path("../fixtures/cassettes", __FILE__)
`rm -rf #{path}`
end
group :development, :test do
gem 'capybara'
gem 'rspec'
gem 'rspec-rails'
gem 'autotest'
gem 'autotest-rails'
gem 'cucumber'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'pickler'