This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func privateHelperFunctionThatMayOrMayNotBeSemanticallyEquivalentToTheForceUnwrapOperator<T>(_ arg: T?) -> T { | |
let oof = { fatalError("OH MY GOD it was null all along") } | |
if MemoryLayout<T?>.size == MemoryLayout<T>.size { // zero abstraction optional? | |
if withUnsafeBytes(of: arg, { $0.allSatisfy { $0 == 0 } }) { | |
oof() | |
} | |
return unsafeBitCast(arg, to: T.self) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run w/ `CXX -DX=VAL`, where VAL is the input value | |
// https://godbolt.org/z/KgRth3 | |
template <int N> | |
struct Fib { | |
enum { | |
value = Fib<N-1>::value + Fib<N-2>::value | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tracking cursor position in real-time without JavaScript | |
// Demo: https://twitter.com/davywtf/status/1124146339259002881 | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib: | |
(__TEXT,__text) section | |
_main: | |
0000000100000f30 pushq %rax | |
0000000100000f31 movq 0x8(%rsi), %rdi | |
0000000100000f35 callq 0x100000f88 ## symbol stub for: _atoi | |
0000000100000f3a movl %eax, %edi | |
0000000100000f3c callq __F3fibii | |
0000000100000f41 movl %eax, 0x4(%rsp) | |
0000000100000f45 movl 0x4(%rsp), %eax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'main' | |
source_filename = "main" | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-darwin18.5.0" | |
declare i32 @atoi(i8*) | |
define i32 @main(i32 %argc, i8** %argv) { | |
entry: | |
%0 = alloca i32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fib_it = n => { | |
let [a, b] = [0, 1]; | |
while (n-- > 0) { | |
[a, b] = [b, a + b]; | |
} | |
return a; | |
} | |
const fib_rec = n => { | |
if (n < 2) return n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ocaml | |
(* | |
gpa.ml | |
An OCaml program to calculate your TUM CS GPA | |
Made by Lukas Kollmer ([email protected]) | |
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
OCaml program to count the total amount of space freed up when running `brew cleanup` | |
Usage: | |
brew cleanup | ocaml count_homebrew_cleanup.ml | |
Author: Lukas Kollmer <[email protected]> | |
Date: 2019-02-03 | |
License: MIT | |
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
do { | |
let libobjc = dlopen("/usr/lib/libobjc.A.dylib", RTLD_LAZY)! | |
let _objc_getClass = FFIFunctionInvocation(symbol: "objc_getClass", handle: libobjc, returnType: .pointer, parameterTypes: [.pointer]) | |
var text = "NSProcessInfo".utf8CString | |
var arg: UnsafePointer<CChar>! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(x, y): | |
return (x-y, x+y) | |
def test(x, y): | |
(x_, y_) = f(x, y) | |
print(f"f({x}, {y}) = ({x_}, {y_})") | |
NewerOlder