Skip to content

Instantly share code, notes, and snippets.

View stephensprinkle-zz's full-sized avatar
🤔
Thinking...

Stephen Sprinkle stephensprinkle-zz

🤔
Thinking...
View GitHub Profile
@stephensprinkle-zz
stephensprinkle-zz / gist:2004455
Created March 9, 2012 01:13
Jquery File Extension Validation
validVideoFileExtensions = [ ".mp4", ".m4v", ".mov" ]
validAudioFileExtensions = [ ".mp3", ".m4a" ]
$("input#sermon_video").live "change", ->
if this.type is "file"
sFileName = this.value
if sFileName.length > 0
blnValid = false
j = 0
@stephensprinkle-zz
stephensprinkle-zz / secure-subdomains
Created April 17, 2012 02:26
Test for SSL + Subdomain in Production Rails Controller
before_filter :secure_subdomain_ssl
private
def secure_subdomain_ssl
if Rails.env.production?
if request.subdomain != 'secure' or request.ssl? != true
redirect_to :subdomain => 'secure', :protocol => 'https'
end
end
@stephensprinkle-zz
stephensprinkle-zz / non-secure-domain
Created April 17, 2012 02:32
Test for SSL + Subdomain in Rails Controller to Remove SSL + Subdomain
before_filter :no_secure_subdomain_ssl
def no_secure_subdomain_ssl
if request.subdomain == 'secure' or request.ssl? == true
redirect_to root_url(:host => request.domain, :protocol => 'http' )
end
end
@stephensprinkle-zz
stephensprinkle-zz / ios5-reachability-config-steps
Created May 9, 2012 21:12
How I got reachability working with iOS 5
> Grab the files from Apple's Page
>> https://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html#//apple_ref/doc/uid/DTS40007324-Classes_Reachability_h-DontLinkElementID_5
> Place them in your project (copy in, and ideally place them in your classes group)
> Click on the Reachability.m file and then on the upper right area click on the 'show file inspector' icon.
> Then make sure the target membership is for your project.
> Lastly, turn off arc for this file by doing:
>> Select desired files at Target/Build Phases/Compile Sources
@stephensprinkle-zz
stephensprinkle-zz / android-network-check
Created May 15, 2012 20:08
Test for Network Connection Before Activity Runs in Android
try{
if (isOnline()){
// Activity Stuff Goes Here
} else {
Log.d("Connection Status", "Connection Not Available");
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("No Network Connection");
alertDialog.setMessage("Internet access is necessary for the use of this app.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
@stephensprinkle-zz
stephensprinkle-zz / postgre-db-cleanout
Created May 25, 2012 00:03
How to clean out database without deleting it
rake db:schema:dump
rake db:schema:load
@stephensprinkle-zz
stephensprinkle-zz / stripe-environment-based-keys
Created June 9, 2012 04:12
Stripe Environment Based Keys
production.rb: STRIPE_SECREY_KEY = "XXXX"
development.rb: STRIPE_SECREY_KEY = "YYYY"
initializers/stripe.rb: Stripe.api_key = STRIPE_SECRET_KEY
@stephensprinkle-zz
stephensprinkle-zz / subscriptions.js
Created June 11, 2012 21:35 — forked from justinthiele/subscriptions.js
Updated Subscriptions JS (fixed to work with dynamically loaded forms)
$(function() {
var subscription;
$(function() {
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'));
return subscription.setupForm();
});
subscription = {
setupForm: function() {
return $('#new_subscription').submit(function() {
$('input[type=submit]').attr('disabled', true);
@stephensprinkle-zz
stephensprinkle-zz / vboxheadless-bridged-adapters-import-fix
Created June 20, 2012 04:12
VirtualBox Headless Issues with imported VMs that previously used bridged adapters
vboxmanage showvminfo <vmname>
vboxmanage modifyvm <vmname> --nic1 bridged --bridgeadapter1 <interface>
bam
vboxmanage startvm <vmname> --type headless
or
vboxheadless --startvm <vmname> *for rdp interface
@stephensprinkle-zz
stephensprinkle-zz / softkey-circumvention
Created June 23, 2012 03:12
Simple javascript to circumvent 'Go' softkey buttons for web forms in iOS + Android
$('form').bind('submit', function(){
return false;
});