Skip to content

Instantly share code, notes, and snippets.

weirane /
Last active Apr 20, 2021
Source file for "Lambda Calculus from the Ground Up"
# Source file for my blog "Lambda Calculus from the Ground Up"
# (zh_CN)
# Bool
def TRUE(x):
return lambda y: x
def FALSE(x):
return lambda y: y
weirane /
Last active Feb 14, 2021
Convert exported facebook JSON data to UTF-8 encoded
# Convert all JSON files inside directory `facebook`:
# $ fd --extension=json . facebook -x ./
import json
import sys
def parse(obj):
weirane /
Created May 30, 2020
System tray for email syncing state
# System tray icon displaying email syncing state.
# Tell the tray that email is syncing:
# kill -USR1 $(cat $XDG_RUNTIME_DIR/
# Sync has completed and recalculate new emails:
# kill -USR2 $(cat $XDG_RUNTIME_DIR/
# However, the `Gtk.StatusIcon` used in this script has been deprecated and I haven't found a
# replacement.
weirane / countdown
Last active Feb 15, 2020
Simple countdown script
View countdown
# Count down for a specified time
# Example (count down for 3 minutes and 30 seconds):
# $ countdown 3m 30s
shopt -s extglob
weirane / remove-onmousedown.user.js
Last active Jan 29, 2020
A tampermonkey script to disable redirections of Google search results by removing onmousedown event of <a> tags
View remove-onmousedown.user.js
// ==UserScript==
// @name Remove onmousedown in Google results
// @include*/search?*
// ==/UserScript==
// Much thanks to
(function() {
'use strict';
// This is a solution to a modified version of LeetCode 669. The original problem
// requires the modified root of the binary tree to be returned, while the solution
// below modifies it in place rather than returning the new root.
use std::cell::RefCell;
use std::rc::Rc;
weirane /
Created Dec 29, 2019
Mount drives using dmenu
chosen=$(lsblk -rnpo "name,label,size,type,mountpoint" |
awk '/part $/ { printf "%s %s (%s)\n",$1,$2,$3 }' |
dmenu -i -l 10 -p "Mount which drive?" |
cut -d' ' -f1)
if [ $? = 0 ] && [ -n "$chosen" ]; then
msg=$(udisksctl mount -b $chosen)
notify-send '💻 Mount' "$msg"
use std::path::PathBuf;
fn main() {
let p = PathBuf::from("/home/user");
println!("{}", p.display());