Skip to content

Instantly share code, notes, and snippets.

@bascht
bascht / pinget.rb
Last active September 24, 2024 14:42
Download all a RSS feed and wget all the links for your personal offline reading pleasure. :)
#!/usr/bin/env ruby
# - encoding: utf-8 -
#
# E.g. with: pinget.rb https://feeds.pinboard.in/rss/secret:YOURSECRET/u:YOURUSERNAME/toread/
require 'rss'
require 'open-uri'
require 'uri'
WGET = ['wget',
@alcol80
alcol80 / btrfs-nixos-install.sh
Last active October 22, 2023 12:25
nixos install (boot + btrfs root + btrfs docker)
gdisk /dev/sda # make 1 partition
mkfs.vfat -n BOOT /dev/sda1
mkfs.btrfs -L root /dev/sdb
mkfs.btrfs -L docker /dev/sdc
mount -t btrfs -o noatime,discard,ssd,autodefrag,compress=lzo,space_cache /dev/sdb /mnt/
btrfs subvolume create /mnt/nixos
umount /mnt/
mount -t btrfs -o noatime,discard,ssd,autodefrag,compress=lzo,space_cache,subvol=nixos /dev/sdb /mnt/
@snakeye
snakeye / exif_gps.py
Last active July 11, 2024 19:54
Python: get GPS latitude and longitude coordinates from JPEG EXIF using exifread
import exifread
# based on https://gist.github.com/erans/983821
def _get_if_exist(data, key):
if key in data:
return data[key]
return None
@debanjan-basu
debanjan-basu / Makefile
Created March 29, 2016 12:24
JSON to BSON conversion in C
all: json2bson
clean:
rm -f json2bson
json2bson: json2bson.c
${CC} $(shell pkg-config --cflags json libmongo-client glib-2.0) -Wall -O0 -ggdb3 -std=c99 ${CFLAGS} \
$(shell pkg-config --libs json libmongo-client glib-2.0) -o $@ $^
check: all
./json2bson <test.json >test.bson
@lonsun
lonsun / .fish
Created July 11, 2016 22:46
Fish shell script to remove local Git branches that have been merged and no longer appear on remote.
function git_clean_branches
set base_branch develop
# work from our base branch
git checkout $base_branch
# remove local tracking branches where the remote branch is gone
git fetch -p
# find all local branches that have been merged into the base branch
@detrout
detrout / org-protocol.desktop
Created November 3, 2016 06:06
Desktop file to use org-protocol with xdg-open AKA GNOME 3 / KDE Plasma 5 (Save to ~/.local/share/applications/org-protocol.desktop
[Desktop Entry]
Version=1.0
Name=org-protocol helper
Comment=helper to allow GNOME to open org-protocol: pseudo-urls
TryExec=/usr/bin/emacsclient
Exec=/usr/bin/emacsclient %u
NoDisplay=true
Icon=emacs24
Terminal=false
Type=Application
@nvictus
nvictus / doi2bib
Last active February 27, 2023 23:48
Fetch reference citations in BibTeX, JSON or YAML from DOI
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import tempfile
import requests
import argparse
import textwrap
import sys
@bdarcus
bdarcus / setup.fish
Last active March 30, 2022 04:31
basic post-install setup script for fedora; run w/sudo
#!/usr/bin/env fish
# note: fish at first glance seems much more straightforward to setup with fisher than zsh with zinit
# In particular, fish works with XDG by default, while I wasted a lot of times on env variables
# to get it to work with zsh + zinnit correctly.
# fisher
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
# the theme options are many, but these two do async git update
@mortymacs
mortymacs / increase-emacs-startup.md
Last active February 18, 2020 19:33
Increase emacs startup speed

Add this line in /etc/profile:

if [ ! `ps -x | grep emacs | grep daemon | awk '{ print $2 }'` ]; then
  emacs --daemon 2> /dev/null
fi

Relogin again to start the daemon.

Now you can edit your files with emacsclient command like so:

@chux0519
chux0519 / multi-level-sort.rs
Created February 5, 2019 13:21
multi level sort in rust
/// Multi-level sort a slice of Foobars according to [(field, reverse)]
fn sort_by_names(f: &mut [Foobar], orderings: &[(Foofields, bool)]) {
use std::cmp::Ordering;
f.sort_by(|a, b| {
let mut cmp = Ordering::Equal;
for (field, reverse) in orderings {
if cmp != Ordering::Equal {
break;
}