Skip to content

Instantly share code, notes, and snippets.

View blambeau's full-sized avatar

Bernard Lambeau blambeau

View GitHub Profile
describe 'with an array with non bytes', ->
arg = [2, 4, -12]
subject =
try
type.dress(arg)
catch e
e
it 'should raise an error', ->
TypeError: Cannot read property 'should' of undefined
at World.<anonymous> (/Users/blambeau/work/devel/qjs/features/step_definitions/steps.coffee:59:12)
at Object.invoke (/usr/local/lib/node_modules/cucumber/lib/cucumber/support_code/step_definition.js:84:14)
at Object.execute (/usr/local/lib/node_modules/cucumber/lib/cucumber/ast/step.js:161:22)
at Object.acceptVisitor (/usr/local/lib/node_modules/cucumber/lib/cucumber/ast/step.js:153:12)
at Object.executeStep (/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:192:12)
at Object.processStep (/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:187:14)
at /usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:80:16
at callUserFunctionAndBroadcastAfterEvent (/usr/local/lib/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:104:9)
at iterate (/usr/local/lib/node_modules/cucumber/lib/cucumber/type/collection.js:31:11)
@blambeau
blambeau / ast.rb
Created March 9, 2014 18:20
Q -- Abstract Syntax Tree
[
:system,
[
:type_def,
"Boolean",
[
:union_type,
[
:builtin_type,
"TrueClass"
@blambeau
blambeau / gist:366bd21ff9704c33b9b1
Created May 20, 2014 17:19
Finitio dress/undress
S = Finitio.parse <<-EOF
Uuid = String( ... )
Time = .Date <iso> String( s | ... ) .Finitio.Contract.Time.iso
Physical = {
uuid: String
title: String
at: String
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.8/angular.js"></script>
<script>
var myApp = angular.module('myApp', [
]);
myApp.directive('bang', function() {
return {
link: function(scope, element, attr) {
logger.configure({
default: "none",
override: {
"brolMachin": "all",
"trucBidule": "get"
}
});
customResource.get("brolMachin").then(function(result){
//
@blambeau
blambeau / gist:03e9c8239ce9818a45a8
Last active August 29, 2015 14:11
PostgreSQL and CTEs

Why doesn't PostgreSQL optimize Common Table Expressions?

PostgreSQL does not seem to optimize common table expressions (CTE) very well. At the same time, is seems to optimize properly when views are involved. Any idea why? Is that accidental or is it a technical/theoretical/essential reason? Examples below.

With CTE, restriction after join

Does not seem optimized.

sap=# explain with j as (select * from suppliers natural join shipments) select * from j where status > 20;
@blambeau
blambeau / not_so_flexible_require
Created January 14, 2011 16:30
How [NOT] to require external dependencies
#
# This method allows requiring dependencies with some flexibility.
#
# Implemented algorithm makes greedy choices about the environment:
# 1. It first attempts a simple <code>Kernel.require(name)</code> before
# anything else (even bypassing version requirement)
# 2. If step 1 fails with a LoadError then it falls back requiring the
# gem with specified version (defaults to >= 0) and retries step 1.
# 3. If step 2 fails with a NameError, 'rubygems' are required and step
# 2 is retried.
@blambeau
blambeau / tutorial_d_in_ruby.rb
Created January 28, 2011 13:48
Relational algebra on apache logs, thanks to veritas
require 'veritas/physical/logs'
file = File.expand_path('../access.log', __FILE__)
LOGS = Veritas::Physical::Logs.new(file, [:apache, :combined])
# How many hits per page ??
(debug (summarize LOGS, :path, :count => (count '*')))
# What pages have not been found ??
NOT_FOUND = (restrict LOGS, ->(t){ t[:http_status].eq(404) })
@blambeau
blambeau / hello.coffee
Created February 17, 2011 10:50
An example of syntax
class Hello extends Brick
constructor: ->
# Cell for the current view
@current = new Cell
# View handler for #content
@content = new View
selector: