This file contains 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
# | |
# systemd unit file for Ubuntu 16.04 | |
# | |
# Customize this file based on your bundler location, app directory, etc. | |
# Put this in /lib/systemd/system (Ubuntu). | |
# Run: | |
# - systemctl enable sidekiq | |
# - systemctl {start,stop,restart} sidekiq | |
# | |
# This file corresponds to a single Sidekiq process. Add multiple copies |
This file contains 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
template = "Price of the %s is Rs. %f." | |
# %s - string, %f - float and %d - integer | |
p template % ["apple", 70.00] | |
# prints Price of the apple is Rs. 70.000000. |
This file contains 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
#http://www.queness.com/post/17464/10-ruby-tricks-to-make-your-code-nearly-perfect | |
Ruby is awesome! If you think it’s not, you just haven’t got an opportunity to explore the simplicity, elegance and power of Ruby. | |
A lot of web services and enterprise level platforms use Ruby. Which ones? Twitter, Shopify, Crunchbase, Groupon. What about software? Top orchestrators - Puppet and Chef - are written in Ruby. Millions of user and thousands of developers love this language. And to love it even more, let’s go through some tips and tricks that will make your Ruby code beautiful. Here are tricks provided by Ruby on Rails develompent company RW. | |
1. Organize your list of values into a hash | |
Say, you have a list of values, and to make it easy to process them, why not create a hash? The syntax is pretty straightforward - Hash[...]. Here’s a short example: |
This file contains 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
http://websistent.com/fix-connect-to-php5-fpm-sock-failed-13-permission-denied-while-connecting-to-upstream-nginx-error/ | |
How to fix connect() to php5-fpm.sock failed (13: Permission denied) while connecting to upstream Nginx error | |
October 11, 2014 Web Servers Jesin A 2 Comments | |
nginx php5 fpm socket permission denied thumbnail |
This file contains 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
"%g" % ("%0.2f" % 16.4555) |
This file contains 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
#JS Code | |
#The morris graph expects this type of data for multiple lines | |
Morris.Line({ | |
element: 'line-example', | |
data: [ | |
{ y: '2006', a: 100, b: 90 }, | |
{ y: '2007', a: 75, b: 65 }, | |
{ y: '2008', a: 50, b: 40 }, | |
{ y: '2009', a: 75, b: 65 }, |
This file contains 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 "Log in to the Gmail account and cleanse anyone who appears to have bounced" | |
task :handle_bounces => :environment do | |
require 'gmail' | |
# Open a connection using your default smtp settings, could also define via YML or inline | |
gmail = Gmail.connect!(ActionMailer::Base.smtp_settings[:user_name], ActionMailer::Base.smtp_settings[:password]) | |
# Find everything from the Gmail mailer daemon (unread only) | |
emails = gmail.inbox.emails(:unread, :from => "mailer-daemon@googlemail.com", :subject => "Delivery Status Notification (Failure)") | |
Rails.logger.info("Found #{emails.length} messages") | |
emails.each do |email| | |
# Gmail sets a header "X-Failed-Recipients", with each email that failed |
This file contains 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 ContactForm < MailForm::Base | |
attribute :name, :validate => true | |
attribute :nickname, :captcha => true | |
attribute :email, :validate => /[^@]+@[^\.]+\.[\w\.\-]+/ | |
attribute :message, :validate => true | |
def headers | |
origin = "#{name} <#{email}>" | |
return :subject => ::I18n.t(:subject, :scope => [:actionmailer, :contact_form]), |
This file contains 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 User < ActiveRecord::Base | |
has_one :photo, :dependent => :destroy | |
accepts_nested_attributes_for :photo, :allow_destroy => true | |
end | |
#using paperclip gem for user's images | |
class Photo < ActiveRecord::Base | |
belongs_to :user |
This file contains 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
cd ~ | |
sudo apt-get update | |
sudo apt-get install unzip curl python-software-properties -y | |
#sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" | |
sudo add-apt-repository ppa:ferramroberto/java | |
sudo apt-get update | |
sudo apt-get install sun-java6-jre sun-java6-plugin -y | |
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz |
NewerOlder