Skip to content

Instantly share code, notes, and snippets.

View lerno's full-sized avatar

Christoffer Lerno lerno

View GitHub Profile
@lerno
lerno / example.c3
Created January 24, 2024 21:50
Raylib
View example.c3
module abc;
import raylib;
import std::io;
const NUM_MODELS = 9;
fn void main()
{
// Initialization
//--------------------------------------------------------------------------------------
View list_examples.c3
import std::io;
import std::collections::list;
define DoubleList = List<double>;
fn double test_list_on_heap(int len)
{
DoubleList list; // By default will allocate on the heap
defer list.free(); // Free at end
for (int i = 0; i < len; i++)
@lerno
lerno / threads.c
Last active December 11, 2022 17:17
View threads.c
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <stdbool.h>
static bool is_prime(int n) {
int i = 5;
@lerno
lerno / # php - 2022-10-03_12-51-36.txt
Created October 3, 2022 10:58
php on macOS 12 - Homebrew build logs
View # php - 2022-10-03_12-51-36.txt
Homebrew build logs for php on macOS 12
Build date: 2022-10-03 12:51:36
View gist:acb9c9fd821c6287890aa72e5c9a9418
// Copyright (c) 2020 Christoffer Lerno. All rights reserved.
// Use of this source code is governed by a LGPLv3.0
// a copy of which can be found in the LICENSE file.
#include "vmem.h"
#include "common.h"
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( _WIN64 )
#define PLATFORM_WINDOWS 1
#define PLATFORM_POSIX 0
@lerno
lerno / macro2.c
Created November 6, 2018 22:29
Macro proposal II
View macro2.c
// Switch
macro char * @foo(&x) {
$switch (@typeof(x)) {
$case int: return "int";
$case float: return "float";
$default: return "???";
}
}
char *x = @foo(10); // char *x = "int";
@lerno
lerno / macro.c
Created November 6, 2018 21:48
Macro proposal
View macro.c
// 1. Macros with arguments
macro @foo(int &v) {
v++;
if (v > 10) return 10;
return v;
}
int bar() {
int a = 10;
@foo(a);
@lerno
lerno / gist:6d820600fbf30797ccf4
Last active August 29, 2015 14:15
Implicit unwrap vs optionals - trivial example to illustrate implicit conversion from "possibly null" to "not null" with annotations.
View gist:6d820600fbf30797ccf4
// Assume we also have the following:
void doSomethingWithFoo(@NotNull foo) { ... }
void doSomethingNull() { ... }
void doSomethingMore() { ... }
void doSomething(@Nullable Foo foo)
{
// doSomethingWithFoo(foo); <- this would have been an error in the IDE
// Since foo is @Nullable at this point
if (foo == null)
@lerno
lerno / Blocks
Last active August 29, 2015 14:14
View Blocks
// Synchronous
@implementation A
{
B *b;
}
- (void)doSomething {
/* ... */
BOOL x = [b performOne];
if (x) [b performTwo];
View gist:8eb04509fc425fe274cf
//C
unsigned char result[CC_MD5_DIGEST_LENGTH];
const char *cString = [self UTF8String];
CC_MD5(cString, (CC_LONG)strlen(cString), result);
return bytesToHexString(result, CC_MD5_DIGEST_LENGTH);
//Swift
let digestLength = 16
var result = Array<UInt8>(count: digestLength, repeatedValue: 0)
let cString = cStringUsingEncoding(NSUTF8StringEncoding)!