Skip to content

Instantly share code, notes, and snippets.

Avatar
🇭🇰

Lio李歐 lionello

🇭🇰
View GitHub Profile
@lionello
lionello / fish_prompt.fish
Last active Apr 7, 2020
My FISH prompt (avoids shortened path names, unless too long or in subshells)
View fish_prompt.fish
# 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 Aug 6, 2019 — forked from adisbladis/.direnvrc
Direnv nix cache. Put this file in your HOME folder.
View .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
View .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 Aug 5, 2019
VSCode user settings JSON
View 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,
View config.fish
# 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 Aug 5, 2019
My .vimrc
View .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 Aug 5, 2019
IntelliJ AndroidStudio Keymap
View Visual Studio copy.xml
<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 Jun 14, 2019
Utility to generate plantuml diagram for Fortran project
View graph.py
#!/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)
View .bash_profile
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 Jan 5, 2019
Add support for async middleware and handlers to Express
View express-async.js
/**
* 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)