Skip to content

Instantly share code, notes, and snippets.

View agseco's full-sized avatar

Alejandro Garcia Seco agseco

View GitHub Profile
package com.yourproject.datastructures;
import java.io.*;
import java.util.*;
import java.util.function.Consumer;
/**
* Disk-backed array list
* @param <E> element type
*/
@jivimberg
jivimberg / CoroutinesUtils.kt
Last active October 11, 2023 00:16
SQS Consumer using Kotlin coroutines and pool of workers.
package com.jivimberg.sqs.published
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.yield
import java.lang.Thread.currentThread
suspend fun CoroutineScope.repeatUntilCancelled(block: suspend () -> Unit) {
while (isActive) {
@gvolpe
gvolpe / di-in-fp.md
Last active July 14, 2024 23:25
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
@sylvainleris
sylvainleris / MiddlewareES6.js
Last active March 16, 2023 12:42 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
class Middleware {
constructor() {
// Array prototype last
if (!Array.prototype.last) {
Array.prototype.last = function() {
return this[this.length - 1];
}
}
package my.netty.http.upload;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.HttpRequestDecoder;
@zerda
zerda / .gitlab-ci.yml
Last active October 8, 2020 04:05
Gitlab CI for spring boot project
image: maven:3.3-jdk-8-alpine
cache:
key: "$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME"
paths:
- .m2/
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2"
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@vasanthk
vasanthk / System Design.md
Last active July 15, 2024 10:23
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?
@briceburg
briceburg / AppServiceProvider.php
Last active July 20, 2019 07:55
laravel 5 - configuring minimal log level
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Log;
use Config;
class AppServiceProvider extends ServiceProvider
{
@transitive-bullshit
transitive-bullshit / logger.js
Last active July 9, 2024 04:09
winston logger with filename:linenumber
// NOTE: this adds a filename and line number to winston's output
// Example output: 'info (routes/index.js:34) GET 200 /index'
var winston = require('winston')
var path = require('path')
var PROJECT_ROOT = path.join(__dirname, '..')
var logger = new winston.logger({ ... })
// this allows winston to handle output from express' morgan middleware