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
# Access number | |
cat production.log | grep "^Processing" | wc | awk '{print $1}' | |
# Each IP access number | |
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq -c | |
# Independent IP number | |
cat production.log | grep "^Processing" | awk '{print $4}' | uniq | wc | awk '{print $1}' | |
cat production.log | grep “^Processing” | awk ‘{print $4}’ | uniq | wc -l |
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
# gems | |
gem 'google-api-client' | |
gem 'signet' | |
# Rails.root/config/initializers/google_api_client.rb | |
require 'google/api_client' | |
require 'google/api_client/client_secrets' | |
require 'google/api_client/auth/installed_app' | |
$google_api_client = Google::APIClient.new( | |
:application_name => 'Example for Google API client', |
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
# References | |
# http://stackoverflow.com/questions/6115612/how-to-convert-an-entire-mysql-database-characterset-and-collation-to-utf-8 | |
# http://www.a2hosting.com/kb/developer-corner/mysql/convert-mysql-database-utf-8 | |
ALTER DATABASE [DB-NAME] CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
ALTER TABLE [TABLE-NAME] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; | |
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
::-webkit-input-placeholder { | |
color: black; | |
} | |
:-moz-placeholder { /* Firefox 18- */ | |
color: black; | |
} | |
::-moz-placeholder { /* Firefox 19+ */ | |
color: black; |
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
# Refs: http://stackoverflow.com/questions/7527887/validate-image-size-in-carrierwave-uploader | |
class ImageSizeValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
unless value.blank? | |
image = MiniMagick::Image.open(value.path) | |
checks = [ | |
{ :option => :width, | |
:field => :width, |
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
# Only upper case alphabets [A-Z] | |
value = ""; | |
8.times{value << (65 + rand(25)).chr} >>} | |
#or | |
(0...8).map{65.+(rand(26)).chr}.join | |
(0...8).map{ ('A'..'Z').to_a[rand(26)] }.join | |
# Lower case and upper case [a-zA-Z] | |
value = ""; | |
8.times{value << ((rand(2)==1?65:97) + rand(25)).chr} >>} |
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
<!--Normal CSS selector name--> | |
<div class="here-is-a-css-class-name"> | |
.... | |
</div> | |
<!--Noram JS selector name(CSS selector with prefix 'js-') to To avoid the javascript code was thrown error --> | |
<div class="js-action-name"> | |
.... | |
</div> | |
<!--Both CSS selector and JS selector work together--> | |
<div class="style-class-name js-action-name"> |
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
# .powenv | |
export BYEBUGPORT=3001 | |
# config/initializers/byebug.rb | |
if Rails.env.development? and ENV['BYEBUGPORT'] | |
require 'byebug' | |
Byebug.start_server 'localhost', ENV['BYEBUGPORT'].to_i | |
end | |
# restart Pow process |
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
# Big thank you to Scott Wheeler and BBG in the Shopify API Forums | |
# http://ecommerce.shopify.com/c/shopify-apis-and-technology/t/paginate-api-results-113066 | |
module ShopifyAPI | |
class Base | |
RETRY_AFTER = 60 | |
def self.find_all(params = {}, &block) | |
params[:limit] ||= 50 | |
params[:page] = 1 |
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
desc "Database related tasks" | |
namespace :database do | |
desc "Convert to utf8mb4" | |
task convert_to_utf8mb4: :environment do | |
connection = ActiveRecord::Base.connection | |
database = connection.current_database | |
connection.execute "ALTER DATABASE #{database} CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;" | |
puts "Converted #{database} character set" |