Skip to content

Instantly share code, notes, and snippets.

View nylki's full-sized avatar

Tom Brewe nylki

View GitHub Profile
@drewolbrich
drewolbrich / View+WindowGeometryPreferences.swift
Last active March 20, 2024 22:19
A visionOS SwiftUI view modifier that can be used to hide a window's resize handles or to constrain a window's aspect ratio
//
// View+WindowGeometryPreferences.swift
//
// Created by Drew Olbrich on 1/30/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@wata
wata / ISOString.swift
Last active March 28, 2023 14:46
A simple ISO string parsing and converting library for Swift
public struct ISOString {
/// Parse ISO 6709 string.
/// e.g. "+34.0595-118.4460+091.541/"
/// SeeAlso: [ISO 6709](https://en.wikipedia.org/wiki/ISO_6709)
public static func parse(iso6709 text: String?) -> CLLocation? {
guard
let results = text?.capture(pattern: "([+-][0-9.]+)([+-][0-9.]+)"),
let latitude = results[safe: 1] as NSString?,
let longitude = results[safe: 2] as NSString?
else { return nil }
from math import *
# a performant solution would store a prefix sum of line lengths to
# a sidechannel and then use that to do a bsearch; on the GPU,
# you'd do a sum tree / histopyramid as a preprocessing step
def find_point(points, d):
d = d
for i in range(1, len(points)):
x0,y0 = points[i-1]
x1,y1 = points[i]
@ljaraque
ljaraque / tensorflow-gpu-ubuntu.md
Last active March 12, 2022 10:32
Install tensorflow-gpu in ubuntu

Install tensorflow-gpu1.8 in ubuntu18.04 with CUDA9.2, cuDNN7.2.1 and NVIDIA Driver 396

ljaraque@yahoo.com

Overview

This is a summary of the process I lived in order to enable my system with CUDA9.2, cuDNN7.2.1, Tensorflow1.8 and NVIDIA GEFORCE GTX860M GPU. You can just skip the steps marked with FAILED. I decided to keep them there in order to be useful for others who tried those paths too.

FAILED (Next section is successfull) Install NVIDIA driver (FAILED, THIS WILL INSTALL DRIVER 390 which is not compatible with CUDA9.2):

ubuntu-drivers devices
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@DenTelezhkin
DenTelezhkin / MeasureAppStartupTime.swift
Last active November 27, 2023 07:28
Measure iOS app startup time, in seconds, from the time user tapped an icon on the home screen (using time, when app process was created). Swift 4.
// Returns number of seconds passed between time when process was created and function was called
func measureAppStartUpTime() -> Double {
var kinfo = kinfo_proc()
var size = MemoryLayout<kinfo_proc>.stride
var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
sysctl(&mib, u_int(mib.count), &kinfo, &size, nil, 0)
let start_time = kinfo.kp_proc.p_starttime
var time : timeval = timeval(tv_sec: 0, tv_usec: 0)
gettimeofday(&time, nil)
let currentTimeMilliseconds = Double(Int64(time.tv_sec) * 1000) + Double(time.tv_usec) / 1000.0
@neingeist
neingeist / zornis pasta al limone[pasta italian via:zornem lemon vegetarian 4star].markdown
Created December 12, 2017 18:30
zornis pasta al limone[pasta italian via:zornem lemon vegetarian 4star].md

zutaten

  • 500g trockene pasta
  • 2-3 zitronen
  • olivenöl
  • pecorino oder parmesan
  • salz, pfeffer

optional:

  • petersilie
@neingeist
neingeist / rosenkohl-in-erdnusssoße.markdown
Last active December 12, 2017 18:58
rosenkohl in erdnusssoße
  • 1 netz rosenkohl
  • 1 zwiebel
  • etwas gemüsebrühe
  • (nicht probiert: zucker)
  • pfeffer

für die soße:

  • 3el erdnussbutter
  • 1-2el sojasoße
@jsantell
jsantell / web-ar-projects.md
Last active June 29, 2019 03:01
Projects for WebARonARKit and WebARonARCore

Projects for WebARonARKit and WebARonARCore

New Projects

Leave a comment to add a project you've created or found!

Browsers

@Rich-Harris
Rich-Harris / service-workers.md
Last active March 28, 2024 23:58
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.