Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View avatar-lavventura's full-sized avatar
🤖
Focusing

alper avatar-lavventura

🤖
Focusing
View GitHub Profile
@marcogalluzzi
marcogalluzzi / hackerrank_cutting_metal_surplus.py
Last active January 19, 2024 10:34
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 November 23, 2023 03:31
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)))
@jkpl
jkpl / writing_tech_articles.md
Last active April 16, 2024 10:45
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
}