Skip to content

Instantly share code, notes, and snippets.

View lionello's full-sized avatar
🇭🇰

Lio李歐 lionello

🇭🇰
View GitHub Profile
@lionello
lionello / fish_prompt.fish
Last active April 7, 2020 04:48
My FISH prompt (avoids shortened path names, unless too long or in subshells)
# name: Classic + Vcs (custom)
# author: Lily Ballard & Lionello Lunesu
function fish_prompt --description 'Write out the prompt'
set -l last_pipestatus $pipestatus
set -l normal (set_color normal)
# Color the prompt differently when we're root
set -l color_cwd $fish_color_cwd
set -l prefix
@lionello
lionello / .direnvrc
Last active August 6, 2019 08:37 — forked from adisbladis/.direnvrc
Direnv nix cache. Put this file in your HOME folder.
#!/bin/bash
#
# Cache nix-shell environment
#
# - watches shell.nix (or default.nix), ~/.direnvrc and .envrc
# - based on https://github.com/direnv/direnv/wiki/Nix
#
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
if [[ ! -f "$shell_file" ]]; then return; fi
@lionello
lionello / .direnvrc
Last active August 6, 2019 08:31 — forked from sveitser/.direnvrc
#!/bin/bash
#
# Cache nix-shell environment
#
# - watches shell.nix (or default.nix), ~/.direnvrc and .envrc
# - based on https://github.com/direnv/direnv/wiki/Nix
#
use_nix() {
local shell_file=$(test -f shell.nix && echo shell.nix || echo default.nix)
if [[ ! -f "$shell_file" ]]; then return; fi
@lionello
lionello / settings.json
Last active August 5, 2019 12:46
VSCode user settings JSON
{
"telemetry.enableTelemetry": false,
"window.openFilesInNewWindow": "off",
"go.useLanguageServer": true,
"terminal.integrated.shell.windows": "/Users/llunesu/.nix-profile/bin/fish",
"workbench.colorTheme": "Dark (Monokai)",
"editor.rulers": [
0, 80, 120
],
"files.trimTrailingWhitespace": true,
# Avoid default fish path abbreviation
set -g -x fish_prompt_pwd_dir_length 0
# Use vim as default editor in fish
set -g -x EDITOR vim
# Force language of CLI tools to English (US)
set -g -x LANG en_US.UTF-8
#status --is-interactive; and source (rbenv init -|psub)
@lionello
lionello / .vimrc
Last active August 5, 2019 07:11
My .vimrc
set nocompatible " be iMproved, required
filetype off " required
" Set the runtime path to include Vundle and initialize
"set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#begin()
"Plugin 'VundleVim/Vundle.vim'
"Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
"call vundle#end() " required
@lionello
lionello / Visual Studio copy.xml
Created August 5, 2019 06:32
IntelliJ AndroidStudio Keymap
<keymap version="1" name="Visual Studio copy" parent="Visual Studio">
<action id="$Copy">
<keyboard-shortcut first-keystroke="ctrl c" />
<keyboard-shortcut first-keystroke="meta c" />
</action>
<action id="$Cut">
<keyboard-shortcut first-keystroke="ctrl x" />
<keyboard-shortcut first-keystroke="shift delete" />
<keyboard-shortcut first-keystroke="meta x" />
</action>
@lionello
lionello / graph.py
Last active June 14, 2019 01:44
Utility to generate plantuml diagram for Fortran project
#!/usr/bin/env python3
import itertools
import sys
import re
import os
from collections import defaultdict
MODULE = re.compile(r'^(END )?MODULE\s+([A-Z0-9_]+)', re.IGNORECASE)
USE = re.compile(r'^USE\s+([A-Z0-9_]+)(\s*,\s*ONLY\s*:\s*([A-Z0-9_,]+))?', re.IGNORECASE)
BEGIN = re.compile(r'^(SUBROUTINE|PROGRAM|((COMPLEX|LOGICAL|INTEGER|REAL|CHARACTER)(\([^)]+\))? )?FUNCTION)\s+([A-Z0-9_]+)', re.IGNORECASE)
if [ "$(uname -s)" != "Linux" ] && [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
source ~/.profile
PATH=/usr/local/sbin:$PATH
function __smile() { if [ $? -ne 0 ]; then echo ":("; else echo ":)"; fi }
GIT_PS1_SHOWDIRTYSTATE=true
PS1="\n\$(__smile)\[\e[1m\]\w\[\e[0m\]\$(__git_ps1)\n\$ "
@lionello
lionello / express-async.js
Last active January 5, 2019 03:56
Add support for async middleware and handlers to Express
/**
* Wrap an Express middleware or handler for async support.
* @param {function} fn The middleware or handler to wrap
* @returns {function} Wrapped function
*/
exports.wrap = function(fn) {
if (fn.length === 4) {
// Wrap error handler
return (err, req, res, next) => {
const r = fn(err, req, res, next)