Skip to content

Instantly share code, notes, and snippets.

View whb07's full-sized avatar

william bright whb07

View GitHub Profile
// Allowed manner of interacting with arrays
// where returning an array by value from a function isn't allowed
unsigned char buffer[10];
// pass in a pointer to the initialized array you want to mutate
void hiBuffer(unsigned char *buff){
buff[0] = 'h';
buff[1] = 'i';
};
// return an array
fn get_buff() -> [char; 3]{
return ['a', 'b', 'c']
}
// even better return a vector!
fn get_buff_vec() -> Vec<u8>{
// vec! is a macro
return vec![0u8; 16];
}
int findLastSlash(const char *filepath, int len_filepath){
int idx = 0;
int location = -1;
while(filepath[idx] != '\0' && idx < len_filepath){
if(filepath[idx] == '\\' || filepath[idx] == '/'){
location = idx;
}
idx++;
}
https://rix0r.nl/blog/2015/08/13/cmake-guide/
@whb07
whb07 / Program.fs
Created July 21, 2020 12:15
interop with C FFI on F#
module InteropWithNative =
[<DllImport(@"/tmp/hellofsharp/build/liblib.dylib", CallingConvention = CallingConvention.Cdecl)>]
extern int fibbo(int)
@whb07
whb07 / .eslintrc.json
Created August 3, 2020 13:03
solid all around eslint with TS + react
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"react-app",
"plugin:react/recommended",
"airbnb"
],
@whb07
whb07 / Program.fs
Last active February 2, 2021 13:56
// Learn more about F# at http://fsharp.org
open System
open System.Runtime.InteropServices
// let SL = StructAttribute()
[<StructLayout(LayoutKind.Sequential)>]
[<Struct>]
@whb07
whb07 / clang.txt
Last active May 22, 2021 16:35
IWYU failed builds Windows 10
PS C:\Users\william\Downloads\include-what-you-use\build> cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH="C:/Program Files/LLVM/lib"
-- IWYU: out-of-tree configuration
-- The C compiler identification is Clang 12.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 12.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
PS C:\Users\user1\Downloads\include-what-you-use\build> cmake .. -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH="C:/Program Files/LLVM/lib" -DCMAKE_BUILD_TYPE=Release
-- IWYU: out-of-tree configuration
-- The C compiler identification is Clang 13.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 13.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
@whb07
whb07 / launch.json
Created July 11, 2021 15:28
run config for F#
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",