Skip to content

Instantly share code, notes, and snippets.

View bsingr's full-sized avatar

bsingr

View GitHub Profile
@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 / 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 / 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 / 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 / .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 / client-example.js
Created December 18, 2014 18:01
hibiscus xmlrpc nodejs client example
// call the hibiscus xml rpc from nodejs
// see http://www.willuhn.de/wiki/doku.php?id=develop:xmlrpc#xml-rpc-aufrufe_im_detail
// install:
// npm install --save xmlrpc underscore
// run:
// node client-example.js
var xmlrpc = require('xmlrpc'),
var view = {
foo: null
}
var template = "lalala {{foo}} lalelu";
var html = Mustache.to_html(template, view);
// html is empty now
var view = {
foo: {id: 1},
bar: [{id: 2}]
}
var template = "lalala {{#foo}}{{id}}{{/foo}} lalelu {{#bar}}{{id}}{{/bar}}";
var html = Mustache.to_html(template, view);
// Works just like <tt>jQuery.fn.bind()</tt> with a couple noteable differences.
//
// * It binds all events to the application element
// * All events are bound within the <tt>eventNamespace()</tt>
// * Events are not actually bound until the application is started with <tt>run()</tt>
// * callbacks are evaluated within the context of a Sammy.EventContext
//
// See http://code.quirkey.com/sammy/docs/events.html for more info.
//
bind: function(name, data, callback) {
[...]
wrapped_callback = function(response) {
var new_content = response,
all_content = "";
$.each(data_array, function(i, idata) {
// extend the data object with the context
//---------------------------------------
// dpree:
// the following line eats some of my data, e.g.: {"items": myItems}
//---------------------------------------