Skip to content

Instantly share code, notes, and snippets.

@jeremyjh
jeremyjh / DeclareFields.hs
Created February 18, 2014 01:44
non-working example of declareFields
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Control.Lens
declareFields [d|
globalMonitor :: Process ()
globalMonitor = do
let initState = [] :: [MxEvent]
void $ mxAgent (MxAgentId "lifecycle-listener-agent") initState [
mxSink $ \ev -> do
let act =
case ev of
(MxProcessDied pid (DiedException msg)) -> liftMX $ say $ debug $ "[Error] " ++ show pid ++ " DiedException: " ++ msg
(MxProcessDied pid DiedDisconnect) -> liftMX $ say $ show pid ++ " DiedDisconnect"
@jeremyjh
jeremyjh / cocos_ref.cpp
Created October 10, 2014 16:44
simple cocs2d-x Ref integration to entityx
/*
* File: cocos_ref.h
* Author: jeremy
*
* Created on June 28, 2014, 8:38 PM
*/
#ifndef COCOS_REF_H
#define COCOS_REF_H
@jeremyjh
jeremyjh / dining.rs
Last active August 29, 2015 14:25
Rust Dining Philosphers implementation using fair Arbitrator solution
extern crate rand;
use std::thread;
use std::sync::Arc;
use std::sync::mpsc::{Sender, Receiver, channel};
use rand::Rng;
fn main() {
let waiter = Waiter::new();
@jeremyjh
jeremyjh / ctags.rake
Created October 3, 2012 00:24
Rebuild CTAGS including only bundled gems and rails project files
desc "Regenerate tags (CTAGS)"
task :ctags do
puts " * Regenerating Tags"
excludes = %w{
.git
.git*
*.yml
app/views
app/assets
coverage
@jeremyjh
jeremyjh / NodeProcess.hs
Created December 5, 2013 01:24
example helpers to make cloud haskell easier in repl
-- Functions intended to make it easier to work with distributed-process
-- from the REPL.
module NodeProcess where
import Control.Distributed.Process
import Control.Distributed.Process.Serializable
import Control.Concurrent.MVar
import Control.Concurrent (threadDelay)
@jeremyjh
jeremyjh / bigapp_web.ex
Last active September 1, 2017 15:33
Web Context Example
defmodule BigappWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use BigappWeb, :controller
use BigappWeb, :view
@jeremyjh
jeremyjh / bigapp_webdefview.ex
Created September 1, 2017 15:40
bigapp_web.ex def view pass opts
def view(opts) do
quote do
use Phoenix.View, unquote(opts)
# Import convenience functions from controllers
...
@jeremyjh
jeremyjh / bigapp_web.ex
Created September 2, 2017 12:24
bigapp_web alternate view head
def view(opts \\
[root: "lib/bigapp_web/templates",
namespace: BigappWeb]) do
quote do
use Phoenix.View, unquote(opts)
@jeremyjh
jeremyjh / using-view.ex
Last active September 2, 2017 12:47
bigapp_web.ex defmacro __using__ clause
@webdir "bigapp_web"
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(:view) do
view_path =
__CALLER__.file
|> String.split(@webdir)
|> List.last