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
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" |
#!/usr/bin/ruby | |
# | |
# Download lecture videos of courses from Coursera (http://www.coursera.org). | |
# | |
# Install requirements: | |
# | |
# $ gem install curb trollop nokogiri capybara ruby-progressbar | |
# | |
# Example -- Download all video lectures of courses "Calculus: Single Variable" | |
# and "Introduction to Astronomy": |
#!/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" | |
# Or: require 'facets/enumerable/find_yield' | |
module Enumerable | |
def map_detect | |
self.each do |member| | |
if (result = yield(member)) | |
return result | |
end | |
end | |
nil | |
end |
#!/bin/bash | |
# | |
# Simple monitoring using a finite state machines | |
set -e -u -o pipefail | |
# Print debug output to standard error | |
debug() { | |
echo "[${FUNCNAME[1]}] $@" >&2 | |
} |
class Importer | |
CODES = {:header, "00F", :data => "00I"} | |
def self.import_products(fileobj) | |
fileobj.lines.each_slice(4).map do |group_lines| | |
type, *data_lines = group_lines.map(&:strip) | |
case type | |
when CODES[:header] | |
# what to do/return here? | |
when CODES[:data] |
#!/bin/sh | |
# | |
# Resize videos to a given size. | |
# Depedencies: libav | |
debug() { | |
echo "$@" >&2 | |
} | |
to_num() { local NUM_STRING=$1 |