Skip to content

Instantly share code, notes, and snippets.

@zhhz
zhhz / index.html
Created July 6, 2017 15:23
Solitaire
<div id="app">Loading...</div>
@zhhz
zhhz / app.html
Last active November 22, 2016 15:56 — forked from jdanyow/app.html
Aurelia Validation Demo-1
<template>
<h1>from app tpl</h1>
<router-view></router-view>
</template>
from scapy.all import *
import requests
import time
MAGIC_FORM_URL = 'http://put-your-url-here'
def record_poop():
data = {
"Timestamp": time.strftime("%Y-%m-%d %H:%M"),
"Measurement": 'Poopy Diaper'
}

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.

@zhhz
zhhz / webapp.rb
Created November 16, 2010 14:18 — forked from igrigorik/webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
curl -u your_gmail_account:your_password --silent "https://mail.google.com/mail/feed/atom" | tr -d 'n' | awk -F '' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"
class PurchaseOrder
include DataMapper::Resource
storage_names[:default] = ...
property :id, Serial, :field => 'purchaseorderindex'
...
property :closed_date, Date, :field => 'closeddate'
...
has n, :items, :model => 'PurchaseOrderLineItem', :child_key => [:po_id, Integer], :deleted => false
@zhhz
zhhz / route.rb
Created September 14, 2009 20:04
# merb-core-1.0.9/lib/merb-core/dispatch/router/route.rb
- SEGMENT_REGEXP_WITH_BRACKETS = /(:[a-z_]+)(\[(\d+)\])?/
+ SEGMENT_REGEXP_WITH_BRACKETS = /(:[a-z0-9_]+)(\[(\d+)\])?/
@zhhz
zhhz / router.rb
Created September 14, 2009 20:00
namespace :ordering do |order|
order.resources :codebook2s do |cb2|
cb2.resources :codebook2_line_items
end
...
...
end
def generate_daily_pos_report
# create a fake request
fake_request = Merb::Request.new({})
# init the controller
controller = Purchasing::Reports.new(fake_request)
# gets all the pos created on today
pos = PurchaseOrder.all(:deleted => false, :po_date => date)
results = "No purchase orders created on #{date}"
if pos.size > 0