Skip to content

Instantly share code, notes, and snippets.

View vi4m's full-sized avatar
:atom:
coding

✪ vi4m Marcin Kliks vi4m

:atom:
coding
View GitHub Profile
@vi4m
vi4m / why_i_stopped_answering_questions.md
Last active July 5, 2024 12:55
Why I stopped answering half of the questions

Why I Stopped Answering Most Questions

Recently, I started rejecting general questions. General questions are often wrong. Yes, you can ask wrong questions, and it's worse than giving bad answers.

It's especially evident today with questions about AI's future, the future of jobs, or other simplistic questions. Wrong questions lead to harmful actions and consequences.

For example, people often ask, "Will AI take my job?" Answering "yes" can lead to negative outcomes. Another bad question might be, "Are immigrants bad?" While some might be, asking such questions is harmful.

So, how to ask good questions? The more you know about a topic, the better the questions you can ask. No wonder the answer to the Ultimate Question of Life, the Universe, and Everything is 42; the question itself is crucial.

#! /usr/bin/swift
//
// - This is just some AppKit boilerplate to launch a window.
//
import AppKit
@available(OSX 10.15, *)
class AppDelegate: NSObject, NSApplicationDelegate {
let window = NSWindow()
let windowDelegate = WindowDelegate()
@4np
4np / HowTo use xcconfig or plist with SPM.md
Last active August 5, 2024 11:06
How to use a .xcconfig file and a .plist with a Swift Package Manager based project.

How to use a .xcconfig file and a .plist file with SPM

Worth a read for some more context.

Create a Package.xcconfig file

Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:

/// Package.xcconfig
@chriseidhof
chriseidhof / goroutines.swift
Created February 16, 2018 12:36
goroutines.swift
import Foundation
protocol Channel: IteratorProtocol {
func send(_ value: Element?)
}
/// A blocking channel for sending values.
///
/// `send` and `receive` must run in separate separate execution contexts, otherwise you get a deadlock.
final class BlockingChannel<A>: Channel {
@swizzlr
swizzlr / profiling_swift_in_linux.md
Created November 15, 2017 19:51
Profiling Swift Apps on Linux

Profiling Swift in Linux

In order to profile memory leakage/heap growth in Swift on Linux, you need to a) run it on Linux b) use a profiling tool.

Docker and Valgrind to the rescue.

Installing Valgrind in a Linux container

We're using the official Swift image here: FROM swift:4.

@stinger
stinger / Swift3Dates.swift
Last active May 21, 2018 02:04
Swift 3: Working with dates
//: # Swift 3: Working with dates
import Foundation
let date = Date()
let myLocale = Locale(identifier: "bg_BG")
//: ### Setting an application-wide `TimeZone`
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case.
if let myTimezone = TimeZone(abbreviation: "EEST") {
print("\(myTimezone.identifier)")
@dayreiner
dayreiner / docker-1.10.0-rc1-xhyve-osx-install.md
Last active November 9, 2020 13:48
HOWTO: Docker 1.10.0-rc1 on OSX El Capitan with docker-compose 1.6.0-rc1 and docker-machine 0.6.0-rc1. Use Xhyve driver instead of virtualbox for performance.

Docker 1.10.0 RC1 with Docker Compose 0.6 and Docker Machine 1.6 and Xhyve on OSX

Updated install instructions for RC2 are available here

docker

The steps below will uninstall docker, docker-machine and docker-compose under OSX using virtualbox (via either brew or toolbox, or both), and replace them with the latest RC versions of docker, compose and machine using the Xhyve driver for better performance under OSX using Hypervisor.framework.

@chriseidhof
chriseidhof / TypedExpr.swift
Last active February 3, 2018 23:01
Typed Expressions in Swift
// Variables just contain an integer. We can have a maximum of `Int.max` variables in our program. ¯\_(ツ)_/¯
private struct Var {
static var freshVarIx = 0
let ix: Int
init() {
Var.freshVarIx+=1
ix = Var.freshVarIx
}
}
@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active July 28, 2024 00:09
Using Swift libraries in Python

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions:

@tanb
tanb / xhyve-freebsd-tutorial-1.md
Last active November 27, 2021 13:07
FreeBSD running on xhyve tutorial. (Appendix: Resize image with qemu. Create FreeBSD VM with qemu).

TL;DR

  • Create 5GB FreeBSD image.
  • Install FreeBSD on xhyve.
  • Mount host directory.

Requisites