Skip to content

Instantly share code, notes, and snippets.

View n0an's full-sized avatar

Anton Novoselov n0an

View GitHub Profile
@n0an
n0an / Two simulaltors
Created May 1, 2017 19:42
Two Xcode simulaltors
cd /Applications/Xcode.app/Contents/Developer/Applications/
open -n Simulator.app/
PRESS OK IN ALERT IF THERE'S ONE
Then in top menu press Hardware - Device - iOS 10.3 - SELECT MODEL
import webbrowser, time
webbrowser.open('https://stackoverflow.com/questions/tagged/ios')
time.sleep(2)
webbrowser.open('https://stackoverflow.com/questions/tagged/swift')
@n0an
n0an / pdfFromVisio.py
Created May 17, 2017 13:34
pdf from visio
#! python3
import pyautogui, time, logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s.%(msecs)03d: %(message)s', datefmt='%H:%M:%S')
# Set these to the correct coordinates for your particular computer.
uncheckAutoOpenPDF = (139, 522)
curl --upload-file testfile https://transfer.sh/testfile
@n0an
n0an / introrx.md
Created September 16, 2017 10:04 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
Here's what I would try. First run
```
diskutil list
```
to get the name to the disk you're trying to format. The below commands assume this is "disk1", but replace "disk1" with the correct disk if it's something different.
Now unmount the disk:
```
diskutil unmountDisk force disk1
```
cd ~/Library/Android/sdk/tools/bin/
./avdmanager list avd
cd ~/Library/Android/sdk/tools/
emulator @Nexus_5X_C4S_Demo
@n0an
n0an / events.py
Created October 1, 2020 18:51 — forked from ryanquinlan/events.py
Cisco Meeting Server Events Websocket using Python websocket-client
import websocket
# Get auth token via POST to /api/v1/authTokens
# Use returned token to open a websocket connection to wss://host:port/events/v1
# Token is passed as the URL parameter authToken
try:
self.logger.info("Getting auth token ...")
api_conn = api.ApiConnection(self.address, self.username, self.password, port=self.port)
response = api_conn.doPost("authTokens", {})
@n0an
n0an / SwiftConcurrency.md
Created January 5, 2022 13:50 — forked from FWEugene/SwiftConcurrency.md
All about concurrency

Threads

Foundation offers a Thread class, internally based on pthread, that can be used to create new threads and execute closures.

// Detaches a new thread and uses the specified selector as the thread entry point.
Thread.detachNewThreadSelector(selector: Selector>, toTarget: Any, with: Any)

// Subclass
class MyThread: Thread {
@n0an
n0an / libdispatch-efficiency-tips.md
Created January 5, 2022 19:36 — forked from tclementdev/libdispatch-efficiency-tips.md
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