Skip to content

Instantly share code, notes, and snippets.

View Krelborn's full-sized avatar

Matthew Styles Krelborn

View GitHub Profile
@Krelborn
Krelborn / Signal.hpp
Last active September 12, 2017 17:02
Simple Signals and Slots implementation for C++11
//
// Signal.hpp
//
// Simple Signals and Slots implementation for C++11
//
#pragma once
#include <cassert>
#include <functional>
@Krelborn
Krelborn / tasks.json
Last active May 28, 2017 10:22
Running Ant based tasks in VS Code on Windows with Bash
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "C:/Windows/sysnative/bash.exe",
"isShellCommand": true,
"showOutput": "always",
"args":[
"--login",
"ant",
@Krelborn
Krelborn / Sync.swift
Created May 23, 2015 10:46
Simple way to perform an asynchronous closure synchronously. Useful for unit testing synchronous calls like NSURLSession etc.
/**
* Simple way to perform an asynchronous closure synchronously
*
* Simply use the **run** method to execute the given closure that executes something with an
* asynchronous closure and signal when its complete.
*
* Sync.run { sync in somethingWithAsyncCallback { sync.signal() } }
*/
public struct Sync {
private var semaphore: dispatch_semaphore_t
@Krelborn
Krelborn / gist:f881418592122f82c102
Created January 26, 2015 20:30
Dynamic label height with KILabel
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row < self.timeline.count)
{
NSDictionary *tweet = self.timeline[indexPath.row];
NSAttributedString *string = [TLTimelineViewController decorateLabelStringForMessage:tweet];
// Measure the string, it's height is dynamic based on content. We calculate
// a width for the string by assuming the cell will fill the width of the table
// minus some padding applied around elements.
@Krelborn
Krelborn / .gitignore
Last active August 29, 2015 14:02 — forked from octocat/.gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@Krelborn
Krelborn / FizzBuzz.playground
Created June 6, 2014 21:31
My Swift implementation of FizzBuzz
for i in 1...100
{
var isDivisibleBy3 = ((i % 3) == 0)
var isDivisibleBy5 = ((i % 5) == 0)
if isDivisibleBy3 && isDivisibleBy5
{
println("FizzBuzz")
}
else if isDivisibleBy3
@Krelborn
Krelborn / KnightRider
Created February 12, 2014 19:48
My first Arduino program
/*
Knight Rider
Strobe a set of LEDs like the Knight Rider car!
*/
// Number of LED in our array
enum { kLedCount = 8 };
// Array of pins controlling LEDs
@Krelborn
Krelborn / FizzBuzz.cpp
Created June 27, 2012 09:35
My C++ implementation of FizzBuzz. Trying to be as simple and readable as possible.
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, const char * argv[])
{
for (int i = 1; i <= 100; i++)
{
bool isDivisibleBy3 = ((i % 3) == 0);
@Krelborn
Krelborn / Hello.py
Created January 9, 2012 16:49
Testing gist with a Hello World script
# Usual Hello World script in Python.
# Hey look, this comment is longer than the code!
print "Hello World"