Skip to content

Instantly share code, notes, and snippets.

View CTMacUser's full-sized avatar

Daryle Walker CTMacUser

View GitHub Profile
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@mcroydon
mcroydon / nntpd.js
Created February 2, 2011 05:45
A minimal NNTP implementation in node.js
var net = require('net');
var END = '\r\n';
var groups = ['nodejs.test'];
var articles = {
'<1@127.0.0.1>' : {body : 'An article.'},
'<2@127.0.0.1>' : {body : 'Another article.'},
};
@dabrahams
dabrahams / constexpr_demo.cpp
Created December 11, 2011 01:29
Fun with C++11 constexpr
#include <iostream>
#include <iomanip>
//
// Utilities
//
// RETURNS() is used to avoid writing boilerplate "->decltype(x) { return x; }" phrases.
//
// USAGE: auto function(<arguments>) RETURNS(<some-expression>);
//
@dabrahams
dabrahams / pi.cpp
Created December 17, 2011 19:40
More fun with constexpr
// Copyright Dave Abrahams 2011. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <iostream>
#include <iomanip>
#include <boost/math/constants/constants.hpp>
#ifndef TRACE
# define CONSTEXPR constexpr
#else
@dabrahams
dabrahams / noexcept.cpp
Created December 30, 2011 16:43
Test of where noexcept-ness is measured
#include <iostream>
#include <exception>
#include <cassert>
struct tracked
{
int id;
static int next;
tracked()
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@pyrtsa
pyrtsa / gist:2275320
Created April 1, 2012 13:27
C++11 metaprogramming
// Here are a few tricks I've used with the trunk versions of clang and libc++
// with C++11 compilation turned on. Some might be obvious, some not, but at
// least they are some kind of improvement over their C++03 counterparts.
//
// Public domain.
// =============================================================================
// 1) Using variadic class templates recursively, like in the definitions for
// "add<T...>" here:
@ogrant
ogrant / has_callable.cpp
Created April 1, 2012 15:29
C++11 Metaprogramming - Traits to check whether a function with a specific name can be called in the context defined by a signature
// Here is a traits structure I wrote to be able to determine if a function with
// a given name can be called in the context defined by a signature. This was
// originally not possible in C++03 - or at least a one solution works everywhere
// did not exist AFAIK.
//
// Olivier Grant
//
#include <iostream>
#include <iomanip>
@protocol APRemoteAddressBook <NSObject>
- (void) allPeople: (void (^)(NSArray *, NSError *)) reply;
- (void) mailingAddressesForPersonWithIdentifier: (NSString *) identifier
reply: (void (^)(NSArray *, NSError *)) reply;
- (void) emailAddressesForPersonWithIdentifier: (NSString *) identifier
reply: (void (^)(NSArray *, NSError *)) reply;
- (void) phoneNumbersForPersonWithIdentifier: (NSString *) identifier
reply: (void (^)(NSArray *, NSError *)) reply;
@end
@syzdek
syzdek / cli-nsrunloop.m
Created July 31, 2012 21:36
Creating an NSRunLoop for a command line utility.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop