Skip to content

Instantly share code, notes, and snippets.

View bsdelf's full-sized avatar

bsdelf bsdelf

  • Shanghai
View GitHub Profile
@bsdelf
bsdelf / hide-twitter-trending.js
Created March 9, 2023 06:20
hide-twitter-trending.js
@bsdelf
bsdelf / gist:be794d961cce72781dcec1e4a78c0724
Last active December 1, 2022 03:44
how to customize xfce4-terminal shortcuts
% cat ~/.config/xfce4/terminal/accels.scm
(gtk_accel_path "<Actions>/terminal-window/new-tab" "<Super>t")
(gtk_accel_path "<Actions>/terminal-window/close-tab" "<Super>w")
(gtk_accel_path "<Actions>/terminal-window/copy" "<Super>c")
(gtk_accel_path "<Actions>/terminal-window/paste" "<Super>v")
(gtk_accel_path "<Actions>/terminal-window/search" "<Super>f")
(gtk_accel_path "<Actions>/terminal-window/prev-tab" "<Super>Left")
(gtk_accel_path "<Actions>/terminal-window/next-tab" "<Super>Right")
(gtk_accel_path "<Actions>/terminal-window/move-tab-left" "<Super><Shift>Left")
(gtk_accel_path "<Actions>/terminal-window/move-tab-right" "<Super><Shift>Right")
class Range {
constructor(from, to, step = 1) {
this.value = from;
this.to = to;
this.step = step;
}
next() {
if (this.value > this.to) {
return { value: undefined, done: true };
@bsdelf
bsdelf / yarn-list.js
Last active June 7, 2023 12:55
yarn list direct dependencies with locked version
const path = require('path');
const exec = require('child_process').exec;
function run(command) {
return new Promise((resolve, reject) => {
exec(command, function (error, stdout, stderr) {
if (error) {
reject(error);
} else {
resolve(stdout);
@bsdelf
bsdelf / binary_trees.cc
Last active December 4, 2019 03:16
benchmarks game - binary trees
#include <inttypes.h>
#include <condition_variable>
#include <deque>
#include <iostream>
#include <memory>
#include <mutex>
#include <thread>
#include <variant>
#include <vector>
cita git:(develop) ? % make release
RUSTFLAGS='-F warnings' cargo build -j 1 --all --release
Compiling create-genesis v0.1.0 (/tmp/cita/tools/create-genesis)
Compiling librocksdb-sys v6.1.2
error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> /tmp/cita/target/release/build/librocksdb-sys-9f0f3e945a905dbc/out/bindings.rs:3:8392
|
3 | pub const __GNUC_VA_LIST : u32 = 1 ; pub const __WORDSIZE : u32 = 64 ; pub const __DARWIN_ONLY_64_BIT_INO_T : u32 = 0 ; pub const __DARWIN_ONLY_VERS_1050 : u32 = 0 ; pub const __DARWIN_ONLY_UNIX_CONFORMANCE : u32 = 1 ; pub const __DARWIN_UNIX03 : u32 = 1 ; pub const __DARWIN_64_BIT_INO_T : u32 = 1 ; pub const __DARWIN_VERS_1050 : u32 = 1 ; pub const __DARWIN_NON_CANCELABLE : u32 = 0 ; pub const __DARWIN_SUF_64_BIT_INO_T : & 'static [ u8 ; 9usize ] = b"$INODE64\0" ; pub const __DARWIN_SUF_1050 : & 'static [ u8 ; 6usize ] = b"$1050\0" ; pub const __DARWIN_SUF_EXTSN : & 'static [ u8 ; 14usize ] = b"$DARWIN_EXTSN\0" ; pub const __DARWIN_C_ANSI : u3
@bsdelf
bsdelf / utf8.js
Created August 26, 2019 09:55
detect utf8 in pure js
// Reference:
// https://stackoverflow.com/questions/1031645/how-to-detect-utf-8-in-plain-c
export const isUtf8 = (data) => {
if (data.length <= 0) {
return false;
}
for (let i = 0; i < data.length; ) {
const a = data[i];
if ([0x09, 0x0a, 0x0d].includes(a) || (0x20 <= a && a <= 0x7e)) {
package main
import (
"os"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/kataras/iris"
"github.com/astaxie/beego"
@bsdelf
bsdelf / EasyJumpPreciseMotionAce.vim
Created November 14, 2017 07:32 — forked from gfixler/EasyJumpPreciseMotionAce.vim
A Vim take on Emacs' AceJump mode, itself based on Vim's PreciseJump and EasyMotion plugins
" ACEJUMP
" Based on emacs' AceJump feature (http://www.emacswiki.org/emacs/AceJump).
" AceJump based on these Vim plugins:
" EasyMotion (http://www.vim.org/scripts/script.php?script_id=3526)
" PreciseJump (http://www.vim.org/scripts/script.php?script_id=3437)
" Type AJ mapping, followed by a lower or uppercase letter.
" All words on the screen starting with that letter will have
" their first letters replaced with a sequential character.
" Type this character to jump to that word.
@bsdelf
bsdelf / main.cc
Created August 17, 2014 13:38
remove watermark for "pdf.th7.cn/down/files/1407/Real%20World%20OCaml.pdf"
/*
* clang++ -I/usr/local/include -pipe -std=c++11 -stdlib=libc++ -o main.cc.o -c main.cc
* clang++ -L/usr/local/lib -lpodofo -stdlib=libc++ -o b.out main.cc.o
*
*/
#include <iostream>
#include <string>
#include <list>
using namespace std;