This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objects = main.o Var.o List.o | |
CCFLAGS = -Wall -Wextra -Wpedantic | |
main : $(objects) | |
cc $(CCFLAGS) -o main $(objects) | |
.PHONY : clean | |
clean: | |
rm -f main $(objects) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ifconfig eth0 | grep -P '[0-9].[0-9].[0-9].[0-9]$' | awk '{ print $2 }' | awk '{split($0,a,":"); print a[2]}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <limits.h> /* for LONG_MAX, INT_MAX */ | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#define IS_ASCII_DIGIT(c) (((c >= 48) && (c <= 57))) | |
long __my_atoi(char* buffer) | |
{ | |
if(buffer == NULL) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global _start | |
section .text | |
_start: | |
; write (sys_write) | |
; %rdi | |
; unsigned int fd | |
; %rsi | |
; const char __user *buf | |
; %rdx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
/* | |
* https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html | |
*/ | |
bool isPowerOf2(unsigned int x) | |
{ | |
/* | |
* Convert # into binary | |
* If there is more than 1 "1", then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* return the Hamming Weight | |
*/ | |
int my_pop_count(size_t x) | |
{ | |
unsigned setBits = 0; | |
do { | |
int rem = x % 2; | |
if(rem == 1) { | |
setBits++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdio.h> | |
bool is_power_of_two(size_t); | |
int my_pop_count(size_t); | |
int main() | |
{ | |
size_t n = 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
int main() | |
{ | |
int r[10]; | |
for(size_t i = 0; i < 10; i++) { | |
r[i] = i + 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void read_file(void) | |
{ | |
FILE* fp = fopen("a.dat", "rb"); | |
size_t bread = 0; | |
int data; | |
if(fp == NULL) { | |
fprintf(stderr, "Read error\n"); | |
exit(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isWebScaleCapable() { | |
return true; | |
} | |
if(isWebScaleCapable()) { | |
INIT_WEB_SCALE(); | |
} |