Skip to content

Instantly share code, notes, and snippets.

View Zorgatone's full-sized avatar

Tommaso Ricci Zorgatone

View GitHub Profile
@Zorgatone
Zorgatone / .Xcompose
Created December 19, 2022 16:09
IT Italian - EN English .Xcompose / WinCompose keyboard layout shortcuts
# for Emacs: -*- coding: utf-8 -*-
#
# User-defined key sequences for WinCompose
# by Sam Hocevar <sam@hocevar.net>
#
# Key sequences have the following form:
#
# <Multi_key> <key>… : "resulting text"
#
@Zorgatone
Zorgatone / planet.exs
Created December 27, 2020 20:02
Planets in Elixir
defmodule Planet do
defstruct [:x, :y]
def gen_planet(x, y) do
xr = rem x, 7
yr = rem y, 11
if x > 4 and y > 8 and xr > 3 and xr < 6 and rem(yr, xr) === 1 do
%Planet{x: x, y: y}
else
@Zorgatone
Zorgatone / Bounds.java
Created December 26, 2020 18:39
Simple Octree implementation in Java (Immutable OOP)
package tk.zorgatone.simpleoctree;
public interface Bounds {
Point getTopRight();
Point getBottomLeft();
}
@Zorgatone
Zorgatone / input.txt
Last active November 23, 2020 16:57
Chess knight moves interview question solution
70
7
15
67
3
@Zorgatone
Zorgatone / react-native-clean.function.zsh
Last active April 10, 2021 09:20
react-native-clean function for use in .zshrc
react-native-clean() {
if [ ! -f "react-native.config.js" ] && [ ! -f "app.json" ]; then
echo >&2 "Probably not a react-native project root folder!"
return 1
else
echo "Detected react-native project root folder..."
fi
if [ -x "command -v watchman" ]; then
watchman watch-del-all
@Zorgatone
Zorgatone / fizzbuzz.rb
Created August 6, 2018 19:41
fizzbuzz.rb
def fizzbuzz(n)
1.upto(n) do |i|
div_by_5 = i % 5 == 0
div_by_3 = i % 3 == 0
if div_by_3 && div_by_5
puts "#{i} Fizzbuzz"
elsif div_by_3
puts "#{i} Fizz"
elsif div_by_5
puts "#{i} Buzz"
@Zorgatone
Zorgatone / movies_hash.rb
Last active July 30, 2018 18:40
Codecademy - movies hash
def get_title
print 'Enter movie title: '
title = gets.chomp
if title.length < 1
print 'Invalid title!'
return nil
else
return title.to_sym
end
@Zorgatone
Zorgatone / .profile
Last active May 19, 2018 10:12
WariorJS
eyJ3YXJyaW9yTmFtZSI6IlpvcmdhdG9uZSIsInRvd2VyTmFtZSI6ImJlZ2lubmVyIiwiZGlyZWN0b3J5UGF0aCI6Ii4iLCJsZXZlbE51bWJlciI6NSwic2NvcmUiOjE3NiwiY2x1ZSI6ZmFsc2UsImVwaWMiOmZhbHNlLCJlcGljU2NvcmUiOjAsImF2ZXJhZ2VHcmFkZSI6bnVsbCwiY3VycmVudEVwaWNTY29yZSI6MCwiY3VycmVudEVwaWNHcmFkZXMiOnt9fQ==
@Zorgatone
Zorgatone / die.c
Last active September 10, 2017 10:26
Die utility - terminate C program with error message and exit code
#include <stdarg.h>
#include "util.h"
void vsfdie(FILE * stream, int code, const char *format, va_list arg) {
vfprintf(stream, format, arg);
va_end(arg);
exit(code);
}
@Zorgatone
Zorgatone / password-generator.js
Created August 25, 2017 08:52
Generate password with custom character set and length
// EcmaScript 2015
export default class PasswordGenerator {
constructor(
charset = ""
) {
this.charset = charset.toString().split("").sort().reduce((a, b) => {
if (a.charAt(a.length - 1) === b) {
return a;
}