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: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')
$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: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();
@zackperdue
zackperdue / gist:4726516
Last active December 12, 2015 06:08
Note: Modal body is part of another view. (using twitter bootstrap) Why is my Form tag not showing up? Driving me nuts!!!!
<!-- unexpected html. missing form element once it is rendered to page -->
<div class="modal-body">
<p>This is a safety feature so you don't do something you didn't mean to do.</p>
<div class="control-group">
<div class="controls">
<input type="password" name="password" placeholder="Your Account Password">
</div>
</div>
$controller = Request::current()->controller();
$action = Request::current()->action();
$directory = Request::current()->directory();
$controller_name = ($directory)? $directory.'_'.$controller : $controller;
if ( ! $this->a2->allowed($controller_name, $action))
{
HTTP::redirect(Route::url('account', array('action' => 'login')));
}
@zackperdue
zackperdue / gist:7631681
Created November 24, 2013 20:00
ActiveModel::ForbiddenAttributesError in BlueprintsController#create
Controller:
class BlueprintsController < ApplicationController
protect_from_forgery with: :exception
def index
@blueprints = Blueprint
end
@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
= 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 / 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.
@zackperdue
zackperdue / DropdownMenu.jsx
Last active January 17, 2020 19:25
ReactJS Dropdown Menu with optgroup
import React from 'react';
var SelectInput = React.createClass({
propTypes: {
groupBy: React.PropTypes.string,
options: React.PropTypes.array.isRequired,
placeholder: React.PropTypes.string,
selected: React.PropTypes.string
},