Skip to content

Instantly share code, notes, and snippets.

@bahrieinn
bahrieinn / user.rb
Created November 18, 2013 03:47
Code Sample from Twoppleganger
class User < ActiveRecord::Base
def self.from_omniauth(auth)
where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
end
def self.create_from_omniauth(auth)
create! do |user|
user.provider = auth['provider']
user.uid = auth['uid']
@bahrieinn
bahrieinn / carousel.js
Last active December 22, 2015 09:59 — forked from ksolo/carousel.js
Image Carousel
@bahrieinn
bahrieinn / form-validator.js
Last active December 22, 2015 09:48 — forked from ksolo/form-validator.js
Form Validation
// shorthand for $(document).ready();
$(document).ready(function(){
$("form").submit(function(e) {
e.preventDefault();
var emailInput = $("input").first().val();
var passwordInput = $("input").last().val();
if (!validateEmail(emailInput)) {
$("#errors").append("<li>Invalid Email</li>");
@bahrieinn
bahrieinn / zoo.js
Last active December 22, 2015 09:19 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
// Animal Constructor
function Animal(name, legs){
this.name = name;
this.legs = legs;
}

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
# Solution for Challenge: Pig-latin. Started 2013-08-06T15:39:01+00:00
def is_vowel?(word) #add is_vowel? helper method to make code in
/[aeiou]/i === word[0] #to_pig_latin more expressive
end
def to_pig_latin(word)
if is_vowel?(word)
word
else