View gist:c60466b32e5e7204f83e243f316d067e
/* | |
* Example of embedding Github gists. | |
*/ |
View pseudo_meltdown.c
#include <setjmp.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <string.h> | |
void primer(char probe[256]) { | |
// Some specific address | |
int addr = 136322; | |
// This will throw segmentation fault, but we're "catching it" | |
char v = *(char *)addr; |
View spectre.js
if (bigvalue < a.length) { | |
value = a[bigvalue]; | |
if (value & 1 > 0) { | |
x = a[100]; | |
} else { | |
x = a[200]; | |
} | |
} | |
// Timing attack | |
const t1 = performance.now(); |
View will_change.css
.moving-element { | |
will-change: transform; | |
} |
View last_child_efficient.css
.final-box-title { | |
/* styles */ | |
} |
View last_child_expensive.css
.box:nth-last-child(-n+1) .title { | |
/* styles */ | |
} |
View measurement.js
performance.mark('expensive-start'); | |
expensive(); | |
performance.mark('expensive-end'); | |
const value = performance.measure( | |
'expensive-mark', | |
'expensive-start', | |
'expensive-end', | |
); |
View on_click.js
button.onclick = () => { | |
expensive(); | |
} |
View iterate.c
for(p = servinfo; p != NULL; p = p->ai_next) { | |
sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); | |
if (sockfd == -1) { | |
perror("client: socket"); | |
continue; | |
} | |
if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) { | |
close(sockfd); | |
perror("client: connect"); |
View gist:5cd0e806a83ff68d33016555607c5ebb
struct addrinfo { | |
int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc. | |
int ai_family; // AF_INET, AF_INET6, AF_UNSPEC | |
int ai_socktype; // SOCK_STREAM, SOCK_DGRAM | |
int ai_protocol; // use 0 for "any" | |
size_t ai_addrlen; // size of ai_addr in bytes | |
struct sockaddr *ai_addr; // struct sockaddr_in or _in6 | |
char *ai_canonname; // full canonical hostname | |
struct addrinfo *ai_next; // linked list, next node |
NewerOlder