Skip to content

Instantly share code, notes, and snippets.

View line-o's full-sized avatar
🌱
weeding the garden

Juri Leino line-o

🌱
weeding the garden
View GitHub Profile
@allenwb
allenwb / short-functions.js
Created March 11, 2012 08:13 — forked from dherman/short-functions.js
using do () {} for concise functions
// 1. No new syntax for non-TCP functions.
//
// This approach does do include a shorter syntax for regular functions, so if a classic JS function
// is what you want you use the classic long form function expression:
a.some(function (x){
if (invalid(x))
return true;
console.log(x);
});
@pgherveou
pgherveou / pull-stream.swift
Created August 31, 2016 23:34
pull stream playground in swift
// https://github.com/dominictarr/pull-stream-examples/blob/master/pull.js
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
/// Pull stream events
enum Event<T> {
case next(T)
case error(Error)
@bahamat
bahamat / nginx_log_format_bunyan.conf
Last active September 14, 2016 08:12
nginx log_format bunyan
log_format bunyan '{'
'"name": "nginx/$nginx_version",'
'"hostname": "$hostname",'
'"pid": "$pid",'
'"level": 30,'
'"time": "$time_iso8601",'
'"v": 0,'
'"msg": "access",'
'"remoteAddress": "$remote_addr",'

Build the docker image and start the container.

Start Xvfb in the container via

$ /etc/init.d/xvfb start

Run Chrome with working WebGL in kiosk mode

@joewiz
joewiz / fib-exist.xq
Last active October 10, 2020 16:51 — forked from apb2006/fib.xq
XQuery tail recursive Fibonacci function, with timing, for eXist-db
xquery version "3.1";
(: forked from https://gist.github.com/apb2006/4eef5889017be4a50685a467b2754d27
: with tests returned in the style of https://so.nwalsh.com/2020/10/09-fib :)
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){
switch ($n)
case 0 return $a
case 1 return $b
default return local:fib($n - 1, $b, $a + $b)
@apb2006
apb2006 / fib.xq
Created October 9, 2020 19:31
XQuery tail recursive Fibonacci function
declare function local:fib($n as xs:integer, $a as xs:integer, $b as xs:integer){
switch ($n)
case 0 return $a
case 1 return $b
default return local:fib($n - 1, $b, $a + $b)
};
declare function local:fib($n as xs:integer){
local:fib($n,0,1)
};
@jed
jed / tee.js
Last active November 24, 2020 17:59
Teeing an asynchronous iterator
function tee(asyncIterable) {
let source = asyncIterable[Symbol.asyncIterator]()
return [[], []].map((buffer, i, buffers) => ({
async next() {
if (0 in buffer) return buffer.shift()
let item = await source.next()
if (!item.done) buffers[1 - i].push(item)
@joewiz
joewiz / list-packages-with-dependency.xq
Created June 2, 2021 15:50
Find which EXPath packages declare a particular dependency, in eXist-db
xquery version "3.1";
declare namespace pkg="http://expath.org/ns/pkg";
array {
for $app in xmldb:get-child-collections("/db/apps")
let $package-metadata := doc("/db/apps/" || $app || "/expath-pkg.xml")
where $package-metadata//pkg:dependency[@package eq "http://exist-db.org/apps/shared"]
order by $app
return

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@joewiz
joewiz / system-properties.xq
Created March 10, 2022 18:32
Display all system properties and their values - for eXist-db
xquery version "3.1";
(: @see https://exist-db.org/exist/apps/fundocs/index.html?q=util:system-property
: @see https://github.com/eXist-db/exist/blob/develop/exist-core/src/main/resources-filtered/org/exist/system.properties
:)
let $exist-properties :=
(
"vendor",
"vendor-url",
"product-name",