Blynx is a functional and statically-typed programming language.
It generates Javascript code, so it can be used both client-side (in a browser) or server-side (with node.js).
State: in development
#!/bin/bash | |
# | |
# Toggle the state (STOPPED/RUNNING) of a process, clicking to its window. | |
set -e | |
debug() { echo "$@" 2>&1; } | |
die() { local MESSAGE=$1 | |
debug "Error: $MESSAGE" | |
exit 1 |
#!/usr/bin/ruby | |
# http://code.google.com/codejam/contest/dashboard?c=635101#s=p0 | |
# | |
# Author: tokland@gmail.com | |
class Problem | |
# Create a directory (as array of slugs) in an existing filesystem and | |
# return the final filesytem and the total creation cost. | |
def self.create_directory(filesystem, slugs) | |
if (head = slugs.first) |
# http://www.elpais.com/videos/sociedad/cubo/suma/cero/elpepusoc/20110505elpepusoc_2/Ves/ | |
faces_vertices = [[0,1,2,3], [0,1,4,5], [4,5,6,7], [2,3,6,7], [0,3,4,7], [1,2,5,6]] | |
vertices_solution = ([+1, -1].repeated_permutation(8)).select do |vertices_values| | |
faces_values = faces_vertices.map do |vertices| | |
vertices_values.values_at(*vertices).inject(:*) | |
end | |
(vertices_values + faces_values).inject(:+) == 0 | |
end |
#!/usr/bin/ruby-1.9 | |
require 'set' | |
class Problem11 | |
def self.solve(boxes, nails_per_box, weights) | |
(1..nails_per_box).to_a.repeated_combination(boxes).select do |combination| | |
weights.repeated_permutation(boxes).map do |weights| | |
weights.zip(combination).map do |weight, value| | |
weight * value | |
end.inject(:+) |
# Usage: | |
# $loopc 3 echo 'hello world' | |
# hello world | |
# hello world | |
# hello world | |
# | |
function loopc { | |
LIMIT=$1 | |
shift 1 |
exports.getProperty = function(name, obj) { | |
return obj[name]; | |
}; |
# Rationale: How to chain functions with type (a -> transformation_of_a) # | |
# as they were (a -> a)? | |
# | |
# If the functions were "normal" (a -> a), we'd write simply: fun3(fun2(fun1(1))) | |
def fun1(x): | |
return ("ok", 1*x) if x > 1 else ("fail", "fun1: value of x is ugly: %s" % x) | |
def fun2(x): | |
return ("ok", 2*x) if x > 2 else ("fail", "fun2: value of x is ugly: %s" % x) |
#!/bin/bash | |
# all-in-one extractor for the most usual archive formats. Requires Bash >= 4 | |
set -e -u -o pipefail | |
declare -A COMMANDS=( | |
[z]="compress -d" | |
[gz]="gunzip" | |
[bz2]="bunzip2" | |
[zip]="unzip -qo" | |
[rar]="unrar x" |
#!/bin/sh | |
# | |
# Requirements: echoprint-codegen, curl, js-beautify | |
# | |
set -e -u -o pipefail | |
SERVER="http://developer.echonest.com/api/v4/song/identify" | |
API_KEY=FILDTEOIK2HBORODV | |
FILE=$1 | |
echoprint-codegen "$FILE" | |