Skip to content

Instantly share code, notes, and snippets.

@klemenzagar91
klemenzagar91 / MulticastDelegateV2.swift
Created June 22, 2017 12:16
Multicast Delegate with hash table
class MulticastDelegate <T> {
private let delegates: NSHashTable<AnyObject> = NSHashTable.weakObjects()
func add(delegate: T) {
delegates.add(delegate as AnyObject)
}
func remove(delegate: T) {
for oneDelegate in delegates.allObjects.reversed() {
if oneDelegate === delegate as AnyObject {
@pim-borst
pim-borst / AsyncSDServer.ino
Last active June 10, 2023 03:09
Serve files from an SD-card using Me No Dev's async webserver for the ESP8266.
/*
* Example how to serve files from an SD-card using Me No Dev's async webserver for the ESP8266.
* See https://github.com/me-no-dev/ESPAsyncWebServer
*
* Basically I copied the code for serving static files from SPIFFS and modified it for the SD library.
* To resolve conflicts between SPIFFS and SD File classes I had to include the sd namespace in SD.h and SD.cpp in packages/esp8266/hardware/esp8266/2.3.0/libraries/SD/src.
* So in SD.h put "namespace sd { ... }; using namespace sd;" around everything excluding the # preprocessor directives.
* And in SD.cpp put "namespace sd { ... };" around everything excluding the # preprocessor directives.
*
* Also, don't forget to fill in your WiFi SSID and password and put an index.htm file on your SD card.
@veproza
veproza / AGPS.md
Last active July 23, 2023 04:36
Getting u-blox MAX-7C GPS to work with Assisted A-GPS

Getting u-blox MAX-7C GPS to work with Assisted A-GPS

So you got your u-blox GPS and wired it up only to look at it struggling to get a valid fix? Under less than ideal conditions, it can take a better part of half an hour. That's because unlike your smartphone GPS, it doesn't have the luxury of having downloaded all the auxiliary navigation data (almanacs and the lot) out-of-band, via fast mobile connection. Instead it relies on the satellite's signal itself, which is being transmitted to you at meager 50 bits per second (I'm not missing "kilo" there, it's three orders of magnitude slower than your 2G GPRS connection).

Luckily, the u-blox receivers are fitted with what the company calls "AssistNow" capability and it does exactly the same thing your iPhone does - feeds the GPS with pre-downloaded almanacs, speeding up the acquisition process to mere seconds.

In principle, the process looks easy enough - we just need to download the data, and then push them to the receiver. Sadly, the AssistNow documentat

@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@bradley219
bradley219 / .gitignore
Last active April 9, 2024 09:03
PID C++ implementation
.DS_Store
@CocoaBeans
CocoaBeans / config.fish
Last active October 27, 2022 21:08
Fish shell custom prompt
########################################################################################
### Fish Custom Overrides
### Creates a shell prompt in the form of:
###
### ----------------------------------------------------------------------- 11:56:05
### kevin@kross /S/L/F/C/V/A/F/L/V/A/Support >
########################################################################################
set --global fish_prompt_username_color 555555
@nzjrs
nzjrs / gdk-gstappsrc-stream.c
Created December 2, 2010 10:47
GStreamer Streaming AppSrc Example
/* gcc gdk-gstappsrc-stream.c -Wall `pkg-config --cflags --libs gstreamer-app-0.10 gdk-pixbuf-2.0` -o gdkstream */
#include <gst/gst.h>
#include <gst/app/gstappsrc.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>