Skip to content

Instantly share code, notes, and snippets.

View YarekTyshchenko's full-sized avatar

Yarek T YarekTyshchenko

View GitHub Profile

Remove dangling images:

docker images -q --filter dangling=true | xargs docker rmi

Remove stopped containers:

docker ps -q --filter status=exited | xargs docker rm -vf
@YarekTyshchenko
YarekTyshchenko / gist:b2a5b9dd42248f817037
Last active March 4, 2016 13:20
logspout docker snippet
docker rm -vf logspout
docker run -d --name logspout --restart=always --volume=/var/run/docker.sock:/tmp/docker.sock -p 8000:8000 gliderlabs/logspout:v2
# Then run in a shell:
curl http://${DOCKER_HOST:0:17}:8000/logs
# Connect to logspout log viewer
curl http://<ip_of_docker_host>:8000/logs
@YarekTyshchenko
YarekTyshchenko / hadoop.js
Created April 2, 2015 11:22
Poor man's Hadoop in Javascript
var reduce = function(k, list) {
return [k, list];
};
var map = function(yield, item) {
yield(item[0], item[1]);
};
var PoorMansHadoop = function(map, reduce, data) {
var r = data.map(function(node) {
var mapperOutput = [];
var yield = function() {
curl -XGET http://localhost:9200/test/prodtest/_search -d '
{
"query": {
"filtered": {
"filter": {
"nested": {
"path": "productsOptionValues",
"filter": {
"or": [{
"and": [{
<?php
date_default_timezone_set('Europe/London');
$xml_data = @file_get_contents("http://admin:admin@10.150.6.5:8161/admin/xml/queues.jsp");
if (!$xml_data) die('No Data');
$xml = simplexml_load_string($xml_data);
$result = $xml->xpath("//queues/queue");
foreach ($result as $queue) {
$stats = $queue->stats;
@YarekTyshchenko
YarekTyshchenko / ioping.sh
Created March 13, 2013 23:44
ioping collectd plugin
#!/bin/bash
# Collectd plugin to monitor disk IO Wait time
# Author Yarek T
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
ENDPOINT='/tmp/'
IOPING='/usr/local/bin/ioping'
while sleep "$INTERVAL"
@YarekTyshchenko
YarekTyshchenko / allowence.php
Created December 22, 2012 16:31
Hacky script to get o2's allowence stats when tethering
<?php
date_default_timezone_set('Europe/London');
$balance = @file_get_contents('http://wap.o2.co.uk/mybalance') or die('No Connection');
$result = simplexml_load_string($balance);
$output = array();
foreach($result->body->div as $div) {
$jackpot = false;
foreach($div->attributes() as $c => $k) {
if((string)$c === 'class' && (string)$k === 'm4') {
@YarekTyshchenko
YarekTyshchenko / gist:1156620
Created August 19, 2011 11:35
Developer's Nightmare
<?php
declare(ticks = 1);
function ReallyObscureFunctionName()
{
if (!rand(0,1)%2) throw new Exception();
}
register_tick_function('ReallyObscureFunctionName');
// Dome benign code
@YarekTyshchenko
YarekTyshchenko / pear_client.php
Created July 6, 2011 16:55
Failover implementation in PEAR Net_Gearman
<?php
require_once 'Net/Gearman/Client.php';
while (true) {
while (!process('reverse', 'hellp'));
echo '.';
}
$gc = null;
function process($function, $data) {