Skip to content

Instantly share code, notes, and snippets.

View agaro1121's full-sized avatar

Anthony Garo agaro1121

View GitHub Profile
@agaro1121
agaro1121 / Mac SSH Autocomplete
Created February 24, 2017 16:38 — forked from aliang/Mac SSH Autocomplete
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@agaro1121
agaro1121 / ParentChild.scala
Created May 24, 2017 23:50 — forked from archie/ParentChild.scala
Examples of testing Akka actor parent-child relationships, mostly based on findings from https://www.assembla.com/spaces/akka/tickets/3043#/activity/ticket:
package pc
import akka.actor.Actor
import akka.actor.Props
import akka.actor.ActorRef
import akka.actor.ActorRefFactory
class Parent extends Actor {
val child = context.actorOf(Props[Child], "child")
var ponged = false
@agaro1121
agaro1121 / Camel2Underscore.scala
Last active July 19, 2017 18:19 — forked from sidharthkuruvila/gist:3154845
Utility to functions to convert between camel case and underscore separated names
/**
* Takes a camel cased identifier name and returns an underscore separated
* name
*
* Example:
* camelToUnderscores("thisIsA1Test") == "this_is_a_1_test"
*/
def camelToUnderscores(name: String) = "[A-Z\\d]".r.replaceAllIn(name, {m =>
"_" + m.group(0).toLowerCase()
})

The process to view records in kinesis are as follows:

  1. Get a shard iterator:
aws kinesis get-shard-iterator --shard-id shardId-000000000000 --shard-iterator-type LATEST --stream-name
  1. Run your producer using kpl or anyother library and language.

  2. Read records of the recently created shard iterator:

@agaro1121
agaro1121 / ExposeHostPort.md
Created July 19, 2017 14:42 — forked from DavidDeCoding/ExposeHostPort.md
Exposing port on host machine to docker container

The vice versa can easily be done by including -p flag. But the way to expose ports of host machine to a docker container is bit convoluted, but can be done.

The steps are:

  1. Create an alias for the ip you want to use.
sudo ifconfig lo0 alias 172.16.123.1
  1. add the flag to docker:

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@agaro1121
agaro1121 / npm-scripts-for-docker.md
Created April 25, 2018 03:22 — forked from duluca/npm-scripts-for-docker.md
npm scripts for Docker

These are generic npm scripts that you can copy & paste into your package.json file as-is and get access to convinience scripts to manage your Docker images all in one place.

Looking for npm scripts for AWS ECS? Go here!

Watch the video: Do More With Less JavaScript

Docker Containers for Static or Angular/React/Vue/etc SPA Websites

@agaro1121
agaro1121 / Main.scala
Created August 30, 2018 09:30 — forked from htimur/Main.scala
Example of extracting KinesisConsumer during Kinesis source creation for the WW-Digital/reactive-kinesis library
import akka.actor.{ActorRef, ActorSystem}
import akka.stream.scaladsl.Sink
import com.weightwatchers.reactive.kinesis.consumer.KinesisConsumer
import com.weightwatchers.reactive.kinesis.stream._
object Main extends App {
val sys = ActorSystem("kinesis-consumer-system")
var consumer = Option.empty[KinesisConsumer]
@agaro1121
agaro1121 / app.js
Created October 7, 2018 22:49 — forked from camshaft/app.js
Superagent circuit breaker
/**
* Module dependencies
*/
var request = require("superagent")
, breaker = require("./breaker");
// Add the circuit breaker to the default middleware
request.middleware.push(breaker(3000));
// ...snip...
@agaro1121
agaro1121 / logback_disable_in_unit_tests.md
Created October 29, 2018 16:11 — forked from traviskaufman/logback_disable_in_unit_tests.md
Logback: Disable all logging in unit tests

After scouring the internet and piece-mealing together the correct way to do this, here is a step-by-step, all-in-one-place guide to making logback STFU when running your unit tests.

Here's how to do it

Save the following as logback-test.xml under src/test/resources:

<configuration>
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
      <pattern>%msg%n</pattern>