Skip to content

Instantly share code, notes, and snippets.

/**
*
* Also see comments on the function main().
*
* Depends only on the libs that come with elasticsearch:
* elasticsearch-0.15.2.jar
* lucene*.jar
*
* Place the ElasticTest.java file and the above jars in the same folder.
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@brain64bit
brain64bit / install-ruby-win7.md
Last active August 29, 2015 14:03
Install Ruby 2, Rails 4.1.1 and RMagick on Windows 7

Installation Ruby 2.0.0, Rails 4.1.1, Rmagick 2.13.2 on Windows 7

Installing rails and its dependencies always painfull in windows, thankfully to railsinstaller or rubyinstaller but here i want show how install ruby, rails and rmagick based on my experience:

  1. First install rails FTW, its like railsinstaller but at least more latest ruby and rails than railsinstaller. Its contain ruby 2.0.0-p481 32bit and rails 4.1.1
  2. In here you've got ruby 2.0.0 and rails 4.1.1 installed in your system. Open your cmd and type ruby -v and rails -v to make sure ruby on rails installed properly.
  3. Download Devkit 4.7.2 32bit
  4. Download ImageMagick-6.7.9-9-Q16-windows-dll.exe install on C:/imagemagick
  5. from
<link rel="import" href="../core-pages/core-pages.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@brain64bit
brain64bit / Ansibel
Last active August 29, 2015 14:07 — forked from yudapc/Ansibel
$ sudo apt-get install python-pip
$ sudo pip install boto
$ sudo pip install https://github.com/KMK-ONLINE/ansible/zipball/elasticache_redis_vpc
create new file with name "hostfile" :
[yudaserver]
128.199.146.166
create new file with name "nginx.yml" :
- name: DEPLOYMENT
@brain64bit
brain64bit / gist:48569ff0c6c146b0c8ef
Created December 4, 2014 07:02 — forked from dhh/gist:1014971
Rails Concerns Example
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@brain64bit
brain64bit / gist:7cfcd25bf99b99159b02
Last active August 29, 2015 14:15 — forked from cpjolicoeur/gist:3590737
PostgreSQL mighty function

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@brain64bit
brain64bit / introrx.md
Last active August 29, 2015 14:15 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.