Skip to content

Instantly share code, notes, and snippets.

@pauloromeira
pauloromeira / 0_README.md
Last active November 13, 2023 11:33
Simple backup to external device script

Simple backup to external device

This just sync any folder with an external device by using crontab. It's meant to run sparsely, hence it mounts and unmounts the device on every execution.

It consists of two scripts:

  1. with_device.sh: mounts and umounts the external device - should be in a folder with restricted access
  2. simple_backup.sh: does the actual backup using rsync - can be in any folder

Crontab sample:

@pauloromeira
pauloromeira / apps_script-balance_portfolio.gs
Last active September 20, 2021 03:21
Apps Script (Google Sheets) - Balance Portfolio
/* ---------- General Helpers ---------- */
function _sort_idxs(items) {
return items.map((item, idx) => [item, idx]).sort().map(i => i[1]);
}
function _sort_apply(idxs, items) {
return idxs.map(idx => items[idx]);
}
@pauloromeira
pauloromeira / 81-thinkpad-dock.rules
Created January 13, 2019 23:12 — forked from seanf/81-thinkpad-dock.rules
Example ThinkPad docking script for multi-monitor
# Save this file (after modifying ID_VENDOR and ID_MODEL if necessary) as /etc/udev/rules.d/81-thinkpad-dock.rules
# These values seem to work for "ThinkPad Mini Dock Plus Series 3"
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{ID_VENDOR}=="17ef", ENV{ID_MODEL}=="100a", RUN+="/etc/sbin/thinkpad-dock.sh"
@pauloromeira
pauloromeira / 90-monitor.conf
Last active November 15, 2018 15:45
Ubuntu monitor config for 2560x1080 ultrawide monitors
Section "Monitor"
Identifier "HDMI-2"
Modeline "2560x1080_55.00" 209.98 2560 2720 2992 3424 1080 1081 1084 1115 -HSync +Vsync
EndSection
Section "Screen"
Identifier "Screen0"
Monitor "Monitor-HDMI-2"
DefaultDepth 24
SubSection "Display"
Depth 24
@pauloromeira
pauloromeira / vim_compile.sh
Created October 8, 2018 04:54
Vim compile script
cd ~
rm -rf vim
git clone https://github.com/vim/vim.git
# export LD_LIBRARY_PATH=$HOME/.pyenv/versions/3.7.0/lib
# export PATH=$HOME/.pyenv/versions/3.7.0/bin:$PATH
cd vim
./configure --with-features=huge \
--enable-multibyte \
@pauloromeira
pauloromeira / gitreplace.sh
Created April 10, 2018 02:29
Replace string in all Git history.
git filter-branch --tree-filter "find . -name '*.*' -exec sed -i '' -e 's/OLDSTRING/NEWSTRING/g' {} \;" -f
@pauloromeira
pauloromeira / montyhall.py
Last active January 1, 2018 04:31
Monty Hall Proof
#!/usr/bin/env python
from random import shuffle
options = [1, 0, 0]
iterations = 1000000
stick = 0
change = 0
@pauloromeira
pauloromeira / README-Template.md
Created October 18, 2017 00:44 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@pauloromeira
pauloromeira / config_0
Last active February 27, 2022 11:56
Tilda config file
tilda_config_version = "1.3.1"
# command = ""
font = "Monospace 11"
key = "<Primary><Shift>space"
addtab_key = "<Shift><Control>t"
fullscreen_key = "F11"
toggle_transparency_key = "F12"
toggle_searchbar_key = "<Shift><Control>f"
closetab_key = "<Shift><Control>w"
nexttab_key = "<Control>Page_Down"
@pauloromeira
pauloromeira / tlp
Last active November 9, 2024 08:32
My TLP config file (/etc/default/tlp) for ThinkPad
# ------------------------------------------------------------------------------
# tlp - Parameters for power saving
# See full explanation: http://linrunner.de/en/tlp/docs/tlp-configuration.html
# dir: /etc/default/tlp
# Hint: some features are disabled by default, remove the leading # to enable
# them.
# Set to 0 to disable, 1 to enable TLP.