Skip to content

Instantly share code, notes, and snippets.

View zerothabhishek's full-sized avatar

Abhishek Yadav zerothabhishek

View GitHub Profile
@zerothabhishek
zerothabhishek / read-times-large-values.markdown
Last active January 18, 2017 04:40
read times for large key values - Memcache and Redis

Memcache

Server: Ubuntu 16.04.1
Client: Ubuntu 16.04.1, Ruby 2.3 client (Dalli)
Memcache version: 1.4.25
Config changes:

  • Changed bind setting to allow external connections

Client code:

@zerothabhishek
zerothabhishek / partial-calculator.rb
Last active June 23, 2016 12:15
The partial calculator problem I used in interviews
#
# We have something called a PartialCalculator in the code
# for calculating some health related parameters.
#
# The PartialCalculator works like this -
#
# - take an input hash
# - merge the given data with some standard values
# - calls a FullCalculator with the values (in the overall method)
#
@zerothabhishek
zerothabhishek / agenda.md
Last active July 10, 2016 05:03
FizzBuzz Agenda

The workshop shall be a series of lectures and coding sessions (mentioned as Practical here)

Session-1: Basics

  • Lecture:
    • variables
    • Branching
    • puts, p
    • Define a method
  • IRB
@zerothabhishek
zerothabhishek / db.rake
Created May 11, 2016 05:35 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@zerothabhishek
zerothabhishek / git-process.md
Last active March 25, 2016 17:56
A git process I like

A Git process

  • Developer creates a new branch for every bug-fix or feature
  • Feature branch is always created from master
  • Developer watches master branch for changes. If another team member updates the master, she updates feature branch too.
  • Feature branches are updated using rebase, not by merging
  • Developer deploys the feature branch for demo/QA
  • Another team member reviews code in the feature branch
  • After demo and review passes, developer squash-merges the feature branch in her master, and pushes to the origin master
  • For production-deployment, developer sets a tag on the origin/master, and deploys using the tag
@zerothabhishek
zerothabhishek / nov-minutes.md
Created December 1, 2015 10:06
Minutes of November meet-up

The November 2015 meetup was held at the Postmark office on 21st. Here are some pictures.

The meet-up began with an introductory talk about the host company by Mithin. After that we went into the first talk, Speed up Mongo, by Gaurav Shah. The talk was about various lessons learned about Mongo performance in production. The talk also spawned many minor discussions via which we went into some other nitty-gritties of Mongo-Db. The slides are worth a look if you are planning to use Mongo for a project, and are curious about scaling.

The second talk was on Fraud Detection and Prevention in Ecommerce by Ketan Jain. This talk was about the many techniques that Postmark and similar companies apply to check fraud. An interesting and relatable talk, as many scenarios discussed are applicable in In

@zerothabhishek
zerothabhishek / explain-join-2.sql
Last active December 1, 2015 03:19
Explain Join with indexes
EXPLAIN
SELECT posts.*, comments.*
FROM posts LEFT JOIN comments
ON posts.id = comments.post_id;
# Before adding indexes
QUERY PLAN
------------------------------------------------------------------------
Hash Right Join (cost=394.50..2589.00 rows=50000 width=150)
@zerothabhishek
zerothabhishek / explain-join-1.sql
Last active December 1, 2015 03:21
Sql left Join
SELECT posts.*, comments.*
FROM posts LEFT JOIN comments
ON posts.id = comments.post_id;
Confreaks:
http://confreaks.tv/videos/larubyconf2013-refactoring-fat-models-with-patterns
http://confreaks.tv/videos/railsconf2015-nothing-is-something
http://confreaks.tv/videos/railsconf2012-ten-things-you-didn-t-know-rails-could-do
http://confreaks.tv/videos/burlingtonruby2014-breaking-up-with-the-asset-pipeline
http://confreaks.tv/videos/railsconf2015-docker-isn-t-just-for-deployment
http://confreaks.tv/videos/rubyconf2014-enumerable-for-fun-profit
http://confreaks.tv/videos/rubymanor3-programming-with-nothing
@zerothabhishek
zerothabhishek / gist:bba03d4a28977d17284d
Last active August 29, 2015 14:17
ruby-case-when-with-lambda
def foo(x)
case x
when 10 then 'The number Ten'
when String then 'A String'
when lambda{|x| x%2==1 } then 'An odd number'
when (1..9) then 'In range'
end
end