Skip to content

Instantly share code, notes, and snippets.

Tom Rochette tomzx

Block or report user

Report or block tomzx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View relative-to-absolute.py
import os
import re
from argparse import ArgumentParser
argument_parser = ArgumentParser()
argument_parser.add_argument('root')
argument_parser.add_argument('file')
args = argument_parser.parse_args()
@tomzx
tomzx / CreateMissingForeignKeyMigration.php
Created May 2, 2018
CreateMissingForeignKeyMigration
View CreateMissingForeignKeyMigration.php
<?php
namespace App\Console\Commands;
use Doctrine\Common\Inflector\Inflector;
use Doctrine\DBAL\Types\IntegerType;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class CreateMissingForeignKeyMigration extends Command
View colors.php
<?php
class Colors {
private $foreground_colors = array();
private $background_colors = array();
public function __construct() {
// Set up shell colors
$this->foreground_colors['black'] = '0;30';
$this->foreground_colors['dark_gray'] = '1;30';
@tomzx
tomzx / bootstrap.sh
Created Dec 4, 2016 — forked from keo/bootstrap.sh
Setup encrypted partition for Docker containers
View bootstrap.sh
#!/bin/sh
# Setup encrypted disk image
# For Ubuntu 14.04 LTS
CRYPTFS_ROOT=/cryptfs
apt-get update
apt-get -y upgrade
apt-get -y install cryptsetup
View gkm.js
'use strict';
// TODO: Verify if we're getting loaded from multiples location and prevent creating new child processes?
var EventEmitter2 = require('eventemitter2').EventEmitter2;
var path = require('path');
var spawn = require('child_process').spawn;
var events = new EventEmitter2({wildcard: true});
var javaPath = '';
View xmlToArray.php
<?php
function xmlToArray($xml, $options = array()) {
$defaults = array(
'namespaceSeparator' => ':',//you may want this to be something other than a colon
'attributePrefix' => '@', //to distinguish between attributes and nodes with the same name
'alwaysArray' => array(), //array of xml tag names which should always become arrays
'autoArray' => true, //only create arrays for tags which appear more than once
'textContent' => '$', //key used for the text content of elements
'autoText' => true, //skip textContent key if node has no attributes or child nodes
@tomzx
tomzx / xml2js.php
Created Feb 15, 2016
PHP xml2js (attributes to $, nodeValue to _)
View xml2js.php
<?php
function xml2js($xmlnode)
{
$root = func_num_args() <= 1;
$jsnode = [];
if ($root) {
$nodename = $xmlnode->getName();
$jsnode[$nodename] = xml2js($xmlnode, true);
@tomzx
tomzx / measure.php
Last active Jan 21, 2016
Shorten melody-like script to install composer packages for a script
View measure.php
<?php
$packages = [
// Your packages here
'tomzx/file-tracker: ~0.1@dev',
];
$commands = [
['require', 'packages' => $packages, '--no-update' => true],
['install'],
@tomzx
tomzx / melody-bootstrapper.php
Last active Jan 21, 2016
Melody bootstrapper
View melody-bootstrapper.php
<?php
<<<CONFIG
packages:
- "your/dependencies: 1.0"
CONFIG;
if ( ! file_exists('composer.phar')) {
file_put_contents('composer.phar', fopen('https://getcomposer.org/composer.phar', 'r'));
}
View gh,js
Statistical profiling result from null, (1219 ticks, 0 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
834 68.4% /lib/x86_64-linux-gnu/libc-2.19.so
268 22.0% /usr/local/bin/node
96 7.9% [vdso]
18 1.5% /lib/x86_64-linux-gnu/libpthread-2.19.so
1 0.1% /lib/x86_64-linux-gnu/ld-2.19.so
You can’t perform that action at this time.