This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ARGV.each do |path| | |
files = Dir.glob(File.join(path, '**', "*.{jpg}"), File::FNM_CASEFOLD).each do |f| | |
puts File.path(f) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sum(List<Integer> nums) { | |
int sum = 0; | |
for(Integer i: sums) { | |
sum+=i | |
} | |
return sum; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int myFactorial( int integer) | |
{ | |
if( integer == 1) | |
return 1; | |
else | |
{ | |
return(integer*(myFactorial(integer-1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Idea < ActiveRecord::Base | |
attr_accessible :title, :note | |
has_and_belongs_to_many :tags | |
def tags_attributes(hash) | |
hash.each do |sequence, tag_values| | |
tags.find_or_create_by_name(tag_values[:name]) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repo = Repo.init_bare("public/git/myrepo.git") | |
fname = Time.now.to_i.to_s | |
File.open("public/git/" + fname, 'w') {|f| f.write('hello git' + fname)} | |
repo.add(fname) | |
repo.commit_index('my commit') | |
logger.info repo.commits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGPoint touchLocation = CCDirector.sharedDirector().convertToGL(CGPoint.make(ev.getX(), ev.getY())); | |
if(touchLocation.x > largestX || touchLocation.x < smallestX) { | |
if(!(touchLocation.y > largestY || touchLocation.y < smallestY)) { | |
sprite.setPosition(sprite.getPosition().x, touchLocation.y); | |
} | |
} else if(touchLocation.y > largestY || touchLocation.y < smallestY) { | |
if(!(touchLocation.x > largestX || touchLocation.x < smallestX)) { | |
sprite.setPosition(touchLocation.x, sprite.getPosition().y); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float largestX = dirtyFoot.getPosition().x + (dirtyFoot.getContentSize().getWidth()/2); | |
float smallestX = dirtyFoot.getPosition().x - (dirtyFoot.getContentSize().getWidth()/2); | |
float smallestY = dirtyFoot.getPosition().y - (dirtyFoot.getContentSize().getHeight()/2); | |
float largestY = dirtyFoot.getPosition().y + (dirtyFoot.getContentSize().getHeight()/2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MobileBackend::Application.routes.draw do | |
devise_for :posts | |
devise_for :users, :controllers => { :sessions => "sessions" } | |
devise_scope :user do | |
# namespace :api do | |
# namespace :v1 do | |
resources :sessions, :registration, :only => [:create, :destroy] | |
# end | |
# end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, | |
:recoverable, :rememberable, :trackable, :validatable, :token_authenticatable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :email, :password, :password_confirmation, :remember_me, :authentication_token | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < Devise::SessionsController | |
def create | |
respond_to do |format| | |
format.html { super } | |
format.json { | |
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") | |
# render :status => 200, :json => { :error => "Success" } | |
render :status => :ok, :json => { :response => 'ok', :auth_token => User.authentication_token } | |
} | |