Skip to content

Instantly share code, notes, and snippets.

View RodrigoDornelles's full-sized avatar
:bowtie:
IEEE 754

RodrigoDornelles

:bowtie:
IEEE 754
  • Porto Alegre, RS, Brasil
View GitHub Profile
@RodrigoDornelles
RodrigoDornelles / generic.c
Created June 25, 2021 13:39
Simple generic programming example using C11
#include <stdio.h>
const char* tni();
const char* tnf();
#define typename(T) ((_Generic((T), int: tni, float: tnf))())
int main()
{
int foo;
#!/usr/bin/env bash
if [ `whoami` != 'root' ]
then
echo "[!] Error: requires root!";
exit;
fi
echo " * Clearing ram PageCache";
sync;
echo 1 > /proc/sys/vm/drop_caches;
@RodrigoDornelles
RodrigoDornelles / computational-measures.md
Last active January 4, 2021 17:28
computational data quantity list of information

Computational Measures

  • Bit smallest computational unit, only use two values. (ex: 0 or 1)
  • Byte composed of 8 bits, enough to show a simple and unique character. ASCII

Kb, Mb, Gb, Tb

1 Kilobit 1000 bits
1 Megabit 1000 Kilobits
1 Gigabit 1000 Megabits
@RodrigoDornelles
RodrigoDornelles / bubble.hack
Last active December 9, 2020 00:20 — forked from PedroEscudero/bubble.php
Bubble script for testing speed of Hack
function bubble_sort(dict $array): string {
$start = microtime(true);
do
{
$sw = false;
for($i = 0, $size = count($array) - 1; $i < $size; $i++)
{
if( $array[$i] > $array[$i + 1] )
{
$aux = $array[$i + 1];
@RodrigoDornelles
RodrigoDornelles / gist:aae1882bc29ca67bb521196a2181a51d
Created December 1, 2020 18:22
simple slugfy sql command with regex
UPDATE page SET slug = regexp_replace(title, '[^a-z]+', '-', 'g');
@RodrigoDornelles
RodrigoDornelles / gist:f1fda8ba4d88b15f85169474dcf1d1bb
Created November 30, 2020 20:44
mysql dump to postgres stdin
mysqldump -u <username> -p<password> -T . <database> --fields-terminated-by '\t' --fields-escaped-by '\'
@RodrigoDornelles
RodrigoDornelles / concat_two_files.py
Last active January 12, 2021 15:25
concatenate two files line by line using a simple python script.
import sys, itertools
try:
file1, file2 = open(sys.argv[1], 'r').readlines(), open(sys.argv[2], 'r').readlines()
[sys.stdout.write(l1.replace('\n', '') + l2.replace('\n', '')) for (l1,l2) in itertools.zip_longest(file1, file2, fillvalue='')]
except:
sys.stderr.write('[!] Error: require two valid files!')