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 / 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 / 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 / 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
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! [
@lepinekong
lepinekong / menus.red
Created December 26, 2017 17:17
Menu and Submenus
Red [title: "Menus" needs: 'view]
g: layout [area 400x400]
g/menu: [
"No Submenus" [
"Print" prnt
---
"Quit" kwit
]
"Sub-menus" [
"Sub-menus" [