Skip to content

Instantly share code, notes, and snippets.

View schrodervictor's full-sized avatar
🖖
Live long and prosper.

Victor Schröder schrodervictor

🖖
Live long and prosper.
View GitHub Profile
var runner = require('child_process');
runner.exec(
'php -r \'include("settings.php"); print json_encode($databases);\'',
function (err, stdout, stderr) {
var connection = JSON.parse(stdout).default.default;
console.log(connection.database);
// result botdb
}

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this->anything()
@schrodervictor
schrodervictor / vagrant.py
Last active August 29, 2015 14:22 — forked from lorin/vagrant.py
#!/usr/bin/env python
# Adapted from Mark Mandel's implementation
# https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py
import argparse
import json
import paramiko
import subprocess
import sys
@schrodervictor
schrodervictor / node_debian_init.sh
Last active September 6, 2015 16:02 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@schrodervictor
schrodervictor / boot.js
Last active September 6, 2015 16:18 — forked from jdx/boot.js
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@schrodervictor
schrodervictor / node-and-npm-in-30-seconds.sh
Last active September 7, 2015 06:18 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@schrodervictor
schrodervictor / better-nodejs-require-paths.md
Last active September 13, 2015 21:43 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@schrodervictor
schrodervictor / 00. tutorial.md
Created September 22, 2015 20:31 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler
@schrodervictor
schrodervictor / README.md
Created May 8, 2017 16:41 — forked from smoya/README.md
Get php trace -on segmentation fault- using xdebug
  • Enable the tracer on your xdebug.ini file (see the xdebug.ini file).
  • If you are gonna trace an http request, make sure your xdebug.trace_output_dir is writable by the webserver user (www-data).
  • Execute your script or your request. You can use produce_segmentation.php to test.
  • See the trace file(s) on your xdebug.trace_output_dir.
@schrodervictor
schrodervictor / product.sql
Created April 20, 2018 10:37
Product SQL (OMG Magento, really?)
SELECT
-- Attributes in the pivot table:
-- `p`.`whatever` AS `whatever`
p.entity_id AS id,
p.sku AS sku,
-- Attributes in the EAV tables:
-- IFNULL(`store_whatever`.`value`, `default_whatever`) AS `whatever`