Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@jrelo
jrelo / Makefile
Created April 24, 2016 02:38
Basic linux kernel module Makefile.
obj-m += test_module.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
@jrelo
jrelo / japanese_colors.sh
Created May 9, 2016 18:01
Echo japanese color names in their respective colors using ascii color codes.
#!/bin/bash
echo -e "\e[34m青い \e[31m赤い \e[32m緑 \e[93m黄色い \e[35m紫 \e[95mピンク \e[30m黒い \e[97m白い \e[33mオレンギ"
@jrelo
jrelo / rsync_parallel.sh
Last active May 10, 2016 04:38 — forked from rcoup/rsync_parallel.sh
Parallel-ise an rsync transfer when you want multiple concurrent transfers happening,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@jrelo
jrelo / sysinitv_to_systemd.md
Last active May 10, 2016 22:58
sysinitv -> systemd cheat sheet from fedoraproject.org
Sysvinit Command Systemd Command Notes
service frobozz start systemctl start frobozz Used to start a service (not reboot persistent)
service frobozz stop systemctl stop frobozz Used to stop a service (not reboot persistent)
service frobozz restart systemctl restart frobozz Used to stop and then start a service
service frobozz reload systemctl reload frobozz When supported, reloads the config file without interrupting pending operations.
service frobozz condrestart systemctl condrestart frobozz Restarts if the service is already running.
service frobozz status systemctl status frobozz Tells whether a service is currently running.
ls /etc/rc.d/init.d/ systemctl (or) systemctl list-unit-files --type=service (or) ls /lib/systemd/system/.service /etc/systemd/system/.service Used to list the services that can be started or stopped. Used to list all the services and other units.
chkconfig frobozz on syst
@jrelo
jrelo / bitflip.pl
Created May 26, 2016 21:24
flip single bit using perl.
[16:25:27] root@na:~ # echo "A"|xxd -b
0000000: 01000001 00001010 A.
[16:25:30] root@na:~ # echo "A"|perl -e '$byte=shift(@ARGV);$bit=shift(@ARGV);undef $/; $in=<>; substr($in,$byte,1) = substr($in,$byte,1) ^ chr(1<<$bit); print $in' 0 1|xxd -b
0000000: 01000011 00001010 C.
@jrelo
jrelo / gist:183328e6dfabf8103ba5ea491808ae65
Created October 7, 2016 13:54 — forked from afair/gist:2402068
Perl References for Kittens

Perl References

Simple Perl variables are called scalars. Examples of scalar values are

   $number      = 123;
   $string      = "String";
   $file_handle = open "<filename";
   $null_value  = undef;
 $reference = \"Reference of a String";
@jrelo
jrelo / print_env.c
Created October 25, 2016 01:15
Test setenv and print environment variables from *envp[] arg in main() versus extern char** environ;
#include <stdio.h>
#include <stdlib.h>
extern char** environ;
int main(int argc, char *argv[], char *envp[])
{
int i;
setenv("TESTVAR", "watvalue123", 1);
printf("From char *envp[]:\n");
@jrelo
jrelo / ulli.c
Created November 10, 2016 20:50
unsigned long long int
#include <stdio.h>
#include <limits.h>
int main() {
unsigned long long ulli;
printf("%d", sizeof(ulli));
printf("%llu\n", ULLONG_MAX);
printf("%llu ... or \n", ~(unsigned long long)0);
printf("%llu\n", (unsigned long long)0 - 1);
return 0;
@jrelo
jrelo / ftrace-it.sh
Created November 10, 2016 20:51
ftrace it
#!/bin/bash
DEBUGFS=`grep debugfs /proc/mounts | awk '{ print $2; }'`
echo $$ > $DEBUGFS/tracing/set_ftrace_pid
echo function > $DEBUGFS/tracing/current_tracer
echo 1 > $DEBUGFS/tracing/tracing_on
exec $*
echo 0 > $DEBUGFS/tracing/tracing_on
@jrelo
jrelo / curltest.sh
Created November 10, 2016 20:52
curl test
cat <<EOF> curl-format.txt
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n