Skip to content

Instantly share code, notes, and snippets.

Avatar

Soenke Ruempler s0enke

View GitHub Profile
View gist:641015
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
@s0enke
s0enke / test.php
Created Jun 15, 2011
Stubbing protected methods
View test.php
<?php
require 'PHPUnit/Framework/TestCase.php';
class CouchDB
{
public function doGeloet()
{
return $this->makeRequest();
}
@s0enke
s0enke / gist:1397483
Created Nov 27, 2011
gearman client endlessloop
View gist:1397483
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:
View gist:1923191
#!/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:1950130
Created Mar 1, 2012
gearman and libdrizzle connecting to percona server 5.5
View gist:1950130
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
@s0enke
s0enke / gist:2035559
Created Mar 14, 2012
mysql tmp file creation geloet
View gist:2035559
(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:5886169
Created Jun 28, 2013
what is wrong with bash?
View gist:5886169
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:7821956
Last active Dec 30, 2015
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
View gist:7821956
# 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 / puppet_iteration.pp
Last active Jan 1, 2016
this is an example usage of iterators in puppet 3.4
View puppet_iteration.pp
# 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 / test.rb
Created May 16, 2014
trying to merge a `let` from included context
View test.rb
require 'rspec'
shared_context 'test' do
let(:something) {['something']}
end
describe 'something' do
include_context 'test'
let(:something) { super().merge(['another']) }