Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# based on: https://gist.github.com/ihor/3829571/raw/911dc06391ab7fa4e7ac152594ff2bb23ae40869/supervisor
DAEMON=/usr/local/bin/supervisord
OPTS=''
#OPTS='-c /usr/local/etc/supervisor/supervisord.conf'
NAME=supervisor
DESC=supervisor
PID_FILE='/tmp/supervisord.pid'
@bastman
bastman / pcntl_example.php
Created July 4, 2013 06:28
example snippet for php pcntl extension
<?php
declare(ticks = 300);
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
function signal_handler($signal) {
var_dump(array('signal'=>$signal));
@bastman
bastman / execAndLog.sh
Created July 23, 2013 08:02
execute, log and echo
#!/bin/bash
execAndLog ()
{
local logFile=./logfile_$( date +%d%m%y%H%M).txt
if [ $1 == 'cd' ]
then
echo "cd $2 ..." 2>&1 | tee -a $logFile
cd $2
echo " --> you are here: $(pwd)" 2>&1 | tee -a $logFile
@bastman
bastman / ini2json.php
Created October 8, 2013 16:23
convert ini file to json file. quick-n-dirty coded, works well :)
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
/**
* @param $errno
* @param $errstr
* @param $errfile
* @param $errline
* @throws ErrorException
@bastman
bastman / build.properties
Created October 8, 2013 16:29
phing example tasks
project.environment.name=local
project.name=${phing.project.name}
dir.build_xml=${project.basedir}
project.host.default=${project.environment.name}.${project.name}.mydomain.com
dir.project=${dir.build_xml}/../../..
CrowdparkRpc = {
invokeRpc: function (httpMethod, url, method, params, baseParams, callback) {
var method = '' + method;
if (!params) {
var params = [];
}
var rpc = {
method: method,
params: params
@bastman
bastman / CrowdparkJsonRpcApiClientProvider.js
Created June 23, 2014 07:27
angularjs: json-rpc - provider - a very basic example
'use strict';
angular.module('CrowdparkJsonRpc').provider(
'CrowdparkJsonRpcApiClient',
function (){
@bastman
bastman / createSqlInsertIntoTableOnDuplicateKeyUpdate
Created July 8, 2014 16:12
Quick n dirty template to generate simple sql query: INSERT INTO TABLE ON DUPLICATE KEY UPDATE ...
/**
* @param string $table
* @param array $rowInsert
* @param array $rowUpdate
* @return array
*/
function createSqlInsertIntoTableOnDuplicateKeyUpdate($table, $rowInsert, $rowUpdate)
{
$insertColumnTokens = array();
$insertValueTokens = array();
@bastman
bastman / 0_reuse_code.js
Created August 7, 2014 08:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bastman
bastman / ClientFactory
Created April 15, 2015 13:31
ClientFactory - Generics Example. Create Instances using Reflection
public class ClientFactory {
public static <T extends Client> T createClient(Class<T> clientClass, String host, Integer port)
{
try {
Constructor<T> constructor = clientClass.getConstructor(
String.class, Integer.class
);
T client = constructor.newInstance(