Skip to content

Instantly share code, notes, and snippets.

View filipeamoreira's full-sized avatar

Filipe A Moreira filipeamoreira

View GitHub Profile
@samoshkin
samoshkin / toggle_keybindings.tmux.conf
Last active February 2, 2025 07:21
tmux.conf excerpt to toggle on/off session keybindings and prefix handling
bind -T root F12 \
set prefix None \;\
set key-table off \;\
set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\
set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\
set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\
if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
refresh-client -S \;\
bind -T off F12 \
@ykomatsu
ykomatsu / nix-macos.md
Created October 22, 2017 12:50
Installing Nix on macOS in single-user mode
@posener
posener / go-shebang-story.md
Last active June 6, 2025 17:44
Story: Writing Scripts with Go

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@nepsilon
nepsilon / how-to-force-a-file-download-in-the-browser.md
Last active April 5, 2017 05:57
How to force a file download in the browser? — First published in fullweb.io issue #93

How to force a file download in the browser?

The use case is simple, you have /reports/593874951.pdf on your web server and want to let your user download it — and if possible with a meaningful name.

In the past, you may tried using the Content-Disposition HTTP header to achieve this, but today, with Safari getting the support for the download attribute it’s going to simplify a lot of things.

Using the download attribute is simple as pie:

<a href="/reports/593874951.pdf" download="report.pdf">
 Download report
<html>
<script>
var db = openDatabase('watch','1.0','watch',104857600);
db.transaction(function(t) {
t.executeSql("CREATE TABLE IF NOT EXISTS events(time DATETIME, duration INTEGER, url TEXT);", []);
});
var event = null;
function eventclose(e) {
@marianogappa
marianogappa / backpressure.go
Created December 4, 2016 04:53
Example backpressure implementation in Go
/*
This snippet is an example of backpressure implementation in Go.
It doesn't run in Go Playground, because it starts an HTTP Server.
The example starts an HTTP server and sends multiple requests to it. The server starts denying
requests by replying an "X" (i.e. a 502) when its buffered channel reaches capacity.
This is not the same as rate-limiting; you might be interested in https://github.com/juju/ratelimit
or https://godoc.org/golang.org/x/time/rate.
@MarcoWorms
MarcoWorms / mini-redux.js
Last active June 3, 2024 04:42
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@briankung
briankung / docker-pry-rails.md
Last active January 2, 2025 05:19
Using pry-rails with Docker
@ttscoff
ttscoff / init.lua
Last active June 6, 2025 19:31
Hammerspoon config examples for hyper key
-- A global variable for the Hyper Mode
k = hs.hotkey.modal.new({}, "F17")
-- Trigger existing hyper key shortcuts
k:bind({}, 'm', nil, function() hs.eventtap.keyStroke({"cmd","alt","shift","ctrl"}, 'm') end)
-- OR build your own
launch = function(appname)