Skip to content

Instantly share code, notes, and snippets.

@amit352
amit352 / rubymethodlookup.md
Created July 30, 2017 03:09 — forked from damien-roche/rubymethodlookup.md
A Primer on Ruby Method Lookup

A Primer on Ruby Method Lookup

Method lookup is a simple affair in most languages without multiple inheritance. You start from the receiver and move up the ancestors chain until you locate the method. Because Ruby allows you to mix in modules and extend singleton classes at runtime, this is an entirely different affair.

I will not build contrived code to exemplify the more complicated aspects of Ruby method lookup, as this will only serve to confuse the matter. If you are having trouble following method lookup in your own programs, it is not because Ruby has strange rules (it does), it is because your code is too tangled.

When you pass a message to an object, here is how Ruby finds what method to call:

1. Look within singleton class

@amit352
amit352 / Vagrantfile
Created November 22, 2017 03:20 — forked from ganine/Vagrantfile
Basic Vagrantfile with provisioning shell script
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.provision :shell, :privileged => false, :path => "bootstrap_ubuntu1204.sh"
end
@amit352
amit352 / Vagrantfile
Created November 22, 2017 03:20 — forked from ganine/Vagrantfile
Basic Vagrantfile with provisioning shell script
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.provision :shell, :privileged => false, :path => "bootstrap_ubuntu1204.sh"
end
@amit352
amit352 / gist:81d541a601126b6be999df5e467c3ebc
Created January 13, 2018 13:27 — forked from crazed/gist:7670423
getting a moto x back to stock on mac os x
  1. grab the moto-fastboot version of fastboot here

  2. grab the appropriate stock firmware here (tip: you want the one that matches your android build number in settings -> about phone)

  3. unzip this file somewhere and make it easy to run the moto-fastboot-osx64 command from step 1

  4. get your phone into fastboot mode, google it if needed but just power the phone off, hold the down volume key and power button for 3 seconds then let go, should get you there

  5. verify you are ready for flashing:

     ./moto-fastboot-osx64 devices
     -- should list a device --
    
  6. most of the time you just need to flash system and recovery images, so from your unzipped stock firmware files do this:

@amit352
amit352 / System Design.md
Created October 6, 2018 04:43 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@amit352
amit352 / new_mac.md
Created February 17, 2019 02:30 — forked from mikedijkstra/new_mac.md
How to setup a new mac for Ruby on Rails development with MongoDB, Imagemagick and POW

Makre sure your home directory does not have a space in it or gcc will crap itself

1. Download and install Xcode

2. Install Command Line Tools (Xcode > Preference > Downloads)

4. Install Git

$ brew install git

@amit352
amit352 / tc.rb
Created June 16, 2019 07:46 — forked from chikadance/tc.rb
ruby: tcp socket sample(input line must end with \n)
#!/usr/bin/env ruby
# socket example - client side
# usage: ruby clnt.rb [host] port
require "socket"
if ARGV.length >= 2
host = ARGV.shift
else
@amit352
amit352 / nginx-tuning.md
Created September 4, 2019 08:52 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.