Skip to content

Instantly share code, notes, and snippets.

View fullofcaffeine's full-sized avatar

Marcelo Serpa fullofcaffeine

View GitHub Profile
@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 May 11, 2016 14:51
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";
@vlucas
vlucas / markdown-import.php
Last active May 19, 2024 17:58
Imports Markdown files in a local directory into a WordPress installation
<?php
// Turn on all error reporting so we can see if anything goes wrong
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
// Relative path to your wp-config.php file (to connect to the database)
require '../wp-config.php';
require './frontmatter.php'; // Parses YAML frontmatter - https://github.com/Modularr/YAML-FrontMatter
require './Parsedown.php'; // Markdown parser - https://github.com/erusev/parsedown