Skip to content

Instantly share code, notes, and snippets.

View panchoh's full-sized avatar
🍊

pancho horrillo panchoh

🍊
View GitHub Profile
@shivakar
shivakar / tls-server-in-memory-cert.go
Created December 12, 2015 17:16
TLS server with in-memory self-signed certificate
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"errors"
"log"
@joedicastro
joedicastro / configuration.nix
Last active July 20, 2024 22:53
My NixOS configuration
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
## DISK CONFIGURATION
imports =
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active July 24, 2024 08:58
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@tjamet
tjamet / tls-http-server.go
Created April 13, 2018 18:57
TLS HTTP server using in-memory certificate
// From https://github.com/golang/go/blob/c0547476f342665514904cf2581a62135d2366c3/src/net/http/server.go#L3223
// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted
// connections. It's used by ListenAndServe and ListenAndServeTLS so
// dead TCP connections (e.g. closing laptop mid-download) eventually
// go away.
type tcpKeepAliveListener struct {
*net.TCPListener
}
func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
@ddevault
ddevault / Makefile
Last active February 20, 2024 14:17
Tiny Wayland compositor
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
wayland-scanner server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h
@fnky
fnky / ANSI.md
Last active July 24, 2024 02:06
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@camsaul
camsaul / preview-markdown.el
Last active November 12, 2021 02:09
Markdown live previews source
;;; -*- lexical-binding: t; coding: utf-8; -*-
(defun cam/-scroll-percentage ()
(/ (float (line-number-at-pos (window-start)))
(float (line-number-at-pos (point-max)))))
(defun cam/-set-window-start-to-percentage (scroll-percentage)
(goto-char (point-min))
(let ((target-line-number (truncate (* (line-number-at-pos (point-max)) scroll-percentage))))
(forward-line (1- target-line-number)))
@windwp
windwp / media_preview.lua
Last active May 30, 2024 14:28
telescope media preview
local utils = require('telescope.utils')
local defaulter = utils.make_default_callable
local actions = require('telescope.actions')
local finders = require('telescope.finders')
local make_entry = require('telescope.make_entry')
local pickers = require('telescope.pickers')
local previewers = require('telescope.previewers')
local builtin = require('telescope.builtin')
local conf = require('telescope.config').values
local flatten = vim.tbl_flatten
@miyl
miyl / pipewire-out-default-switch.sh
Last active May 22, 2024 15:23
Pipewire default sink (output) switching (Pulseaudio pactl)
#! /usr/bin/env sh
# This script switches between whatever sinks exist.
# Removing pulseaudio (but not libpulse) means removing pacmd, so this is an attempt at switching the default via pactl instead.
# Sinks can be specified by name or index. Index changes sometimes when you disconnect and reconnect, restart or whatever, so names are better as they are persistent.
# Annoyingly the command used to switch audio over to a new sink cannot take a name as its argument, otherwise I'd only need the name here.
# TODO: Trigger a zenity or dmenu dialog with entr that asks whether to switch monitor and/or sound to hdmi? Could do
# the same for mounting.
@dietrichm
dietrichm / 99-logitech-webcam.rules
Last active November 8, 2022 10:53
Logitech C505e HD Webcam flickering
SUBSYSTEM=="video4linux", KERNEL=="video[0-9]*", ATTRS{product}=="C505e HD Webcam", ATTR{index}=="0", RUN+="/usr/bin/v4l2-ctl -d $devnode --set-ctrl=power_line_frequency=1"