Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
rogeriochaves / rxclj.cljs
Created April 30, 2015 13:21
Comparing RxJS on javascript and clojurescript
(ns rxjsclj.core
(:require [Rx]))
(defn stream-for [x]
(.map (.interval js/Rx.Observable 2000) x))
(def providers (.from js/Rx.Observable [1 2 3]))
(-> (stream-for providers)
(.concatMap #(.map % stream-for))
@rogeriochaves
rogeriochaves / gist:ad633f47dab497a84ad0
Created May 8, 2015 17:08
Make ajax request fail
(function (originalOpen) {
XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
if (url.match(/limits/)) url = "REJECTED";
originalOpen.call(this, method, url, async, user, password);
};
})(XMLHttpRequest.prototype.open);
@rogeriochaves
rogeriochaves / main.hs
Created November 22, 2015 00:02
Contacts Program in Haskell
import Data.List
main = do
putStrLn "Welcome to the contacts list program!"
mainMenu [] -- initial contacts list state
mainMenu :: [String] -> IO b
mainMenu contacts = do
putStrLn "1 - Add new contacts; 2 - Show contacts; 3 - Sort contacts"
@rogeriochaves
rogeriochaves / pipe.hs
Created November 24, 2015 01:02
pipe operator in haskell, very simple
x |> f = f x
something x = repeat x
|> filter (> 3)
|> map (+ 1)
|> take 5
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
Verifying that +rchaves is my blockchain ID. https://onename.com/rchaves
module Tests exposing (..)
import Test exposing (..)
import Expect
import Fuzz exposing (list, int, tuple, string)
import String
all : Test
all =
module Main exposing (..)
import ElmTest exposing (..)
import Example
tests : Test
tests =
Example.tests
module Main where
import Task
import Console exposing (..)
import Graphics.Element exposing (Element)
import ElmTest exposing (..)
import Example
tests : Test
var gulp = require('gulp'),
shell = require('gulp-shell');
gulp.task('build-tests', shell.task([
'elm-make --warn test/TestRunner.elm --output test.js'
]))
gulp.task('run-tests', ['build-tests'], shell.task([
'node test.js'
]))