Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@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
@jrelo
jrelo / endianness.sh
Created November 10, 2016 20:52
test endianness
if [[ `echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6` -ne 1 ]]; then echo "big endian";else echo "little endian";fi
python -c "import struct; print 'little endian' if ord(struct.pack('L', 1)[0]) else 'big endian'"
@jrelo
jrelo / addtimes.sh
Created November 10, 2016 20:53
add times with awk
#!/bin/sh
EPOCH='jan 1 1970'
sum=0
for i in $(cat ${1})
do
echo $i
sum="$(date -u -d "$EPOCH $i" +%s) + $sum"
echo $sum
done
echo -e "(${sum}) / 60 / 60"|bc -l
@jrelo
jrelo / perlmodinfo.pl
Created November 15, 2016 15:53
perl mod info
#!/usr/bin/per
use warnings;
use lib '/opt/somelib/dir';
use SOME::Thing::Else;
for my $module ( @ARGV ) {
my $package = $module;
# From This::That to This/That.pm
s/::/\//g, s/$/.pm/ for $module;
@jrelo
jrelo / lesscolor.sh
Created November 23, 2016 03:31
Add colors in less pager with pygmentize.
cat <<EOF > ~/.lesscolor
#!/bin/sh
case "$1" in
*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
*.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
*.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
*.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass)
pygmentize -f 256 "$1";;
.bashrc|.bash_aliases|.bash_environment)
pygmentize -f 256 -l sh "$1"
@jrelo
jrelo / The Technical Interview Cheat Sheet.md
Created February 1, 2017 18:41 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@jrelo
jrelo / DoublyLinkedList.c
Created February 1, 2017 21:30 — forked from mycodeschool/DoublyLinkedList.c
Doubly Linked List implementation in C
/* Doubly Linked List implementation */
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node* next;
struct Node* prev;
};
@jrelo
jrelo / ld_search_paths.sh
Created February 2, 2017 14:58
ld(linker) search paths
ldconfig -v 2>/dev/null | grep -v ^$'\t'
ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
gcc -print-search-dirs | sed '/^lib/b 1;d;:1;s,/[^/.][^/]*/\.\./,/,;t 1;s,:[^=]*=,:;
$ gcc -m64 -Xlinker --verbose 2>/dev/null | grep SEARCH | sed 's/SEARCH_DIR("=\?\([^"]\+\)"); */\1\n/g' | grep -vE '^$'
@jrelo
jrelo / limits.h.c
Created February 2, 2017 15:00
var limits
#include <stdio.h>
#include <limits.h>
int main() {
printf("The number of bits in a byte %d\n", CHAR_BIT);
printf("The minimum value of SIGNED CHAR = %d\n", SCHAR_MIN);
printf("The maximum value of SIGNED CHAR = %d\n", SCHAR_MAX);
printf("The maximum value of UNSIGNED CHAR = %d\n", UCHAR_MAX);
@jrelo
jrelo / nofile_test.c
Last active February 2, 2017 15:04
NOFILE rlimit get/set/test
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
(gdb) set $rlim = &{0ll, 0ll}
# the number 7 here is important.