Skip to content

Instantly share code, notes, and snippets.

View a2gs's full-sized avatar
😎
nice

André Augusto Giannotti Scotá a2gs

😎
nice
View GitHub Profile
@a2gs
a2gs / floatError.c
Last active March 3, 2019 04:46
Floating-point error
#include <stdio.h>
int main(int argc, char *argv[])
{
double x = 516.80, y = 0;
long resp1 = 0, resp2 = 0;
resp1 =(long) (x * 100.0);
y = x * 100.0;
resp2 = (long)y;
printf("x[%f] y[%f] resp1[%ld] resp2[%ld] [%f]\n", x, y, resp1, resp2, (x * 100.0));
@a2gs
a2gs / gprof_test.c
Last active March 4, 2019 02:49
gprof(1) Usage
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
void f1(void)
{
sleep(2);
}
unsigned int f2(unsigned int x)
@a2gs
a2gs / getaddrinfo.c
Created February 20, 2019 01:34
getaddrinfo(3) usage
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#define ADDSZ (50)
@a2gs
a2gs / tmux-cheatsheet.markdown
Created February 26, 2019 02:45 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@a2gs
a2gs / leapYear.c
Last active March 4, 2019 02:43
Leap year calculation
/*
* 1 - is
* 0 - is not
*/
int a2gs_AddSubDate_isLeapYear(int year)
{
if(year % 4 == 0){
if(year % 100 == 0){
if(year % 400 == 0)
return(1);
@a2gs
a2gs / loopFgets.c
Created March 9, 2019 19:30
Loop above fgets() return instead feof()
/*
gcc -o loopFgets loopFgets.c -g -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-result -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -D_POSIX_SOURCE=1 -D_DEFAULT_SOURCE=1 -D_GNU_SOURCE=1
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define MAX_BUFF (10000)
@a2gs
a2gs / ShellScript_Oracle_DB.sh
Created March 12, 2019 20:00
Shell script accessing Oracle DB little sample
#!/usr/bin/sh
DATA=`date +'%d%m%Y'`
TABELA=TABELA_ABC
CAMPO=DATA_CRIACAO
TEMPO=30
DB_USER=db_user
DB_PASSWORD=db_user_password
DB_INSTANCE=connection_instance
@a2gs
a2gs / ShellScript_AWK.sh
Created March 12, 2019 20:03
Shell script calling a (inside) AWK script
#!/usr/bin/sh
func(){
awk -v VAR1=$3 -v VAR2=$4 '
BEGIN{
}
{
print VAR1 VAR2
print
@a2gs
a2gs / gdbinit
Created March 13, 2019 04:55 — forked from chrislongo/gdbinit
.gdbinit - A user-friendly gdb configuration file
# INSTALL INSTRUCTIONS: save as ~/.gdbinit
#
# DESCRIPTION: A user-friendly gdb configuration file.
#
# REVISION : 7.3 (16/04/2010)
#
# CONTRIBUTORS: mammon_, elaine, pusillus, mong, zhang le, l0kit,
# truthix the cyberpunk, fG!, gln
#
# FEEDBACK: https://www.reverse-engineering.net
@a2gs
a2gs / exit_vrs_return.c
Last active March 16, 2019 05:19
exit() vrs return() into main()
#include <stdio.h>
#include <stdlib.h>
static char *message;
void cleanup(void)
{
printf("message = \"%s\"\n", message);
}