Skip to content

Instantly share code, notes, and snippets.

View deepakdargade's full-sized avatar
🎯
Focusing

Deepak Dargade deepakdargade

🎯
Focusing
View GitHub Profile
@deepakdargade
deepakdargade / sidekiq.service
Created January 29, 2019 05:32
Systemd service file for Sidekiq
#
# 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
@deepakdargade
deepakdargade / array.rb
Last active February 25, 2017 13:24 — forked from revathskumar/array.rb
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.
@deepakdargade
deepakdargade / ruby-tricks
Created November 12, 2015 11:05
10 Ruby Tricks to Make Your Code Nearly Perfect
#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:
@deepakdargade
deepakdargade / wordpress php permission issue
Created October 3, 2015 07:36
wordpress php permission issue
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
"%g" % ("%0.2f" % 16.4555)
@deepakdargade
deepakdargade / morris.js
Created February 21, 2014 14:11
Morris js - line chart example
#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 },
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
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]),
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
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