Skip to content

Instantly share code, notes, and snippets.

@clarking
clarking / curl_gpt.cpp
Created June 9, 2023 20:49
simple chat-gpt request example
#include <iostream>
#include <string>
#include <curl/curl.h>
// Callback function to write response data from API
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response)
{
size_t totalSize = size * nmemb;
response->append((char*)contents, totalSize);
return totalSize;
@clarking
clarking / bytecodeless.st
Created May 8, 2023 06:20
bytecode-less smalltalk
"(C)1984-1985 Jecel Assumpcao Jr"
"$Id: st84.txt,v 1.1.1.1 1995/06/29 00:14:36 root Exp $"
"This is an implementation of Smalltalk described
in Smalltalk itself. This was designed in late 1984, but
what follows is a translation into English of the
February 26, 1985 version. It is only a paper design
as there was no way to test it then and represents
the first real object oriented design for the author.
@clarking
clarking / HttpServer.cs
Created September 28, 2022 03:37 — forked from define-private-public/HttpServer.cs
A Simple HTTP server in C#
// Filename: HttpServer.cs
// Author: Benjamin N. Summerton <define-private-public>
// License: Unlicense (http://unlicense.org/)
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Threading.Tasks;
@clarking
clarking / MurmurHash3.h
Created September 17, 2022 18:57
MurmurHash3.cpp
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH3_H_
#define _MURMURHASH3_H_
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
@clarking
clarking / Life.HC.Z
Created December 31, 2021 05:49 — forked from bcoles/Life.HC.Z
Conway's Game of Life in HolyC for TempleOS. Ported from Rosetta Code. Original C Source: http://rosettacode.org/wiki/Conway's_Game_of_Life#C
// Conway's Game of Life in HolyC for TempleOS
// Ported from Rosetta Code. Original C Source:
// - http://rosettacode.org/wiki/Conway's_Game_of_Life#C
#define WIDTH 60
#define HEIGHT 40
#define SLEEP 100
U32 Universe[HEIGHT][WIDTH];
U64 COUNT;
@clarking
clarking / FloatingOrigin
Created December 9, 2021 08:11 — forked from ThomasSchoenbeck/FloatingOrigin
Floating origin to handle large worlds in Unity.
// Based on the Unity Wiki FloatingOrigin script by Peter Stirling
// URL: http://wiki.unity3d.com/index.php/Floating_Origin
using UnityEngine;
using UnityEngine.SceneManagement;
public class FloatingOrigin : MonoBehaviour
{
[Tooltip("Point of reference from which to check the distance to origin.")]
public Transform ReferenceObject = null;
@clarking
clarking / perlin.py
Created November 7, 2021 13:41 — forked from eevee/perlin.py
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
@clarking
clarking / CMakeLists.txt
Created October 15, 2021 02:57 — forked from fracek/CMakeLists.txt
CMake and GTK+ 3
# Thanks to @danger89 and @Ilothar for updating the gist.
# Set the name and the supported language of the project
project(hello-world C CXX)
# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 3.10)
# Use the package PkgConfig to detect GTK+ headers/library files
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0)
@clarking
clarking / AdbCommands
Created October 14, 2021 19:44 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@clarking
clarking / C_v1.bnf
Created July 21, 2021 02:12 — forked from arslancharyev31/C_v1.bnf
C .bnf grammar. Version 1.
{
tokens=[
space='regexp:\s+'
identifier='regexp:[a-zA-Z][a-zA-Z0-9_]*'
integer-constant='regexp:\d+'
character-constant='regexp:[a-zA-Z]'
floating-constant='regexp:[+-]?([0-9]*[.])?[0-9]+f'
enumeration-constant='regexp:[a-zA-Z][a-zA-Z0-9_]*' // Same as identifier
]