Skip to content

Instantly share code, notes, and snippets.

@pzel
pzel / gist:1056023
Created June 30, 2011 11:10
unable to fire event
zombie = require('zombie');
assert = require('assert');
vows = require('vows');
url = "http://localhost:4568/";
// Load the page from localhost
vows.describe('The tags page').addBatch({
'Presence' : {
@pzel
pzel / helpers.rb
Created August 11, 2011 17:53 — forked from foysavas/helpers.rb
Carrierwave, DataMapper, & Sinatra starring in "Imagine the Possibilities"
def is_ajax_request?
if respond_to? :content_type
if request.xhr?
true
else
false
end
else
false
end
@pzel
pzel / gist:1250123
Created September 29, 2011 06:43
Capybara-webkit version (from 1056023)
# coding: utf-8
ENV['RACK_ENV'] = 'test'
require './nejiro'
require 'rspec'
require 'capybara'
require 'capybara/rspec'
require 'capybara-webkit'
p@maple:/usr/local/src/camping$ git diff
diff --git a/Gemfile b/Gemfile
index b0b1ee2..aee38c4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -9,6 +9,12 @@ if rack = ENV['RACK']
end
end
+group :development do

Project Build Tools: Output on first run vs. second run with no new changes

Cabal-install (Haskell), initial run:

Running cabal install for the first time, we get a full report of the steps taken to build the project.

hproject$ cabal install
Resolving dependencies...
@pzel
pzel / ct_tty_hook.erl
Created July 10, 2014 13:52
Reasonable TTY output for common tests.
%%% @doc Common Test Example Common Test Hook module.
-module(ct_tty_hook).
%% @doc Add the following line in your *.spec file to enable
%% reasonable, tty error reporting for your common tests:
%% {ct_hooks, [ct_tty_hook]}.
%% Callbacks
-export([id/1]).
-export([init/2]).
@pzel
pzel / UTF8-trim.md
Last active May 21, 2018 21:29
String.strip() inconsistency

Unintiuitive behavior in String.strip()

I just ran across unintuitive behavior in [String.strip]

When the last U8 preceding the trailing whitespace is a fragment of a utf-8 sequence, it gets chopped off along with the following whitespace.
Whe the last U8 preceding the end of the string is a fragment of a utf-8 sequence, that last codepoint gets mangled to its first octet.

This goes against the prinicple of least surprise. Encoding issues notwithstanding,

@pzel
pzel / example.pony
Last active May 25, 2018 23:18
Returning internal state as a val to a promise
// This works
actor Router
let _env : Env
var _notifiers : Map[String val, ChatSession tag]
new create(env: Env) =>
_env = env
_notifiers = Map[String val, ChatSession tag].create(10)
fun ref _user_list() : Array[String] val =>
class Maybe[A : Equatable[A] val] is Equatable[Maybe[A]]
let v : (A val | None)
new val create(thing: A) => v = thing
new val empty() => v = None
fun eq(that: box->Maybe[A]): Bool =>
match (this.v, that.v)
| (let v' : A, let v'' : A) => v' == v''
| (let n' : None, let n'' : None) => true
@pzel
pzel / Makefile
Created February 21, 2019 22:15
Makefile
.setup: $(wildcard deps/**)
@echo setting up
@touch .setup
test: .setup
@echo tests ran