Skip to content

Instantly share code, notes, and snippets.

View WietseWind's full-sized avatar
⌨️
Focusing

Wietse Wind WietseWind

⌨️
Focusing
View GitHub Profile
@WietseWind
WietseWind / sftp.twig
Created July 27, 2016 19:42
sFTP connection using nodum
<h1>sFTP</h1>
{# Using RSA key, or stop after 22 (port number) and enter password before port number argument #}
{% set sftp = api.IO_sftpClient('10.100.92.34', 'sftp_user_account', '', 22, '-----BEGIN RSA PRIVATE KEY-----
MIICWgIBAAKBgQCeYa9kXyHDER1ZOsdlDdcTTXH8H00g1ajIHsS++LfWUyTyFQod
IBJQKBmSoNrEc8aDsZ4G2TwKAM7riJj4uRdHsMJwPkHlqgQkEhODwlXpmslQ1Cfw
...
...
...
@WietseWind
WietseWind / readzip.twig
Created July 27, 2016 19:43
Read zip to static folder using nodum
<h1>ZIP, check static map</h1>
{% set zip = api.IO_staticFile('sample.zip').get() %}
{% for file in api.IO_readZip(zip, true) %}
{% do api.IO_staticFile('unpack/' ~ file.name).set(file.data) %}
{% endfor %}
@WietseWind
WietseWind / validate.twig
Created July 27, 2016 19:43
Form validation using nodum
<h1>{{ 'Form Validation Sample'|t }}</h1>
{% set v = validate
.requireToken
.setRetention(3)
.preventDuplicate()
.setId('TESTFRM')
.setType('post')
.field('Tx', [ 'minlength(10)','isempty' ], 'Geef een toelichting op van minimaal 10 karakters of laat leeg.'|t )
.field('captcha', 'captcha', 'Valideer de reCAPTCHA'|t )
@WietseWind
WietseWind / captcha.twig
Created July 27, 2016 19:43
Using captcha with nodum
<h1>Captcha</h1>
{{ param.post|pre }}
{{ validate.checkCaptcha|pre }}
<form method="post" action="{{ index }}">
{{ validate.getCaptcha()|raw }}
@WietseWind
WietseWind / doctohtml.twig
Created July 27, 2016 19:44
Document to html using nodum
<h1>Doc 2 HTML</h1>
{#{% set file = api.IO_staticFile('test/Projectplan_iPublications_Cron.pdf').get() %}#}
{% set url = 'http://vinkhuiswerk.nl/wp-content/uploads/2012/02/AlgemeneVoorwaarden-2014-2015.docx' %}
{{ url|pre }}
{% set file = api.HttpReader_Get(url) %}
{{file|pre}}
{% set dummy = api.Document_toHtml(file, false, false, true, baselocation~'static') %}
@WietseWind
WietseWind / social.twig
Created July 27, 2016 19:44
Social Profile (set API keys in config first) using nodum
<h1>Social Profile</h1>
{# ---- UITLOGGEN VERWERKEN ---- #}
{% if rest.get.logout %}
{% do socialprofile.doLogout(rest.get.logout) %}
{% endif %}
{# ---- INLOGGEN VERWERKEN ---- #}
@WietseWind
WietseWind / dom.twig
Created July 27, 2016 19:45
Read DOM using nodum
<h1>Dom</h1>
{% set data = api.HttpReader_Get('https://www.simplicate.nl/') %}
{{ (data|dom_body).find('div.home-links')[0]|raw }}
@WietseWind
WietseWind / simplicate.twig
Created July 27, 2016 19:45
Simple Simplicate using nodum
<h1>Simplicate API</h1>
{% set data = api.Simplicate_V2.crm('organization', {
fields : 'name',
q : '*ipub*',
offset : 0,
limit : 10,
sort : '-name'
}).get %}
@WietseWind
WietseWind / ftp.twig
Created July 27, 2016 19:46
FTP using nodum
<h1>FTP ISM</h1>
{% set ftp = api.IO_ftpClient('test.nl', 'User123', 'Passw5=Y', 21, false, 4).utf8(true).pasv(true) %}
{{ ftp.dir('/Handleidingen/')|pre }}
@WietseWind
WietseWind / mail.twig
Created July 27, 2016 19:47
Generate PDF attachments and send mail using nodum
<h1>PDF Tests</h1>
{% set pdf1 = api.PDF_generate('test', 'generated.pdf', 'landscape', { naam: "Wietse" }) %}
{% set pdf2 = api.PDF_generate('<b>Hoi!</b> Werkt het?', 'generated-inline.pdf') %}
Filename: <b>{{ pdf1.name }}</b><br />
Filelength: <b>{{ pdf1.data|length }}</b><br />
{% do api.IO_staticFile( pdf1.name ).set( pdf1.data ) %}
{% do api.IO_staticFile( pdf2.name ).set( pdf2.data ) %}