Skip to content

Instantly share code, notes, and snippets.

View mayuresh-srivastava's full-sized avatar
🏠
Working from home

Mayuresh Srivastava mayuresh-srivastava

🏠
Working from home
View GitHub Profile

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@mayuresh-srivastava
mayuresh-srivastava / Alphasights_technical_challenge.md
Created November 5, 2020 13:20 — forked from tadast/Alphasights_technical_challenge.md
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency.Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Update: I no longer work for the company and this challenge is no longer used, but I'll leave the gist here in case people want to practice.

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If Sasha is a friend of Ash, Ash is always a friend of Sasha as well.

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!

Cover Letter

My name is Ivo and I am an Italian agile software developer who loves coding and solving problems in a simple yet creative fashion. During my years of web development I have grown a strong passion for fronted development which led me to a good understanding of its underlaying technologies. I love hacking the hell out of web apps and getting a grasp of cutting edge technologies in order to keep up with time and deliver the best user experience possible.

While user experience still plays a big role in what I enjoy doing, I've learnt how important it is to write stable yet maintainable and scalable backend solutions. Even though I started out with PHP, I soon naturally came closer to the NodeJS environment while still embracing more "elegant" technologies such as Ruby or Java either adopting frameworks or by implementing architectures from scratch.

I discovered the Agile Manifesto and eXtreme Programming back while joining XPeppers in 2013 and I’ve tried my best to apply either values and prin

require 'benchmark'
N = 10_000_000
Benchmark.bmbm do |bm|
bm.report('String') do
N.times do
a = 'foobarfoobarhmm'
a.sub('foo', 'BAR')
end
@mayuresh-srivastava
mayuresh-srivastava / .gitattributes
Created August 10, 2018 18:10 — forked from tpope/.gitattributes
Fewer conflicts in your Rails apps
Gemfile.lock merge=bundlelock
db/schema.rb merge=railsschema
console.log("Start");
setTimeout(function(){
console.log("I am Insdie the TimeOut");
}, 3000);
console.log("Ends");
@mayuresh-srivastava
mayuresh-srivastava / string_boolean.rb
Last active October 7, 2016 22:09 — forked from equivalent/README.md
String "false" to_bool ... or how to convert Rails/SimpleForm radio buttons to boolean
module StringToBoolean
def to_bool
return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
class String; include StringToBoolean; end
module BooleanToBoolean
@mayuresh-srivastava
mayuresh-srivastava / default.css
Created October 5, 2016 06:42 — forked from anonymous/default.css
User Registration Widget CSS files.
/*------------------------------------*\
JANRAIN CAPTURE WIDGET DEFAULT.CSS
\*------------------------------------*/
/*
* Default.css acts as a base stylesheet for the capture widget which you can
* extend/modify with your own theme stylesheet.
*
* Default.css aims to set a baseline of styling and standard coloring to elements
* that could appear in your capture widget.
*
@mayuresh-srivastava
mayuresh-srivastava / pg_import_csv_to_heroku.sh
Created September 14, 2016 12:56 — forked from jboesch/pg_import_csv_to_heroku.sh
Importing a CSV dump of Postgres data into Heroku
# You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things".
"1", "Something", "0.50", "2013-05-05 10:00:00"
"2", "Another thing", "1.50", "2013-06-05 10:30:00"
# Now you want to import it, go to the command line and type:
$ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;"
# Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this: