Skip to content

Instantly share code, notes, and snippets.

View JanC's full-sized avatar

Jan Chaloupecky JanC

  • N26
  • Berlin
View GitHub Profile
@satoshin2071
satoshin2071 / PatternMatchingPart4.swift
Created May 24, 2016 08:37
Swift Pattern Matching, Part 4: if case, guard case, for case. Shakyo practice.
/*
From http://alisoftware.github.io/swift/pattern-matching/2016/05/16/pattern-matching-4/
Shakyo practice
Pattern Matching, Part 4: if case, guard case, for case
*/
import XCPlayground
lsof -i :19421 #find out which PID zoom server is on
lsof -i :19424 #if you are running Ring Central for Meetings (rebranded zoom) check this port out
lsof -i :19433 #if you are running Chinese version of Zoom (Zhumu) check this port out
kill -9 PID #kill the server - insert PID number you will find
rm -rf ~/.zoomus/ #remove zoom server from your Mac
rm -rf /Applications/zoom.us.app/Contents/Frameworks/ZoomOpener.app/ #remove zoom server from the zoom app bundle
@dbarden
dbarden / json.py
Last active November 21, 2020 06:34
json chisel command
#!/usr/bin/python
# Example file with custom commands, located at /magical/commands/example.py
import lldb
import fbchisellldbbase as fb
def lldbcommands():
return [ JSON() ]
class JSON(fb.FBCommand):
// Version 1: Using initializer directly
struct ContentView: View {
@State var count = 0
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View {
VStack {
Text("container: \(count)")
.padding()
@jmcd
jmcd / AnnotationCoordinateUtility.m
Last active October 4, 2021 19:32
Calculate a new coordinate given a starting coordinate, bearing and distance. Objective-C
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
#import "AnnotationCoordinateUtility.h"
@implementation AnnotationCoordinateUtility {
}
+ (void)mutateCoordinatesOfClashingAnnotations:(NSArray *)annotations {
@NSExceptional
NSExceptional / AutoLayout.md
Last active December 8, 2021 06:19
The best damn AutoLayout guide I've ever seen

Edit Feb 4 5:16 PM: Skip to the bottom if you just want the article

It has been brought to my attention that rehosting someone else's content without asking them — even if you link to the original content — is not exactly polite. I did not ask the author before I rehosted his article, and while I feel I should have known better than to that, it just didn't occurr to me. It's not exactly plagarism, but it's still wrong on some level. I have reached out to him now about hosting it here publically, and if he says it's alright, I'll put it back.

You can find the original article here, on his site, and on his Medium page.

@nicklockwood
nicklockwood / Deprecated.md
Last active March 28, 2022 08:16
Writing Objective-C framework code that works on multiple OS versions AND can be compiled using multiple SDK versions without warnings can be a PITA. Here's my approach:

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro
@samwize
samwize / DynamicKey.swift
Created September 28, 2017 06:59
A CodingKey that is dynamic -- it can be any string! Encode/decode with a Dictionary of `[String : Any]` in the model.
/**
```
// Encode a model with properties of type [String : Any]
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties)
if let properties = properties {
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties)
}
```
*/
struct DynamicKey: CodingKey {
@fnordomat
fnordomat / CDWiFi (České dráhy) WiFi Internet Access
Last active November 7, 2023 16:58
Automatic negotiation of a captive portal: connect to icomera wifi in CD trains without having to jump through hoops.
# I believe this is the necessary and sufficient step to get internet access on board the Czech long distance trains (e.g. EuroCity which runs from Prague to Kiel)
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user/authenticate'
# It says "500 internal server error" but that doesn't keep it from working.
# check with this request, answer should contain "authenticated":1
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user'
# Also nice: GPS data (but seems outdated)
curl -vLA '' 'http://cdwifi.cz/portal/internal/api/x6/position'
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/