Skip to content

Instantly share code, notes, and snippets.


Andrei Tofan andrei-tofan

View GitHub Profile
andrei-tofan / test_imap.php
Created Jul 17, 2017
Test local IMAP server
View test_imap.php
// To connect to an IMAP server running on port 993 on the local machine,
// do the following:
$mbox = imap_open("{}INBOX", "delivery", "Ahgn8WKqyQGqgpeXiInh");
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
andrei-tofan / example.js
Last active Mar 19, 2022
node.js writable buffer stream (pdfkit example)
View example.js
* Convert PDFDocument to Base64
const PDFDocument = require('pdfkit');
const stream = require('./stream');
// crate document and write stream
let doc = new PDFDocument();
let writeStream = new stream.WritableBufferStream();
andrei-tofan / express_app.js
Created May 13, 2017
Run node.js express app under a low privilege user
View express_app.js
var express = require('express')
var app = express()
* After app starts, demote the app to a low privilege user
function demote() {
if(process.platform != 'linux') {
return false;
andrei-tofan /
Last active May 5, 2017
LeadBI Email Automation Placeholders

LeadBI Email Automation Placeholders

Placeholders allows you to create personalized emails content and urls.


[[placeholder_name]] - will be replaced with the value of the placeholder.

Avalable Placeholders

  • [[first_name]]
  • [[last_name]]
  • [[website]]
andrei-tofan /
Last active May 5, 2017
LeadBI Native Forms Integration

LeadBI Native Forms Integration

LeadBI Native Forms allows you to capture data from existing website forms.

Target a specific form

To target a specific form you need to specify an html5 id associated with the form, by not specifying it leadbi will try to capture all forms from the page.

Form Attributes

  • Email - any input with the text 'email' in the name field or any input with the attribute data-leadbi-email="true"
  • Full Name - any input with the text 'full?name' in the name field or any input with the attribute data-leadbi-full-name="true"
andrei-tofan /
Last active May 23, 2017
LeadBI SignUp Free Trial API
andrei-tofan / private_area.js
Last active May 5, 2017
LeadBI user identification api
View private_area.js
// check if $leadbi_website api is available
// fetch user object of the current visitor
window.$leadbi_website.getCurrentUser(function (err, user) {
// call the identify api
// calling this method multiple times for the same email address will not create duplicate contacts
return user.identify({
andrei-tofan /
Last active May 5, 2017
LeadBI API access documentation

LeadBI API Access

In order to access the leadbi api you need to create a api key in the account section. After the api key is created you can make api calls using the following headers:

  • X-Access-Id - api key id
  • X-Access-Secret - api key secret

Request Example

GET /api/v1/websites
andrei-tofan / ninja-forms.js
Last active Jun 25, 2020
Ninja Forms JavaScript Hook
View ninja-forms.js
var form_id = 3;
// listen to all ajax completed events
jQuery(document).ajaxComplete(function (event, jqXHR, ajaxOptions) {
// try to parse response
var data = JSON.parse(jqXHR.responseText || '{}');
// check if the ajax request is for our form
if ( == form_id) {
andrei-tofan / leadbi_native_form.js
Last active May 5, 2017
LeadBI Native Form Integration
View leadbi_native_form.js
var native_formid = '3638a022-2823-4541-b31c-1856f6a72933';
// get form instance
window.$leadbi_forms.getForm(native_formid, function (err, form) {
// form data
var data = {
first_name: 'test', // optional
last_name: 'test', // optional