Skip to content

Instantly share code, notes, and snippets.

View halloweeks's full-sized avatar
💭
I may be slow to respond.

Hallo Weeks halloweeks

💭
I may be slow to respond.
View GitHub Profile
@halloweeks
halloweeks / main.cpp
Last active January 16, 2023 12:49
c++ url decoder
#include <iostream>
#include <stdlib.h>
#include <string>
std::string url_decode(char *url) {
std::string temp, output;
char ch;
for (unsigned int index = 0; index < strlen(url)+1; index++) {
if (url[index] == '%') {
temp += url[index+1];
@halloweeks
halloweeks / log.txt
Last active January 12, 2024 08:20
c++ zlib compress decompress string
# compile
g++ zlib.cpp -o zz -lz
# run
root@localhost:~# ./zz
Orignal string size: 43
Original string: halloweeks halloweeks halloweeks halloweeks
--------------------
Compressed string size: 22
@gomons
gomons / zlib_strings.cpp
Last active March 6, 2023 17:57
Compressing STL Strings with zlib
// Copyright 2007 Timo Bingmann <tb@panthema.net>
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
//
// Original link http://panthema.net/2007/0328-ZLibString.html
#include <string>
#include <stdexcept>
#include <iostream>
#include <iomanip>
@meritozh
meritozh / exec.cpp
Created April 5, 2016 07:12
use c++ to execute a command and get the output of command. It only grab stdout. Use perror or add "2>&1" for grabbing stderr.
#include <iostream>
#include <cstdarg>
#include <string>
#include <fstream>
#include <memory>
#include <cstdio>
std::string exec(const char* cmd) {
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
if (!pipe) return "ERROR";
@oleksiiBobko
oleksiiBobko / tcp_server.c
Last active November 10, 2023 08:48
Simple socket server in C using threads (pthread library) Compiles on linux
/*
C socket server example, handles multiple clients using threads
Compile
gcc server.c -lpthread -o server
*/
#include<stdio.h>
#include<string.h> //strlen
#include<stdlib.h> //strlen
#include<sys/socket.h>