Skip to content

Instantly share code, notes, and snippets.

🕴
up

Saad saadbinakhlaq

🕴
up
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 Chrome iOS bug
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.body-container {
height: 1500px;
}
.navbar-fixed-top {
View keybase.md

Keybase proof

I hereby claim:

  • I am saadbinakhlaq on github.
  • I am saadbinakhlaq (https://keybase.io/saadbinakhlaq) on keybase.
  • I have a public key whose fingerprint is 2B7E 6109 4E94 B83D BC62 3902 F943 309E 2035 426C

To claim this, I am signing this object:

View database.yml.example mysql2
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
View gist:1d7cfa8013686869a957
(master)~/Projects/flask-sockets-tutorial$ gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker main:app
2014-05-12 17:50:28 [4666] [INFO] Starting gunicorn 18.0
2014-05-12 17:50:28 [4666] [INFO] Listening at: http://127.0.0.1:8000 (4666)
2014-05-12 17:50:28 [4666] [INFO] Using worker: socketio.sgunicorn.GeventSocketIOWorker
2014-05-12 17:50:28 [4670] [INFO] Booting worker with pid: 4670
* Restarting with reloader
2014-05-12 17:50:29 [4671] [INFO] Starting gunicorn 18.0
2014-05-12 17:50:29 [4671] [ERROR] Connection in use: ('127.0.0.1', 8000)
2014-05-12 17:50:29 [4671] [ERROR] Retrying in 1 second.
2014-05-12 17:50:30 [4671] [ERROR] Connection in use: ('127.0.0.1', 8000)
You can’t perform that action at this time.