Skip to content

Instantly share code, notes, and snippets.

View lmammino's full-sized avatar
🦁
Roar!

Luciano Mammino lmammino

🦁
Roar!
View GitHub Profile
@lmammino
lmammino / README.md
Last active May 16, 2020 19:08
Bummy Snake

Bummy snake

An incomplete Snake implementation using a Raspberry Pi 3, an adafruit st7735 screen and Python

Bummy Snake demo

:)

@lmammino
lmammino / LICENSE
Last active June 19, 2023 14:37
Decode Body of JWT tokens with bash
The `decode` function has been re-adapted from code provided by Moodstocks SAS and
therefore the following license applies to it:
Copyright (C) 2014 by Moodstocks SAS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@lmammino
lmammino / components.clickable-buttons.js
Created August 9, 2019 08:50
Exposing configurable functions to components
import Ember from 'ember';
export default Ember.Component.extend({
onPrimaryClick: null,
onSecondaryClick: null,
actions: {
triggerPrimaryClick() {
if (this.onPrimaryClick) {
@lmammino
lmammino / example.js
Last active May 21, 2019 14:04
Readable stream that allows you to display a png in the terminal
'use strict'
const { readFileSync } = require('fs')
const PngTerm = require('./pngTerm')
const [,, filePath] = process.argv
const pngBuffer = readFileSync(filePath)
const image = new PngTerm(pngBuffer)
@lmammino
lmammino / README.md
Last active May 7, 2019 16:40
Compile and run rust programs

Allows to compile and run a Rust program under unix systems:

./rrun <rust_file_name> <runtime_arguments>

For instance:

./rrun args 1 2 3 4 5
@lmammino
lmammino / README.md
Created March 17, 2019 10:57
Pass arrays to shared libraries from python using C types

Pass arrays to shared libraries from python using C types

This example implements a simple shared library in C.

This library called libfifthy exposes a function called add_fifthy which takes an array of integers and modify it in place by adding 50 to all elements.

Then there's some code in python which builds an array and invokes the add_fifthy from the shared library and reads the altered array values.

Usage

@lmammino
lmammino / example.go
Last active October 8, 2024 11:51
Ldap filter beautifier
package main
import (
"fmt"
"./ldap"
)
var filter = "(&(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) )))(objectCategory=user)(department=IT)(physicalDeliveryOfficeName=Amsterdam)))"
func main() {
@lmammino
lmammino / README.md
Created October 7, 2018 18:28
Node.js design pattern: Asynchronous serial iteration over a collection using callbacks

This is an example of a very common Node.js design pattern: a serial asynchronous iteration over a collection (array) using callbacks.

If you are interested in learning more about common (and even less common!) Node.js design patterns, you should check out the book Node.js Design Patterns by Mario Casciaro and Luciano Mammino (spoiler alert: that's me :P):

https://www.nodejsdesignpatterns.com/


To run the example:

@lmammino
lmammino / app-bundle.js
Created April 12, 2018 18:16
A sample webpacked bundle from http://poo.loige.co
This file has been truncated, but you can view the full file.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@lmammino
lmammino / gen_dkim.py
Created March 3, 2018 17:52
Generate dkim keys and a TXT record file for AWS Route 53
#!/usr/bin/env python
# Usage
# ./gen_dkim.py mail.yourdomain.tld
import sys
from subprocess import call
from os import devnull
if len(sys.argv) < 2: