Skip to content

Instantly share code, notes, and snippets.

View drkibitz's full-sized avatar
🎩
deducing

Dr. Kibitz drkibitz

🎩
deducing
View GitHub Profile
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@drkibitz
drkibitz / lftp-mirror-wordpress.sh
Last active December 20, 2015 00:39
lftp mirror wordpress in jenkins
git checkout $GIT_BRANCH
git pull --rebase origin $GIT_BRANCH
lftp -e "open mybookmark; mirror -a --verbose=1 --parallel=10 --use-pget-n=3 --delete --only-newer --exclude .git --exclude .svn --exclude ^cgi-bin/$ --exclude ^wp-content/cache/$ $WORKSPACE; quit;"
@drkibitz
drkibitz / jenkins-conditional-push-check.sh
Last active December 20, 2015 00:39
jenkins conditional to check if push is allowed
# Rebase any commits on top of anything new from remote
git pull --rebase $UPSTREAM_GIT_REMOTE $UPSTREAM_GIT_BRANCH
# get the tracking-branch name
tracking_branch=$(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD))
# creates global variables $1 and $2 based on left vs. right tracking
# inspired by @adam_spiers
set -- $(git rev-list --left-right --count $tracking_branch...HEAD)
behind=$1
@drkibitz
drkibitz / tonic-cache.php
Last active December 20, 2015 00:59
Tonic MetadataCacheInclude Example
<?php
/**
* This is example output for the Tyrell example.
* It has been reformatted for readability.
*/
return array (
'Tyrell\\Everything' => array (
'class' => '\\Tyrell\\Everything',
'namespace' => array ('Tyrell'),
'filename' => '/path/to/my-tonic-app/src/Tyrell/Everything.php',
@drkibitz
drkibitz / gist:6127432
Last active December 20, 2015 11:58
Another (more simple) pixi.js PIXI.InteractionManager Proposal Usage
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x66FF99);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(400, 300);
// Implements EventListener Interface (DOM Events Level 3)
renderer.view.addEventListener('mousedown', {
startTarget: null,
// Implement the EventListener Interface
handleEvent: function (event) {
@drkibitz
drkibitz / gist:6127080
Last active December 20, 2015 11:59
pixi.js PIXI.InteractionManager Proposal Usage
// create an new instance of a pixi stage
var stage = new PIXI.Stage(0x66FF99);
// create a renderer instance
var renderer = PIXI.autoDetectRenderer(400, 300);
// create a manager instance, passing stage and renderer.view
var manager = new PIXI.InteractionManager(stage, renderer.view);
stage
.on('click', function (event) {
console.log(event.type, event.target); // 'click', PIXI.DisplayObject {}
//I wanted a more elegant linkedlist example than the others, so purely for academic purposes I created one.
var LinkedList = function(e){
var that = {}, first, last;
that.push = function(value){
var node = new Node(value);
if(first == null){
first = last = node;
@drkibitz
drkibitz / grunt-shell.js
Last active December 24, 2015 02:39
Run shell command as grunt task, like `grunt $:/etc:ls:-laG`, or `grunt $::npm:pack`. Use it with `grunt.task.run('$:blah');`. $:opt_chdir_value:cmd_name:arg1:arg2
module.exports = function(grunt) {
'use strict';
var path = require('path');
var spawn = require('child_process').spawn;
grunt.registerTask('$', 'Run command in the form $::cmd:arg1:arg2, or $:/blah:cmd:arg.', function() {
var done = this.async();
var args = Array.prototype.slice.call(arguments);
var cwd = process.cwd();
@drkibitz
drkibitz / build-openfl-samples.sh
Created January 23, 2014 05:39
Bash script to build all openfl-samples
## Needed for CI environment
export NEKOPATH=""
export HAXEPATH=""
export HAXE_STD_PATH=""
DIST="/path/to/dist"
rm -fR $DIST
SAMPLES=$(lime create openfl | sed -nr 's/ - (.+)/\1/p')
for sample in $SAMPLES
@drkibitz
drkibitz / otool-ls-r
Created February 9, 2014 08:11
Recursively list paths of shared libraries required by given binary. Usage: `otool-ls-r /bin/bash`
#!/bin/bash
list=""
otool_list() {
local lib="$1"
local libs=""
if [[ "$list" == "${list/:$lib/}" ]]; then
echo "$lib"
list="$list:$lib"