Skip to content

Instantly share code, notes, and snippets.

View lazywithclass's full-sized avatar

Alberto Zaccagni lazywithclass

View GitHub Profile
@lazywithclass
lazywithclass / blog-post.md
Last active March 12, 2024 18:40
Looking at the most beautiful program ever written - part 1

Looking at the most beautiful program ever written - part 1

I am going to have a look at what William Byrd presented as The most beautiful program ever written.

Beauty here refers to computer programs, specifically about Lisp. There might be errors as this is something I wrote to make sense of that interpreter, proceed at your own risk.

Thanks a lot to Carl J. Factora for the help.

The program

@lazywithclass
lazywithclass / blog-post.md
Created February 20, 2017 02:22
Building the Atreus keyboard

Building the Atreus keyboard

I've always wanted a keyboard that I could easily bring with me, and use it everytime I have to code.
This way I don't have to switch between my laptop keyboard and my work one.

Meet the Atreus.

Electronics experience not needed

I had never soldered before, nor do I know anything about electronics.

global
log 127.0.0.1 local0
user root
group root
daemon
defaults
log global
mode http
option httplog
@lazywithclass
lazywithclass / blog-post.md
Created February 20, 2017 02:25
Logging request body in HAProxy

Logging request body in HAProxy

On the 14th of October HAProxy 1.6 was released! Among all features announced I am particularly interested in the ability to log the body of a request.

It wasn't straightforward for me to understand how to do that, which is why I'm blogging it.

The relevant part could be found in the "Captures" section of the announcement, this is how I changed it to suit my needs:

# you need this so that HAProxy can access the request body
@lazywithclass
lazywithclass / blog.md
Last active February 21, 2022 21:39
Bandwidth throttling on FreeBSD

Bandwidth throttling on FreeBSD

Installing FreeBSD in VirtualBox will help a lot, I've also set

  • PasswordAuthentication yes
  • PermitRootLogin yes

followed by a /etc/rc.d/sshd restart to allow root to login from my tmux environment on the host box. Make sure you have sshd installed and running on the virtual image. This way I could have multiple tmux panes and copy / paste working (which wasn't in my case).

1) Write an algorithm (choose the language you prefer) that given a character string, for instance {‘c’,’a’,’i’,’o’,’p’,’a’}, will print out the list of characters appearing at least 2 times. In this specific example, it would return {‘a’}. Afterwards, comment out the cost in terms of space and time.

// I've left out validation to concentrate on the algorithm itself, I hope it's ok

// O(n) time
@lazywithclass
lazywithclass / blog-post.md
Created February 20, 2017 02:38
Attending the Recurse Center

Attending the Recurse Center

I'll miss the sea, but a person needs new experiences. They jar something deep inside, allowing him to grow. Without change something sleeps inside us, and seldom awakens. The sleeper must awaken.

-- Duke Leto Atreides

So I've been accepted into the Recurse Center (https://www.recurse.com/) for Spring 1, 2017.

@lazywithclass
lazywithclass / blog-post.md
Last active February 9, 2021 06:22
On whiteboard interviews

On whiteboard interviews - lazyblog

What follows is my highly opinionated point of view on the matter, I tried to write the few things I know and think about whiteboard interviews. I hope this helps. If you don't agree with something just comment below, email me, whatever works for you, I want to hear different point of views, me being salty doesn't affect my willingness to listen to people and change my mind.

Also sorry for the wall of text.

@lazywithclass
lazywithclass / gist:1402456
Created November 28, 2011 22:49
Fibonacci tail recursion in Java
public static long tailRecursive(long n) {
if (n <= 2) {
return 1;
}
return tailRecursiveAux(0, 1, n);
}
private static long tailRecursiveAux(long a, long b, long count) {
if(count <= 0) {
return a;
@lazywithclass
lazywithclass / blog-post.md
Created October 10, 2017 19:24
[Teaching programming] Lesson one

[Teaching programming] Lesson one - lazyblog

I hate to use "teaching" and "lesson", but those are the easiest words that come to mind right now.

I will be teaching a friend of mine how to program, from zero to (hopefully) web dev so she can see if it could be something she would like to do for a living.

The book

To give her the basic concepts I am going to use The Little Schemer. I feel like it's