Skip to content

Instantly share code, notes, and snippets.

View kYroL01's full-sized avatar
🥊

Michele Campus kYroL01

🥊
View GitHub Profile
@kYroL01
kYroL01 / HashTable.cpp
Last active August 29, 2015 14:25 — forked from Karlina-Bytes/HashTable.cpp
Hash Table Example
//*****************************************************************
// HashTable.cpp
// HashTable
//
// Created by Kar Beringer on June 18, 2014.
//
// This header file contains the Hash Table class definition.
// Hash Table array elements consist of Linked List objects.
//*****************************************************************
@kYroL01
kYroL01 / the_descent.c
Created August 9, 2016 13:58
Solution for game "The Descent" on CodingGame
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**
* The while loop represents the game.
* Each iteration represents a turn of the game
* where you are given inputs (the heights of the mountains)
* and where you have to print an output (the index of the moutain to fire on)
* The inputs you are given are automatically updated according to your last actions.
@kYroL01
kYroL01 / built_strings
Created September 2, 2016 10:52
Given a string, for every char (digit or alphabet) print the string from begin and end of every single element
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**
* Given a string, print subsequents for every chars
* i.e D4b = ABCD01234ab
**/
int main()
{
@kYroL01
kYroL01 / armstrong_number.c
Last active July 12, 2021 16:39
Armstrong number: An n-digit number equal to the sum of the n-th powers of its digits.
#include <math.h>
int is_armstrong_number(int x)
{
int i = 0, c_pow = 0, sum = 0;
int digit = x;
int module = x;
while(digit != 0) {
digit /= 10;
@kYroL01
kYroL01 / curl.md
Last active November 24, 2020 17:21 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@kYroL01
kYroL01 / server.php
Created July 25, 2020 15:26 — forked from BenMorel/server.php
(Medium) Sample PHP server
<?php
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($sock, '0.0.0.0', 10000);
for (;;) {
socket_recvfrom($sock, $message, 1024, 0, $ip, $port);
$reply = str_rot13($message);
socket_sendto($sock, $reply, strlen($reply), 0, $ip, $port);
}
@kYroL01
kYroL01 / curl_pcap.c
Last active July 12, 2021 16:38
curl_pcap
/**
* Take the URL of remote pcap from command line and download the file to disk
* It check if the extension is allowed (pcap-cap-pcapng)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#define FILENAME_LEN 1000
@kYroL01
kYroL01 / tcp_client.c
Created February 17, 2021 11:08 — forked from teraPacket/tcp_client.c
example TCP client using libuv (version 1.0)
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
//based on https://gist.githubusercontent.com/snatchev/5255976/
//raw/8392c42d719bb775053036e32b21affdf932c1b7/libuv-tcp-client.c
//which was based on libuv 0.1, there is considerable difference there.
static void on_close(uv_handle_t* handle);
static void on_connect(uv_connect_t* req, int status);
static void on_write(uv_write_t* req, int status);
@kYroL01
kYroL01 / dir_cleaner.c
Last active July 16, 2021 10:11
Directory Cleaner with date format name
/* -*- compile-command: "gcc -Wall -pedantic -g3 dir_cleaner.c -o dir_cleaner" -*- */
#define _XOPEN_SOURCE 500
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ftw.h>
#include <dirent.h>
#include <unistd.h>
@kYroL01
kYroL01 / slice_passing.go
Last active July 24, 2021 21:25
Time calculation of passing slice as a pointer vs as a value
package main
import (
"fmt"
"time"
"strconv"
"strings"
)
func track(msg string) (string, time.Time) {