Skip to content

Instantly share code, notes, and snippets.

@dry1lud
dry1lud / combine-retry.md
Last active November 27, 2023 10:07
Retry operation in Swift/Combine.

There is a function .retry() in Combine that helps to retry a request. Although it is not enough just to call retry() to achieve retring logic. The retry() function does not do another request but it re-subscribes only to a publisher. To make another request the tryCatch() might be used. In the code below if the first call fails there are three attempts to retry (retry(3)):

import UIKit
import Combine
import PlaygroundSupport

enum CustomNetworkingError: Error {
    case invalidServerResponse
}
@dastergon
dastergon / ec2_info_retriever.py
Last active October 11, 2024 16:44
A basic boto3 based tool for retrieving information from running EC2 instances.
from collections import defaultdict
import boto3
"""
A tool for retrieving basic information from the running EC2 instances.
"""
# Connect to EC2
ec2 = boto3.resource('ec2')

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

anonymous
anonymous / cracker.py
Created October 9, 2013 04:40
import hashlib
import timeit
from random import randint
def hashx(x):
m = hashlib.sha1()
m.update(x)
return m.digest()
@RajivKurian
RajivKurian / Image processing pipeline
Last active December 23, 2015 11:59
Image processing application outline. Either Java + JNI or C++.
THREAD A.
while (1) {
long oldThreadBSequence = 0
int n = epoll_wait(epfd, events, MAXEVENTS, timeOut = 0) // timeOut = 0 means no waiting.
// Any equivalent for Netty? So far I have only seen callbacks.
for (int i = 0; i < n ; i ++) {
if (event is of type connection) {
int infd = acceptConnection()
makeSocetNonBlocking(infd)
Store this connection in a an object in a map.
@pbailis
pbailis / gist:5660980
Last active April 27, 2020 11:46
Assorted distributed database readings

Context: I was asked for a list of interesting reading relating to "distributed databases, behavior under partitions and failures, failure detection." Here's what I came up with in about an hour.

For textbooks, "Introduction to Reliable and Secure Distributed Programming" is a superb introduction to distributed computing from a formal perspective; it's really not about "programming" or "engineering" but about distributed system fundamentals like consensus, distributed registers, and broadcast. Used in Berkeley's Distributed Computing course (and HT to @lalithsuresh) Book Site

Notes from courses like Lorenzo Alvisi's Distributed Computing class can be great.

There are a bunch of classics on causality, [Paxos](ht

@codahale
codahale / SetBenchmark.java
Created April 3, 2013 18:49
An example of how to use Caliper: http://code.google.com/p/caliper/.
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import java.util.HashSet;
import java.util.TreeSet;
public class SetBenchmark extends SimpleBenchmark {
// If you add a main function, you can run it from your IDE.
public static void main(String[] args) throws Exception {
new Runner().run(
#lang r5rs
(define-syntax var
(syntax-rules ()
((_ x) (vector x))))
(define-syntax var?
(syntax-rules ()
((_ x) (vector? x))))
@akaptur
akaptur / gist:3836483
Created October 4, 2012 21:10
.bashrc settings
alias git=hub
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
# START:prefix
set -g prefix C-a
# END:prefix
# Free the original Ctrl-b prefix keybinding
# START:unbind
unbind C-b
# END:unbind