This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source file for my blog "Lambda Calculus from the Ground Up" | |
# https://blog.ruo-chen.wang/r/10 (zh_CN) | |
# How to play with it: | |
# First load this file into the python interpreter: | |
# $ python3 -i lambda-calculus.py | |
# Then try: | |
# >>> toint(FACT(FOUR)) | |
# Bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Convert all JSON files inside directory `facebook`: | |
# $ fd --extension=json . facebook -x ./facebook-convert.py | |
import json | |
import sys | |
def parse(obj): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# System tray icon displaying email syncing state. | |
# Tell the tray that email is syncing: | |
# kill -USR1 $(cat $XDG_RUNTIME_DIR/mailtray.pid) | |
# Sync has completed and recalculate new emails: | |
# kill -USR2 $(cat $XDG_RUNTIME_DIR/mailtray.pid) | |
# | |
# However, the `Gtk.StatusIcon` used in this script has been deprecated and I haven't found a | |
# replacement. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Count down for a specified time | |
# Example (count down for 3 minutes and 30 seconds): | |
# $ countdown 3m 30s | |
shopt -s extglob | |
time=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Remove onmousedown in Google results | |
// @include https://www.google.*/search?* | |
// ==/UserScript== | |
// Much thanks to https://gist.github.com/3081371 | |
(function() { | |
'use strict'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
// | |
// https://leetcode.com/problems/trim-a-binary-search-tree/ | |
// https://rust.cc/article?id=93bb5260-7e17-4d1c-bc42-08a9873f219c | |
use std::cell::RefCell; | |
use std::rc::Rc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::path::PathBuf; | |
fn main() { | |
let p = PathBuf::from("/home/user"); | |
println!("{}", p.display()); | |
} |