Skip to content

Instantly share code, notes, and snippets.

doug:rust-libs doug$ cat junk.rs
#![crate_id = "junk#0.1"]
use std::libc::c_int;
#[no_mangle]
pub extern fn dothing(a: c_int, b:c_int) -> c_int {
return a + b;
}
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active April 15, 2024 20:34
GLSL Math functions

Trigonometry

const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;

float PHI = (1.0+sqrtf(5.0))/2.0;
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-color.md
Last active August 29, 2022 15:54
GLSL color functions

RGB - YUB

mat3 yuv2rgb = mat3(1.0, 0.0, 1.28033, 1.0, -0.21482, -0.38059, 1.0, 2.12798, 0.0);
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, -0.09991, -0.33609, 0.43600, 0.615, -0.5586, -0.05639);

RGB - HSV

@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active June 8, 2024 06:11
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@woxtu
woxtu / gist:c186b173be3a53171533
Last active March 4, 2019 05:37
Face detection in Rust
pub mod cv {
extern crate libc;
use self::libc::{c_char, c_double, c_int, c_schar, c_void};
#[repr(C)]
pub struct HaarClassifierCascade;
#[repr(C)]
pub struct MemStorage;
@charliewynn
charliewynn / AHK Script
Last active November 17, 2017 01:52
K95 profile, with autohot key
;you have to re-map the f keys so they work.
;Otherwise AHK will just 'wait' for the number key after - if there is non then nothing happens
f1::f1
f2::f2
f3::f3
f4::f4
f5::f5
f6::f6
f7::f7
f8::f8
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@trissylegs
trissylegs / ipc.c
Created June 25, 2015 10:22
Demonstration of shared memory using C and Rust
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
@CMCDragonkai
CMCDragonkai / higher_kinded_types_in_rust_and_haskell.md
Last active April 15, 2024 16:50
Rust/Haskell: Higher-Kinded Types (HKT)

Rust/Haskell: Higher-Kinded Types (HKT)

A higher kinded type is a concept that reifies a type constructor as an actual type.

A type constructor can be thought of in these analogies:

  • like a function in the type universe
  • as a type with a "hole" in it
@durka
durka / countmacro.rs
Last active April 13, 2016 23:50 — forked from anonymous/playground.rs
Rust macros: counting with an accumulator
// cargo-deps: lazy_static
#[macro_use] extern crate lazy_static;
macro_rules! declare_array {
// INTERNAL
// last element (proceed to output)
(@parse $size:expr, ($val:expr) -> [$($accs:expr),*] $thru:tt) => {
declare_array!(@output $size + 1usize, [$($accs,)* $val] $thru);