Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
<?php
/**
* Converts UTF-8 to XML-safe HTML entities: Изложение => &#1048;&#1079;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1077;
*/
function xmlencode($string) {
$string = (string) $string;
// Replace < and ' and & etc.
$string = htmlspecialchars($string, ENT_XML1 | ENT_QUOTES);
javascript: (function(f, a) {
f = new Blob(['"Date","Description","Amount"\n', [].map.call(queryAllShadow('ing-ow-expandable-item', queryAllShadow('ing-feat-transaction-period').reverse()[0]), row => ([
row.closest('.date-item').querySelector('time').getAttribute('datetime'),
row.querySelector('h5').textContent.trim(),
row.querySelector('h5 + strong').textContent.trim().replace(',', '.').replace('−', '-'),
]).map(col => '"' + col.replace(/"/g, '""') + '"').join(',')).join('\n')], {type: 'text/plain'});
a = document.createElement('a');
a.download = 'trans.csv';
a.href = URL.createObjectURL(f);
a.click();
<?php
$utcStart = microtime(true);
// Last modified timestamp
defined('TIMESTAMP') or define('TIMESTAMP', 'D d-M-Y H:i');
// Permissions
defined('ENABLE_DOWNLOAD') or define('ENABLE_DOWNLOAD', false);
defined('ENABLE_SOURCE') or define('ENABLE_SOURCE', false);
@rudiedirkx
rudiedirkx / SendUserInvitationJob.php
Created August 31, 2016 17:50
User invitation jobs
<?php
class SendUserInvitationJob {
protected $user;
protected $tests;
function __construct(User $user, array $tests) {
$this->user = $user;
$this->tests = $tests;
}
# all at once:
vendor/bin/behat
# per feature:
find features/ -type f -name *.feature | xargs -n 1 vendor/bin/behat
@rudiedirkx
rudiedirkx / query.sql
Created May 24, 2016 21:29
SELECT ANY, multi UPDATE, multi DELETE
-- SELECT
SELECT *
FROM orders O
WHERE 5 <= ANY(SELECT amount FROM order_lines WHERE order_id = O.id);
SELECT *
FROM orders O
WHERE id IN (SELECT order_id FROM order_lines WHERE amount >= 5);
ClientController (page callback)
- Annotations
- @Get/@Post - URI
- @Middleware - auth
- AuthServiceProvider - auth definition
- UserPolicy - auth callbacks
User model (entity type)
- Shared logic
- Authenticable
script=$1
echo $script
while [ true ]; do
DT=$(date +"%Y%m%d_%H%M%S")
FILE="/tmp/keepalive-$DT.log"
echo $FILE
echo
touch $FILE
// console.log(process.argv);
var port = parseInt(process.argv[2]);
if ( !port || isNaN(port) ) {
console.log('\nPort arg must be int.\n\n');
process.exit();
}
var status = [0, 0, 0, 0, 0, 0, 0, 0];
<?php
// sendmail_path="C:\XAMPP\php\php.exe C:\WWW\mailtodisk.php \"C:\XAMPP\mailoutput\__TIME__-__RAND__-__SUBJECT__.eml\""
// sendmail_path = "/usr/bin/php /var/www/mailtodisk.php \"/var/www/mailoutput/__TIME__-__RAND__-__SUBJECT__.eml\""
// file_put_contents(__DIR__ . '/mailtodisk.log', print_r($_SERVER, 1));
// Destination folder/filename is required
$destination = @$_SERVER['argv'][1];
if (!$destination) {