Skip to content

Instantly share code, notes, and snippets.

;; help links
;; https://github.com/magit/magit/discussions/4674#discussioncomment-2668452
;; magit-blob-previous
;; magit-blob-next
;; * some links:
;; __ http://www.mattduck.com/2021-05-upgrading-to-emacs-28.html
(require 'package) ;; https://stackoverflow.com/a/14838150/2402577
(setq message-log-max t)
;; (when (eq system-type 'darwin)
;; (setq debug-on-error t))
uname_out="$(uname -s)"
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export COLORTERM=truecolor
export DEFAULT_USER="$(whoami)"
export ZSH=$HOME"/.oh-my-zsh"
CASE_SENSITIVE="true" # Uncomment the following line to use case-sensitive completion.
@marcogalluzzi
marcogalluzzi / hackerrank_cutting_metal_surplus.py
Last active August 17, 2024 18:25
Solution in Python to the HackerRank problem "Cutting metal surplus"
#
# HackerRank - Cutting Metal Surplus
#
# The owner of a metal rod factory has a surplus of rods of arbitrary lengths. A local contractor offers to buy any of the factory's
# surplus as long as all the rods have the same exact integer length, referred to as saleLength. The factory owner can increase the
# number of sellable rods by cutting each rod zero or more times, but each cut has a cost denoted by costPerCut. After all cuts have
# been made, any leftover rods having a length other than saleLength must be discarded for no profit. The factory owner's total profit
# for the sale is calculated as:
#
# totalProfit = totalUniformRods × saleLength × salePrice − totalCuts × costPerCut
@amarao
amarao / blame-praise.py
Last active September 28, 2025 15:59
Example of argparse with subparsers for python
#!/usr/bin/env python
import argparse
def main(command_line=None):
parser = argparse.ArgumentParser('Blame Praise app')
parser.add_argument(
'--debug',
action='store_true',
help='Print debug info'
@Blaisorblade
Blaisorblade / default-to-cycling-flycheck.el
Last active September 8, 2021 06:09
Emacs: Default `M-g n` and `M-g p` to flycheck if active, and (optionally) cycle for flycheck
;; Caveat: I'm an Elisp noob. I expect this will break if invoked before flycheck mode is possible, and am not sure that's possible.
;; Invoke flycheck preferentially when flycheck-mode is enabled.
;; My own workaround for https://github.com/commercialhaskell/intero/issues/268.
(defun flycheck-or-norm-next-error (&optional n reset)
(interactive "P")
(if flycheck-mode
(flycheck-next-error n reset)
(next-error n reset)))
@jpallari
jpallari / writing_tech_articles.md
Last active April 10, 2025 02:10
Writing tech articles

Writing tech articles

This is a description of how I write tech articles for various blogs. Hopefully someone else will find this useful as well.

Create a Gist for the article

When I begin writing a new article, I create a new [GitHub Gist][gist] for the article files. The Gist contains a file for the article text and code examples related to the article.

@kracekumar
kracekumar / auto-remove.el
Last active June 17, 2022 11:16
Emacs auto remove unused import statements in current python file
;;; auto-remove.el --- Auto remove unused functions in python
;;; Commentary:
;; Uses external tool autoflake to remove unused imports from a Python file.
;;; Code:
(defcustom python-autoflake-path (executable-find "autoflake")
"Autoflake executable path.
@welldan97
welldan97 / system-wide-clipboard.zsh
Created March 10, 2013 09:51
Zsh copy & paste system wide for OS X, like in emacs
pb-kill-line () {
zle kill-line
echo -n $CUTBUFFER | pbcopy
}
pb-kill-whole-line () {
zle kill-whole-line
echo -n $CUTBUFFER | pbcopy
}