Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
:shipit:
i don't make rails apps you use, i make the rails apps you use faster..

Tom Scott tubbo

:shipit:
i don't make rails apps you use, i make the rails apps you use faster..
View GitHub Profile
$(document).ready(function() {
function hideHeader() {
$("#headerBox").animate({height: default_height}, speed, function(){
$(".securekey_toggle").show("drop");
});
$("#headerAnimateWrapper").hide();
}
$(".testtoggle").click(function() {
@tubbo
tubbo / README.md
Last active December 14, 2015 07:58 — forked from jasondew/gist:5050066
Add implementation, tests and CLI.
@tubbo
tubbo / duck.rb
Last active December 14, 2015 09:49 — forked from kalleth/duck.rb
class Duck
attr_accessor :quack
def initialize(with_quack)
self.quack = with_quack
end
def get_angry_tubbo
self.quack
end
<!-- code removed as not relavent -->
<div class="tab-pane fade in" id="specs">
<%= render :partial => 'secure/specifications/form' %>
</div>
<!-- code removed as not relavent -->
class DeejaysController < ApplicationController
# GET /deejays
# GET /deejays.json
def index
@deejays = Deejay.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @deejays }
class ContestEntriesController < ApplicationController
def create
@contest_entry = ContestEntry.new(params[:contest_entry])
@contest_entry.save
redirect_to root_path
end
class Problem < ActiveRecord::Base
attr_accessible :body, :title
validates :title, length: { minimum: 3 }
end
@tubbo
tubbo / Description
Last active December 16, 2015 16:19
My problem is that I'm not sure the approach is the right one, although, it respects the patterns of MVC.
In the end, I gent the following error:
#<NoMethodError: undefined method `formats' for nil:NilClass>
org/jruby/RubyKernel.java:227:in `method_missing'
I don't really understand what format has to do with this. I tried to return both :layout => true and :layout => false, but I got the same error.
So the approach is as follows:
@tubbo
tubbo / user.rb
Last active December 19, 2015 20:49 — forked from almaron/user.rb
def get_auth
self.authentications.reduce({}) { |auths,auth| auths[auth.provider] = auth.id }
end
// Validates a single input
function validate(input) {
if (!input.getAttribute('required')) { return false; }
(!input.value) ? new Error(input.name + "is required.") : true
}
// Takes in an array of inputs, and tells us if they're all valid or no
function isFormInvalid(inputs) {
return inputs.map(validate) // Validates all fields
.filter(Boolean) // Keeps only the errors