Skip to content

Instantly share code, notes, and snippets.

View elamperti's full-sized avatar

Enrico Lamperti elamperti

View GitHub Profile
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 26, 2024 07:44
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@iphoting
iphoting / ledger.sh
Last active March 29, 2019 06:00
Ledger Bash Completion
# Assumption : bash-completion package is installed and enabled
# Try it : just "source ledger"
# Here are three possible ways to install this file
# 1. As ~/.bash_completion file
# 2. As ~/.bash_completion.d/ledger file, with additional file
# ~/.bash_completion which contents ". ~/.bash_completion.d/ledger"
# 3. As /etc/bash_completion.d/ledger
_ledger()
{
@alienhaxor
alienhaxor / _formhelpers.py
Last active September 5, 2022 17:42 — forked from maximebf/gist:3986659
Jinja2 macro to render WTForms fields with Twitter Bootstrap. This fork renders the fields according to bootstrap 3.0.0
{% macro render_field(field) -%}
{% set with_label = kwargs.pop('with_label', False) %}
{% set placeholder = '' %}
{% if not with_label %}
{% set placeholder = field.label.text %}
{% endif %}
<div class="form-group {% if field.errors %}error{% endif %}">
{% if with_label %}
<label for="{{ field.id }}" class="control-label">
{{ field.label.text }}{% if field.flags.required %} *{% endif %}:
@anoved
anoved / star.scad
Created March 18, 2014 15:48
OpenSCAD pointed star module
// points = number of points (minimum 3)
// outer = radius to outer points
// inner = radius to inner points
module Star(points, outer, inner) {
// polar to cartesian: radius/angle to x/y
function x(r, a) = r * cos(a);
function y(r, a) = r * sin(a);
// angular width of each pie slice of the star
@staltz
staltz / introrx.md
Last active July 26, 2024 04:24
The introduction to Reactive Programming you've been missing
@T3chArmy
T3chArmy / readme
Last active March 29, 2019 10:09 — forked from lowjoel/sleepbot-migrate-to-sleep_as_android.rb
Migrates SleepBot data to Sleep as Android's format. Updated!
When exporting from mysleepbot.com:
-go to settings
-Change Date Format to Day/Month/Year
-Change Time Format to 24 hours
-Go to Entries
-Select from date that is older than your first sleepbot entry
-Select to date as todays date
-Export as CSV name file sleepbot-raw.csv
-Edit file and remove the first line and also do a find & replace and remove all 's from the file
@davidblewett
davidblewett / lp-ssh-add.sh
Last active December 12, 2021 11:12
Allow storage of SSH private keys in LastPass, and use lpass CLI to retrieve and load into ssh-agent. The general idea is to store the private key armored ASCII in an "SSH Key" Secure Note, in a specific folder (i.e.: "Secure Notes\SSH" ).
#!/bin/sh
#
# Import all SSH keys from LP
#
PREFIX=~
SSH_ASKPASS=$PREFIX/bin/lp-askpass.sh
export SSH_ASKPASS
# This is needed to force ssh-add to honor our SSH_ASKPASS.
DISPLAY=foo
export DISPLAY
@derblub
derblub / spotify.nowplaying.sh
Last active March 20, 2024 23:15
Get playback status from Spotify via DBus
#!/bin/bash
# if spotify is started
if [ "$(pidof spotify)" ]; then
# status can be: Playing, Paused or Stopped
status=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$`
artist=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$`
album=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "album"|egrep -v "album"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
title=`dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 o
@crash7
crash7 / rewrite-git-message-by-commit-hash
Created August 22, 2015 01:40
Rewrite git message for specifics commits
git filter-branch -f --msg-filter '
read commit
declare -A commits_replaces;
commits_replaces["<commit hash>"]="new message"
if [[ ${commits_replaces[$GIT_COMMIT]} ]]; then
echo ${commits_replaces[$GIT_COMMIT]};
else
echo $commit
fi' -- --all
@paulirish
paulirish / what-forces-layout.md
Last active July 25, 2024 07:49
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent