Skip to content

Instantly share code, notes, and snippets.

View s0enke's full-sized avatar

Soenke Ruempler s0enke

View GitHub Profile
@s0enke
s0enke / puppet_iteration.pp
Last active January 1, 2016 00:49
this is an example usage of iterators in puppet 3.4
# challenge: write an ini file from hiera input
# $cache_cluster_instances = [
# { host => 'cache-a', weight => 1 },
# { host => 'cache-b', weight => 0.5 },
# { host => 'cache-c', weight => 0.5 },
# ]
$cache_cluster_instances = hiera('cache_cluster_instances')
@s0enke
s0enke / gist:7821956
Last active December 30, 2015 11:19
as puppet is declarative and the catalogue is a graph, we can just include the realization of virtual resources anywhere in code. even at the stage where the virtual resource gets declared
# this leads to the realization of both declared resources:
# soenke♥kellerautomat:~/projects/playground (master)$ puppet apply manifests/init.pp
# virtual resource 2
# /Stage[main]/Some_module/Virtual_resource_declarer2[virtual resource 2]/Virtual_resource[virtual resource 2]/Notify[virtual resource 2]/message: defined 'message' as 'virtual resource 2'
# virtual resource 1
# /Stage[main]/Some_module/Virtual_resource_declarer1[virtual resource 1]/Virtual_resource[virtual resource 1]/Notify[virtual resource 1]/message: defined 'message' as 'virtual resource 1'
# Finished catalog run in 0.61 seconds
node default {
@s0enke
s0enke / gist:5886169
Created June 28, 2013 16:52
what is wrong with bash?
soenke♥kellerautomat:~/Private/admin-server-scripts (master)$ function ./wtf() { figlet "Y U DRUNK BASH?"; }
soenke♥kellerautomat:~/Private/admin-server-scripts (master)$ ./wtf
__ __ _ _ ____ ____ _ _ _ _ _ __ ____ _ ____ _ _ ___
\ \ / / | | | | | _ \| _ \| | | | \ | | |/ / | __ ) / \ / ___|| | | |__ \
\ V / | | | | | | | | |_) | | | | \| | ' / | _ \ / _ \ \___ \| |_| | / /
| | | |_| | | |_| | _ <| |_| | |\ | . \ | |_) / ___ \ ___) | _ ||_|
|_| \___/ |____/|_| \_\\___/|_| \_|_|\_\ |____/_/ \_\____/|_| |_|(_)
@s0enke
s0enke / gist:2035559
Created March 14, 2012 10:19
mysql tmp file creation geloet
(debian-sys-maint@localhost[root@www44:mysqld.sock]) [cms]
> SHOW SESSION STATUS like '%Tmp%';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| Created_tmp_disk_tables | 0 |
| Created_tmp_files | 369 |
| Created_tmp_tables | 2 |
+-------------------------+-------+
3 rows in set (0.00 sec)
@s0enke
s0enke / gist:1950130
Created March 1, 2012 14:25
gearman and libdrizzle connecting to percona server 5.5
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("192.168.2.133")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=3, events=POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
read(3, 0x911e70, 32768) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
read(3, "Q\0\0\0\n5.5.20-55-log\0\370&\0\0007_\\.n`x[\0"..., 32768) = 85
close(3) = 0
write(1, "ERROR _libdrizzle_query\n", 24ERROR _libdrizzle_query
) = 24
#!/bin/bash
while [ 1 ]
do
for (( i = 1 ; $i < 4 ; i++ ))
do
echo -e "Sw_on$i""user\x00\n" | nc -u -q 1 dev-steckdose01.jimdo.office 75
echo $i ON
sleep 0.5;
done
for (( i = 3 ; $i > 0 ; i-- ))
@s0enke
s0enke / gist:1397483
Created November 27, 2011 12:16
gearman client endlessloop
gearman versions:
$ dpkg -l *gearman* | grep ^ii
ii gearman-job-server 0.13-1 Job server for the Gearman distributed job queue
ii gearman-tools 0.13-1 Tools for the Gearman distributed job queue
ii libgearman-dbg 0.13-1 Debug symbols for the Gearman Client Library
ii libgearman4 0.13-1 Library providing Gearman client and worker func
sometimes my gearman php client gets into an endless loop:
@s0enke
s0enke / test.php
Created June 15, 2011 21:33
Stubbing protected methods
<?php
require 'PHPUnit/Framework/TestCase.php';
class CouchDB
{
public function doGeloet()
{
return $this->makeRequest();
}
soenke@kellerautomat:~$ time ruby -e '999999.times do puts "yeah"; end' >/dev/null
real 0m0.730s
user 0m0.710s
sys 0m0.010s
soenke@kellerautomat:~$ time ruby -e 'puts "yeah" * 999999' >/dev/null
real 0m0.014s
user 0m0.010s
sys 0m0.000s