Skip to content

Instantly share code, notes, and snippets.

View xieyunzi's full-sized avatar
🎛️
Automation

Reiner xieyunzi

🎛️
Automation
View GitHub Profile
@xieyunzi
xieyunzi / colortest.sh
Created May 30, 2019 13:05
colortest.sh display ANSI colours and test bold/blink attributes
#!/bin/bash --
#
# display ANSI colours and test bold/blink attributes
# orginates from Eterm distribution
#-------------------------------------------------------------------------
ESC=$'\x1b'
CSI="${ESC}["
RST="${CSI}m"
@xieyunzi
xieyunzi / color-spaces.pl
Created May 30, 2019 13:04
color-spaces.pl
#!/usr/bin/perl
# Author: Todd Larason <[email protected]>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
print "256 color mode\n\n";
# display back ground colors
for ($fgbg = 38; $fgbg <= 48; $fgbg +=10) {
@xieyunzi
xieyunzi / TrueColour.md
Created May 30, 2019 13:00 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Terminal Colors

There exists common confusion about terminal colors. This is what we have right now:

  • Plain ASCII
  • ANSI escape codes: 16 color codes with bold/italic and background
  • 256 color palette: 216 colors + 16 ANSI + 24 gray (colors are 24-bit)
  • 24-bit true color: "888" colors (aka 16 milion)
@xieyunzi
xieyunzi / send-packet.py
Created April 2, 2019 15:51 — forked from zarzen/send-packet.py
using scapy create tcp packet and catch it by wireshark
from scapy.all import *
def main():
"""
"""
packet = IP(dst="192.168.100.123")/TCP()/"from scapy packet"
send(packet)
def packet_with_seq_n():
@xieyunzi
xieyunzi / if->.clj
Created March 1, 2019 05:34
if->.clj
;; idea from https://stackoverflow.com/questions/11676120/why-dont-when-let-and-if-let-support-multiple-bindings-by-default
(defmacro if->
"Use this to avoid `if else nested hell`.
(if-> [true (prn 1) (prn 2) true (prn 3) (prn 4) false (prn 5) (prn 6)])"
[bindings]
(if (seq bindings)
`(if ~(first bindings)
(let [r# ~(second bindings)]
(or (if-> ~(vec (drop 3 bindings)))
r#))
@xieyunzi
xieyunzi / codesign_gdb.md
Created August 8, 2018 10:03 — forked from gravitylow/codesign_gdb.md
Codesign gdb on macOS

If you are getting this in gdb on macOS while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. gdbc)
@xieyunzi
xieyunzi / Makefile
Last active August 8, 2018 06:52
makefile for c
CFLAGS= -I../include
# https://stackoverflow.com/questions/22551167/using-a-result-of-shells-find-as-a-target-in-a-makefile
sources = $(shell find . -maxdepth 1 -name '*.c')
include $(sources:.c=.d)
# http://www.microhowto.info/howto/automatically_generate_makefile_dependencies.html
# generate dependencies
%.d: %.c
@set -e; rm -f $@; \
@xieyunzi
xieyunzi / makefile.md
Last active August 8, 2018 04:21
make create directories
BUILD_DIR = build

all: directories build

directories:
	mkdir -p $(BUILD_DIR)

build:
	gcc -c -o $(BUILD_DIR)/test test.c
curl -o /tmp/api.json http://127.0.0.1:80/docs/swagger.json && docker run -p 8099:8080 -e SWAGGER_JSON=/tmp/api.json -v /tmp/api.json:/tmp/api.json swaggerapi/swagger-ui
@xieyunzi
xieyunzi / gist:3b853baa562a59e6effe319e7a888280
Created July 19, 2018 15:08 — forked from juanje/gist:3797297
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir