Skip to content

Instantly share code, notes, and snippets.

Gabriele Petronella gabro

Block or report user

Report or block gabro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gabro
gabro / validation.flow.js
Last active Feb 24, 2020
Dynamic object validation using $ObjMap in Flow
View validation.flow.js
/* @flow */
// A simplified representation of types using phantom types (so that we store the Type information both at value and type level)
class Type<T> {};
class StringT extends Type<string> {}
class NumberT extends Type<number> {}
// A schema for a User
const User = {
name: new StringT(),
@gabro
gabro / git-working-history
Last active Oct 21, 2019
Github-like working directory history
View git-working-history
#!/bin/bash
FILES=`git ls-tree --name-only HEAD .`
MAXLEN=0
IFS=$(echo -en "\n\b")
for f in $FILES; do
if [ ${#f} -gt $MAXLEN ]; then
MAXLEN=${#f}
fi
done
View sublime.tex
\documentclass{article}
\title{LaTeX is now Sublime}
\author{Gabriele Petronella}
\begin{document}
\maketitle
\section{My first section}
@gabro
gabro / main.tex
Created Dec 7, 2012
An example of a multi-part LaTeX document
View main.tex
\documentclass{article}
\title{A long document}
\author{Gabriele Petronella}
\date{\today}
\begin{document}
\maketitle
@gabro
gabro / extension.ts
Created Sep 28, 2018
VSCode decoration API
View extension.ts
'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import { window, commands, ExtensionContext, Range, Position, TextEditor, workspace, DecorationOptions } from 'vscode';
const decorationType = window.createTextEditorDecorationType({ })
function addDecorations(e: TextEditor) {
try {
@gabro
gabro / AssetPicker.swift
Created Nov 2, 2015
A block-based asset picker for videos, photos and files
View AssetPicker.swift
import Photos
import MobileCoreServices
class AssetPicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIDocumentPickerDelegate, UIDocumentMenuDelegate {
static let sharedInstance = AssetPicker()
private lazy var cameraPicker: UIImagePickerController = {
let cameraPicker = UIImagePickerController()
View ScastieModifier.scala
package docs
import mdoc.Reporter
import mdoc.StringModifier
import scala.meta.inputs.Input
import java.util.UUID
/** Transforms scala code blocks into Scastie snippets
*
* ==Usage==
View babel-increment.js
export default function (babel) {
const { types: t } = babel;
return {
visitor: {
NumericLiteral(path) {
path.node.value += 1
}
}
};
View eslint-no-console.js
export default function(context) {
return {
CallExpression(node) {
const { callee } = node;
if (callee.type === "MemberExpression" && callee.object.name === "console" && callee.property.name === "log") {
context.report(node, "Do not use console.log");
}
}
};
}
View gist:26221d7c21ac0430fd944a4e6ab2095c
parser | AST | ES2017 | ES next
-----------|:---------------:|:------:|:--------------:
acorn | ESTree | ✅ | only stage-4
babylon | Babylon AST | ✅ | ✅
espree | ESTree | ✅ | same as acorn
esprima | ESTree | ✅ | ❌
flow | ESTree + custom | ✅ | ✅
TypeScript | TypeScript AST | ✅ | ✅
You can’t perform that action at this time.