Skip to content

Instantly share code, notes, and snippets.

Avatar

Benedikt Terhechte terhechte

View GitHub Profile
View gist:d21c75d594853a376f118a7cab5d10f3
# cat usr/share/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "Silead GSLx680 Touchscreen"
#Option "MinX" "2583"
#Option "MaxX" "65478"
#Option "MinY" "683"
#Option "MaxY" "65876"
Option "SwapXY" "0" # unless it was already set to 1
Option "InvertX" "0" # unless it was already set
@terhechte
terhechte / gist:f3d54ff9f7f1c47af2643ded54855ff2
Last active Jan 4, 2020
Table With Paragraph GitHub Flavourted Markdown Example
View gist:f3d54ff9f7f1c47af2643ded54855ff2

Hello

e lines ab d
second ene b x
second ene b x
thirrd ene
@terhechte
terhechte / wwdc2007videos.md
Last active Jul 27, 2019
WWDC 2007 Video Listing
View wwdc2007videos.md

WWDC 2007 Video Listing

Content and Media

  • 1-01 Session 601 - Improving Your Video With Professional Preprocessing.mov
  • 1-02 Session 602 - The Encoding Process In Depth.mov
  • 1-03 Session 603 - Delivering Your Media.mov
  • 1-04 Session 604 - Iterative Cocoa and Web Application Design.mov
  • 1-05 Session 605 - Understanding Web Accessibility for Building Better Websites.mov
  • 1-06 Session 606 - Motion Graphics Design Using Quartz Composer.mov
  • 1-07 Session 607 - Development Methods for WebKit AJAX Applications.mov
@terhechte
terhechte / count_loc.py
Created Jul 9, 2019
Unobtrusive Project Language Distribution
View count_loc.py
# Usage:
# python ./count_loc.py [code-repository-folder]
# example:
# python ./count_loc.py ~/Development/our_code/
# Will count the number of files as well as the total lines
# of code in your project for different types (cpp, m, h, swift)
# and print out a json blob with the answers.
import os, sys, json
@terhechte
terhechte / pattern-examples.swift
Created Aug 22, 2015
Swift pattern examples for the swift, for, and guard keywords
View pattern-examples.swift
import Foundation
// 1. Wildcard Pattern
func wildcard(a: String?) -> Bool {
guard case _? = a else { return false }
for case _? in [a] {
return true
}
@terhechte
terhechte / benchmark.swift
Created Oct 12, 2018
Swift implementation of benchmark
View benchmark.swift
import Cocoa
func resize(image: [Int], width: Int, scale: Int) -> [Int] {
var result = [Int]()
result.reserveCapacity(image.count / scale)
for i in stride(from: 0, to: image.count, by: width) {
for i2 in stride(from: i, to: (i + width), by: scale) {
var sum = 0
for i3 in i2..<(i2 + scale) {
sum += image[i3]
@terhechte
terhechte / gist:1b7a4b1c4bc1eaa5826014379ad79c4c
Created Oct 12, 2018
C Implementation of benchmark test
View gist:1b7a4b1c4bc1eaa5826014379ad79c4c
#include <stdlib.h>
#include <stdio.h>
// We're using int64_t as `usize` and `Int` in Rust / Swift also have 8byte
int64_t* resize_image(int64_t* image, int64_t size, int64_t width, int64_t scale, int64_t* rsize) {
int64_t *result = malloc(sizeof(int64_t) * (size / scale));
int64_t pos = 0;
for (int64_t i=0; i<size; i+=width) {
for (int64_t i2=i; i2<(i + width); i2+=scale) {
View swift_process_env_example.swift
func runCocoaPods() {
DispatchQueue.global(qos: .userInitiated).async {
let process = Process()
// The trick is launching a proper login shell that hosts the task in question
// so that the environment is being initialized correctly
// `-l` forces a login shell
// `-c` tells bash to run a specific command automatically
process.launchPath = "/bin/bash"
process.currentDirectoryPath = "/Users/terhechte/Dev/tmp/testRunCocoaPods"
process.arguments = [
@terhechte
terhechte / slow_kvo_dictionary_example1.m
Created Dec 7, 2011
Example 1 of slow and fast NSDictionary access
View slow_kvo_dictionary_example1.m
//
// slow_kvo_dictionary_example.m
//
// Created by Benedikt Terhechte on 07.12.11.
// appventure.me
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
You can’t perform that action at this time.