Skip to content

Instantly share code, notes, and snippets.

View lazywithclass's full-sized avatar

Alberto Zaccagni lazywithclass

View GitHub Profile
@lazywithclass
lazywithclass / simulate-work.sh
Created November 6, 2017 11:20
Simulate work in a directory adding and updating files
#!/bin/bash
while true; do
filename=$(((RANDOM %10) + 1))
if [ -f $filename ]; then
mkfile 30m data/$filename
else
randomstring=$(LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | fold -w ${1:-$(((RANDOM %1000000) +1))} | head -n 1)
echo $randomstring >>data/$filename
fi
@lazywithclass
lazywithclass / blog-post.md
Created November 6, 2017 10:26
[Teaching programming] Lesson three

[Teaching programming] Lesson three - lazyblog

Thoughts

There was some confusion on how to use functions and recursion in the end. I didn't spot that previously. I am starting to think that a lot of what "being a teacher" means is to understand when your audience got the idea you're trying to pass on.

So what didn't I understand? For sure the fact that going from

@lazywithclass
lazywithclass / exercises.scm
Last active October 27, 2017 09:28
Exercises after The Little Schemer chapter 2 (2)
;; in the previous solution we implemented 2nd and last
;; but we did not define proper return values for the edge cases,
;; this time we will
;; your task will be to provide those values, as you can imagine
;; (sum 4 'gatto) does not have an answer
;; make it so that expressions will return true
;; a suggestion would be to paste the definitions of 2nd and last
;; above the exercises and fix the errors you get, by returning proper values
@lazywithclass
lazywithclass / exercises.scm
Last active October 23, 2017 16:02
Exercises after The Little Schemer chapter 2
;; write the function "2nd" that given a list of atoms
;; returns the second atom
;; return values for illegal cases are up to you
;; try to be reasonable though
(define 2nd
(lambda (lat)
;; ...
))
;; then write the results for these applications by running your function
(2nd '()) ;; ???
@lazywithclass
lazywithclass / blog-post.md
Last active October 22, 2017 13:07
[Teaching programming] Lesson two

[Teaching programming] Lesson two - lazyblog

From the previous lesson

It wasn't clear, and still isn't to me as of now, how S-exps are counted in a list, for example

;; how many are here? Is it 2?
(((a b c) d))
@lazywithclass
lazywithclass / exercises.scm
Last active October 16, 2017 22:02
Exercises after The Little Schemer chapter 1
;; given leq? that checks for lists equality
;; complete the following, so that the result is true
;; all these exercises can be solved with combinations of
;; car, cdr, cons
;; be creative!
;; this is just an example I solved for you :)
;; l -> (1 2 3)
;; m -> (0 1 2 3)
@lazywithclass
lazywithclass / blog-post.md
Last active July 26, 2017 10:07
Learning Vue.js

Learning Vue.js - lazyblog

A lot of time has passed since I willingly wanted to learn a frontend JS framework, I am doing it again because

  • Vue's docs seems to be detailed enough
  • there's a nice and easy way to start
  • I've used it for a take home assignment as part of a job interview and loved how it all came together easily and almost painless
  • enriches HTML the Angular.js way, so that's something I already know
@lazywithclass
lazywithclass / blog-post.md
Last active July 12, 2017 16:14
Implementing racket/trace in JavaScript

Implementing racket/trace in JavaScript - lazyblog

This is a blog post / diary of my journey through this task, as I'm writing this words I have no idea how and if I will be able to achieve the goal. But, if you're reading this, then probably there's hope.

Why

racket/trace prints calls to a function, that could be useful when dealing with recursion:

@lazywithclass
lazywithclass / blog-post.md
Created May 22, 2017 20:01
Spacemacs nodejs-repl configuration repacing Skewer

It took some time to figure out how to override Skewer's defaults, turns out this is what worked, without the hook it was not working.

(add-hook 'js2-mode-hook #'(lambda ()
                             (spacemacs/set-leader-keys-for-major-mode 'js2-mode
                               "'" 'nodejs-repl
                               "ee" 'nodejs-repl-send-last-sexp
                               "eb" 'nodejs-repl-send-buffer
 "er" 'nodejs-repl-send-region)))
@lazywithclass
lazywithclass / blog-post.md
Created February 20, 2017 02:23
Reference an existing IAM role from a CloudFormation template in AWS

Reference an existing IAM role from a CloudFormation template in AWS

So I was looking for a way to remove keys from our servers, Amazon itself suggest that you use IAM instead, so I tried that.

How

Under Resources define

"Testing": {