I hereby claim:
- I am neektza on github.
- I am neektza (https://keybase.io/neektza) on keybase.
- I have a public key whose fingerprint is 7990 35A1 892F DAEE E2F7 485F 3818 D6B1 1712 E2E5
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
{-# LANGUAGE OverloadedStrings #-} | |
module Meetup.Types.Event where | |
import Data.Text | |
import Data.Aeson | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad (mzero) | |
import Data.ByteString.Lazy |
require 'bundler/setup' | |
require 'rubygems' | |
require 'celluloid' | |
require 'celluloid/io' | |
# defining a supervision group via inheritance | |
class Scraper < Celluloid::SupervisionGroup | |
supervise Publisher, as: :publisher | |
supervise Commander, as: :commander | |
supervise SourceSupervior, as: :source_supervisor,\ |
module EventMachine | |
class Reactor | |
def run_timers | |
@timers.each do |t| | |
if t.first <= @current_loop_time | |
@timers.delete t | |
EventMachine::event_callback "", TimerFired, t.last | |
else | |
break |
SELECT COUNT("entities".*, COALESCE(ts_rank(to_tsvector('english', "entities"."title"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."url"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."body"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."origin_id"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."feed_name"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."type_name"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."image"::text), plainto_tsquery('english', 'something'::text)), 0) + COALESCE(ts_rank(to_tsvector('english', "entities"."cached_tag_list"::text), plainto_tsquery('english', 'something'::text)), 0) AS "rank323835418192 |
I hereby claim:
To claim this, I am signing this object:
use std::env; | |
use std::fs::File; | |
use std::path::Path; | |
use std::io::BufReader; | |
use std::io::prelude::*; | |
use std::collections::HashMap; | |
use std::error::Error; | |
extern crate rand; | |
use rand::{thread_rng, Rng}; |
At...
Why are we using anonymous module here? Because we want to stay in the same context, so we can use the prepend variable.
and...
prepend doesn’t exist in the context of the new method, since it’s a local variable. We have to define a method dynamically to use it.
.. maybe better to mention that by defining the module and the method in a block, we stay in the same lexical [closure](http://en.wikipedia.org/wiki/Closure_(computer_science\)), and in that way we can access the local variables. What I'm trying to say is that we don't need to define these things anonymously or dynamically; we just need to define them in a the same lexical closure, and we achieve that by using blocks.
// Section: "Prototype-based OO programming", 2nd example | |
var bFunc = function() { return this } | |
var b = { name: "b", fun: bFunc } | |
b.fun() | |
// => Object {name: "b", fun: function} |
class SomeServiceObject | |
def initialize(foo) | |
@foo = foo | |
end | |
def a_method | |
manipulate(foo) | |
end | |