Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
Focusing

Apostolis Stergiou apostergiou

🌊
Focusing
View GitHub Profile
@apostergiou
apostergiou / attributes.rb
Created Apr 23, 2019 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
View attributes.rb
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@apostergiou
apostergiou / test_mail_purge.rb
Created Apr 1, 2019 — forked from adamsanderson/test_mail_purge.rb
An example of using MiniTest::Mock
View test_mail_purge.rb
require 'minitest/mock'
require 'minitest/unit'
require 'date'
MiniTest::Unit.autorun
class TestMailPurge < MiniTest::Unit::TestCase
class MailPurge
def initialize(imap)
@imap = imap
View ci-cd-example.diagram
Git Actions: CI System Actions:
+-------------------------+ +-----------------+
+--► Create a Feature Branch | +---► Build Container |
| +------------+------------+ | +--------+--------+
| | | |
| | | |
| +--------▼--------+ | +-------▼--------+
| +---► Push the Branch +-------+ | Push Container |
| | +--------+--------+ +-------+--------+
@apostergiou
apostergiou / go-kit.md
Created Feb 19, 2019 — forked from posener/go-kit.md
Why I Recommend to Avoid Using the go-kit Library
View go-kit.md

Why I Recommend to Avoid Using the go-kit Library

There is a trending 'microservice' library called go-kit. I've been using the go-kit library for a while now. The library provide a lot of convenience integrations that you might need in your service: with service discovery with Consul, distributed tracing with Zipkin, for example, and nice logic utilities such as round robin client side load balancing, and circuit breaking. It is also providing a way to implement communication layer, with support of RPC and REST.

@apostergiou
apostergiou / gist:d43948a9b43d3535a796ca46234710fa
Created Dec 27, 2018 — forked from kingbin/gist:9435292
Manually Start/Stop PostgresSQL on Mac
View gist:d43948a9b43d3535a796ca46234710fa
# Stop PostgreSQL from auto starting
sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Enable PostgreSQL to auto start
sudo launchctl load -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
# Start postgres
$ sudo su postgres
Password:
bash-3.2$ pg_ctl -D /Library/PostgreSQL/9.3/data/ start
@apostergiou
apostergiou / backtrace.rb
Created Sep 25, 2018
ruby print backtrace
View backtrace.rb
rescue_from StandardError do |exception|
# Handle only JSON requests
raise unless request.format.json?
err = {error: exception.message}
err[:backtrace] = exception.backtrace.select do |line|
# filter out non-significant lines:
%w(/gems/ /rubygems/ /lib/ruby/).all? do |litter|
not line.include?(litter)
@apostergiou
apostergiou / Makefile
Created Sep 12, 2018 — forked from ahawkins/Makefile
Example Makefile
View Makefile
RUBY_IMAGE:=$(shell grep FROM Dockerfile | cut -f2 -d' ')
DYNAMODB_IMAGE:=dynamodb:latest # original value ommitted
APP_IMAGE:=inventory_service/app
TAG:=$(shell git rev-parse --short HEAD)
REGISTRY:=example.registry.com # original value omitted
.DEFAULT_GOAL:= build
@apostergiou
apostergiou / rubymethodlookup.md
Created May 13, 2018 — forked from damien-roche/rubymethodlookup.md
A Primer on Ruby Method Lookup
View rubymethodlookup.md

A Primer on Ruby Method Lookup

Method lookup is a simple affair in most languages without multiple inheritance. You start from the receiver and move up the ancestors chain until you locate the method. Because Ruby allows you to mix in modules and extend singleton classes at runtime, this is an entirely different affair.

I will not build contrived code to exemplify the more complicated aspects of Ruby method lookup, as this will only serve to confuse the matter. If you are having trouble following method lookup in your own programs, it is not because Ruby has strange rules (it does), it is because your code is too tangled.

When you pass a message to an object, here is how Ruby finds what method to call:

1. Look within singleton class

@apostergiou
apostergiou / web-servers.md
Created May 1, 2018 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@apostergiou
apostergiou / System Design.md
Created Feb 19, 2018 — forked from vasanthk/System Design.md
System Design Cheatsheet
View System Design.md

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?