Skip to content

Instantly share code, notes, and snippets.

@Gydo194
Gydo194 / PubSubServer.php
Created October 22, 2017 15:23
Native PHP Pub/Sub server (BETA)
<?php
/*
* PubSubServer.php
* native PHP Pub/Sub server
* Author: Gydo194
* Version: 1.0
* Date: 2210171714
*/
@Gydo194
Gydo194 / Auth2.php
Last active October 24, 2017 09:22
PHP Authentication class
<?php
/*
* WARNING: this is highly in beta and could contain many bugs or architectural issues.
* It also has NO database support, line 153 defines the correct username and password.
*
* This is a test authentication mechanism for use in PHP web applications.
* Do not use this yet for production!
*/
@Gydo194
Gydo194 / Auth demo.php
Last active November 16, 2017 17:25
PHP authentication demo
<?php
defined("AUTH_SESSION_VAR_NAME") || define("AUTH_SESSION_VAR_NAME", "user");
if (!isset($_REQUEST["nosess"]))
session_start();
class Auth {
/*
@Gydo194
Gydo194 / Server.java
Created December 23, 2017 09:25
Java TCP broadcast
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Scanner;
@Gydo194
Gydo194 / commandshell.ino
Created January 7, 2018 09:04
Arduino integrated command parser shell
//enabling DEBUG will make handle() spit out the function name and argument to serial before calling it.
//total sketch size when compiled for arduino UNO: 7094 bytes
#define DEBUG false
#include <HashMap.h>
class ArgumentParser {
private:
@Gydo194
Gydo194 / udp_pubsub.py
Created February 24, 2018 20:33
python_udp_pubsub_server
import logging
from pprint import pprint
import socket
import json
HOST = "127.0.0.1"
PORT = 1234
BUFFER_SIZE = 2 * 1024 #2Kb buffer
@Gydo194
Gydo194 / main.cpp
Created March 2, 2018 13:46
C++ echo server (not my work)
//this is not my work but posted so i can find it back.
//I did make some modifications, the original was pulled from the web
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
#include <arpa/inet.h> //close
#include <sys/types.h>
@Gydo194
Gydo194 / server.cpp
Created March 2, 2018 18:58
C++ echo server (single client)
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
#include <arpa/inet.h> //close
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@Gydo194
Gydo194 / main.cpp
Created March 4, 2018 11:23
more advanced c++ echo server (single client)
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
#include <arpa/inet.h> //close
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@Gydo194
Gydo194 / server.c
Created March 4, 2018 17:46
C99 compliant TCP multi-client single threaded chat server (again, not my work)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>