Skip to content

Instantly share code, notes, and snippets.

View iaintshine's full-sized avatar

Boguslaw Mista iaintshine

View GitHub Profile
@iaintshine
iaintshine / unwatch-gh-org.js
Created January 31, 2019 06:46 — forked from offirgolan/unwatch-gh-org.js
Unwatch All Org Repos
// Navigate to https://github.com/watching and then run:
// Taken from: https://stackoverflow.com/questions/11043374/how-to-unwatch-multiple-repos-easily-on-github
Array.prototype
.slice.apply(document.querySelectorAll('.js-subscription-row'))
.forEach(el => { const org = el.querySelector('a[href^="/YOUR_ORG"]'); if (org) el.querySelector('button').click()});
@iaintshine
iaintshine / akka-default.conf
Created November 2, 2017 13:17
Akka 2.5 default config
####################################
# Akka Actor Reference Config File #
####################################
# This is the reference config file that contains all the default settings.
# Make your edits/overrides in your application.conf.
# Akka version, checked against the runtime version of Akka. Loaded from generated conf file.
include "version"
@iaintshine
iaintshine / docker_compose.rb
Created October 30, 2017 13:26
Use docker-compose in Ruby tests
module Docker::Compose
class Session
def wait(timeout = 10)
Timeout.timeout(timeout) do
loop do
containers = ps
return if containers
.map { |container| running?(container.id) }
.all?
end
@iaintshine
iaintshine / coalesce.java
Created September 15, 2017 21:15
coalesce with functional interface
private Long coalesce(Map<String, Object> payload, Function<Map<String, Object>, Long>... fs) {
return Arrays.stream(fs)
.map(f -> f.apply(payload))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
}
@iaintshine
iaintshine / GracefulStop.java
Created September 5, 2017 13:17
Graceful Stop example in akkka
long timeout = 5L;
try {
// https://petabridge.com/blog/how-to-stop-an-actor-akkadotnet/
// http://doc.akka.io/docs/akka/current/java/actors.html - "Graceful Stop"
//
// I don't specify stopMessage as by default it's PoisonPill, I want the processing of messages to be finished
// by the target actor.
CompletionStage<Boolean> stopped = gracefulStop(queueActor, Duration.create(5, TimeUnit.SECONDS));
stopped.toCompletableFuture().get(timeout + 1, TimeUnit.SECONDS);
@iaintshine
iaintshine / active_span.rb
Last active August 2, 2017 22:48
Ruby OpenTracing current span propagation proposal
class ActiveSpan
def span
end
# Mark the end of the active period for the ActiveSpan
def deactivate
end
end
@iaintshine
iaintshine / service-checklist.md
Created September 12, 2016 19:25 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@iaintshine
iaintshine / latency.markdown
Created February 12, 2016 17:00 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@iaintshine
iaintshine / custom_fields_filtering.rb
Created September 16, 2015 18:46
BaseCRM Ruby gem - sample code that shows how to filter by custom field value
require 'bundler'
Bundler.setup
require 'logger'
require 'basecrm'
access_token = "BASECRM_ACCESS_TOKEN"
client = BaseCRM::Client.new(access_token: access_token,
verbose: true,
@iaintshine
iaintshine / john_leads.sh
Created July 3, 2015 13:43
Fetch all leads from Base with name John and sort by external id custom fields and pretty print useful information
curl -X GET "https://api.getbase.com/v2/leads?first_name=john&sort_by=custom_fields:number:desc" -H "Authorization: Bearer $BASECRM_ACCESS_TOKEN" -g -v | python -mjson.tool | jq '[{name: .items[].data.first_name, custom_fields: .items[].data.custom_fields}]'