Skip to content

Instantly share code, notes, and snippets.

@robertjpayne
robertjpayne / NSManagedObjectArchiving.h
Created October 29, 2011 10:28
NSManagedObject Archiving and Unarchiving
#import <Foundation/Foundation.h>
@interface NSManagedObjectArchiver : NSObject
/*
* Takes a NSManagedObject and converts it to a NSData archive - it traverses all relationships ( including circular ) and archives it
*/
+ (NSData *)archivedDataWithRootObject:(NSManagedObject *)pObject;
@end
@d-ronnqvist
d-ronnqvist / VideoView.m
Created November 8, 2013 08:55
This is the source code behind the Mac Video Wall that I was trying to port to iOS in [this Stack Overflow question](http://stackoverflow.com/questions/19065816/ios-alternative-to-qtmovielayer-that-has-non-nil-contents)
//
// VideoView.m
// MacVideoWall
//
// Created by David Rönnqvist on 9/28/13.
// This is the source code behind the Mac Video Wall that I was trying to port to iOS in [this Stack Overflow question](http://stackoverflow.com/questions/19065816/ios-alternative-to-qtmovielayer-that-has-non-nil-contents)
//
#import "VideoView.h"
@andymatuschak
andymatuschak / CollectionViewDataSource.swift
Last active February 12, 2021 09:44
Type-safe value-oriented collection view data source
//
// CollectionViewDataSource.swift
// Khan Academy
//
// Created by Andy Matuschak on 10/14/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
@drewmccormack
drewmccormack / MCURLExtensions.m
Created July 14, 2011 13:05
NSURL category method to get the UTI of a file
@implementation NSURL (MCExtensions)
-(NSString *)UTI
{
FSRef fileRef;
Boolean isDirectory;
NSString *utiString = nil;
if ( !self.isFileURL ) return nil;
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@amboar
amboar / README.md
Last active June 8, 2022 08:39
String Clustering Performance

String Clustering with Python (and C)

I became interested in string clustering through developing fpos, a set of Python scripts for graphing my spending habits. In a clear failure of research I missed the existance of libraries like:

@adamkl
adamkl / regen-domain-types.js
Last active September 28, 2022 15:04
Generating typescript definitions from .graphql files using apollo-codegen and graphql-code-generator
const { introspectSchema } = require("apollo-codegen");
const { executeWithOptions } = require("graphql-code-generator/dist/cli");
const fs = require("fs");
const path = require("path");
const graphqlPath = "./src/graphql/";
const schemaInput = "./src/graphql/temp.graphql";
const jsonOutput = "./src/graphql/temp.json";
const dtsOutput = "./src/graphql/domain.d.ts";
@samwize
samwize / mocha-guide-to-testing.js
Created February 8, 2014 05:53
Explain Mocha's testing framework - describe(), it() and before()/etc hooks
// # Mocha Guide to Testing
// Objective is to explain describe(), it(), and before()/etc hooks
// 1. `describe()` is merely for grouping, which you can nest as deep
// 2. `it()` is a test case
// 3. `before()`, `beforeEach()`, `after()`, `afterEach()` are hooks to run
// before/after first/each it() or describe().
//
// Which means, `before()` is run before first it()/describe()
@nicferrier
nicferrier / gist:2277987
Created April 1, 2012 19:34
Clone a git repo if it does not exist, or pull into it if it does exist
#!/bin/sh
REPOSRC=$1
LOCALREPO=$2
# We do it this way so that we can abstract if from just git later on
LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]
then
@jayj
jayj / flexbox.less
Last active November 20, 2023 04:51
CSS3 Flexbox - LESS Mixins
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox