Skip to content

Instantly share code, notes, and snippets.

@lepinekong
lepinekong / financialLoanFormulas.js
Last active October 7, 2017 08:00
Financial Loan Formulas
function Finance() {};
Finance.CalcMonthlyPayment = function (a,monthlyInterestRate, duration) {
var Q = (1 + monthlyInterestRate);
var n = duration;
var monthlyPayment = a * Math.pow(Q,n) * (1-Q) / (1 - Math.pow(Q,n));
return monthlyPayment;
}
@lepinekong
lepinekong / blog-template.r.tpl
Last active October 7, 2017 08:28
Rebolview (http://www.rebol.com/downloads.html) scripts for migrating wordpress mu to new domain name with phpmyadmin (no SSH access needed)
;; ===================================================
;; this is used by new-blog.r to output list of blogs in blogs.txt
;; ===================================================
rebol[]
sql_file_rootname: "<#sql-file-rootname#>"
domainname: "<#domain-name#>"
db_prefix: "<#db-prefix#>"
@lepinekong
lepinekong / csv-tools.r
Created October 7, 2017 08:04
Rebol utilities
;; ===================================================
;; Script: csv-tools.r
;; downloaded from: www.REBOL.org
;; on: 16-Sep-2017
;; at: 21:13:49.846747 UTC
;; owner: brianh [script library member who can update
;; this script]
;; ===================================================
REBOL [
Title: "CSV Handling Tools"
@lepinekong
lepinekong / autoload.red
Last active October 18, 2017 22:52
Html5 DSL
Red[]
to-rebol-file: :to-red-file
print "get-vars loaded"
get-vars: func[source-file][
vars: []
html-template: read to-rebol-file source-file
rules: [any [thru "<%" copy var to "%>" (append vars var)]]
parse html-template rules
@lepinekong
lepinekong / gist:88473968601901f82bc5781285543cdf
Last active November 9, 2017 19:44
Replacing form by win between ```
rules: [
(code: false)
any [
thru {```} (code: not code)
any [
to "form" mark: (
if code [remove/part mark 4 insert mark "win"]
)
|
thru {```} (code: not code)
@lepinekong
lepinekong / gist:574c327539b7f0591442a6932bbe96bf
Created November 10, 2017 17:34
value? of system/words/test where test has not been defined yet
>> make-system: function[_param][
[ param: _param
[ if value? system/words/:param [
[ system/words/:param: function[][
[ print "test ok"
[ ]
[ system/words/:param
[ ]
[ ]
== func [_param /local param][param: _param
@lepinekong
lepinekong / base58.red
Last active January 15, 2018 10:49
Blockchain / Bitcoin algorithm for base58 encoding (base58 fundamental understanding purpose only)
; Warning: works only for small strings (like "Hello") because of lack of BigInteger support currently
; Download Red-lang.org and copy and paste the code, see execution sample at the bottom
base58-alphabet: ["1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" "G" "H" "J" "K" "L" "M" "N" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"]
to-base58: func[string][
base: 58
i: 0
n: length? string
set 'cum 0
unfold: function [spec][
to string! collect [
repeat i length? bitset: charset spec [
if bitset/:i [keep to char! i]
]
]
]
to-base58: function [string][
base58: rejoin [
@lepinekong
lepinekong / debug.red
Last active December 26, 2017 11:39
Red debugger
debug: func[var][
varName: to-string var
varValue: get var
print rejoin [varName ": " varValue]
]
to-debug: func[ /local test][
test: 20
debug 'test
@lepinekong
lepinekong / debug.red
Last active December 26, 2017 17:11
??
??: func [
"Prints a word and the value it refers to (molded)"
'value [word! path!]
'comment [word! string! unset!]
][
switch/default type?/word get/any 'comment [
unset! [