Reid Draper @reiddraper
We'll be using a tool called redbug, which is an abstraction and safety layer of Erlang's built-in dbg tracing facilities. You can follow along at home:
module PktHdrStorableInstance where | |
import Foreign.Marshal.Utils (with) | |
import Foreign.Ptr (plusPtr) | |
import Foreign.Storable | |
import Network.Pcap | |
import Network.Pcap.Base (toPktHdr) | |
#include <pcap.h> |
defmodule Enex do | |
defmacro map enum, clauses do | |
fnc = {:fn, [], [clauses]} | |
quote do: Enum.map(unquote(enum), unquote(fnc)) | |
end | |
defmacro reduce enum, acc, clauses do | |
fnc = {:fn, [], [clauses]} | |
quote do: Enum.reduce(unquote(enum), unquote(acc), unquote(fnc)) | |
end |
configurations { | |
apt | |
} | |
dependencies { | |
compile 'com.squareup.dagger:dagger:1.1.0' | |
apt 'com.squareup.dagger:dagger-compiler:1.1.0' | |
} | |
android.applicationVariants.all { variant -> |
Sample project for the "Getting started with JavaFX in Clojure" ( https://coderwall.com/p/4yjy1a ) ProTip. |
private AtomicReferenceArray<Thread> consumerWorker; | |
@Override | |
public void block() throws InterruptedException { | |
boolean parked=false; | |
for(int index=0;index<consumer;index++) | |
{ | |
if(consumerWorker.get(index)==null && consumerWorker.compareAndSet(index, null, Thread.currentThread())) |
(use 'clojure.core.async) | |
(defprotocol ISendable | |
(channel [this])) | |
(defn async-agent [state] | |
(let [c (chan Long/MAX_VALUE) ;; <<-- unbounded buffers are bad, but this matches agents | |
a (atom state)] | |
(go-loop [] | |
(when-let [[f args] (<! c)] |
module Main (main) where | |
import Data.Maybe | |
import Control.Applicative | |
import Control.Monad | |
import Control.Concurrent | |
import Control.Concurrent.STM.TChan | |
import GHC.Conc | |
import System.Random |
// the advanced handler will allow to postpone for a given time. | |
// instead of using the java.lang.Thread class, the new class is java.lang.Runnable class | |
android.os.Handler.Handler | |
android.os.Message | |
java.lang.Runnable | |
Handler msgHandler = new Handler() { | |
@Override |
package com.example.models; | |
import android.database.ContentObserver; | |
import android.database.Cursor; | |
import android.os.Handler; | |
import android.os.Looper; | |
import java.io.Closeable; | |
import java.util.concurrent.atomic.AtomicReference; |
We'll be using a tool called redbug, which is an abstraction and safety layer of Erlang's built-in dbg tracing facilities. You can follow along at home: