Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
😎
losing my sight, losing my mind, go to the general to save some time

Tom Scott tubbo

😎
losing my sight, losing my mind, go to the general to save some time
View GitHub Profile
jQuery(function($) {
// create a convenient toggleLoading function
var fooToggleSpinner = function() { $("#divSpinner").toggle() };
$("#runSpinner")
.bind("ajax:loading", fooToggleSpinner)
.bind("ajax:complete", fooToggleSpinner)
jQuery(function($) {
$("#runSpinner").bind("ajax:loading", function() { $("#divSpinner").show() });
$("#runSpinner").bind("ajax:complete", function() { $("#divSpinner").hide() });
respond_to :html, :json
def update
@cart = Cart.find(params[:id])
@cart.update_attributes(params[:cart])
respond_with @cart
end
Capybara::Driver::Webkit::WebkitInvalidResponseError: Javascript failed to execute
def confirm_current_user_account
case @customer_account.customer_type
when 'User' then
if @customer_account.customer == current_user
@customer = @customer_account
else
redirect_to bank_root_path, alert: "Error."
end
when 'Company'
unless current_user.companies.find(@customer_account.customer).nil?
def edit():
icon_name = request.vars.item_0 if request.vars else None
icon_name = urllib.unquote(icon_name)
model = Icon()
if icon_name:
icon_object = bw.objectQuery("icon", icon_name)
model.populate(icon_object)
icon_form = SQLFORM.factory(*model.fields())
@tubbo
tubbo / gist:1343302
Created November 6, 2011 18:47 — forked from anonymous/gist:1343297
WaitiGer - autoscroll
<script type = "text/javascript" >
var x;
function autoscroll(){
self.scrollBy(0,x)
}
function playautoscroll(){
x = 1;
setInterval(function() { autoscroll(); },10.01);
@tubbo
tubbo / gist:1368091
Created November 15, 2011 19:40
Diaspora Conversations Controller
class ConversationsController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :json, :js
def index
page = params[:page]
id = params[:conversation_id]
@conversations = current_user.visible_conversations page
@visibilities = current_user.visibilities page
@tubbo
tubbo / ruby.rb
Created December 22, 2011 21:12
more efficient way to do this?
@company.company_type = case params[:plantype]
when 'executive' then '2'
when 'business' then '3'
else
'1'
end
@tubbo
tubbo / application.html.erb
Created December 29, 2011 16:46 — forked from fringedgentian/application.html.erb
issues with including javascript and css
<!DOCTYPE html>
<html>
<head>
<title>IApp</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>