Skip to content

Instantly share code, notes, and snippets.

View sobstel's full-sized avatar

sobstel

  • 22:57 (UTC +02:00)
View GitHub Profile
@sobstel
sobstel / service.thor.rb
Created February 8, 2012 19:30
Service task for Mac OS X
class Service < Thor
desc "apache", "Apache"
def apache(action)
service action do |s|
s.down { %x[sudo apachectl stop] }
s.up { %x[sudo apachectl start] }
end
end
desc "memcached", "Memcached"
@sobstel
sobstel / russian_roulette.sh
Created March 8, 2012 12:45
Russian roulette ;-)
#!/bin/sh
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live”
@sobstel
sobstel / DoctrineCacheAdapter.php
Created May 13, 2012 07:59
Doctrine\Common\Cache\CacheProvider performance-aware adapter
<?php
class DoctrineCacheAdapter extends \Doctrine\Common\Cache\CacheProvider {
private $cache_driver;
public function __construct($cache_driver) {
$this->cache_driver = $cache_driver;
}
public function getCacheDriver() {
@sobstel
sobstel / apache24.rb
Created October 13, 2012 23:30
homebrew formula for apache2 (2.4.3)
require 'fileutils'
require 'formula'
class Apache24 < Formula
homepage 'https://httpd.apache.org/'
url 'https://www.apache.org/dist/httpd/httpd-2.4.3.tar.gz'
sha1 '845ca56816b0352c7759b6b8f47bd012c0864efd'
version '2.4.3'
skip_clean ['bin', 'sbin']
@sobstel
sobstel / local.httpdfwd.plist
Last active October 15, 2015 12:01
OS X: forward port 80 to 8080
<!--
sudo vim /Library/LaunchDaemons/local.httpdfwd.plist
sudo launchctl load -Fw /Library/LaunchDaemons/local.httpdfwd.plist
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
@sobstel
sobstel / td-agent.conf
Last active November 17, 2015 07:47
Forwarding fluentd internal tag to loggly automatically
#
# install https://github.com/tagomoris/fluent-plugin-forest
#
# test
<source>
type tail
format /^(?<log>.*)$/
tag test
path /tmp/test.log
@sobstel
sobstel / macos_remove_multiple_items_from_open_with.sh
Created April 28, 2013 16:35
Remove multiple items in the Mac OSX (Lion) ‘Open With’
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
@sobstel
sobstel / LibratoClient.php
Created October 3, 2013 16:59
Simple Librato client for PHP
<?php
class LibratoClient
{
protected $user;
protected $token;
protected $metrics;
public function __construct($user, $token)
@sobstel
sobstel / index.html
Created November 23, 2013 16:19
Centered block element with unknown width
<div id="container">
<div id="element">
centered content
</div>
</div>
@sobstel
sobstel / convert_csv_to_sql.php
Created June 24, 2014 14:57
Convert CSV to SQL INSERT statements
<?php
$file = $argv[1];
$table = $argv[2];
$ls = file($file);
$out = "";
foreach ($ls as $l) {
$d = str_getcsv(trim($l));