(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/bin/ruby --verion => 2.0.0-p353
In Ruby, self is a special variable that always references the current object.
-module(generic_proxy). | |
-export([run/0]). | |
-define(PORT_FROM, 63790). | |
-define(PORT_TO, 6379). | |
-define(BACKLOG, 10000). | |
run() -> | |
{ok, Socket} = gen_tcp:listen(0, [ |
In the mid-80s, while reading through my roommate's collection of Scientific American back issues, I encountered this introduction to Lisp written by Douglas Hofstadter. I found it very charming at the time, and provide it here (somewhat illegally) for the edification of a new generation of Lispers.
In a testament to the timelessness of Lisp, you can still run all the examples below in emacs if you install these aliases:
(defalias 'plus #'+)
(defalias 'quotient #'/)
(defalias 'times #'*)
(defalias 'difference #'-)
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval
.
You can find instance_eval
used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
;; The Computer Language Benchmarks Game | |
;; http://shootout.alioth.debian.org/ | |
; | |
;; Adapted from the Java -server version | |
; | |
;; contributed by Marko Kocic | |
;; modified by Kenneth Jonsson, restructured to allow usage of 'pmap' | |
;; modified by Andy Fingerhut to use faster primitive math ops, and | |
;; deftype instead of defrecord for smaller tree nodes. | |
;; https://github.com/jafingerhut/clojure-benchmarks/blob/master/binarytrees/binarytrees.clj-4.clj modified by RH for 1.3 |