Skip to content

Instantly share code, notes, and snippets.

View kLabz's full-sized avatar
🦆
\_o<

Rudy Ges kLabz

🦆
\_o<
View GitHub Profile
@kLabz
kLabz / Test.hx
Created December 8, 2021 07:20
Haxe GADTs for API endpoints
class Test {
static function main() {
var req = makeRequest(Foo, r -> trace(r.foo));
req.send();
var req2 = makeRequest(Bar(42), r -> trace(r.answer));
req2.send();
}
static function makeRequest<T>(endpoint:Endpoint<T>, handler:T->Void) {
@kLabz
kLabz / Main.hx
Last active May 6, 2021 08:27
Haxe C# dictionary iteration
import cs.system.collections.generic.IEnumerator_1;
import cs.system.collections.generic.KeyValuePair_2;
import cs.system.collections.generic.Dictionary_2;
using Main;
@:nativeGen class Main {
public static function main() {
var dict = new Dictionary_2<String, String>();
dict.Add('hello', 'world');
@kLabz
kLabz / A.md
Last active February 13, 2021 12:22
List<T> modification
@kLabz
kLabz / A.md
Last active February 13, 2021 12:22
Strictly typed event handlers
@kLabz
kLabz / hlc.md
Created October 21, 2020 13:17 — forked from Yanrishatum/hlc.md
How to compile HL/C

How to compile HL/C

Prepwork/terms

Because I have no trust in people.

  • <hashlink> points to your installation of Hashlink, e.g. folder in which hl.exe (or Unix executable) is, alongside with library binaries (.hdll files), and include folder.
  • <src> points to the folder containing generated HL/C sources. One that contains hlc.json file.
  • <app> refers to your output executable name, including extension.
  • <main> refers to your entry-point file name, including extension (see below).
  • I provide example of doing it on Windows via MSVC cl.exe, but Unix should be more or less same with replacement of argument flags and compiler.
  • I expect that you DO have a compiler installed and can call cl.exe or other compiler from command-line.
@kLabz
kLabz / DefaultClient.hx
Created June 8, 2020 07:54
Haxe + Apollo: getting started
import apollo.client.ApolloClient;
import apollo.cache.inmemory.InMemoryCache;
import apollo.link.ApolloLink;
import apollo.link.http.HttpLink;
import apollo.link.error.ErrorLink;
import apollo.link.error.ErrorResponse;
class DefaultClient extends ApolloClient<Any> {
public function new(uri:String) {
super({
@kLabz
kLabz / App.html
Last active April 1, 2020 13:39 — forked from RaycatWhoDat/App.html
Macro issues.
<div className="App">
<header className="App-header">
<img src=$logo className="App-logo" alt="logo" />
<p>
Edit <code>src/App.hx</code> and save to reload.
</p>
</header>
</div>
@kLabz
kLabz / README.md
Created July 30, 2019 13:55
Haxe MaterialUI: withStyles

Using Styles.withStyles to style your components

Component without public props

private typedef Props = {
	var classes:TClasses;
}

private typedef TClasses = Classes<[
@kLabz
kLabz / 00 - README.md
Created June 2, 2019 14:38
[Haxe] Use lix projects without lix
  • Place lix-to-install and lix-to-haxelib in a directory being in your $PATH (~/.bin for example, which you may have to add to your $PATH) and chmod them with chmod +x.

  • Generate a install.hxml file by running this in your project: lix-to-install > install.hxml

  • Install dependencies via haxelib (needs HaxeFoundation/haxelib#456): haxelib install --skipdeps --always install.hxml

@kLabz
kLabz / Test.hx
Created May 2, 2019 08:20
Extends<T>
class Test {
static function main() {
var a:Extends<A> = extended({a: "hello", b: "world"});
$type(a); // Extends<A>
trace(haxe.Json.stringify(a));
a.a = "bye";
// a.a = 42; // Int should be String
// a.b = "nope"; // Extends<A> has no field b
trace(haxe.Json.stringify(a));