Skip to content

Instantly share code, notes, and snippets.

@rogeriochaves
rogeriochaves / gist:9625019
Created March 18, 2014 17:31
YDN-DB's IndexedDB vs Pure LocalStorage
I made this: http://jsperf.com/ydn-db-s-indexeddb-vs-pure-localstorage, check it out
@rogeriochaves
rogeriochaves / gist:937848ab4a5f383c2c6c
Created March 19, 2015 22:07
Testing RxJS Observables on Jasmine 1.3
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.4.3/rx.all.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.4.3/rx.testing.min.js"></script>
<script src="http://daniellmb.github.com/jasmine-run/jasmine-1.3.1-run.js"></script>
<script>
var waitsForObservable = function (observable, callback, opt_timeout) {
var result, timeout;
timeout = opt_timeout || 5000;
runs(function(){
@rogeriochaves
rogeriochaves / gist:4cb72f3306c0209800b1
Created April 28, 2015 03:02
Jasmine Pretty Printer when comparing objects
jasmine.MAX_PRETTY_PRINT_DEPTH = 3;
jasmine.pp = (function (j$) {
function PrettyPrinter() {
this.ppNestLevel_ = 0;
this.seen = [];
}
PrettyPrinter.prototype.format = function(value) {
this.ppNestLevel_++;
@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))
<div id="window_drive" class="abs window">
<div class="abs window_inner">
<div class="window_top">
<span class="float_left">
<img src="assets/images/icons/icon_16_drive.png" />
Alunos
</span>
<span class="float_right">
<a href="#" class="window_min"></a>
<a href="#" class="window_resize"></a>
@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 / 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 / gist:4552752
Created January 17, 2013 01:29
Just trying to simulate jquery like methods binding with ruby
class JQuery
class << self
attr_accessor :thread
end
def self.get(url, &block)
block.call("resposta")
return self
end
@rogeriochaves
rogeriochaves / quadrados.css
Created May 22, 2013 15:49
CSS do jogo quadrados
/* CSS declarations go here */
.quadrado{
width:50px; height:50px; background:#F00; position: absolute;
}
@rogeriochaves
rogeriochaves / quadrados.js
Created May 22, 2013 15:51
JavaScript do jogo Quadrados
Quadrados = new Meteor.Collection("quadrados");
if (Meteor.isClient) {
Template.quadrados.quadrados = function () {
return Quadrados.find({});
};
Meteor.startup(function () {
var quadrado = Quadrados.insert({x: Math.random() * 500, y: Math.random() * 500});
Session.set("quadrado", quadrado);