Skip to content

Instantly share code, notes, and snippets.

@irisli
irisli / imgcat.sh
Created March 8, 2019 22:19
Image cat from iTerm (i didn't write this. Just hosting this here)
#!/bin/bash
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
# only accepts ESC backslash for ST. We use TERM instead of TMUX because TERM
# gets passed through ssh.
function print_osc() {
if [[ $TERM == screen* ]] ; then
printf "\033Ptmux;\033\033]"
else
@irisli
irisli / colors.md
Last active October 6, 2021 18:13
Github Flavored Markdown (GFM) Colored text

Using diff: red/green monospaced text

+ Green.Like all Byzantine agreement protocols, SCP makes no assumptions about the rational behavior of attackers.
- Red. Like all Byzantine agreement protocols, SCP makes no assumptions about the rational behavior of attackers.
Black. Like all Byzantine agreement protocols, SCP makes no assumptions about the rational behavior of attackers.

Using code comments: gray text

@irisli
irisli / __UC Berkeley Landmarks.md
Last active April 29, 2026 07:34
UC Berkeley landmarks coordinates (longitude and latitude) in JSON format

UC Berkeley landmarks coordinates (longitude and latitude) in JSON format

The js script converts xml files from the UC Berkeley website's map.

These may be outdated. Run the script yourself to get the latest data.

I do not own this data. I am simply converting the data between formats.

@irisli
irisli / 1-setupRaid.sh
Last active June 28, 2016 18:48
RAID setup for EC2 instances with ephemeral instance storage
# 8 disk raid 0
# sudo mdadm --create --verbose /dev/md0 --level=0 --name=EPHEMERAL_RAID --raid-devices=8 /dev/xvdb /dev/xvdc /dev/xvdd /dev/xvde /dev/xvdf /dev/xvdg /dev/xvdh /dev/xvdi
@irisli
irisli / creating-a-stellar-transaction.js
Last active June 28, 2024 15:03
Creating a Stellar transaction using JS Stellar SDK
// I made this gist in hopes that it is a good tutorial on creating, signing,
// and submitting a transaction using JS Stellar SDK.
// This gist assumes that you have:
// 1. Secret key of a funded account to be the source account
// 2. Public key of a funded account as a recipient
// 3. Access to JS Stellar SDK (https://github.com/stellar/js-stellar-sdk)
// This code can be run in the browser at https://www.stellar.org/developers/
// That site exposes a global StellarSdk object you can use.
@irisli
irisli / configure-make.txt
Created July 20, 2015 23:45
./configure && make
ubuntu@ip-172-31-34-58:~/stellar-core (master)./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
@irisli
irisli / callerName.js
Last active July 18, 2023 14:03
JavaScript get caller in strict mode
"use strict";
var stackTrace = (new Error()).stack; // Only tested in latest FF and Chrome
var callerName = stackTrace.replace(/^Error\s+/, ''); // Sanitize Chrome
callerName = callerName.split("\n")[1]; // 1st item is this, 2nd item is caller
callerName = callerName.replace(/^\s+at Object./, ''); // Sanitize Chrome
callerName = callerName.replace(/ \(.+\)$/, ''); // Sanitize Chrome
callerName = callerName.replace(/\@.+/, ''); // Sanitize Firefox
console.log(callerName)