This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"ThisIsAUniqueID".scan(/(?:[A-Z][^\WA-Z]+|[A-Z]+(?![^\WA-Z]))/) | |
# ==> ["This", "Is", "A", "Unique", "ID"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require "ostruct" | |
require "fileutils" | |
require "pp" | |
require "rake/loaders/makefile" | |
extend FileUtils | |
Rake.application.options.instance_eval { | |
#trace = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.mvc._ | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
import play.api.Play.current | |
import play.api.libs.functional.syntax._ | |
import play.api.libs.json._ | |
import play.api.libs.json.Json.toJson | |
import play.api.libs.iteratee.{Concurrent, Iteratee} | |
import play.api.libs.concurrent.Akka |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mach/mach.h> | |
// http://stackoverflow.com/questions/8223348/ios-get-cpu-usage-from-application | |
double getCurrentCPUUsage() | |
{ | |
thread_array_t threads; | |
mach_msg_type_number_t threadCount; | |
if (task_threads(mach_task_self(), &threads, &threadCount) != KERN_SUCCESS) { | |
return -1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __sf_iOS_SFSeq_hpp_ | |
#define __sf_iOS_SFSeq_hpp_ | |
#include <memory> | |
#include <vector> | |
#include <iostream> | |
namespace sf { | |
template<typename A> class SeqBuilder; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __sf_iOS_SFRLUCache_hpp_ | |
#define __sf_iOS_SFRLUCache_hpp_ | |
#include <unordered_map> | |
#include <utility> | |
namespace sf { | |
// http://twitter.github.io/commons/apidocs/com/twitter/common/util/caching/LRUCache.html | |
template<typename KeyT, typename ValT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iconv.h> | |
static NSString *decode(const char *encoding, char *src, size_t len, double capacityRatio=2) | |
{ | |
if (len == 0) { | |
return @""; | |
} | |
auto size = size_t(len * capacityRatio); | |
auto dest = (char*) malloc(size); | |
size_t pos = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
.DS_Store | |
*.swp | |
*~.nib | |
DerivedData/ | |
build/ | |
xcuserdata | |
xcuserdata/**/* | |
*.pbxuser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <tuple> | |
namespace { | |
using std::forward; | |
using std::move; | |
using std::tuple; | |
template<size_t H, size_t ...T> struct apply_by_tuple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A trivial type just for this example | |
final class Id <A> { | |
let raw: A | |
init(_ a: A) { self.raw = a } | |
} | |
// A typeclass of the Monad | |
infix operator >>| { associativity left precedence 95 } | |
public protocol Monad { | |
typealias Elem |