Skip to content

Instantly share code, notes, and snippets.

💭
What's on my mind ?

Rajeev N Bharshetty rShetty

💭
What's on my mind ?
Block or report user

Report or block rShetty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kachayev
kachayev / concurrency-in-go.md
Last active Oct 30, 2019
Channels Are Not Enough or Why Pipelining Is Not That Easy
View concurrency-in-go.md
@blairanderson
blairanderson / DependencyInjectionInRuby.md
Last active Sep 5, 2019
Dependency Injection in Ruby. Originally from Jim Weirich’s blog which does not exist except for googles cache.
View DependencyInjectionInRuby.md

Dependency Injection in Ruby 07 Oct 04

Introduction

At the 2004 Ruby Conference, Jamis Buck had the unenviable task to explain Dependency Injection to a bunch of Ruby developers. First of all, Dependency Injection (DI) and Inversion of Control (IoC) is hard to explain, the benefits are subtle and the dynamic nature of Ruby make those benefits even more marginal. Furthermore examples using DI/IoC are either too simple (and don’t convey the usefulness) or too complex (and difficult to explain in the space of an article or presentation). I once attempted to explain DI/IoC to a room of Java programmers (see onestepback.org/articles/dependencyinjection/), so I can’t pass up trying to explain it to Ruby developers.

Thanks goes to Jamis Buck (the author of the Copland DI/IoC framework) who took the time to review this article and provide feedback.

What is Dependency Injection?

@staltz
staltz / introrx.md
Last active Nov 12, 2019
The introduction to Reactive Programming you've been missing
View introrx.md
@speric
speric / poodir-notes.md
Last active Oct 25, 2019
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz
View poodir-notes.md

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.
@dmichael
dmichael / httpclient.go
Last active Sep 17, 2019
Light wrapper for the Go http client adding (essential) timeouts for both connect and readwrite.
View httpclient.go
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@henrik
henrik / rules.md
Last active Jul 15, 2019
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
View rules.md
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active Nov 12, 2019
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
View delayed_job_matcher.rb
module DelayedJob
module Matchers
def enqueue_delayed_job(handler)
DelayedJobMatcher.new handler
end
class DelayedJobMatcher
def initialize(handler)
@handler = handler
@attributes = {}
View gist:3183650
Fork it, use it, break it, fix it,
Comm it, push it, pull - request it,
Fetch it, branch it, patch it, fake it,
Merge it, git: it, never - https: it.
Write it, cut it, paste it, save it,
Build it, check it, quick - rewrite it,
Clone it, crack it, crop it, comp it,
Drag and drop it, gzlib - gzip it.
View tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
You can’t perform that action at this time.