Skip to content

Instantly share code, notes, and snippets.

View kidsil's full-sized avatar

Asaf Zamir kidsil

View GitHub Profile
@kidsil
kidsil / .zshrc
Created May 21, 2024 12:15
git first and last commits using git log - zsh functions/aliases
# Function to show the first X commits
function git-first {
git log --format="%H" | tac | head -n $1 | xargs git log -p
}
# Function to show the last X commits
function git-last {
git log -p -n $1
}
@kidsil
kidsil / white-or-brown-noise.sh
Created January 17, 2024 15:21
White and Brown noise on Linux - No sox needed
# Brown noise
ffmpeg.ffplay -f lavfi -showmode 0 -i 'anoisesrc=color=brown'
# White Noise
ffmpeg.ffplay -f lavfi -showmode 0 -i 'anoisesrc=color=white'
@kidsil
kidsil / create-shuffled-albums.sh
Created November 16, 2023 10:09
Cmus create shuffled albums playlist from your library
#!/bin/bash
# Album limit
ALBUM_LIMIT=10
# Get latest library from cmus
cmus-remote -C "save -l $(pwd)/cmus-library.pl"
# Use awk to group songs by album
awk -F'/' '{
@kidsil
kidsil / head.html
Created October 13, 2022 14:23
Ultimate Jekyll meta_description conditional
{% comment %} TODO this should likely be resolved by proper layout usage (dedicated paginator page layout for starters) {% endcomment %}
{% assign meta_desc = site.description %}
{% unless page.url == '/' %}
{% if page.meta_description %}
{% capture meta_desc %}{{ page.meta_description }}{% endcapture %}
{% elsif page.excerpt %}
{% capture meta_desc %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% endcapture %}
{% elsif page.content %}
{% if page.content contains "for post in paginator.posts" %}
@kidsil
kidsil / generate_categories.rb
Last active October 13, 2022 15:24
Generating Tags and Categories pages and links - old and liquid based fixes
# encoding: utf-8
#
# Jekyll category page generator.
# http://recursive-design.com/projects/jekyll-plugins/
#
# Version: 0.2.4 (201210160037)
#
# Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
#
@kidsil
kidsil / bookmarks.js
Created August 4, 2022 12:34
PR Scripts - bookmarks for GitHub PRs
// Add these to your browser as bookmarks:
// Filter commentless files
javascript:document.querySelectorAll('#files%20>%20div%20>%20div').forEach((e)%20=>%20{%20if%20(e.querySelectorAll('[data-disable-with="Resolving%20conversation%E2%80%A6"]').length%20===%200)%20{%20e.style.display%20=%20'none';%20}%20%20})
// Filter viewed files
javascript:document.querySelectorAll('#files%20input[name="viewed"][data-ga-click$="value:true"]').forEach(e=>{e.closest(".file").style.display="none"});
// Fold All (a bit slow)
javascript:document.querySelectorAll('.file-info > button[aria-expanded="true"]:nth-child(1)').forEach((e) => { e.click() })
@kidsil
kidsil / .zshrc
Created October 13, 2021 13:22
Alias for local.run on .zshrc
# Alias for local.run (locally served content), defaults to localhost:80
function locrun {
INPUT_HOST=$1
if [ -z "$1" ];
then INPUT_HOST="localhost:80"
else INPUT_HOST=$1
fi
ssh -R 80:$INPUT_HOST nokey@localhost.run
}
@kidsil
kidsil / pdfcomp
Created October 8, 2021 07:39
pdf compress alias zsh
# Alias to compress pdf
function pdfcomp {
INPUT_FILE=$1
FILE_EXTENSION="${INPUT_FILE##*.}"
FILE_NAME="${INPUT_FILE%.*}"
OUTPUT_FILE="$FILE_NAME-compressed.$FILE_EXTENSION"
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$OUTPUT_FILE $INPUT_FILE
}
@kidsil
kidsil / speedup.sh
Created February 17, 2021 17:28
Script to Speed up Audio to 1.5 (for podcasts on cmus)
#!/bin/bash
for file in "$@"; do
echo "$file"
ffmpeg -i $file -af atempo=1.5 faster_$file
done
@kidsil
kidsil / javascript.json
Created June 10, 2020 11:34
VS Code console.log snippet with filename & line number
"Console_Log_File": {
"prefix": "clg",
"body": [
"console.log('${TM_FILENAME}#${TM_LINE_NUMBER}: ', ${1:var});"
]
}
//expands clg to console.log('filename.js#line-number: , VAR);