Skip to content

Instantly share code, notes, and snippets.

View jbro885's full-sized avatar
💭
I am Securing Infrastructure

jbbro88501 jbro885

💭
I am Securing Infrastructure
View GitHub Profile
@jbro885
jbro885 / discord_gateway_client.c
Created October 5, 2024 10:05 — forked from ahnaf-zamil/discord_gateway_client.c
A client for the Discord Gateway API written in C
/*
Discord Gateway (WebSocket) API client in C (Tested using GCC/MingW)
Dependencies: Winsock, OpenSSL 3.0
Copyright (C) 2022 DevGuyAhnaf - All Rights Reserved
Note: I'm a beginner in C, so please forgive any mistakes
*/
@jbro885
jbro885 / lbForth.c
Created March 6, 2024 13:00 — forked from lbruder/lbForth.c
A minimal Forth compiler in ANSI C
/*******************************************************************************
*
* A minimal Forth compiler in C
* By Leif Bruder <leifbruder@gmail.com> http://defineanswer42.wordpress.com
* Release 2014-04-04
*
* Based on Richard W.M. Jones' excellent Jonesforth sources/tutorial
*
* PUBLIC DOMAIN
*
@jbro885
jbro885 / sendfd.c
Created February 12, 2024 10:36 — forked from kokjo/sendfd.c
Send a file descriptor over an abstract unix domain socket
// compile with: gcc -static -o sendfd sendfd.c
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <strings.h>
int send_fd(int sock, int fd){
// This function does the arcane magic for sending
// file descriptors over unix domain sockets
struct msghdr msg;
@jbro885
jbro885 / loopback_filesystem.sh
Created February 9, 2024 01:22 — forked from dwallraff/loopback_filesystem.sh
Create and mount a loopback filesystem
#!/usr/bin/env bash
## Loopback Filesystem
# This script will create and mount a loopback filesystem
# Useful if you need to limit director(ies) by size
# but only have one volume
# This script needs to be run with sudo
LO_FILESYSTEM_NAME=my_loopback
LO_FILESYSTEM_MB_SIZE=5
@jbro885
jbro885 / gtk3-input.c
Created January 31, 2024 11:41 — forked from makotokato/gtk3-input.c
GTK3 keyboard sample
// build:
// gcc gtk3-entry-keyboard-event.c `pkg-config --cflags gtk+-3.0` `pkg-config
// --libs gtk+-3.0`
#include <gtk/gtk.h>
static gboolean print_keypress(GtkWidget *widget, GdkEventKey *event,
gpointer user_data) {
printf("keypress: %#06x %#06x\n", event->keyval, event->hardware_keycode);
return FALSE;
@jbro885
jbro885 / Simple Client.c
Created January 25, 2024 08:26 — forked from Abhey/Simple Client.c
Simple client server chat system in C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
int main(){
@jbro885
jbro885 / time.c
Created January 22, 2024 01:42 — forked from ikeating/time.c
#include <stdio.h>
#include <time.h>
int main()
{
time_t seconds = time(NULL);//Unix epoch 00:00:00 UTC on 1 January 1970
if (seconds == -1)
{
@jbro885
jbro885 / SHA256.c
Created January 12, 2024 04:26 — forked from AugFJTan/SHA256.c
C implementation of SHA-256
/* File : SHA256.c
* Description: C implementation of SHA-256 (256-bit Secure Hash Algorithm).
*
* Author : AugFJTan
* Last Modified 18 Feb 2018 06:50 PM
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@jbro885
jbro885 / hashes.c
Created January 11, 2024 23:04 — forked from sgsfak/hashes.c
Some simple hash functions.. in C
#include <stdint.h>
/*
* The Dan Bernstein popuralized hash.. See
* https://github.com/pjps/ndjbdns/blob/master/cdb_hash.c#L26 Due to hash
* collisions it seems to be replaced with "siphash" in n-djbdns, see
* https://github.com/pjps/ndjbdns/commit/16cb625eccbd68045737729792f09b4945a4b508
*/
uint32_t djb33_hash(const char* s, size_t len)
@jbro885
jbro885 / delta_encoding.c
Created December 30, 2023 10:22 — forked from CMCDragonkai/delta_encoding.c
C: Delta Encoding with ASCII String Example (https://en.wikipedia.org/wiki/Delta_encoding)
#include <stdio.h> // puts and printf
#include <string.h> // strlen
// delta encoding and decoding on ASCII strings
// basically the char type is converted into an int type to allow for addition and subtraction
// doing so is basically doing arithmetic on the ASCII codepoints
void delta_encode(signed char * buffer, int length) {
signed char last = 0;
for (int i = 0; i < length; i++) {