Skip to content

Instantly share code, notes, and snippets.

View CTMacUser's full-sized avatar

Daryle Walker CTMacUser

View GitHub Profile
@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()
@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
#include <boost/array.hpp>
namespace boost
{
template<typename T>
inline boost::array<T, 0>
make_array()
{
boost::array<T, 0> res;
#!/bin/sh
# FindInFile.sh
#
#
# Created by Gregory Hill on 2/28/13.
#
# Usage:
# ./FindInFile.sh <baseDir>
# e.g. ~/Desktop/Code/Pandora/dev/Pandora
// Asynchronous read
let task = NSURLSession.sharedSession().streamTaskWithHostName("chat.example.com", port: 5555)!
task.resume()
task.readDataOfMinLength(16384, maxLength:65536, timeout: 30.0) {
(data: NSData?, eof: Bool, error: NSError?) in
//
}
@hlung
hlung / CocoaAsyncSocket startTLS_without_cert.m
Last active August 22, 2017 21:38
CocoaAsyncSocket (https://github.com/robbiehanson/CocoaAsyncSocket) code for where/how to run -startTLS: method. We are connecting to server with self-signed certificate and don't include the certificate (public key .pem) in the client.
#pragma mark - GCDAsyncSocketDelegate
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port {
[self secureSocket:sock];
}
// We are connecting to server with self-signed certificate and don't include the certificate
// (public key .pem) in the client. So we skip all the cert checking. To actually check, see
// http://stackoverflow.com/questions/9874932/ssl-identity-certificate-to-run-an-https-server-on-ios
- (void)secureSocket:(GCDAsyncSocket *)sock {
// It has been changed in CocoaAsyncSocket v7.4, some old option keys are now unavailable and will throw exception.
// Use GCDAsyncSocketManuallyEvaluateTrust and evaluate in -socket:didReceiveTrust: delegate instead.
@mikezs
mikezs / BoyerMoore.swift
Created November 24, 2015 13:53
Proper Boyer-Moore string searching in Swift 2.0
/**
* Implemention from here: http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140
*/
extension String {
private func preBmBc(forString x: String) -> [Character: Int] {
let m = x.characters.count
var bmBc = [Character: Int](/*count: alphabetSize, repeatedValue: m*/)
for i in 0...m - 2 {
@jerrykrinock
jerrykrinock / SSYShipProduct.pl
Last active July 4, 2018 21:49
This script is for shipping OS X apps outside the Mac App Store. It will run you through a comprehensive quality-control checklist, supports alpha, beta and production channels, builds the product (or re-ships a previous build to a different channel), codesigns all components with Developer ID per Apple TN2206, builds the Help Book from Markdown…
#!/usr/bin/perl
=com
PURPOSE
This script will
Force you through a comprehensive quality-control checklist
Run Deploymate
Get the latest version number by reading it from product's Info.plist