Skip to content

Instantly share code, notes, and snippets.

View k0nserv's full-sized avatar

Hugo Tunius k0nserv

View GitHub Profile
@k0nserv
k0nserv / .slate
Created September 13, 2015 20:39
# This is the default .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
config windowHintsSpread true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config windowHintsDuration 10000
@k0nserv
k0nserv / NestedEquality.swift
Last active September 2, 2015 18:45
This code makes xCode sad under xCode 7 Beta 6(7A192o)
private func nestedEquality<T>(lhs: [[T]], _ rhs: [[T]], equal: ([T], [T]) -> Bool) -> Bool {
if lhs.count != rhs.count {
return false
}
for var i = 0; i < lhs.count; i++ {
if false == equal(lhs[i], rhs[i]) {
return false
}
}
@k0nserv
k0nserv / test.cpp
Last active August 29, 2015 14:27
Reinterpret casting in Swift
uint32_t test[2] = { 0xFF28A9C9, 0xAC912F9D };
uint8_t *test2 = reinterpret_cast<uint8_t *>(test);
@k0nserv
k0nserv / fizz_buzz.rb
Created April 28, 2015 12:42
Iterative FizzBuzz
print '1'
print '2'
print 'Fizz'
print '4'
print 'Buzz'
print 'Fizz'
print '7'
print '8'
print 'Fizz'
print 'Buzz'
@k0nserv
k0nserv / app_store.rb
Last active August 29, 2015 14:18
Find your apps ranking in the app store for the apps keywords and other searchterms
require 'net/http'
require 'uri'
require 'json'
BASE_URL = 'https://itunes.apple.com/search'
BUNDLE_ID = nil
STORE_COUNTRY_CODE = 'us'
LIMIT = 200
# Set to true to try combining every keyword
@k0nserv
k0nserv / 2015.m
Last active August 29, 2015 14:12
2014 and 2015
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"YYYY";
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1419872056];
NSLog (@"%@", [dateFormatter stringFromDate:date]); // 2015
@k0nserv
k0nserv / accept
Last active August 29, 2015 14:10
Accepting invites restfully alternative
POST /teams/1829/members?invite_id=481293 HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: close
Content-Length: 18
{"user_id":214293}
@k0nserv
k0nserv / accept
Last active August 29, 2015 14:10
Accepting invites restfully
PATCH /invites/:id HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: close
Content-Length: 19
{"accepted":true}
@k0nserv
k0nserv / spotify.js
Last active December 7, 2015 11:24
Figure out how much money you have contributed to the music industry by paying for Spotify. Run the following at https://www.spotify.com/se/account/subscription/receipt/.
(function (window) {
"use strict";
var isAtTheCorrectURL = location.href.indexOf("account/subscription/receipt/") !== -1;
if (!isAtTheCorrectURL) {
console.log("Please run this script at https://www.spotify.com/us/account/subscription/receipt/ after logging in");
return;
}
var payments = document.querySelectorAll("#table-receipts > tbody > tr > td.receipt-price");
//
// HTKVOMappingStrategy.h
//
// Created by Hugo Tunius on 16/02/14.
// Copyright (c) 2014 Hugo Tunius. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HTMappingStrategy.h"