Skip to content

Instantly share code, notes, and snippets.

@waseem
waseem / example.rb
Last active August 29, 2015 14:07 — forked from anonymous/example.rb
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
@waseem
waseem / cats.rb
Last active August 29, 2015 14:07
def cats_text(count = 0)
return "Cats (" + count.to_s + ")" if count > 1
"Cats"
end
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
# 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|
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)
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();
}
}
console.log($scope.accessRef.constructor.toString()); // => function Object() { [native code] }
console.log(Object.prototype.toString($scope.accessRef)); // => [object Object]
$ 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}
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
@waseem
waseem / user.rb
Last active August 29, 2015 13:57
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