Skip to content

Instantly share code, notes, and snippets.

View cilindrox's full-sized avatar
💭
:suspect:

Gaston Festari cilindrox

💭
:suspect:
View GitHub Profile
@cilindrox
cilindrox / find_primes.java
Last active August 24, 2021 14:32
A prime-finding snippet for Java using a 'sieve' method for calculating primes.
/**
* This will iterate up-to the sqrt of num
* in order to check if it can be written as 'nxn=axb'
**/
public boolean isPrime(int num) {
// check for even nums
if (num % 2 == 0) return false;
// http://stackoverflow.com/a/5813926
for (int i = 3; i*i <= num ; i+=2) {

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription
@cilindrox
cilindrox / xgh.md
Last active August 22, 2018 15:59
eXtreme Go Horse

eXtreme Go Horse (XGH) Process

Source: [http://gohorseprocess.wordpress.com]

1. I think therefore it's not XGH.

In XGH you don't think, you do the first thing that comes to your mind. There's not a second option as the first one is faster.

2. There are 3 ways of solving a problem:

the right way, the wrong way and the XGH way which is exactly like the first one but faster. XGH is faster than any development process you know (see Axiom 14).

@cilindrox
cilindrox / copy_disks.md
Last active August 24, 2021 14:25
How-To Determine Programs Using Open Port? -- taken from http://blog.jdpfu.com/2014/01/03/how-to-determine-programs-using-open-port

First, you'll need to list your disks. Just use the following to see which /dev/diskN node we're going to:

diskutil list

We'll need to unmount the disk to be cloned. We'll use the following command for that:

diskutil unmountDisk /dev/diskN
@cilindrox
cilindrox / tmux-cheatsheet.markdown
Created July 1, 2016 13:38 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@cilindrox
cilindrox / postgres-cheatsheet.md
Created April 21, 2018 23:59 — forked from so0k/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

// link to "iw3mp.exe" +set dedicated 1 +set sv_punkbuster 1 +exec dedicated.cfg +map_rotate
// Put this file under CoD4/main install folder
set sv_hostname "chorilan"
// Security
set g_password ""
set rcon_password "changeMe!"
// Maximum Clients

acme.sh

# root's required due to lighttpd perms and pihole struct
sudo -i

curl https://get.acme.sh | sh -s email=email@example.com
# Alternatively, clone and exec locally.

mkdir -p /etc/lighttpd/certs/pihole.mylab.domain/
@cilindrox
cilindrox / balance.go
Created February 16, 2019 14:57
Local Load Balancer implementation in go
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build OMIT
package main
import (
"container/heap"
@cilindrox
cilindrox / style.css
Created April 13, 2019 20:28
style.css
body {
font-family: Liberation Sans, Arial, sans-serif;
background-color: #fffaf7;
line-height: 1.3;
}
main {
max-width: 70ch;
padding: 2ch;
margin: auto;
}