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 <sys/mman.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#define PAGESIZE sysconf(_SC_PAGE_SIZE) | |
int main() { | |
uint8_t* ptr = (uint8_t*) mmap(NULL, PAGESIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); |
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
const std = @import("std"); | |
pub const std_options = .{ | |
.log_level = .info, | |
}; | |
fn handle_connection(connection: std.net.Server.Connection, filename: []u8) !void { | |
std.log.info("Client {} connected", .{connection.address}); | |
defer { | |
connection.stream.close(); |
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
const std = @import("std"); | |
const COLOR_RED = "\x1b[0;31m"; | |
const COLOR_RESET = "\x1b[0m"; | |
fn print_usage(exec: [*:0]u8) void { | |
std.debug.print("Usage: {s} FILE PATTERN\n", .{exec}); | |
} | |
fn string_contains_substring(allocator: std.mem.Allocator, string: []u8, substring: []u8) !std.ArrayList([2]usize) { |
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
/* | |
* This program will print the content of a file and then waits for a change of the file and prints the added content. | |
* Author: AdriDoesThings <adri@adridoesthings.com> | |
*/ | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> |
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 <pwd.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(int argc, char* argv[]) { | |
if (argc < 3) { | |
fprintf(stderr, "Usage: %s USER COMMAND [ARGS]...\n", argv[0]); | |
return -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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <dirent.h> | |
#include <sys/stat.h> | |
off_t* count_filesize_of_directory(char *path) { | |
DIR *dir = opendir(path); | |
if (dir == NULL) { | |
perror("error while reading directory"); |
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 <stdint.h> | |
#include <stdio.h> | |
int main(int argc, char* argv[]) { | |
int file_index = 0; // index of the current file | |
while (file_index + 1 < argc || file_index == 0) { | |
FILE *file; // contains the pointer to the file | |
if (file_index + 1 == argc) { // no file path is given, use stdin | |
file = stdin; | |
} else { // file path is given, argv[file_index + 1] is file path |
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 <asm-generic/errno-base.h> | |
#include <asm-generic/errno.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <errno.h> |
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
!root | |
.log | |
.syslog | |
.test | |
0 | |
000 | |
0000 | |
000000 | |
02 | |
09 |
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
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.38/deno-dom-wasm.ts"; | |
const url = "https://www.vbb.de/fahrinformation/zug-um-zug-mehr-schiene/{LINE}/" | |
async function checkLine(line: string) { | |
const response = await fetch(url.replace('{LINE}', line)) | |
if (response.status == 200) { | |
const dom = new DOMParser().parseFromString(await response.text(), "text/html") | |
const headline = dom?.getElementById("content")!.getElementsByTagName("header")[0].getElementsByTagName("h1")[0].textContent.trim() | |
console.log(`${headline}`) |
NewerOlder