Skip to content

Instantly share code, notes, and snippets.

View fullofcaffeine's full-sized avatar

Marcelo Serpa fullofcaffeine

View GitHub Profile
@jdonaldson
jdonaldson / Config.hx
Last active May 24, 2019 17:34
Utility Classes for Haxe
using haxe.macro.Context;
import haxe.macro.Expr;
/**
Simple config merge routine. Supply a series of anonymous objects, and this macro will merge them into a single instance.
This is useful for providing a series of overrides for config, so I've gone with that name.
The benefit is that the macro preserves all of the typing info, so you still get completions, etc. on the merged object.
**/
class Config {
public static macro function merge<T>(arr : Array<ExprOf<T>>) : Expr {
@lleqsnoom
lleqsnoom / Shell.hx
Created September 21, 2017 14:06
haxe linux/mac shell commands with pipes
package;
import sys.io.Process;
using StringTools;
class Shell
{
public static function main() {
trace(exec('ioreg -c IOSerialBSDClient | grep usbmodem | grep IODialinDevice | cut -d " -f 4'));
}
@luispabon
luispabon / borg-backup.sh
Last active February 16, 2018 06:09
Encrypted borg backup to s3 of home folder
#!/bin/bash
# NOTE: decided to actually make a more reusable version with README and all, to be found at
# this repo: https://github.com/luispabon/borg-s3-home-backup
@haxiomic
haxiomic / Partial.hx
Last active February 26, 2023 11:44
Haxe macro to make all fields of a type optional (similar to Typescript's Partial<T>)
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.TypeTools;
#if !macro
@:genericBuild(PartialMacro.build())
#end
class Partial<T> {}
class PartialMacro {
@Fuco1
Fuco1 / org-archive-subtree.el
Created October 30, 2016 13:12
Archive subtrees under the same hierarchy as original in the archive files.
(defadvice org-archive-subtree (around fix-hierarchy activate)
(let* ((fix-archive-p (and (not current-prefix-arg)
(not (use-region-p))))
(afile (org-extract-archive-file (org-get-local-archive-location)))
(buffer (or (find-buffer-visiting afile) (find-file-noselect afile))))
ad-do-it
(when fix-archive-p
(with-current-buffer buffer
(goto-char (point-max))
(while (org-up-heading-safe))
@RealyUniqueName
RealyUniqueName / KeyValueIterator.hx
Last active October 14, 2016 10:35
Key-value map iterator
class KeyValueIterator<K,V> {
var map:Map<K,V>;
var keys:Iterator<K>;
static public inline function pairs<K,V>(map:Map<K,V>) return new KeyValueIterator(map);
public inline function new(map:Map<K,V>) {
this.map = map;
this.keys = map.keys();
}
@daronco
daronco / letsencrypt-webroot-apache.md
Last active February 15, 2024 11:50
Letsencrypt with webroot on Apache

Config Apache with /etc/apache2/conf-available/le.conf:

Alias /.well-known/acme-challenge/ "/var/www/html/.well-known/acme-challenge/"
<Directory "/var/www/html/">
    AllowOverride None
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>
@deathbeam
deathbeam / greet.spoon
Last active February 11, 2025 00:31
Spoon compiler test
#!/usr/bin/env coffee
# Spoon code:
greet = name -> trace "Hello #{name}, how are you?"
greet "Person"
# Compiler result (fully working Haxe code):
#
# class Greet {
# static public function main() {
@fponticelli
fponticelli / Server.hx
Last active April 29, 2016 15:51
A multi-process webserver with abe and nodejs + cluster.
import abe.App;
import bl.server.*;
import js.Node.*;
import js.node.Cluster;
import js.node.Os;
import npm.Chalk.*;
class Server {
public static var defaultPort(default, null) = 8787;
public static var defaultHost(default, null) = "0.0.0.0";