Skip to content

Instantly share code, notes, and snippets.

View crazyboycjr's full-sized avatar
🎯
Focusing

Jingrong Chen crazyboycjr

🎯
Focusing
  • Duke University
  • Durham, NC
  • 02:29 (UTC -05:00)
View GitHub Profile
@crazyboycjr
crazyboycjr / spsc_queue.cc
Last active February 11, 2020 15:42
SpscQueue
#include <atomic>
#include <array>
#include <vector>
#include <cassert>
#include <memory>
#include <thread>
#include <chrono>
#include <cstdio>
/*!
@crazyboycjr
crazyboycjr / show_lldp.sh
Created August 7, 2019 05:10
demonstrate how to execute on mellanox os remotely
#!/bin/bash
read -r -d '' data << EOF
{
"execution_type": "sync",
"commands": [
"show lldp remote",
"show running-config"
]
}
./bootstrap.sh
./b2 tools/bcp
mkdir ../extract
dist/bin/bcp build chrono coroutine context log predef headers tools/boost_install ../extract
./bootstrap.sh --with-libraries=coroutine
./b2 --prefix=./dist --build-type=minimal variant=release link=static debug-symbols=on coroutine install -j 4
g++ b.cc -o b -g -Iextract/dist/include -Lextract/dist/lib/ -lboost_coroutine -lboost_context -lboost_thread
@crazyboycjr
crazyboycjr / word_list.js
Created September 1, 2019 09:03
扇贝背单词小插件
// usage: open chrome console, paste this and enter
const WORD_PER_PAGE = 10;
const START_PAGE = 1;
const END_PAGE = 10;
const BOOK_ID = 'tvbmg';
// const WORD_LIST_TYPE = 4; // 今日新词
const WORD_LIST_TYPE = 5; // 今日复习
function playItHere(e, link) {
@crazyboycjr
crazyboycjr / flags.vim
Last active September 11, 2019 13:34
hindent.vim for codefmt
" Copyright 2014 Google Inc. All rights reserved.
" Copyright 2019 Jingrong Chen [email protected]
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
" http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
@crazyboycjr
crazyboycjr / btrfs-snapshot.service
Last active January 4, 2020 08:46
btrfs snapshot automation
[Unit]
Description=Btrfs snapshot
[Service]
Type=oneshot
ExecStart=/usr/local/bin/do-btrfs-snapshot.sh
StandardOutput=journal
[Install]
WantedBy=multi-user.target
@crazyboycjr
crazyboycjr / GnuPlot Qt terminal Description
Last active February 5, 2020 19:38
GnuPlot Qt terminal hotkeys
While a GnuPlot window is active, you can press certain keys to perform certain actions:
a
Auto-scale to full x and y range (based on x and y values) and replot
b
Toggle between thick border (2 pixels wide) and thin border (1 pixel wide)
g
Toggle grid lines
h
Display help in Davinci
@crazyboycjr
crazyboycjr / bandwidth_allocation.py
Last active March 27, 2021 03:37
start_flow.py
#!/usr/bin/env python3
import subprocess
import threading
import shlex
import time
import argparse
hosts = [
'192.168.211.2',
'192.168.211.34',
@crazyboycjr
crazyboycjr / 71-k380-keyboard.rules
Created May 1, 2020 13:24
running xset in udev.rules
# /etc/udev/rules.d/71-k380-keyboard.rules
ACTION=="add", KERNEL=="hidraw[0-9]*", RUN+="/usr/bin/su cjr -c \"DISPLAY=:1 XAUTHORITY=/home/cjr/.Xauthority xset r rate 200 36\""
ACTION=="add", KERNEL=="hidraw[0-9]*", RUN+="/usr/bin/su cjr -c \"DISPLAY=:1 XAUTHORITY=/home/cjr/.Xauthority setxkbmap -option 'ctrl:nocaps'\""
@crazyboycjr
crazyboycjr / cmd-notify
Last active June 27, 2021 21:49
Usage: cmd-notify <your_command>
#!/bin/bash
WORKDIR=$(dirname `realpath $0`)
CMD=$*
env ${CMD}
status=$?
if [ $status -eq 0 ]; then
STATUS_PARAM="--success"