Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
Baabyyy Shark tu tu ru tu tu tu

Roman Gonzalez roman

🦈
Baabyyy Shark tu tu ru tu tu tu
View GitHub Profile
@roman
roman / LongPolling.hs
Created Jan 31, 2014
Composition of Observables in rxhs
View LongPolling.hs
getLastPublishedMessages :: PubSub -> ClientId -> IO (Either SomeException [WebResponse])
getLastPublishedMessages pubsub cid = do
msubject <- getClientSubject pubsub cid
case msubject of
Just subject ->
Observable.toEither .
Observable.first .
Observable.filter (not . null) .
Observable.bufferInterval (Time.microSeconds 1000) .
Observable.concatMap excludeClientId $
@roman
roman / Example.hs
Last active Aug 29, 2015
Example of an "Actor-Like" Reactive Extension management in Haskell
View Example.hs
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Rx.Actor
( GenericEvent, EventBus
, ActorBuilder, ActorM, ActorDef, Actor, RestartDirective(..), InitResult(..)
, SupervisorBuilder, SupervisorStrategy, SupervisorDef, Supervisor
-- ^ * Actor Builder API
, defActor, actorKey, preStart, postStop, preRestart, postRestart
, onError, desc, receive
View example.el
(be/util-eval-on-load ("evil" "be-scala" "scala-mode2")
(evil-define-key 'normal scala-mode-map
(kbd ",gi") 'be/init-scala-repl
(kbd ",rr") 'be/init-sbt-runner
(kbd ",rt") 'be/init-sbt-tester
(kbd ",fl") 'be/scala-repl-load-file
(kbd ",fr") 'be/scala-repl-load-file
(kbd "M-.") 'sbt-find-definitions))
@roman
roman / background.clj
Last active Aug 29, 2015
Naive approach for Bg process handling using Rx + Clojure
View background.clj
(ns clj-playground.background
(:require [rx.lang.clojure.core :as rx]
[rx.lang.clojure.interop :as rxi]
[clj-http.client :as http]
[monads.core :refer [Monad]]
[monads.macros :as monadic])
(:import
[java.util.concurrent Executors]
[rx Observable]
[rx.schedulers Schedulers]))
@roman
roman / RxPlayground.purs
Created Nov 19, 2014
Purescript + rxjs playground
View RxPlayground.purs
module RxPlayground where
import Debug.Trace (trace, print)
import Control.Monad.Eff
import Data.Array ((..))
foreign import data Observable :: * -> *
foreign import data Subject :: * -> *
foreign import data Observer :: * -> *
View WebSocket.purs
module Diplomat.WebSocket (
Url()
, parseUrl
, AttemptCount()
, MsDelay()
, Connection()
, PendingConnection()
, WebSocketEvent(..)
, WebSocketOptions()
@roman
roman / debug.el
Last active Aug 29, 2015
spacemacs tooltip-error (without X support)
View debug.el
Debugger entered--Lisp error: (void-function tooltip-mode)
(tooltip-mode -1)
eval-buffer(#<buffer *load*-146703> nil "/home/vagrant/.emacs.d/spacemacs/config.el" nil t) ; Reading at buffer position 5784
load-with-code-conversion("/home/vagrant/.emacs.d/spacemacs/config.el" "/home/vagrant/.emacs.d/spacemacs/config.el" nil nil)
load("/home/vagrant/.emacs.d/spacemacs/config.el")
(if (file-exists-p file) (load file))
(let ((file (concat dir file))) (if (file-exists-p file) (load file)))
(while --dolist-tail-- (setq file (car --dolist-tail--)) (let ((file (concat dir file))) (if (file-exists-p file) (load file))) (setq --dolist-tail-- (cdr --dolist-tail--)))
(let ((--dolist-tail-- files) file) (while --dolist-tail-- (setq file (car --dolist-tail--)) (let ((file (concat dir file))) (if (file-exists-p file) (load file))) (setq --dolist-tail-- (cdr --dolist-tail--))))
(progn (let ((--dolist-tail-- files) file) (while --dolist-tail-- (setq file (car --dolist-tail--)) (let ((file (concat dir file)))
@roman
roman / packages.el
Created Jan 8, 2015
Clocker's packages.el
View packages.el
(defvar clocker-packages
'(powerline
dash))
(defface clocker/mode-line-clock-in-face
'((t (:foreground "white" :background "#F2686C" :inherit mode-line)))
"Clocker's face for CLOCK-IN mode-line message."
:group 'clocker)
(defun clocker/org-clocking-p ()
View packages.el
(defvar navorski-packages
'(navorski))
(defun navorski/terminal-line-mode ()
(interactive)
(when (term-in-char-mode)
(term-line-mode)
(linum-mode 1))
(when (evil-emacs-state-p)
(evil-normal-state)))
@roman
roman / Observable.hs
Created Jun 5, 2015
Experiments with a Cont Monad approach for Observables
View Observable.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RecursiveDo #-}
module Main where
import Control.Concurrent (myThreadId)
import Control.Exception (SomeException)
import Control.Applicative (Alternative(..))
import Control.Monad (liftM, ap, unless, foldM_)
import Data.IORef (newIORef, atomicModifyIORef', readIORef)