Skip to content

Instantly share code, notes, and snippets.

View bsingr's full-sized avatar

bsingr

  • @coliquio - former Sophos, Git Tower, Inovex, 1&1
  • Lake Constance, Germany
View GitHub Profile
@bsingr
bsingr / .env
Last active August 29, 2015 14:11
arangodb development / deployment scripts
APP_NAME=example
APP_MOUNT=/example
PROD_USER=exampleuser
PROD_PASSWORD=examplesecret
PROD_ENDPOINT=tcp://example.com:8529
@bsingr
bsingr / README.md
Created October 22, 2014 09:21
10k tcp/tls connections with node.js

Generate certs, remember to use to proper CN (my.example.com)

  openssl req -x509 -newkey rsa:2048 -keyout config/key.pem -out config/cert.pem -days 365
  openssl rsa -in config/key.pem -out config/key.pem

Install the server on a host that is reachable from the client via my.example.com. E.g. edit /etc/hosts...

@bsingr
bsingr / cache.rb
Created February 20, 2014 20:25
yaml based cache
require 'yaml'
module Cocoatree
class Cache
attr_reader :path
def initialize filename, logger=nil
@do_not_update_on_fetch = false
@ignore_expiry = false
@logger = logger
@bsingr
bsingr / defines.h
Created February 12, 2014 15:54
Drawing on non-retina devices.
// https://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/graphicsdrawingoverview/graphicsdrawingoverview.html
#define ALIGN_POINT_TO_PIXEL(floatValue) ( (((NSInteger) roundf(floatValue)) % 2 == 0) ? floatValue : floatValue + 0.5f )
// Usage:
// rect.x = ALIGN_POINT_TO_PIXEL(rect.x)
@bsingr
bsingr / outline_view_dynamic_row_height.m
Created February 5, 2014 10:08
dynamic row height for outline / table views
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
NSString *text = item;
return [self sizeForText:text].height;
}
- (NSSize)sizeForText:(NSString *)text
{
CGFloat width = self.outlineView.bounds.size.width;
NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
@bsingr
bsingr / dsl_example.rb
Created December 4, 2013 09:08
ruby example dsl
class ExampleLanguage
def expect_working_tree_entry filename, status_options
puts "Testing working tree entry #{filename} with status #{status_options.values}"
end
end
class Example
attr_reader :name, :block
def initialize name, block
# make bootable .img from .iso live disk on osx
hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/kubuntu.iso)
# Note: OS X tends to put the .dmg ending on the output file automatically.”
# burn bootable .img on usb device
diskutil list
diskutil umountDisk /dev/disk2
sudo dd if=~/path/to/target.img of=/dev/disk2 bs=1m
# gem install flickraw
require 'flickraw'
CODES = '### PASTE HERE ###'
FlickRaw.api_key = CODES.split(':')[0]
FlickRaw.shared_secret = CODES.split(':')[1]
flickr.access_token = CODES.split(':')[2]
flickr.access_secret = CODES.split(':')[3]
@bsingr
bsingr / .gitconfig
Created August 20, 2013 15:14
~/.gitconfig
# increase git log chunk size to 100 lines (will also work for the git-tower.com app)
[diff]
context = 100
@bsingr
bsingr / feed.php
Created August 5, 2013 09:22
php script to proxy a feed from feedblitz including stylesheet (for browsers like chrome)
<?php
require('proxy.php');
// feed delivery service
$response = proxy_request('feeds.feedblitz.com', '/example-blog');
// rewrite stylesheet
$original_style = "feeds.feedblitz.com/feedblitz_rss.xslt";
$fake_style = "example.com/rss.xslt";