Skip to content

Instantly share code, notes, and snippets.

View vdespa's full-sized avatar

Valentin Despa vdespa

View GitHub Profile
<?php
/**
* @copyright This is free software released into the public domain.
* @license GNU General Public License version 2 or later; see http://www.gnu.org/licenses/gpl-2.0.html
*
* Created based on the information found on:
*
* http://stackoverflow.com/questions/14285536/invalid-token-with-joomla-custom-component/14433783#14433783
* http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms
*
@vdespa
vdespa / Basic connection to SAP HANA from PHP
Created December 4, 2013 12:05
Basic connection to SAP HANA from PHP. This is a sample connection to a SAP HANA system. It includes a proper error messaging so if the connection will fail you should be able to get a proper error message.
<?php
/**
* Basic connection to SAP HANA from PHP
*
* This is a sample connection to a SAP HANA system. It includes a proper error messaging so if the connection will fail
* you should be able to get a proper error message.
*
* @license The MIT License (MIT)
* @author Valentin Despa <info[at]vdespa[dot]de>
* @version 1.0 / 04.12.2013
@vdespa
vdespa / h4ck4thon
Last active August 29, 2015 14:19
Mysql connect
<?php
$username = "your_name";
$password = "your_password";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL. \n" . mysql_errno($link) . ": " . mysql_error($link). "\n");
echo "Connected to MySQL<br>";
const newman = require('newman');
newman.run({
collection: require('./postman_collection.json'),
reporters: 'cli'
}).on('start', function (error, args) { // on start of run, log to console
console.log('Running a collection...');
}).on('request', function (error, execution) {
if (error) {
console.error('collection run encountered an error.');
@vdespa
vdespa / writeToDisk.js
Created April 11, 2018 10:44
Newman - Logging request and response body
const newman = require('newman');
newman.run({
collection: require('./postman_collection.json'),
reporters: 'cli'
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
// Log the request body
const newman = require('newman'),
fs = require('fs');
newman.run({
collection: require('./postman_collection.json'),
reporters: 'cli'
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
@vdespa
vdespa / random-filename.js
Created April 11, 2018 11:19
Random file name
const fs = require('fs');
const fileName = Math.random().toString(36).substring(7) + '-foo.txt';
fs.writeFile(fileName, 'bar', function (error) {
if (error) {
console.error(error);
}
});
@vdespa
vdespa / script.js
Created April 11, 2018 11:26
Write file to disk
const fs = require('fs');
fs.writeFile(`foo.txt`, 'bar', function (error) {
if (error) { 
console.error(error); 
}
});
@vdespa
vdespa / script.js
Created April 11, 2018 11:29
Running newman as a Node.js module
const newman = require('newman');
newman.run({
collection: require(‘./postman_collection.json’),
reporters: 'cli'
}, function (err) {
if (err) { throw err; }
console.log('Collection run complete!');
});
newman run "https://www.getpostman.com/collections/f36406f34fcc7d4e0502"