Skip to content

Instantly share code, notes, and snippets.

View rShetty's full-sized avatar
💭
What's on my mind ?

Rajeev N Bharshetty rShetty

💭
What's on my mind ?
View GitHub Profile

Keybase proof

I hereby claim:

  • I am rshetty on github.
  • I am rshetty (https://keybase.io/rshetty) on keybase.
  • I have a public key ASDyxj9eOv84wdGTljH8c1eCr7Y9JjyzQe5yr0oQctRuOwo

To claim this, I am signing this object:

@rShetty
rShetty / cb.go
Last active March 15, 2018 07:23
Circuit breakers
config := heimdall.HystrixCommandConfig{
MaxConcurrentRequests: 100,
ErrorPercentThreshold: 25,
SleepWindow: 10,
RequestVolumeThreshold: 10,
}
hystrixConfig := heimdall.NewHystrixConfig(“MyCommand”, config)
timeout := 10 * time.Millisecond
@rShetty
rShetty / retry.go
Created March 15, 2018 07:21
Retries
backoff := heimdall.NewConstantBackoff(500)
retrier := heimdall.NewRetrier(backoff)
httpClient := heimdall.NewHTTPClient(1 * time.Millisecond)
httpClient.SetRetrier(retrier)
httpClient.SetRetryCount(3)
httpClient.Get(“https://gojek.com/drivers", http.Header{})
@rShetty
rShetty / timeout.go
Created March 15, 2018 07:19
timeouts
httpClient := heimdall.NewHTTPClient(1 * time.Millisecond)
_, err := httpClient.Get(“https://gojek.com/drivers", http.Header{})
@rShetty
rShetty / weighted-distribution.go
Created February 27, 2018 14:41
Weighted Distribution across servers
package main
import (
"container/heap"
"fmt"
)
type Server struct {
name string
priority int
Blackjack is a popular card game played against a Dealer. In this card game the Player is trying to beat the Dealer.
Deck:
The game is played with 4 or more decks containing 52 distinct cards in each (Face values : A, 2-9, J, Q and K; Suits : D,C,S,H)
The entire deck is shuffled before the start of the game.
Beginning:
Player and Dealer are initially dealt 2 cards each. Only one of the Dealer's cards is visible to the Player, the other is hidden. All the cards of the Player are visible to everyone at all times.
Turns:
@rShetty
rShetty / on-jsx.markdown
Created March 9, 2016 04:56 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@rShetty
rShetty / exception_heirarchy.rb
Created March 27, 2015 05:27
Exception Heirarchy
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
next if cls.superclass == SystemCallError # avoid dumping Errno's
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}
end
@rShetty
rShetty / gist:b2d8084f417d269d296f
Created March 18, 2015 02:23
include? vs cover?
require 'benchmark/ips'
Benchmark.ips do |x|
x.config(:time => 5, :warmup => 2)
x.time = 5
x.warmup = 2
no_of_times = 1_000_000
last_value = 10000
@rShetty
rShetty / gist:d9a15645697aa2632037
Last active August 29, 2015 14:16
Benchmark IPS
require 'benchmark/ips'
Benchmark.ips do |x|
x.config(:time => 5, :warmup => 2)
x.time = 5
x.warmup = 2
times = 10000