Skip to content

Instantly share code, notes, and snippets.

🕴
up

Saad saadbinakhlaq

🕴
up
  • Berlin
Block or report user

Report or block saadbinakhlaq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mongoid.rb
module BSON
class ObjectId
def to_json(*args)
to_s.to_json
end
def as_json(*args)
to_s.as_json
end
end
View kv_spec.rb
require 'spec_helper'
describe KV do
describe '#set' do
it 'assigns a value to the instance variable hash' do
kv = KV.new
kv.set('foo', 'bar')
expect(kv.hash['foo'][Time.now.to_i]).to eq('bar')
end
end
View kv.rb
Dir[File.dirname(__FILE__) + '/application/*.rb'].each { |file| require file }
class KV
attr_reader :hash
def initialize
@hash = Hash.new { |h, k| h[k] = {} }
end
def set(key, value)
@hash[key][Time.now.to_i] = value
@saadbinakhlaq
saadbinakhlaq / attachment.rb
Created May 21, 2016 — forked from madwork/attachment.rb
Polymorphic attachments with CarrierWave and nested_attributes
View attachment.rb
class Attachment < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
# Associations
belongs_to :attached_item, polymorphic: true
# Validations
validates_presence_of :attachment
View gist:8062345
<Response>
<GetDigits action="http://example.com/get_digits_test/" method="GET">
<Speak>Please enter your 4-digit pin number, followed by the hash key</Speak>
</GetDigits>
<Speak>Input not received. Thank you</Speak>
</Response>
View gist:8062371
app.route('/get_digits/', methods=['GET'])
def get_digits():
if not digits:
res = plivo.Response()
get_digits = plivo.GetDigits(action='http://162.209.56.40:5006/get_digits_test/
method='GET')
get_digits.addSpeak(body='Press one for sales, press two for support')
res.add(get_digits)
return Response(str(res), mimetype='text/xml')
elif digits == '1':
View gist:6443879
>>> class Parent(object):
... def __init__(self, name, age):
... self.name = name
... self.age = age
... def rep(self):
... print self.name
... print self.age
>>> class Child(Parent):
View Chrome iOS bug
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.body-container {
height: 1500px;
}
.navbar-fixed-top {
You can’t perform that action at this time.