Skip to content

Instantly share code, notes, and snippets.

Avatar

Maxim Velesyuk maximvl

View GitHub Profile
@andelf
andelf / beam_decompile.erl
Created Mar 19, 2013
Erlang BEAM file decompile to .erl file
View beam_decompile.erl
#!/usr/bin/env escript
% -*- mode: erlang -*-
main([BeamFile]) ->
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(BeamFile,[abstract_code]),
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
@avar
avar / 30-income-calculon.pl
Last active Jul 22, 2020
Calculate your income in The Netherlands with and without a 30% ruling.
View 30-income-calculon.pl
# To check if this is up-to-date with the tax rates go to
# http://www.expatax.nl/tax-rates-2016.php and see if there's anything
# newer there.
#
# I make no guarantees that any of this is correct. I calculated this
# at the time and have been updating it when new tax rates come along
# because people keep finding this useful.
#
# There's also an interactive JS version of this created by
# @stevermeister at
View gen_tcp2.erl
-module(gen_tcp2).
-export([listen/2, accept/1, accept/2,
connect/3, connect/4,
send/2, recv/1, recv/2, recv/3,
close/1]).
-export([run/0, run/2]).
%% Naive gen_tcp shim over the socket API
@bryanhunter
bryanhunter / build-erlang-17.0.sh
Last active Oct 26, 2019
Build Erlang 17.0 on a fresh Ubuntu box (tested on 12.04 and 14.04)
View build-erlang-17.0.sh
#!/bin/bash
# Pull this file down, make it executable and run it with sudo
# wget https://gist.githubusercontent.com/bryanhunter/10380945/raw/build-erlang-17.0.sh
# chmod u+x build-erlang-17.0.sh
# sudo ./build-erlang-17.0.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
@dockimbel
dockimbel / eval2.red
Created Apr 3, 2018
Test script for Red/View Android backend
View eval2.red
Red [
Title: "Red Android bridge demo"
Author: "Nenad Rakocevic"
File: %eval2.red
Config: [type: 'dll libRed?: no libRedRT?: yes export-ABI: 'cdecl]
Tabs: 4
Needs: 'View
Rights: "Copyright (C) 2013-2017 Nenad Rakocevic. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
@toomasv
toomasv / l-system.red
Last active Feb 21, 2019
Experiments with L-System
View l-system.red
Red [
Author: "Toomas Vooglaid"
Date: 25-9-2017
Description: {Experiments with L-System}
Last-update: 26-9-2017
Uses: {%models.red https://gist.github.com/toomasv/313e1d8583fb159428222651b76926cd}
Repo: https://github.com/toomasv/l-system
]
context [
ctx: self
@toomasv
toomasv / bezier.red
Last active Mar 23, 2018
Digging deeper into curves
View bezier.red
Red [
Author: "Toomas Vooglaid"
Date: 2018-03-19
Inspiration: https://pomax.github.io/bezierinfo
]
lut: [[1][1 1][1 2 1][1 3 3 1][1 4 6 4 1][1 5 10 10 5 1][1 6 15 20 15 6 1]]
binomial: func [n k /local s nextRow i prev][
while [
n > s: length? lut
@toomasv
toomasv / info.red
Last active Nov 28, 2017
To get info about any function
View info.red
Red []
info: func ['fn /name /intro /args /refinements /locals /return /spec
/arg-num /arg-names /arg-types /ref-names /ref-types /ref-num /type /arity?
/local intr ars refs locs ret arg ref typ irefs
][
intr: copy "" ars: make map! copy [] refs: make map! copy [] locs: copy [] ret: copy [] irefs: copy [] typ: ref-arg: ref-arg-type: none
if path? fn [irefs: copy next to-block fn fn: first fn]
if lit-word? fn [fn: to-word fn]
unless find [op! native! function! action!] type?/word get fn [
cause-error 'user 'message ["Only function types accepted!"]
View fry.red
Red [
Title: "fry.red"
Author: ["Gregg Irwin" "Steeve"]
File: %fry.red
Purpose: {
Factor style fry combinators in Red
http://docs.factorcode.org/content/article-fry.html
works somewhat like a reverse collect/keep
}
]
@rebolek
rebolek / incredidle.red
Created May 15, 2017
Simple tool to show how faces work
View incredidle.red
Red []
inc-value: func [
face
color-id
dest-face
/local value rate
] [
unless face/extra [face/font/color: 255.255.255]
overflow?: false
You can’t perform that action at this time.