Skip to content

Instantly share code, notes, and snippets.

View Zorgatone's full-sized avatar

Tommaso Ricci Zorgatone

  • BrainQuark di Tommaso Ricci
  • Turin, Italy
  • 07:34 (UTC +01:00)
  • LinkedIn in/zorgatone
View GitHub Profile
@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;
}
@Zorgatone
Zorgatone / bulls_and_cows.cpp
Created February 23, 2017 16:24
Bulls and Cows game in C++
#include <iostream>
#include <vector>
#include <stdexcept>
#include <ctime>
#include <cstdlib>
#include <cctype>
using namespace std;
constexpr short int number_of_digits{ 4 };
@Zorgatone
Zorgatone / Matrix.cpp
Last active February 23, 2017 14:37
Matrix in C++11/C++14 using unique_ptr and make_unique
#include "Matrix.hpp"
using namespace std;
using namespace zgt;
struct Matrix::_impl {
unique_ptr<unique_ptr<MatrixRow>[]> _m;
_impl(size_t rows, size_t cols): _m(make_unique<unique_ptr<MatrixRow>[]>(rows)) {
for (size_t i{ 0 }; i < cols; i++) {
@Zorgatone
Zorgatone / kissanime-series-helper.user.js
Last active January 11, 2017 18:44
KissAnime Series Helper
// ==UserScript==
// @name KissAnime Series Helper
// @namespace http://zorgatone.tk/
// @version 0.2
// @description Hides the ads on KissAnime
// @author Zorgatone <[email protected]>
// @include /^https?://kissanime\.(?:com|to|ru)(?:\/.*)?$/
// @update https://rawgit.com/Zorgatone/1fec4be76e649d9d0c6fbe52f73e465a/raw/42c710be90e99f1114e2a94f5369fe0dfc3a0f10/kissanime-ad-blocker.user.js
// ==/UserScript==
@Zorgatone
Zorgatone / kissanime-ad-blocker.user.js
Last active August 23, 2018 10:54
KissAnime Ad-Blocker Userscript
// ==UserScript==
// @name KissAnime Ad-Blocker
// @namespace http://zorgatone.tk/
// @version 0.7.1
// @description Hides the ads on KissAnime
// @author Zorgatone <[email protected]>
// @include /^https?://kissanime\.(?:com|to|ru)(?:\/.*)?$/
// @update https://cdn.rawgit.com/Zorgatone/1fec4be76e649d9d0c6fbe52f73e465a/raw/499b5612ee2f45b8cb7b0702f08cec7da88482d6/kissanime-ad-blocker.user.js
// ==/UserScript==
@Zorgatone
Zorgatone / game-oop.ts
Last active December 23, 2016 10:44
OOP game example
interface IWearable {
wear: () => void;
}
interface IPlayable {}
class GameObject {
toString() {
return JSON.stringify(this, null, " ");
}
function random20Chars() {
return btoa((Math.random()).toFixed(20).slice(2,22)).slice(1, 21);
}
@Zorgatone
Zorgatone / keybase.md
Created September 5, 2016 09:00
keybase.md

Keybase proof

I hereby claim:

  • I am Zorgatone on github.
  • I am zorgatone (https://keybase.io/zorgatone) on keybase.
  • I have a public key whose fingerprint is 5975 04B1 088A 7AC8 F501 11BC E085 FA53 ED8D 7C59

To claim this, I am signing this object:

@Zorgatone
Zorgatone / typeUtils.js
Last active May 6, 2016 10:24
Type Utils (for AngularJS 1.x) v1.0.0 - a collection of useful type filters
/*!
* Type Utils (for AngularJS 1.x) v1.0.0 - a collection of useful type filters
* transpile ES2015 (ES6) with BabelJS
* Copyright 2015 Zorgatone; Licensed MIT
*/
export function isTypeFilter() {
return (val, type) => type === typeof val;
}