Skip to content

Instantly share code, notes, and snippets.

View bcap's full-sized avatar

Bruno Penteado bcap

  • VTEX, ex Meta
  • Lisbon, Portugal
View GitHub Profile
@bcap
bcap / LinuxDualMonitors
Created September 20, 2012 21:05
Adjust double monitors display, edit changing screen names and position
#!/bin/bash
# xrandr --nograb --output <primary display name> --auto --pos 0x0 --primary --preferred
# xrandr --nograb --output <secondary display name> --auto --pos <position X in relation to the primary monitor>x<position Y in relation of the primary monitor>
xrandr --nograb --output VGA1 --auto --pos 0x0 --primary --preferred
xrandr --nograb --output DP1 --auto --pos 1920x200
@bcap
bcap / update.pp
Created January 20, 2013 05:11
Run apt get update in a more reasonable fashion
class apt::update {
# execute apt-get update if any of the following conditions met:
# - there is no apt-get update cache data (eg. first run)
# - any file in the /etc/apt/** was changed after the last execution
# - it was executed more than 24h ago
$apt_update_min_age_in_seconds = "24 * 60 * 60" # you can edit this
$apt_update_condition_1 = "[[ ! -f /var/cache/apt/pkgcache.bin ]]"
$apt_update_condition_2 = "find /etc/apt -cnewer /var/cache/apt/pkgcache.bin | grep ."
$apt_update_condition_3 = "[[ $(( $(date +%s) - $(stat -c %Z /var/cache/apt/pkgcache.bin) )) -gt $(( ${apt_update_min_age_in_seconds} )) ]]"
@bcap
bcap / start-stop-daemon-template
Last active July 21, 2023 11:12
Template file for creating linux services out of executables using the start-stop-daemon
#!/bin/bash
### BEGIN INIT INFO
# Provides: <service name>
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: <service description>
### END INIT INFO
@bcap
bcap / terminal-control.sh
Last active September 21, 2025 10:46
Useful terminal control characters
# Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm)
TC='\e['
CLR_LINE_START="${TC}1K"
CLR_LINE_END="${TC}K"
CLR_LINE="${TC}2K"
# Hope no terminal is greater than 1k columns
RESET_LINE="${CLR_LINE}${TC}1000D"
@bcap
bcap / carbon-vhost
Last active December 19, 2015 00:29
Python HTTP proxy (mod_python) for graphite-carbon
# apache2 virtual host configuration
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog "/var/log/graphite/error.log"
CustomLog "/var/log/graphite/access.log" common
<Location "/carbon-web-proxy/v1.0/">
SetHandler python-program
@bcap
bcap / btsync.conf
Created November 3, 2013 18:44
Simple BTSync config for Linux btsync CLI
{
"device_name": "sync test 1",
"listening_port" : 7788,
"storage_path" : "/var/lib/btsync/.sync",
"check_for_updates" : false,
"use_upnp" : false,
// limits in kB/s. 0 = no limit
"download_limit" : 0,
"upload_limit" : 0,
@bcap
bcap / cc-projects.py
Last active May 17, 2026 15:41
Manage Claude Code session transcripts across project dirs (list/move/copy)
#!/usr/bin/env python3
"""Manage Claude Code session transcripts across project dirs.
Sessions live at ~/.claude/projects/<encoded-cwd>/<uuid>.jsonl where encoded-cwd
is the absolute cwd with non-alphanumeric chars (except '-') replaced by '-'.
Subcommands:
list List absolute cwd of every known project dir.
move Move sessions from a source cwd into a destination cwd.
copy Copy sessions from a source cwd into a destination cwd.