Skip to content

Instantly share code, notes, and snippets.

@syrusakbary
syrusakbary / benchmark.md
Created March 16, 2024 20:16
Pystone benchmark comparison (Native vs CPython interpreter vs Nuitka)

Native

When executing Python natively:

$ python pystone.py
Pystone(1.1) time for 50000 passes = 0.129016
This machine benchmarks at 387549 pystones/second
@Akhil-CM
Akhil-CM / symlink.py
Last active January 18, 2024 05:00
symlink.py :- A simple symlinking tool similar to ln from gnu-coreutils but with more features
@jameshulse
jameshulse / how.sh
Created January 12, 2024 22:16
Bash script to determine how a binary was installed
how() {
YELLOW='\033[1;33m'
NC='\033[0m'
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: $0 <binary name>"
echo ""
echo "This will search for the binary in a few different places and try and determine how it was installed."
return 1
fi
@eggbean
eggbean / install_scoop.ps1
Last active July 19, 2024 07:52
PowerShell script to install scoop for multi-users and install packages that I use.
# PowerShell script to install scoop for multi-user and packages.
# If scoop is already installed, any additional packages are installed
# and shims are reset in order of the package list.
#
# To avoid git ownership warnings, read this:
# https://stackoverflow.com/a/71904131/140872
# git config --global --add safe.directory "*" (double quotes on Windows)
# Test if Admin
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
@sebastiancarlos
sebastiancarlos / free-color.bash
Last active September 8, 2023 20:37
Custom version of the "free" command, with color.
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=Dl2n_fcDjkE
### Add this to your .bashrc
# custom free
# - add common options
# - add color
# - add footer
@JiayinCao
JiayinCao / tiny_fiber.h
Last active May 11, 2024 07:40
Tiny Fiber ( A razor thin cross platform fiber library )
/*
MIT License
Copyright (c) 2023 Jiayin Cao
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@sebastiancarlos
sebastiancarlos / custom-locate.bash
Last active August 23, 2023 11:52
locate is great, but you can make it faster with a custom updatedb
# All my gist code is licensed under the terms of the MIT license.
# Video demo: https://www.youtube.com/watch?v=KFtZbsSG_fA
# add this to your ~/.bashrc or something like that
# alias for every locate database
alias locate="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb-min"
alias locatehome="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb-home"
alias locateall="glocate --regextype=posix-extended --database=${HOME}/tmp/locatedb"
;; emacs-gpt.el -- Control Emacs via ChatGPT
;;
;; Basic idea: take natural language input from user, ask ChatGPT for
;; corresponding elisp, run it.
(defun mark-between-assistant-and-user ()
"Mark the region between \"%assistant%\" and \"%user%\", not including those strings."
(interactive)
(goto-char (point-min))
@maliMirkec
maliMirkec / .bashrc
Created March 15, 2023 13:17
.bashrc
# reload source
alias brc="source ~/.config/fish/.bashrc"
# open explorer in current folder
alias e.="explorer ."
# git: log pretty
alias gl="git log --oneline --graph"
# git: status condensed
@vivekhaldar
vivekhaldar / chat-gpt.el
Last active December 17, 2023 15:51
Emacs lisp to call out to Python script that calls ChatGPT API + Markdown derived mode for the chat transcripts.
;; Emacs Lisp wrapper around Python scripts for ChatGPT.
;;
;; Basic idea is to send buffer as stdin to Python script.
(defvar gpt-script "/Users/haldar/haskell/gpt_turbo/chat.py")
(defun vh/invoke-chat ()
"Send contents of current buffer as stdin to command, then append output to current buffer."
(interactive)
(let*