Skip to content

Instantly share code, notes, and snippets.

View andyarvanitis's full-sized avatar

Andy Arvanitis andyarvanitis

View GitHub Profile
@andyarvanitis
andyarvanitis / blink_ffi.cpp
Created March 18, 2019 03:15
purescript-native Arduino target blinky ffi (experimental)
@andyarvanitis
andyarvanitis / blink.purs
Last active March 19, 2019 02:55
purescript-native Arduino target blinky (experimental)
@andyarvanitis
andyarvanitis / Makefile.arduino
Last active March 19, 2019 03:03
purescript-native makefile to build for Arduino target (experimental)
# PureScript to native binary (via C++) Makefile
#
# Run 'make' or 'make release' to build an optimized release build
# Run 'make debug' to build a non-optimized build suitable for debugging
#
# You can also perform a parallel build with 'make -jN', where N is the
# number of cores to use.
#
# PURS, SRC, OUTPUT, and BIN can all be overridden with the
# command itself. For example: 'make BIN=myutil'
#!/usr/bin/env bash
# Ensure any prebuilt GNUstep packages are uninstalled before running this script
# Adapted from
# http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux
# and https://stackoverflow.com/questions/40698870/compiling-objective-c-on-debian-8-gnu-linux-with-clang-and-gnustep-make
# Show prompt function
function showPrompt()
#include <cstring>
#include "Main.hh"
namespace Main {
static auto bitor_all( const any::array& opts ) -> int {
int combined_opts = 0;
for (auto it = opts.cbegin(), end = opts.cend(); it != end; it++) {
combined_opts |= static_cast<int>(*it);
}
#ifndef MainFFI_HH
#define MainFFI_HH
#include <pcre.h>
#include "PureScript/PureScript.hh"
namespace Main {
using namespace PureScript;
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
import Data.Either (Either(..))
import Data.Tuple (Tuple)
foreign import data PCREOption :: *
foreign import data PCRECode :: *
pcre *pcre_compile(const char *pattern,
int options,
const char **errptr,
int *erroffset,
const unsigned char *tableptr);
import Data.Foldable
-- perform a very large foldr to test tail recursion
addAll :: (Foldable t, Num a) => t a -> a
addAll = Data.Foldable.foldr (+) 0
n :: Integer
n = 1500000
numbersList :: [Integer]
@andyarvanitis
andyarvanitis / reactive_cocoa_macros_eero.h
Last active February 6, 2020 23:52
A couple ReactiveCocoa macro un/defines needed for Eero, and used for these examples.
#undef _RACAbleObject
#define _RACAbleObject(object, property) (object.rac_signalForKeyPath:@keypath(object, property), observer:self)
#undef keypath1
#define keypath1(PATH) \
(((void)(NO && ((void)PATH, NO)), strchr(# PATH, *".") + 1))