Skip to content

Instantly share code, notes, and snippets.

function fzf-default() {
fzf --multi --ansi --select-1 --exit-0 --reverse --height '40%'
}
function fzf-cd() {
local DIR=$(fd --type d | fzf +m --ansi --select-1 --reverse)
if [ -n "$DIR" ]; then
cd $DIR
fi
}
#include <rocksdb/db.h>
class RocksDB {
public:
~RocksDB() { delete db_; }
rocksdb::Status open(const rocksdb::Options& options, std::string_view path) {
assert(!db_);
return rocksdb::DB::Open(options, std::string(path), &db_);
}
@yhirose
yhirose / immutable_update.js
Last active July 5, 2021 13:24
Immutable object update
// Based on 'Easy immutable objects in Javascript'
// https://spapas.github.io/2018/04/05/easy-immutable-objects/
const immutable_update = (obj, path, val) => {
if (!val) {
return path.reduce((obj, [path, val]) => immutable_update(obj, path, val), obj);
}
let parts = (typeof path === 'string' || path instanceof String) ? path.split('.') : path;
@yhirose
yhirose / calc.peg
Created May 8, 2022 13:57
Learn LLVM 12 - Chapter 03 - calc PEG grammar
calc <- decl expr
decl <- ('with' ident (',' ident)* ':')?
expr <- term (term_op term)*
term <- factor (factor_op factor)*
factor <- ident / number / '(' expr ')'
term_op <- < [+-] >
factor_op <- < [*/] >
@yhirose
yhirose / froggy.py
Created July 7, 2022 10:47
Froggy - Simple game on Terminal
#!/usr/bin/env python3
import curses
import datetime
import locale
import noise
ROWS = 16
COLS = 16
def get_rows_and_cols(scr):