Skip to content

Instantly share code, notes, and snippets.

View patsch's full-sized avatar

Patrick Dockhorn patsch

View GitHub Profile
aNfjYFoYFFXHAv6LHh4vYNVrP
@patsch
patsch / apphub.rake
Created January 18, 2022 04:32
Apipie : Combine static ApiPie JSON and Swagger JSON to inject details for array of objects
# -*- coding: utf-8 -*-
require 'fileutils'
# expects #{Rails.root}/doc/apidoc/schema_apipie.json and #{Rails.root}/doc/apidoc/schema_swagger_json.json
# produces: #{Rails.root}/doc/apidoc/schema_swagger_json_nested.json
# add in your lib/tasks folder and run with
# rake apphub:openapi2
namespace :apphub do
# Welcome to Sonic Pi v3.1
# A german children song and the very first thing any german child attempts when learning to play the piano
use_bpm 180
[ :c, :d, :e, :f, :g ].each do |key|
play key
sleep 1
end
@patsch
patsch / solar2013
Created January 18, 2014 22:08
Solar Panels
In May 2013 we installed 12 Solar Panels on the roof; 6 north facing, 6 east facing. Because we have lots of trees providing shade which affects the ability of solar panels to generate power we went with Micro Inverters, so for every 2 panels there is a separate inverter converting the sunshine into amps. I had a look at our last power bill and the effect of the solar is clearly visible - while the off peak consumption is almost unchanged from a year ago (because let's face it - not much sun happening between 11:30pm and 6am), the peak consumption is halved, which not only reduces the need for more greenhouse emissions from power plants, but also saved us over $250. On top of that we also got a credit of $260 for solar contributions we made (where we produced more electricity via Solar than we actually needed). Total savings of over $500 for a quarter. Even assuming that in Winter the solar output is quite a bit less, it should only take about 4 years to get the investment in the solar equipment back. I'm not
@patsch
patsch / iOS table view cell animation
Created July 15, 2013 03:56
iOS table view cell animation
// with animation:
NSURLRequest *ur = [NSURLRequest requestWithURL:imageURL];
// to fade the image in automatically when it's loaded:
// http://stackoverflow.com/questions/13974226/afnetworking-fade-animation-on-image-while-scrolling-uitableview
[cell.imageView setImageWithURLRequest:ur placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request , NSHTTPURLResponse *response , UIImage *image ){
if (request) {
//Fade animation
@patsch
patsch / International Direct Dialling
Created November 16, 2012 03:10
NSArray with international direct dialling codes & country names to populate UITableView for country selection
// array with international direct dialling prefixes to populate table view
NSArray *idd_list = [NSArray arrayWithObjects:@"Afghanistan (+93)",@"Albania (+355)",@"Algeria (+213)",@"American Samoa (+1 684)",@"Andorra (+376)",@"Angola (+244)",@"Anguilla (+1 264)",@"Antarctica (+672)",@"Antigua and Barbuda (+1 268)",@"Argentina (+54)",@"Armenia (+374)",@"Aruba (+297)",@"Australia (+61)",@"Austria (+43)",@"Azerbaijan (+994)",@"Bahamas (+1 242)",@"Bahrain (+973)",@"Bangladesh (+880)",@"Barbados (+1 246)",@"Belarus (+375)",@"Belgium (+32)",@"Belize (+501)",@"Benin (+229)",@"Bermuda (+1 441)",@"Bhutan (+975)",@"Bolivia (+591)",@"Bosnia and Herzegovina (+387)",@"Botswana (+267)",@"Brazil (+55)",@"British Indian Ocean Territory (+)",@"British Virgin Islands (+1 284)",@"Brunei (+673)",@"Bulgaria (+359)",@"Burkina Faso (+226)",@"Burma (Myanmar) (+95)",@"Burundi (+257)",@"Cambodia (+855)",@"Cameroon (+237)",@"Canada (+1)",@"Cape Verde (+238)",@"Cayman Islands (+1 345)",@"Central African Republic (+236)",@"Chad (+235)",@"
@patsch
patsch / MountainLion-Java-Applet-Plugin.txt
Created October 24, 2012 23:47
Problems with the ATO Business Portal (or other Java Applets) & Mountain Lion's latest Java Update - this may help
After I applied the latest Apple Security Update around October 20th 2012 my Java Applets would no longer work;
in particular the ATO Business Portal which I need to submit quarterly data to the Australian Taxation Office.
When using Safari I always got a "Missing Plugin" error - even after I "Enabled Java" in the Security Preferences of Safari.
I confirmed that my Java version was up to date by running:
java -version
which gave me:
@patsch
patsch / whereis
Created October 15, 2011 07:41
Problems with the unix-whereis gem on MacOSX Lion? rename /usr/bin/whereis to /usr/bin/whereis.org and copy this file to /usr/bin instead
#!/bin/sh
# jpegoptim uses the unix-whereis gem which calls whereas
# with '-b' - Mac's whereis does not understand that
# so I fixed up whereis to ignore the '-b' parameter here
# by renaming the original 'whereis' to 'whereis.org' and
# installing this script in place of the original /usr/bin/whereis executable
# if you plan on using the jpegoptim ruby gem (which lead to this patch for me)
# you will also need to ensure that it is installed in a path that whereis looks in