Skip to content

Instantly share code, notes, and snippets.

View davidhcefx's full-sized avatar
PRO

davidhcefx davidhcefx

PRO
View GitHub Profile
@davidhcefx
davidhcefx / IPython Custom Magic Commands.md
Last active August 5, 2023 17:37
defining ipython custom magic command

help - IPython Custom Magic Command

If you are a command-line lover, then it is likely that ipython is already one of your friend. In Python, help() is our swiss army knife. However, always having to embrace commands with parathesis, ( and ), is really a hassle! Wouldn't it be great if we could simply invoke like this?

%help unknown_command
@davidhcefx
davidhcefx / My Tmux Config.md
Last active March 1, 2024 11:27
Clipboard Integration, Mouse Selection, Intuition

My Tmux Config

Features

  • More intuitive. (eg. + to create windows, | to split horizontally, Ctrl+C to copy, End to move to end-of-line)
  • System clipboard integration. (support: MacOS, X-Window, Cygwin)
  • Words highlighted by your mouse will stay on the screen; good for explaining stuff to others.

Installation

  1. Install tmux, for example, via apt-get install tmux.
  2. Under home directory, create a file ~/.tmux.conf with the following contents.
@davidhcefx
davidhcefx / 逆向工程筆記.md
Last active March 7, 2023 03:49
My notes while playing with reverse engineering.

以下是我自己的逆向工程筆記!有錯還請多多指教XD


    ┌───────── ASCII ─────────┐
    │  30   0    20    SPACE  │
    │  41   A    0d0a  CRLF   │
    │  61   a                 │
    └─────────────────────────┘
@davidhcefx
davidhcefx / highlight.js Language to Library Name Mappings.py
Last active April 19, 2022 21:38
Generate mappings from a language to its corresponding script name and dependencies for highlight.js
"""
Generate mappings from a language to its corresponding script name and
dependencies for highlight.js. Tool written by davidhcefx, 2020.8.24.
In highlight.js, we highlight codes via <pre><code class="language"></code></pre>
However, what is the corresponding JS script name for a specific language?
What are the dependencies, if any, in order to use that language?
This tool aims to build the relationships by parsing the source files.
"""
from typing import List, Dict
@davidhcefx
davidhcefx / Disadvantages of Linux.md
Last active April 14, 2022 01:10
Some disadvantages of Linux I know too well...

rsync

I was using rsync -e "ssh" to transfer files between local and remote computer. If I want to transfer a file from remote to local, the command will be like rsync -av --delete -e "ssh" user@ip:/path/to/fileA /home/user/folder/. One day, however, I thought I could transfer a remote folder /path/to/folderA/ to my home /home/user/. After running the command, I found that it started erasing my home directory! Since Linux has disk encryption by default, I failed to rescue those files eventually ;(

bash_history

My bash history was stored as ~/.bash_history. One day, I was running a huge apt upgrade. It took me plenty of time, so I left it and went to sleep. However, I forgot that my laptop was in battery mode. So eventually, the battery ran out, and my computer experienced an abnormal power off, which resulted in me having a corrupted bash_history. I have no backups, so I lost all my bash history ;(

tee

I just learned how to use tee to app

@davidhcefx
davidhcefx / My Man Page Coloring.md
Last active November 4, 2020 14:43
Beautiful man page!

Config

#! /bin/bash
export LESS_TERMCAP_md=$'\e[38;5;203m\e[1m'  # bold: bold red
export LESS_TERMCAP_mb=$'\e[38;5;135m'       # blink: purple
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_us=$'\e[2;1;4;32m'       # underline: green
export LESS_TERMCAP_ue=$'\e[0m'
@davidhcefx
davidhcefx / Make CTFd Display Custom Fields for In-class Projects.md
Last active February 14, 2023 15:59
When using CTFd for in-class projects, you might want to display additional info such as "Is this user a course student?".

Agila Monokai Extended Brown.tmTheme

I am a big fan of Monokai theme and colors. This color scheme is basically the same as Agila's Monokai Extended color scheme, except that all gray backgrounds have been replaced with a nice looking brown one! :) (plus issue #43 been fixed)

Screenshot

Agila Monokai Extended Brown

Note that I only demonstrated the Color Scheme, not the Theme. The theme I used was Spacegray Eighties.

Prettydot - Human readable dot graph language for CFG

Background

[Dot][] is a graph description language in extensions .dot or .gv, and can be read by programs such as Graphviz ([try it online][]). However, it's syntax is too complicated for the goal of generating a simple control-flow graph, and is not very well human readable. Therefore, I defined a new language, prettydot, for this purpose.

@davidhcefx
davidhcefx / Nano's Rainbow Color Testing.md
Last active March 18, 2022 21:39
An overview of 256 color supported by nano config file

Nano's Rainbow Color Testing

An overview of 256 color supported by nano config file.

Instruction

  1. Download the following file rainbow.nanorc.
  2. Run nano -f /path/to/this/file /path/to/this/file

Note that for nano with version < 6.0, only 16 colors would be highlighted.