Skip to content

Instantly share code, notes, and snippets.

View KristianLyng's full-sized avatar

Kristian Lyngstøl KristianLyng

View GitHub Profile
kly@r2d2:~$ ./foo.c.sh foo.c.sh
0x23 0x21 0x2F 0x62 0x69 0x6E 0x2F 0x62 #!/bin/b
0x61 0x73 0x68 0x0A 0x0A 0x0A 0x5F 0x74 ash..._t
0x65 0x6D 0x70 0x3D 0x24 0x28 0x6D 0x6B emp=$(mk
0x74 0x65 0x6D 0x70 0x29 0x0A 0x0A 0x67 temp)..g
0x63 0x63 0x20 0x2D 0x78 0x20 0x63 0x20 cc.-x.c.
0x2D 0x6F 0x20 0x24 0x5F 0x74 0x65 0x6D -o.$_tem
0x70 0x20 0x2D 0x20 0x3C 0x3C 0x5F 0x45 p.-.<<_E
0x4F 0x46 0x5F 0x0A 0x23 0x69 0x6E 0x63 OF_.#inc
0x6C 0x75 0x64 0x65 0x20 0x3C 0x73 0x74 lude.<st
00000000000005c0 <main>:
#include <limits.h>
int main() {
int si = INT_MAX;
unsigned int ui = UINT_MAX;
printf ("si: %d (INT_MAX)\n", si);
5c0: 48 8d 3d fd 01 00 00 lea 0x1fd(%rip),%rdi # 7c4 <_IO_stdin_used+0x4>
int main() {
5c7: 48 83 ec 08 sub $0x8,%rsp
00000000000006f0 <main>:
#include <stdio.h>
#include <limits.h>
int main() {
6f0: 55 push %rbp
6f1: 48 89 e5 mov %rsp,%rbp
6f4: 48 83 ec 10 sub $0x10,%rsp
int si = INT_MAX;
6f8: c7 45 fc ff ff ff 7f movl $0x7fffffff,-0x4(%rbp)
kly@leia:~$ cat foo.c
#include <stdio.h>
#include <limits.h>
int main() {
int si = INT_MAX;
unsigned int ui = UINT_MAX;
printf ("si: %d (INT_MAX)\n", si);
printf ("ui: %u (UINT_MAX)\n", ui);
if (si > si + 1)
kly@leia:~/src/tgnms/extras/tools/lldp$ grep mylog lolwhat.pl
my $mylogindent = "";
mylog("Polling initial systems");
mylog("Probed auto-detected peers: " . scalar @chassis_ids_checked . " Total detected: " . scalar keys %lldppeers );
mylog("Probing complete. Trying to make road in the velling");
mylog("Done. Outputting JSON.");
mylog("$matches interfaces share MAC address. Calling it OK.");
mylog("$res mismatched interfaces versus $matches matched. Not enough for confidence.");
mylog("... So there are two systems that look 50% similar. $bad (But not the other way around)");
mylog("Lacking confidence. Doing in-depth comparison instead");
kly@leia:~$ cat foo.c
#include <stdio.h>
#include <limits.h>
int main(void) {
unsigned int i = UINT_MAX;
if (i > i+1) {
printf("i is larger than i + 1\n");
} else {
printf("i is not larger than i + 1\n");
}
kly@leia:~$ cat foo.c
#include <stdio.h>
#include <limits.h>
int main(void) {
int i = INT_MAX;
if (i > i+1) {
printf("i is larger than i + 1\n");
} else {
printf("i is not larger than i + 1\n");
}
kly@leia:~$ cat foo.c
#include <stdio.h>
#include <limits.h>
int main(void) {
int i = INT_MAX;
int j = i + 1;
printf ("%d vs %d (%s)\n",i,j, (i==j) ? "match" : "no match");
return 0;
}
kly@leia:~$ gcc -Wall -g foo.c
kly@leia:~$ cat foo.c
#include <stdio.h>
int main(void) {
float f = 340282346638528859811704183484516925440.000000;
float x = f * 2;
printf ("%f vs %f (%s)\n",f,x, (f==x) ? "match" : "no match");
return 0;
}
kly@leia:~$ gcc -Wall -g foo.c
kly@leia:~$ ./a.out
kly@leia:~$ cat foo.c
#include <stdio.h>
int main(void) {
float f = 340282346638528859811704183484516925440.000000;
float x = f + 199999999999999999999.9F;
printf ("%f vs %f (%s)\n",f,x, (f==x) ? "match" : "no match");
return 0;
}
kly@leia:~$ gcc -Wall -g foo.c
kly@leia:~$ ./a.out