Skip to content

Instantly share code, notes, and snippets.

@bastman
bastman / Makefile
Last active March 11, 2016 10:26
makefile-execute-inline-php-example
CMD_PHP_CLI=docker run --rm -it \
-v "$(PWD)":"/src" -w "/src" \
php:7-cli
guard-%:
@if [ "${${*}}" == "" ]; then \
echo "CONFIGURATION ERROR! Environment variable $* not set"; \
echo "USAGE : $(USAGE)"; \
exit 1; \
fi
@bastman
bastman / Makefile
Last active March 8, 2016 15:06
docker-php-cli-composer
UID=$(shell id -u)
GID=$(shell id -g)
CMD_PHP_CLI=docker run --rm -it \
-e "$$PATH=$(PATH)" \
-v "$(PWD)":"$(PWD)" -w ${PWD} \
php:7-cli php
CMD_COMPOSER=docker run --rm -v $(PWD):/app -v ~/.ssh:/root/.ssh composer/composer
task :default => 'tasklist'
desc "List & Describe Tasks"
task :tasklist do
sh "rake -P"
sh "rake -T"
end
namespace :composer do
composer_phar="./composer.phar"
@bastman
bastman / GenericMapExample.java
Last active August 29, 2015 14:19
GenericMapExample - How to create a map function - using generics and lambdas
public class GenericMapExample {
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
@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(
@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 / 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 / CrowdparkJsonRpcApiClientProvider.js
Created June 23, 2014 07:27
angularjs: json-rpc - provider - a very basic example
'use strict';
angular.module('CrowdparkJsonRpc').provider(
'CrowdparkJsonRpcApiClient',
function (){
CrowdparkRpc = {
invokeRpc: function (httpMethod, url, method, params, baseParams, callback) {
var method = '' + method;
if (!params) {
var params = [];
}
var rpc = {
method: method,
params: params
@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}/../../..