Skip to content

Instantly share code, notes, and snippets.

View joshdholtz's full-sized avatar
👨‍👩‍👦
Family first then OSS

Josh Holtz joshdholtz

👨‍👩‍👦
Family first then OSS
View GitHub Profile
@joshdholtz
joshdholtz / patch.rb
Created February 17, 2012 16:25 — forked from DAddYE/patch.rb
Postmark w/Padrino
# Add me in lib or somewhere
# lib/postmark_patch.rb
Mail::Message.class_eval do
def html?
content_type_without_symbol && content_type_without_symbol.include?('text/html')
end
end
@joshdholtz
joshdholtz / ViewController.m
Created February 18, 2012 21:35
Load Nib into UIScrollView
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"AddNewProductScrollView" owner:self options:nil];
UIView *myView = [nibContents objectAtIndex:0];
[scrollView addSubview: myView];
[scrollView setContentSize:CGSizeMake(myView.frame.size.width, myView.frame.size.height)];
@joshdholtz
joshdholtz / SplashActivity.java
Created February 23, 2012 02:05
Android Splash Screen
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.Toast;
@joshdholtz
joshdholtz / app.rb
Created March 2, 2012 03:16
Configuring in Padrino
class App < Padrino::Application
register Padrino::Rendering
register Padrino::Mailer
register Padrino::Helpers
layout :layout
configure :production do
puts "In production mode"
Stripe.api_key = Constants::STRIPE_LIVE_KEY
@joshdholtz
joshdholtz / Activity.java
Created March 5, 2012 02:07
Android - Custom List
public class ContactsActivity extends Activity {
List<Contact> contacts;
ContactsAdapter contactsAdapter;
ListView contactsList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@joshdholtz
joshdholtz / app.rb
Created March 14, 2012 13:20
Padrino Component - Redirect request from WWW to non-WWW
class App < Padrino::Application
...
register WWWRedirect
...
end
@joshdholtz
joshdholtz / ProtocolMultipartEntitySnippet.java
Created April 16, 2012 13:05
Protocol Multipart Entity Snippet
// Creates the boundary for the multipart, the content type with the boundary, and the entity
String boundary = "---------------------------14737809831466499882746641449";
String contentType = "multipart/form-data; boundary=" + boundary;
HttpEntity entity = new ProtocolMultipartEntity(boundary, new File("/some/path"));
// Creates the post request
HttpPost httpPostFileRequest = new HttpPost(route);
httpPostFileRequest.addHeader("Content-Type", contentType);
httpPostFileRequest.setEntity(entity);
@joshdholtz
joshdholtz / UIButton+Block.h
Created April 23, 2012 04:37
iOS - UIButton+Block
//
// UIButton+Block.h
// BoothTag
//
// Created by Josh Holtz on 4/22/12.
// Copyright (c) 2012 Josh Holtz. All rights reserved.
//
#define kUIButtonBlockTouchUpInside @"TouchInside"
@joshdholtz
joshdholtz / rable_sequel_patch.rb
Created April 30, 2012 05:07
Patch for using Sequel object in rable template
Sequel::Model.class_eval do
def map
return self.values
end
end
@joshdholtz
joshdholtz / UIImageView+Block.h
Created May 17, 2012 11:29
iOS - UIImageView+Block
//
// UIImageView+Block.h
//
// Created by Josh Holtz on 5/17/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImageView (Block)