Skip to content

Instantly share code, notes, and snippets.

View BillBarnhill's full-sized avatar
💭
Learning Rust

=Bill.Barnhill BillBarnhill

💭
Learning Rust
View GitHub Profile
@nh2
nh2 / haskell-pcap-writing.hs
Created November 25, 2012 22:56
Haskell PCAP writing / dump (instance Storable PktHdr)
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>
@zambal
zambal / gist:5792462
Last active December 18, 2015 13:49
Enum with lots of sugar
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
@pboos
pboos / annotation-processor-build.gradle
Last active August 7, 2020 06:38
Gradle stuff for Android
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()))
@halgari
halgari / gist:7028120
Last active January 31, 2018 12:32
Async Agents via core.async
(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)]
@joastbg
joastbg / stmtchan.hs
Created November 18, 2013 11:19
Haskell - STM example using two threads and a TChan to communicate between the threads
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
@shallowlong
shallowlong / [Android] Handler (Advanced)
Last active January 2, 2016 23:58
The advanced handler to set the runnable task and set time postpond
// 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
@imminent
imminent / CursorSubject.java
Last active August 11, 2016 17:21
CursorSubject is a Reactive Extension version of Android's CursorLoader. Handles retrieving the Cursor in a background thread, sending the result Cursor on the main thread, and resending a Cursor whenever the content changed notification is triggered.
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;

Debugging Erlang Applications In Real Time

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: