Skip to content

Instantly share code, notes, and snippets.

View ba0f3's full-sized avatar
🇻🇳
#VietnamLeavesNoOneBehind

Huy Doan ba0f3

🇻🇳
#VietnamLeavesNoOneBehind
View GitHub Profile
import prompt, unicode, terminal
proc autoComplete(line: seq[Rune], cursorpos: int): seq[string] {.gcsafe.} =
if line.len == 0:
return @[]
if $line == "hi":
result = @["Hello", "Xin chao", "Bonjour"]
else:
var data = file.readFile()
var filedata = splitToChunks(data,24)
echo filedata
for i in filedata:
echo i
client.send(i & "\r\L")
client.send("DONE" & "\r\L")
@ba0f3
ba0f3 / socat-tcp-to-unix-socket.sh
Created August 29, 2019 08:34 — forked from ljjjustin/socat-tcp-to-unix-socket.sh
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3
@ba0f3
ba0f3 / gtk.css
Last active July 1, 2019 04:24
hide title bar on maximized windows (works on gnome-shell 3.32)
/*
CREDIT: Josh Sherman (https://joshtronic.com/2017/07/26/hide-title-bars-in-gnome-shell)
USAGE: copy and paste the code bellow in to ~/.config/gtk-3.0/gtk.css
*/
window.ssd.maximized separator:first-child + headerbar:backdrop,
window.ssd.maximized separator:first-child + headerbar,
window.ssd.maximized headerbar:first-child:backdrop,
window.ssd.maximized headerbar:first-child,
const NULL* = "\0"
type Row = seq[string]
let r: Row = @["qwe", NULL]
#!/usr/bin/perl
use strict;
# Usage:
# make_classless_option({ "subnet/mask" => "router", "subnet/mask" => "router", ... });
# subnet the subnet address, 4 dot-separated numbers
# mask the subnet mask length (e.g. /24 corresponds to 255.255.255.0, /8 corresponds to 255.0.0.0)
# router the router address, 4 dot-separated numbers
sub make_classless_option{
my $routes = shift;
@ba0f3
ba0f3 / gist:3d3e33080c0c82d6fc1717441ca411ab
Created December 3, 2018 04:13 — forked from Iristyle/gist:5005653
Configure HAProxy for userlists

Create SHA512 passwords

# make sure to use a leading space so that the command is not stored in your bash history!!
 mkpasswd -m sha-512 password1
# generates -> $6$yMgsow58.g/Z$mBjHfdVzqcF/LN.iwV23Eyqg.yGPTsp9pOwaStsJ6c4I4zL7BhucVVAkv5guf7OVRr8Pw0mHF4NrWBRCG5ci7/
 mkpasswd -m sha-512 password2
# generates -> $6$RZ86vRkQ$aRKN1HOsk6bDHBbMhS7jSo/p1NGFl4PvwY3KpU.72i./LvITi41nL84EkxOFXl.6Bmhynj/L7pYbfF0rUHtOB0
@ba0f3
ba0f3 / ssl-cert-info.sh
Created November 30, 2018 15:00
Shell script to check SSL certificate info like expiration date and subject. Taken from http://giantdorks.org/alain/shell-script-to-check-ssl-certificate-info-like-expiration-date-and-subject/
#!/bin/bash
usage()
{
cat <<EOF
Usage: $(basename $0) [options]
This shell script is a simple wrapper around the openssl binary. It uses
s_client to get certificate information from remote hosts, or x509 for local
certificate files. It can parse out some of the openssl output or just dump all
@ba0f3
ba0f3 / DumpHex.c
Created June 15, 2018 07:24 — forked from ccbrown/DumpHex.c
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@ba0f3
ba0f3 / ubuntu-resize-rootfs.sh
Created March 19, 2018 16:02
resize rootfs with out need of LiveCD (w/ or w/o LVM) - need to reboot once.
#!/bin/bash
#
# Resize root filesystem during boot.
#
# Alternative: http://www.ivarch.com/blogs/oss/2007/01/resize-a-live-root-fs-a-howto.shtml
# New size of root filesystem
ROOT_SIZE="100G"
# Check current filesystem type