Skip to content

Instantly share code, notes, and snippets.

View holgersindbaek's full-sized avatar

Holger Sindbaek holgersindbaek

View GitHub Profile
@holgersindbaek
holgersindbaek / uninkd_publish
Last active December 11, 2015 21:39
Something is wrong here. I keep getting the following error: field articles not an array It saves the magazine and the issue and links up the relationship there. It also links up the relationship on the first article and it saves the second article (without linking it up to the relationship). And then it crashes. What am I doing wrong here?
def publish
require 'parse-ruby-client'
Parse.init :application_id => "App_ID", :api_key => "App_Key"
@magazine = Magazine.find(params[:magazine_id])
@issue = Issue.find(params[:id])
# Checking to see whether we have a magazine already. Making a new one if we don't and grabbing the old one if we do.
current_magazine = Parse::Query.new("Magazine").value_in("title", [@magazine.title]).get
magazine = nil
if current_magazine.length == 0
@holgersindbaek
holgersindbaek / Mapping Local File
Created January 30, 2013 13:29
If I map this with only the issue mapping and leave out the article relationship, then everything is fine. If I include the article relationship, then I get the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'RKManagedObjectMappingOperationDataSource must be initialized with a managed object context.'
//Setting up objectmapping for issue
RKObjectMapping *issueMapping = [RKObjectMapping mappingForClass:[Issue class]];
[issueMapping addAttributeMappingsFromDictionary:@{
@"title": @"title",
@"description": @"description",
@"cover_url": @"cover_url",
@"published_at": @"published_at",
@"issue_number": @"issue_number"
}];
@holgersindbaek
holgersindbaek / JSON to map
Created January 30, 2013 18:22
JSON to map
{ "issue" : { "articles" : [ { "article_image_url" : "https://uninkd.s3.amazonaws.com/uploads/tiger.jpg",
"main_text" : "<p>Remember <a href=\"http://37signals.com/svn/posts/3329\">when I said we hired Chris</a> after advertising for a GMT position a few months ago? That was a bit of a fib. We were actually blown away bytwo applications during that go-round and decided to hire both of the candidates we liked. Natalie Keshlear joins us from the venerable community team at <a href=\"http://soundcloud.com/\">SoundCloud</a>. She’ll be working with us from Berlin, Germany.Natalie is originally from Southern California, but moved to Berlin about 2 years ago to work for SoundCloud. She loves it there, but decided she couldn’t pass up an opportunity to stay in a place she loved and work with we <a href=\"http://smiley.37signals.com/\">happy-makers</a>. While we were originally looking for only one more European support team member, we decided to treat Chris and Natalie like Pokémon and caught ‘em all.If y
@holgersindbaek
holgersindbaek / gist:7055188
Created October 19, 2013 12:07
Follow the Rabbit
require 'open-uri'
require 'json'
BASE_URL = "http://letsrevolutionizetesting.com/challenge.json"
@counter = 0
def follow_the_rabbit(url)
json = JSON.parse(open(url).read)
puts " "
{
"products": [
{
"title": "SENNEPFARVEDE CHINOS, VAN GILS",
"brand": "VAN GILS",
"price": "799,00 DKK",
"description": "Cool Mustard Chinos fra Van Gils. En kombination med disse fløjls chinos kan gøre selv det mest hverdagsagtige Outfit spændende. Normal pasform. Wear it always with pride and a smile. Farve: Sennepfarvet Kvalitet: Yderstof: 97% Bomuld 3% Elastan Foer: 65% Polyester 35% Bomuld",
"pictures":[
"http://marthoni.dk/images/van-gils-bukser-og-leggings-sennepfarvede-chinos-van-gils-CLYFLAND.jpg",
"http://marthoni.dk/files/product_images/11264/van-gils-bukser-og-leggings-sennepfarvede-chinos-van-gils-CLYFLAND-1.jpg",
@holgersindbaek
holgersindbaek / Rakefile
Created May 21, 2014 15:29
Rakefile for failing Game Center application
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/osx'
begin
require 'bundler'
Bundler.require
rescue LoadError
end
@holgersindbaek
holgersindbaek / console dump
Created May 21, 2014 16:15
Console dump of rake config
➜ 2048_Free git:(master) ✗ rake config
================================================================================
A new version of RubyMotion is available. Run `sudo motion update' to upgrade.
================================================================================
bubble-wrap/camera requires iOS to use.
bubble-wrap/ui requires iOS to use.
build_dir : "./build"
category : "utilities"
codesign_certificate : "Mac Developer: holger sindbæk (553BRGV25S)"
@holgersindbaek
holgersindbaek / head
Created May 31, 2014 12:23
weird head
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="IE=9" http-equiv="x-ua-compatible">
<meta content="695275890">
<meta content="http://www.hif.se/imgs/hif_emblem.png">
<title>HELSINGBORGS IF - www.hif.se</title><!--[if IE 8]>
<link href="css/ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link href="css/formatStylesheet.css" media="all" rel="stylesheet" type=
"text/css">
/* Start General Class */
body {
color: #909090;
}
body.boxed-layout .page {
background-color: #ffffff;
}
a {
color: #909090;
}
var $button = $("<div id='source-button' class='btn btn-primary btn-xs'>&lt; &gt;</div>").click(function() {
var html = $(this).parent().html();
html = cleanSource(html);
$("#source-modal pre").text(html);
$("#source-modal").modal();
});
$('[data-toggle="popover"]').popover();
$('[data-toggle="tooltip"]').tooltip();