Skip to content

Instantly share code, notes, and snippets.

View benjamintanweihao's full-sized avatar

Benjamin Tan Wei Hao benjamintanweihao

View GitHub Profile
@benjamintanweihao
benjamintanweihao / dice_client.rb
Last active August 29, 2015 14:01
DiCE Ruby Client.
#!/usr/bin/env ruby
require 'json'
require 'socket'
class DiceClient
def initialize(host, port)
@host = host
@port = port
puts "Connecting to server..."
We couldn’t find that file to show.
We couldn’t find that file to show.
I have two roles with my client major International Consultancy like Accenture, IBM and HP for 2 years in South China with Node.JS knowledge.
They require people ASAP.
Please also find info about detailed JD:
Locaton: Onsite shenzhen,CHina,
Duration: at least 2 years
Start date:June 1st.
Senior Web Front consultant--Level 8 --need 3
• knowledgeable of mainstream ideologies and capable of primary planning and constructing of front-end framework
defmodule ID3Parser do
def parse(file_name) do
case File.read(file_name) do
{:ok, binary} ->
# ID3 tag information is located at the last 128 bytes.
mp3_byte_size = (byte_size(binary) - 128)
<< _ :: [size(mp3_byte_size), binary], id3_tag :: binary >> = binary
<< "TAG", tags :: binary >> = id3_tag
%% ---
%% Excerpted from "Programming Erlang",
%% published by The Pragmatic Bookshelf.
%% Copyrights apply to this code. It may not be used to create training material,
%% courses, books, articles, and the like. Contact us if you are in doubt.
%% We make no guarantees that this code is fit for any purpose.
%% Visit http://www.pragmaticprogrammer.com/titles/jaerlang for more book information.
%%---
-module(shout).
SELECT locations.name, SUM(items.count_on_hand) AS stock_count, SUM(items.count_on_hand * prices.amount) AS total_price
FROM spree_stock_locations AS locations
INNER JOIN spree_stock_items AS items
ON locations.id = items.stock_location_id
INNER JOIN spree_variants AS variants
ON variants.id = items.variant_id
INNER JOIN spree_prices AS prices
ON prices.variant_id = variants.id
WHERE prices.currency = 'SGD'
GROUP BY (locations.id)

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.

=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')