- How to generate a QR code with ruby script
require 'rqrcode'
# qrcode = RQRCode::QRCode.new("mailto:<[email protected]>?query")
qrcode = RQRCode::QRCode.new("")
png = qrcode.as_png(
bit_depth: 1,
border_modules: 4,| # Traversing arrays and objects in CoffeeScript | |
| # The array and object we use for testing | |
| arr = [1, 2, 3, 4, 5] | |
| obj = {a: 1, b: 2, c: 3, d: 4, e: 5} | |
| # 'in' has a different meaning in CoffeeScript than in JavaScript | |
| # CS: element in array -> JS: array.indexOf(element) >= 0 | |
| console.log '5 in arr: ' + (5 in arr) |
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
require 'rqrcode'
# qrcode = RQRCode::QRCode.new("mailto:<[email protected]>?query")
qrcode = RQRCode::QRCode.new("")
png = qrcode.as_png(
bit_depth: 1,
border_modules: 4, alias deploy='deploy_webport_to_qa'
function deploy_webport_to_qa {
BRANCH=$1
if [ "$BRANCH" = "" ]; then
BRANCH=$(git branch --show-current)
echo "No branch specified."
echo "Using currently checked out: $BRANCH"echo "Press enter to continue or ctl-c to quit"
| # mysql db backup and restore for rails | |
| # by David Lowenfels <[email protected]> 4/2011 | |
| require 'yaml' | |
| namespace :db do | |
| def backup_prep | |
| @directory = File.join(RAILS_ROOT, 'db', 'backup') | |
| @db = YAML::load( File.open( File.join(RAILS_ROOT, 'config', 'database.yml') ) )[ RAILS_ENV ] | |
| @db_params = "-u #{@db['username']} #{@db['database']}" |
| #1===========First code================ | |
| #!/usr/bin/env ruby | |
| databases = { | |
| :local_db => { | |
| :database => 'my_db', | |
| :username => 'root', | |
| :password => 'admin', | |
| :host => 'localhost' |
| // Error Codes for SignUp | |
| ERROR_OPERATION_NOT_ALLOWED` - Indicates that Anonymous accounts are not enabled. | |
| ERROR_WEAK_PASSWORD - If the password is not strong enough. | |
| ERROR_INVALID_EMAIL` - If the email address is malformed. | |
| ERROR_EMAIL_ALREADY_IN_USE - If the email is already in use by a different account. | |
| ERROR_INVALID_CREDENTIAL` - If the [email] address is malformed. | |
| // sending password reset email | |
| ERROR_INVALID_EMAIL` - If the [email] address is malformed. |
| # About Aliases: | |
| alias ls='ls --color=auto -F' | |
| alias grep='grep --color=auto' | |
| alias fgrep='fgrep --color=auto' | |
| alias egrep='egrep --color=auto' | |
| alias ll='ls -alF' | |
| alias la='ls -A' | |
| alias l='ls -CF' | |
| alias less="less -R " |
| # | |
| # Sidekiq auto start using systemd unit file for Ubuntu 16.04 | |
| # | |
| # Put this in /lib/systemd/system (Ubuntu). | |
| # Run: | |
| # 1. systemctl enable sidekiq (to enable sidekiq service) | |
| # 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service) | |
| # | |
| # This file corresponds to a single Sidekiq process. Add multiple copies | |
| # to run multiple processes (sidekiq-1, sidekiq-2, etc). |