Skip to content

Instantly share code, notes, and snippets.

View r-lyeh's full-sized avatar
👻

r-lyeh

👻
View GitHub Profile
@r-lyeh
r-lyeh / astar.h
Created January 28, 2023 00:12 — forked from mmozeiko/astar.h
generic A* in C
// generic A* pathfinding
//
// INTERFACE
//
// mandatory macros
#ifndef ASTAR_POS_TYPE
#error ASTAR_POS_TYPE should specify position type
dumpbin /exports any.dll > any.def
lib /def:any.def /out:any.lib /machine:x64
// useful code snippets gathered from the network (via phillip trudeau)
static float euclidean_mod(float x, float y) { return x - floorf(x / y) * y; }
static bool rect_is_onscreen(RECT rect) { return (MonitorFromRect(&rect, MONITOR_DEFAULTTONULL) != NULL); }
static bool window_is_onscreen(HWND hwnd) { return (MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL) != NULL); }
// Win32: Set the window icon for every window in your app (including MessageBox() calls and assertion failures) instead of just your primary window.
static LRESULT set_window_icon_callback(int type, WPARAM wparam, LPARAM lparam) {
if (type == HCBT_CREATEWND) {
HANDLE instance_hdl = GetModuleHandleA(NULL);
/* This file defines all 2136 Japanese Jōyō kanji (常用漢字)
with the unicode codespoints formatted to fit Nuklear's font config.
#include it as part of the nk_runes definition as shown below.
Don't forget the 0 at the end of the array, as this file doesn't define it.
*/
/* Usage example, incased in #if 0 to allow comments inside comments */
#if 0
static
@r-lyeh
r-lyeh / neural-network-from-scratch.py
Created October 20, 2022 19:51 — forked from svpino/neural-network-from-scratch.py
An implementation of a neural network from scratch
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def neural_network(X, y):
learning_rate = 0.1
W1 = np.random.rand(2, 4)
W2 = np.random.rand(4, 1)
@r-lyeh
r-lyeh / stuns
Created April 15, 2020 10:44 — forked from zziuni/stuns
STUN server list
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net

QueryData (QD)

A Query Data specification that resembles files and directories.

C API

char *result = qd_query(doc,"query");           // Return a single value from your data
array(char*) result = qd_queries(doc,"query");  // Return a result set from your data (array)

Operators

# Ensure GitHub detects files as C rather than Objective-C.
*.c linguist-language=C
*.h linguist-language=C
@r-lyeh
r-lyeh / Quirks of C.md
Created September 10, 2018 11:19 — forked from fay59/Quirks of C.md
Quirks of C

Here's a list of mildly interesting things about the C language that I learned over time.

  1. Combined type and variable/field declaration, inside a struct scope: https://godbolt.org/g/Rh94Go
  2. Compound literals are lvalues: https://godbolt.org/g/Zup5ZB
  3. Switch cases anywhere: https://godbolt.org/g/fSeL18 (also see: Duff's Device)
  4. Flexible array members: https://godbolt.org/g/HCjfzX
  5. {0} as a universal initializer: https://godbolt.org/g/MPKkXv
  6. Function typedefs: https://godbolt.org/g/5ctrLv
  7. Array pointers: https://godbolt.org/g/N85dvv
  8. Modifiers to array sizes in parameter definitions: https://godbolt.org/z/SKS38s
@r-lyeh
r-lyeh / Unicode table
Created March 21, 2018 10:36 — forked from ivandrofly/Unicode table
Unicode table - List of most common Unicode characters *
Unicode table - List of most common Unicode characters *
* This summary list contains about 2000 characters for most common ocidental/latin languages and most printable symbols but not chinese, japanese, arab, archaic and some unprintable.
Contains character codes in HEX (hexadecimal), decimal number, name/description and corresponding printable symbol.
What is Unicode?
Unicode is a standard created to define letters of all languages ​​and characters such as punctuation and technical symbols. Today, UNICODE (UTF-8) is the most used character set encoding (used by almost 70% of websites, in 2013). The second most used character set is ISO-8859-1 (about 20% of websites), but this old encoding format is being replaced by Unicode.
How to identify the Unicode number for a character?
Type or paste a character: