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
@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
@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
@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)]
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()))
Sample project for the "Getting started with JavaFX in Clojure" ( https://coderwall.com/p/4yjy1a ) ProTip.
@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 ->
@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
@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>
@frsyuki
frsyuki / my_thoughts_on_msgpack.md
Created June 11, 2012 02:36
My thoughts on MessagePack

My thoughts on MessagePack

Hi. My name is Sadayuki "Sada" Furuhashi. I am the author of the MessagePack serialization format as well as its implementation in C/C++/Ruby.

Recently, MessagePack made it to the front page of Hacker News with this blog entry by Olaf, the creator of the Facebook game ZeroPilot. In the comment thread, there were several criticisms for the blog post as well as MessagePack itself, and I thought this was a good opportunity for me to address the questions and share my thoughts.

My high-level response to the comments

To the best of my understanding, roughly speaking, the criticisms fell into the following two categories.

@tkqubo
tkqubo / html5TagSyntax.bnf
Last active April 23, 2024 01:49
EBNF notation for HTML5 tag syntax
tag-open := '<' tag-name ws* attr-list? ws* '>'
tag-empty := '<' tag-name ws* attr-list? ws* '/>'
tag-close := '</' tag-name ws* '>'
attr-list := (ws+ attr)*
attr := attr-empty | attr-unquoted | attr-single-quoted | attr-double-quoted
attr-empty := attr-name
attr-unquoted := attr-name ws* = ws* attr-unquoted-value