Skip to content

Instantly share code, notes, and snippets.

View lukaskollmer's full-sized avatar
🧚‍♂️
frolicking

Lukas Kollmer lukaskollmer

🧚‍♂️
frolicking
View GitHub Profile
@lukaskollmer
lukaskollmer / CheckAppleStock.py
Last active January 2, 2017 14:56 — forked from omarshahine/CheckAppleStock
Checks Apple inventory for availability of any Apple SKU. In this example, AirPods
# If you don't have the requests module, you can download by typing:
#
# sudo easy_install -U requests`
#
# into the terminal on macOS
#
# You can change the partnum below with any Apple SKU
#
import urllib
@lukaskollmer
lukaskollmer / .gitignore
Created January 6, 2017 14:36 — forked from TooTallNate/.gitignore
low-level objc runtime apis
*
!*.m
!Makefile
@lukaskollmer
lukaskollmer / LKSwitch.swift
Created January 20, 2017 19:41
Call swift init and omit parentheses because last (and only) argument is a closure
//: Playground - noun: a place where people can play
import UIKit
class LKSwitch : UISwitch {
let action: (UISwitch) -> Void
init(action: @escaping (UISwitch) -> Void) {
self.action = action
super.init(frame: .zero)
@lukaskollmer
lukaskollmer / customUI1.js
Last active January 28, 2017 18:07
Scripter ui.View example
const ui = require("ui");
class MyView extends ui.View {
constructor() {
super()
//
@lukaskollmer
lukaskollmer / lua_map.c
Created February 7, 2017 21:54 — forked from randrews/lua_map.c
Example of embedding Lua in C
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdlib.h>
int map_create(lua_State *lua);
int map_slice(lua_State *lua);
int main(int argc, char **argv){
lua_State *lua = lua_open();
@lukaskollmer
lukaskollmer / ui.View.js
Created February 11, 2017 19:08
Scripter's ui.View code
const objc = require('objc');
const Color = require("./color.js");
const ui = require("../index.js");
const UIView = objc("UIView");
const UIViewController = objc("UIViewController");
const LKJSViewController = objc("LKJSViewController");
const UINavigationController = objc("UINavigationController");
const UIApplication = objc("UIApplication");
@lukaskollmer
lukaskollmer / mapView.js
Created February 18, 2017 13:56
Scripter Map View example
const ui = require("ui");
const mapkit = require("mapkit");
const location = require("location");
let view = new ui.View();
let mapView = new mapkit.MapView();
mapView.backgroundColor = new ui.Color("red");
mapView.showsUserLocation = true;
mapView.mapType = mapkit.MapType.hybridFlyover;
@lukaskollmer
lukaskollmer / weird.js
Created April 8, 2017 19:44
Weird JS behavior
// #1
Number.prototype.add_1 = (n) => {
return this + n;
}
// #2
Object.defineProperty(Number.prototype, 'add_2', {
get: () => {
return function(n) {
return this + n;
@lukaskollmer
lukaskollmer / fib.c
Last active April 9, 2017 16:03
Fibonacci in C
// compile with `clang fib.c -o fib`
#include <stdio.h>
int main() {
int x = 0;
int y = 1;
int z = 0;
do {
@lukaskollmer
lukaskollmer / fib-disassembled
Last active April 9, 2017 16:03
Disassembled Fibonacci
// `otool -tv fib`
fib:
(__TEXT,__text) section
_main:
0000000100000f20 pushq %rbp
0000000100000f21 movq %rsp, %rbp
0000000100000f24 subq $0x20, %rsp
0000000100000f28 movl $0x0, -0x4(%rbp)
0000000100000f2f movl $0x0, -0x8(%rbp)