This file contains hidden or 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
module MyAppEncryptor | |
app = Rails.application | |
config = app.config | |
# PBKDF2 with SHA-1 | |
key_generator = ActiveSupport::KeyGenerator.new(app.secrets[:secret_key_base], iterations: 1000) | |
secret = key_generator.generate_key(config.action_dispatch.encrypted_cookie_salt) | |
sign_secret = key_generator.generate_key(config.action_dispatch.encrypted_signed_cookie_salt) |
This file contains hidden or 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 CreateMerchantUniqIdGens < ActiveRecord::Migration | |
def change | |
create_table :merchant_uniq_id_gens do |t| | |
t.integer :count, :null => false | |
end | |
# Set initial count to 100 | |
single_row = MerchantUniqIdGen.new | |
single_row.count = 100 | |
single_row.save! |
This file contains hidden or 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
wget --mirror -p --convert-links -P ./ <<site>> |
This file contains hidden or 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
### Method 1 | |
gem install oauth2 | |
require 'oauth2' | |
client = OAuth2::Client.new(GOOGLE_KEY, GOOGLE_SECRET, {:site => 'https://accounts.google.com', :authorize_url => "/o/oauth2/auth", :token_url => "/o/oauth2/token"}) | |
response = OAuth2::AccessToken.from_hash(client, :refresh_token => REFRESH_TOKEN).refresh! |
This file contains hidden or 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
//manifest.json | |
{ | |
"name": "bookmark-search-export", | |
"version": "1.0", | |
"manifest_version": 2, | |
"description": "This extention will dump all bookmarks", | |
"browser_action": { | |
"default_icon": "icon.png" | |
}, | |
"background": { |
This file contains hidden or 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
# change shell to bash | |
export SHELL=/bin/bash | |
# install mysql lib | |
sudo apt-get install libmysqlclient-dev | |
# install openssl & dev files | |
sudo apt-get install libssl-dev openssl | |
# install smb client libs |
This file contains hidden or 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
How to configure timezone in Rails | |
==================================== | |
Database table didn't care about timezone's. It just preserves datetime data. | |
Hence it is up to (Rails) applications to manage timezone's. | |
Rails application needs to manage timezone in two ways via configuration - config/application.rb | |
(See http://guides.rubyonrails.org/configuring.html for more details), | |
1. While storing data in DB, which TZ to use | |
> Allows us to use only :local or :utc TZ's |
This file contains hidden or 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
####### Machine A ########### | |
# create package index file | |
cd /var/cache/apt/archives/ | |
dpkg-scanpackages . /dev/null | gzip -c -9 > Packages.gz | |
# start mongoose (code.google.com/p/mongoose) / any webserver with document root as "/var/cache/apt/archives/" | |
mongoose -r /var/cache/apt/archives/ | |
####### Machine B ########### | |
# edit " /etc/apt/sources.list" |
This file contains hidden or 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
logger = Logger.new(File.join( Rails.root, "log", "my_#{ Rails.env}.log"), 'daily') | |
logger.level = Logger::INFO | |
logger.formatter = proc do |severity, datetime, progname, msg| | |
"#{datetime.strftime("%B %d %H:%M:%S")} #{Socket.gethostname}, [#{$$}]:, #{severity} MY_WEBAPP, #{msg}\n" | |
end | |
tag_log = ActiveSupport::TaggedLogging.new(logger) | |
config.logger = tag_log | |
# above code will produce log in format as shown below, |
This file contains hidden or 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
apt-get install dictd | |
apt-get install dict-gcide | |
apt-get install dict-moby-thesaurus | |
"Application -> Office -> Dictionary -> Edit –> Preference -> Add" | |
Description : <<Your description>> | |
Transport : Dictionary Server | |
Hostname : 127.0.0.1 | |
Port : 2628 |