Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@jrelo
jrelo / gist:447e179133aea78a1a38f782a48fec21
Created March 14, 2017 20:11 — forked from derpston/gist:2069716
Unpacking and repacking initramfs images
# Unpack
gzip -cd /boot/initramfs.example | cpio -i
# Repack
find . | cpio --dereference -o -H newc | gzip > /boot/initramfs.example
@jrelo
jrelo / merge_sort.c
Created March 18, 2017 12:36 — forked from mbalayil/merge_sort.c
Merge Sort using recursion in C
/**
* Divide : Divide the n-element array into two n/2-element
* sub-arrays
* Conquer : Sort the two sub-arrays recursively using
* merge sort
* Combine : Merge the two sorted subsequences to form the
* sorted array
**/
#include<stdio.h>
@jrelo
jrelo / virtualbox-clone-fixed-to-dynamic.md
Created March 20, 2017 00:15 — forked from stormwild/virtualbox-clone-fixed-to-dynamic.md
VirtualBox clone fixed size vm to dynamic, resize dynamic vm, expand partition

http://brainwreckedtech.wordpress.com/2012/01/08/howto-convert-vdis-between-fixed-sized-and-dynamic-in-virtualbox/ http://www.webdesignblog.asia/software/linux-software/resize-virtualbox-disk-image-manipulate-vdi/#comment-474

While there is no way to actually switch a VDI between fixed-size and dynamic, you can clone the existing VDI into a new one with different settings with VBoxManage.

VBoxManage clonehd [old-VDI] [new-VDI] --variant Standard
VBoxManage clonehd [old-VDI] [new-VDI] --variant Fixed

If you want to expand the capacity of a VDI, you can do so with

@jrelo
jrelo / Makefile
Created March 22, 2017 04:12 — forked from america/Makefile
simple makefile for C
TARGET = test
CC = gcc
CFLAGS = -c -v
VPATH = src
SRC = test.c
OBJ = $(SRC:.c=.o)
@jrelo
jrelo / Git Cheat Sheet
Created March 22, 2017 17:50 — forked from adamvduke/Git Cheat Sheet
Corey Floyd's git cheat sheet
via: http://groups.google.com/group/phillycocoa/browse_thread/thread/2d05f3eac5a7d260?hl=en
revert file:
git checkout HEAD path/to/file
OR
git checkout filename
pluck one file from another branch
git checkout Branch path/to/file
@jrelo
jrelo / ipv6-regex-test.sh
Created April 8, 2017 19:33 — forked from syzdek/ipv6-regex-test.sh
Simple script to test my IPv6 regular expression.
#!/bin/sh
#
# Use posixregex CLI tool from: https://github.com/syzdek/dmstools/blob/master/src/posixregex.c
RE_IPV4="((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
posixregex -r "^(${RE_IPV4})$" \
127.0.0.1 \
10.0.0.1 \
192.168.1.1 \
@jrelo
jrelo / extract_sql.pl
Created April 13, 2017 12:40 — forked from leoromanovsky/extract_sql.pl
Extract SQL tables from database dump
#!/usr/bin/perl -w
##############################################################################
##
## Written by: Jared Cheney <[email protected]>
##
## Original Template written by:
## Brandon Zehm <[email protected]> and Jared Cheney <[email protected]>
##
## License:
##
@jrelo
jrelo / ns-inet.sh
Created April 30, 2017 01:38 — forked from dpino/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
@jrelo
jrelo / iptables_tcpkill.sh
Created May 6, 2017 17:13 — forked from shekkbuilder/iptables_tcpkill.sh
iptables_killtcp.sh
#!/bin/bash
#more methods: http://rtomaszewski.blogspot.com/2012/11/how-to-forcibly-kill-established-tcp.html
if [ $# -lt 1 ];
then
printf "Usage: $0 <IP>\n" $#
exit 0
fi
raddr=$1
printf "Killing TCP connections to/from ${raddr}...\n"
iptables -I INPUT -s ${raddr} -p tcp -j REJECT --reject-with tcp-reset