Skip to content

Instantly share code, notes, and snippets.

@ahti
ahti / RustLog.playground.zip
Last active September 13, 2018 07:42
Hackish Swift clone of Rusts `log` crate
struct SlidingWindowView<C: RandomAccessCollection>: RandomAccessCollection {
enum EndBehavior {
case stop
case truncate
}
let base: C
let windowSize: Int
let stepSize: Int
let endBehavior: EndBehavior
@ahti
ahti / mp3.tcl
Last active August 9, 2018 04:57
Hex Fiend binary template to read mp3 frames, very rough and needs hexf>=2.10
# This is a binary template for inspecting mp3 files in HexFiend
# http://ridiculousfish.com/hexfiend/
#
# https://www.mp3-tech.org/programmer/frame_header.html
# http://id3.org/id3v2.3.0
set count 0
proc : {args} {lindex $args 0}
p=$(cd ../swift; pwd)
pkgname=swift-git
pkgver=$(cd $p/swift; git describe | tr - _)
pkgrel=1
pkgdesc="Swift git builds."
arch=('x86_64')
url="https://swift.org"
license=('apache')
depends=('python2' 'python2-six' 'libutil-linux' 'icu' 'libbsd' 'libedit' 'libxml2' 'sqlite' 'ncurses' 'libblocksruntime')
makedepends=()
#0 PrintStackTraceSignalHandler(void*) (/usr/bin/swift+0x3f778d4)
#1 llvm::sys::RunSignalHandlers() (/usr/bin/swift+0x3f756ec)
#2 $SignalHandler(int) (/usr/bin/swift+0x3f77a92)
#3 _restore_rt (/usr/lib/libpthread.so.0+0x11a80)
#4 generic specialization <Swift.Int, Foundation.URLSessionTask> of Swift._VariantDictionaryBuffer.ensureUniqueNativeBuffer(withBucketCount: Swift.Int) -> (reallocated: Swift.Bool, capacityChanged: Swift.Bool) (/usr/lib/swift/linux/libFoundation.so+0x6f25ab)
#5 generic specialization <Swift.Int, Foundation.URLSessionTask> of Swift._VariantDictionaryBuffer.nativeRemove(at: Swift._NativeDictionaryIndex<A, B>) -> (key: A, value: B) (/usr/lib/swift/linux/libFoundation.so+0x6f1a99)
#6 Foundation.URLSession._TaskRegistry.remove(Foundation.URLSessionTask) -> () (/usr/lib/swift/linux/libFoundation.so+0x6edf77)
#7 partial apply forwarder for closure #3 () -> () in Foundation._ProtocolClient.urlProtocolDidFinishLoading(Foundation.URLProtocol) -> () (/usr/lib/swift/linux/libFoundation.so+0x
@ahti
ahti / qalc.swift
Last active May 16, 2018 17:25
A script for an Alfred qalc workflow
#!/usr/bin/env bash
/*/../usr/bin/true
source="$0"
compiled="$0".cache
if [[ "$source" -nt "$compiled" ]]; then
swiftc "$source" -o "$compiled" || exit
fi
"$compiled" "$@"
exit
*/
// this needs to run with the `-parse-stdlib` command line option passed to swift:
// swift -parse-stdlib simd.swift
import Swift //Import swift stdlib
struct DoubleX4 {
var _v: Builtin.Vec4xFPIEEE64
subscript(_ idx: Int32) -> Double {
@_transparent
get {
struct Property<T> {
let name: String
}
extension Property {
static var someBool: Property<Bool> { return Property<Bool>(name: "bool") }
static var someString: Property<String> { return Property<String>(name: "lol") }
}
struct Foo {
diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h
index db15b2081..3e6d5df8f 100644
--- a/include/lldb/Utility/TaskPool.h
+++ b/include/lldb/Utility/TaskPool.h
@@ -33,6 +33,7 @@
#include <queue>
#include <thread>
#include <vector>
+#include <functional>
> choco install -debug -verbose -y mpv.portable
Chocolatey is running on Windows v 6.3.9600.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" install -debug -verbose -y mpv.portable
Received arguments: install -debug -verbose -y mpv.portable
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying