Skip to content

Instantly share code, notes, and snippets.

View akaraatanasov's full-sized avatar

Alexander Karaatanasov akaraatanasov

  • NewsUK
  • Sofia
View GitHub Profile
@apple-avadhesh
apple-avadhesh / iOSActionCallbacks.swift
Created September 21, 2021 14:30
iOS Control Action Callbacks
// UITextField
let textField = UITextField()
textField.addAction(
UIAction { action in
let textField = action.sender as! UITextField
print(textField.text ?? "")
},
for: .editingChanged
)
@dankogai
dankogai / gist:52cd6ef645c9fc248547b79dccd8e893
Created September 22, 2018 12:25
swift 4.2 on ubuntu 18.04 quick start
$ cd ~ # home directory で作業
$ sudo apt-get install clang libicu-dev libcurl4
$ wget https://swift.org/builds/swift-4.2-release/ubuntu1804/swift-4.2-RELEASE/swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ tar xvpf swift-4.2-RELEASE-ubuntu18.04.tar.gz
$ export PATH=~/swift-4.2-RELEASE-ubuntu18.04/usr/bin:$PATH
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active September 24, 2024 21:51
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@verticalgrain
verticalgrain / app.js
Last active April 26, 2022 15:37
React Router V4 Redirect after form submission
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class ContactForm extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@amitpdev
amitpdev / adjust_gpx_to_apple_format.awk
Created September 16, 2015 17:17
Use this awk script to adjust standard GPX files downloaded from any site (bikes) into a GPX format that is supported by Xcode.
awk '
BEGIN {
buffer=""
}
{
gsub(/<\/*trk>/,"",$0)
gsub(/<\/*trkseg>/,"",$0)
gsub(/<trkpt/,"<wpt", $0)
gsub(/<\/trkpt>/,"<\/wpt>", $0)
print