Skip to content

Instantly share code, notes, and snippets.

@tomzx
tomzx / model_config.proto
Created June 13, 2023 04:59
Create TF serving configuration in python
syntax = "proto3";
message ModelServerConfig {
ModelConfigList model_config_list = 1;
}
message ModelConfigList {
repeated ModelConfig config = 1;
}
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 20:10
CreateMissingForeignKeyMigration
<?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
@tomzx
tomzx / colors.php
Created December 14, 2016 23:03
PHP colors
<?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 December 4, 2016 00:28 — forked from keo/bootstrap.sh
Setup encrypted partition for Docker containers
#!/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
@tomzx
tomzx / gkm.js
Created July 24, 2016 03:15 — forked from sklink/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 = '';
<?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 February 15, 2016 04:02
PHP xml2js (attributes to $, nodeValue to _)
<?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 January 21, 2016 23:51
Shorten melody-like script to install composer packages for a script
<?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 January 21, 2016 01:45
Melody bootstrapper
<?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'));
}