This file contains 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 someController < ApplicationController | |
def a | |
set_instance_variable | |
#How would i access @instance_variable in this method. | |
#I could make it a class variable right? | |
@instance_variable == 'whatever' #=> true | |
end | |
def b | |
set_instance_variable |
This file contains 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
def cats_text(count = 0) | |
return "Cats (" + count.to_s + ")" if count > 1 | |
"Cats" | |
end |
This file contains 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
irb(main):001:0> class Fookamachi | |
irb(main):002:1> def hackety_hack | |
irb(main):003:2> proc do | |
irb(main):004:3* def hello | |
irb(main):005:4> 'hello' | |
irb(main):006:4> end | |
irb(main):007:3> end | |
irb(main):008:2> end | |
irb(main):009:1> end | |
=> :hackety_hack |
This file contains 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
# contracts_controller.rb | |
class ContractsController < ApplicationController | |
respond_to :html, :xls | |
# GET /contracts | |
# GET /contracts.json | |
def all | |
@contracts = Contract.all_items_i_can_view(current_user) | |
respond_to do |format| |
This file contains 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
authors = [ | |
%{ name: "Jose", langauge: "Elixir" }, | |
%{ name: "Matz", langauge: "Ruby" }, | |
%{ name: "Larry", language: "Perl" } | |
] | |
language_with_an_r = fn (:get, collection, next_fn) -> | |
for row <- collection do | |
if String.contains?(row.language, "r") do | |
next_fn.(row) |
This file contains 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
getConversation: function (id, endAt) { | |
if (endAt) { | |
return $firebase($fbCurrent.child('messages').child(id).endAt(null, endAt).limit(16)).$asArray(); | |
} else { | |
return $firebase($fbCurrent.child('messages').child(id)).$asArray(); | |
} | |
} |
This file contains 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
console.log($scope.accessRef.constructor.toString()); // => function Object() { [native code] } | |
console.log(Object.prototype.toString($scope.accessRef)); // => [object Object] |
This file contains 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
$ AWS_ACCESS_KEY=SOME_KEY AWS_SECRET_KEY=SOME_SECRET_KEY ansible -i ec2.py -u ubuntu us-east-1b -m ping | |
File "/home/waseem/Repositories/Learning/Ansible/ec2.py", line 168 | |
print data_to_print | |
^ | |
SyntaxError: invalid syntax | |
ERROR: failed to parse executable inventory script results: {'msg': '', 'failed': True, 'parsed': False} |
This file contains 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 ResourceArchiver | |
def archive_resource | |
@resource_downloader.download_resource # download_resource is already tested properly | |
@resource_downloader.archive # archive is already tested properly | |
upload_resource_archive # upload_resource_archive s already tested properly | |
end | |
end |
This file contains 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 | |
def update_password(params) | |
if authenticate(params['current_password']) | |
self.password = params['password'] | |
self.password_confirmation = params['password_confirmation'] | |
class << self | |
validates :password, length: { minimum: 6 } | |
end | |
!!save | |
else |