Skip to content

Instantly share code, notes, and snippets.

View qnoid's full-sized avatar
💭
I have been raised by women. My single mother, my grandma, my godmother.

Markos Zoulias Charatzas qnoid

💭
I have been raised by women. My single mother, my grandma, my godmother.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am qnoid on github.
  • I am qnoid (https://keybase.io/qnoid) on keybase.
  • I have a public key ASDnMYvBt96fg6Vw9BVDJpkZxLZg0PMq_k43V8xJz6EFbQo

To claim this, I am signing this object:

{
"bookResponse": {
"bookId": "b7cb191fd0a62feb983be8817bc561a2",
"locale": "en_US",
"title": "Contacts Help",
"meta": {
"productVersion": "11.0",
"platformOSVersion": "10.13",
"icon": "https://help.apple.com/assets/59D1AABE680CE2A0420B6CBB/59D1AABF680CE2A0420B6CC2/en_US/681a028e052633e3539058b41dcdb3b9.png",
"build_date": "Mon Nov 13 04:36:17 GMT 2017",
var APP_VERSION = '1.0.21';
! function e(t, n, r) {
function i(a, l) {
if (!n[a]) {
if (!t[a]) {
var s = "function" == typeof require && require;
if (!l && s) return s(a, !0);
if (o) return o(a, !0);
var c = new Error("Cannot find module '" + a + "'");
throw c.code = "MODULE_NOT_FOUND", c
*{box-sizing:border-box;margin:0;padding:0}
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
address,caption,code,figcaption,pre,th{font-size:1em;font-weight:400;font-style:normal}
fieldset,iframe,img{border:0}
caption,th{text-align:left}
table{border-collapse:collapse;border-spacing:0}
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
audio,canvas,progress,video{display:inline-block;vertical-align:baseline}
button{background:0 0;border:0;box-sizing:content-box;color:inherit;cursor:pointer;font:inherit;line-height:inherit;overflow:visible;vertical-align:inherit}
button:disabled{cursor:default}
@qnoid
qnoid / SuperclassCallsOverridableMethod.playground
Last active August 9, 2017 11:43
Swift ensures that all properties of a derived class are initialised before calling its base class. The compiler will generate a warning. Just move the statement below the assignment to remove the warning. Compared to Java, this is safe. See: http://stackoverflow.com/questions/3404301/whats-wrong-with-overridable-method-calls-in-constructors
import Cocoa
class Plane
{
init()
{
readyToTakeOff();
}
func readyToTakeOff(){
@qnoid
qnoid / Process.swift
Last active July 16, 2017 18:23
Train of thought on how to design the idea of running a series of processes, lazily created, stopping execution early on first error.
// 1
let process = Process()
process.launch()
process.waitUntilExit()
// 2.
let process = Process()
let queue = DispatchQueue()
queue.async {
guard let foo = foo else {
assertionFailure("This shouldn't happen")
return
}
@qnoid
qnoid / AppDelegate.swift
Last active June 16, 2017 19:24
This is a sample project to demonstrate how you can use a computed property to create a reusable function ("closure") that mimics a constant value. Think of it as a way to encapsulate both the data and the function it applies to.
//
// AppDelegate.swift
// Keychain
//
// Created by Markos Charatzas on 07/09/2014.
// Copyright (c) 2014 qnoid.com. All rights reserved.
//
import Cocoa
@qnoid
qnoid / gist:3926817
Created October 21, 2012 12:10
How to trace and debug an iOS crash (Part 2)

Dead end

[Having reached a dead end][7], decided to take a look at the client side in an effort to understand more about the request/response cycle.

First thing was to enable logging for the headers and body of both the [request][1] and the [response][2].

> GET /foo HTTP/1.1  
> "Accept-Encoding" = gzip;  
> "Accept-Language" = [languages];  
> Range = "foo=0-10";  

> "User-Agent" = "[App Bundle Id]/ (unknown, iPhone OS 4.3.3, iPad, Scale/1.000000)";

@qnoid
qnoid / gist:3923802
Created October 20, 2012 16:17
How to trace and debug an iOS crash (Part 1)

There has been a crash.

While preparing for an iOS release, observed a crash on an iPad (iOS 4.3.3, WiFi). The crash was fairly consistent to be considered random but once in a while, it would work as expected. On the other hand, an iPad 3 (iOS 5.1, WiFi/3G) wouldn't exhibit the same behaviour.

The crash was triggered at the completion block of an [AFHTTPRequestOperation][1] while parsing a (JSON) response with an empty body to a NSDictionary using [JSONKit][2].

This was an unexpected behaviour since an empty body response was not defined in the request/response contract.

FACTS

  1. iPad 4.3.3 WiFi