Skip to content

Instantly share code, notes, and snippets.

View zackperdue's full-sized avatar
🛩️
Working from home

Zack Perdue zackperdue

🛩️
Working from home
  • Unicorn
  • Bali, Indonesia
View GitHub Profile
@zackperdue
zackperdue / gist:4659057
Created January 28, 2013 21:12
Does this actually work?
public function action_downloads()
{
$order_ids = ORM::factory('Order', array('id'))
->where('user_id', '=', $this->user->id)
->as_array();
$downloads = ORM::factory('Order_Item')
->where('order_id', 'IN', $order_ids)
->find_all();
$cc_left = substr($cc_number, 0, 4);
$cc_tmp_right = substr($cc_number, 4);
$cc_center = substr($cc_tmp_right, 0, 8);
$cc_right = substr($cc_tmp_right, 8);
echo $cc_number."<br />";
echo $cc_left.$cc_center.$cc_right;
@zackperdue
zackperdue / gist:3557582
Created August 31, 2012 19:11
Auto Reload Browser
Create a new bookmark item then paste the code below into the url field
javascript:(function(p){open('','',p).document.write('%3Cbody%20id=1%3E%3Cnobr%20id=2%3E%3C/nobr%3E%3Chr%3E%3Cnobr%20id=3%3E%3C/nobr%3E%3Chr%3E%3Ca%20href=%22#%22onclick=%22return!(c=t)%22%3EForce%3C/a%3E%3Cscript%3Efunction%20i(n){return%20d.getElementById(n)}function%20z(){c+=0.2;if(c%3E=t){c=0;e.location=u;r++}x()}function%20x(){s=t-Math.floor(c);m=Math.floor(s/60);s-=m*60;i(1).style.backgroundColor=(r==0||c/t%3E2/3?%22fcc%22:c/t%3C1/3?%22cfc%22:%22ffc%22);i(2).innerHTML=%22Reloads:%20%22+r;i(3).innerHTML=%22Time:%20%22+m+%22:%22+(s%3C10?%220%22+s:s)}c=r=0;d=document;e=opener.top;u=prompt(%22URL%22,e.location.href);t=u?prompt(%22Seconds%22,60):0;setInterval(%22z()%22,200);if(!t){window.close()}%3C/script%3E%3C/body%3E')})('status=0,scrollbars=0,width=100,height=115,left=1,top=1')
<input type="file" name="file_selector" id="file_selector" multiple="multiple" accept="video/*">
var fileSelector = document.getElementById('file_selector')
var uploader = new FileUploader({
uploadType: 'Video',
fileInput: fileSelector
})
@zackperdue
zackperdue / README.md
Last active August 29, 2015 14:21
Matchlength.js

Matchlength.js

Attach this plugin to an input field and it matches the width of the field to the number of characters in the field. Great for inline editable text fields!

$('input').matchlength()
@zackperdue
zackperdue / user.rb
Created May 21, 2015 12:04
Overwrite the way the friendly_id gem generates unique slugs.
friendly_id :slug_candidates, use: :slugged, slug_column: :namespace
def slug_candidates
[
[:first_name, :last_name]
]
end
def normalize_friendly_id(value)
super.gsub(/\-/, '')
@zackperdue
zackperdue / Build Log.bash
Last active August 29, 2015 14:07
git push heroku master
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
You are trying to install in deployment mode after changing your Gemfile.
Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.
You have added to the Gemfile: * active_model_serializers You have deleted from the Gemfile: * jbuilder (~> 1.2)
Bundler Output: You are trying to install in deployment mode after changing your Gemfile.
Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.
= form_for Comment.new do |f|
= f.text_area :body
= f.button t("button.submit")
- @video.comments.reverse.each do |comment|
%div{class: 'comment', id: "comment_#{comment.id}"}
= simple_format comment.body
@zackperdue
zackperdue / test.rb
Created March 5, 2014 01:15
Look inside test()
require 'open-uri'
class Participants
def test
participant_data do |io|
# This never gets called
end
end