Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rudiedirkx's full-sized avatar

Rudie Dirkx rudiedirkx

View GitHub Profile
@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) {
javascript:
([].forEach.call(document.scripts, function(el, p) {
var code = el.innerHTML.trim();
if ( (p = code.indexOf('q("talkPage.init",')) > -1 ) {
var json = code.slice(p + 18, -1).trim();
var talk = JSON.parse(json).talks[0];
var url = talk.nativeDownloads.high || talk.nativeDownloads.medium;
var a = document.createElement('a');
a.href = url;
a.download = url.match(/([^\/\?]+)(\?.+?)?$/)[1];
@rudiedirkx
rudiedirkx / node-socket-listener.js
Created November 15, 2015 13:02
Super simple socket listener in Node
var net = require('net');
function log(msg) {
process.stdout.write(msg.trim() + "\n", 'utf8');
}
var port = Number(process.argv[2]);
if ( !port || isNaN(port) ) {
return log('Need valid PORT number as argument.');
}
curl -X PUT -d '"Jeff"' https://cr2jl3cpyv7.firebaseio.com/users/jeff/name.json
curl -X PUT -d '"Carla"' https://cr2jl3cpyv7.firebaseio.com/users/carla/name.json
curl -X PATCH -d '{"jeff/city": "Houston", "carla/city": "Atlantis"}' https://cr2jl3cpyv7.firebaseio.com/users.json
curl -X PATCH -d '{"jeff/family": {"children": 1, "parents": 0, "siblings": 1}, "carla/family": {"children": 4, "parents": 2, "siblings": 3}}' https://cr2jl3cpyv7.firebaseio.com/users.json
curl -X PATCH -d '{"jeff/family/children": 2, "carla/family/parents": 0}' https://cr2jl3cpyv7.firebaseio.com/users.json
{
"carla":{"city":"Atlantis","family":{"children":4,"parents":0,"siblings":3},"name":"Carla"},
"jeff":{"city":"Houston","family":{"children":2,"parents":0,"siblings":1},"name":"Jeff"}
}
javascript:
performance.setResourceTimingBufferSize(5000);
performance.getEntriesByType('resource').some(function(res) {
if (res.name.slice(-5) == '-1.ts') {
console.log(res.name);
return prompt('COPY THIS URL', res.name), true;
}
});
void(0);
<?php
// SELECT a.*, c.d, (c.e = 'foo') AS ee, c.f AS ff
// FROM table1 a, table3 m
// LEFT JOIN table2 b ON a.x = c.x AND a.x <> '4'
// WHERE m.x = a.x AND a.y < 100 AND (a.z BETWEEN 1 AND 9 OR a.z = -1)
// GROUP BY (c.e = 'foo'), c.f
// HAVING MAX(m.n) > 2
// ORDER BY c.e DESC
// LIMIT 100