Skip to content

Instantly share code, notes, and snippets.

@kmcallister
kmcallister / MOVED.md
Last active August 29, 2015 14:07
151-byte static binary for x86-64 Linux, all code in Rust
@Sorix
Sorix / FetchedResultsDataSource.swift
Last active September 8, 2022 12:29
UITableViewDataSource boilerplate with NSFetchedResultsController
import UIKit
import CoreData
public protocol FetchedResultsDelegate {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: AnyObject) -> UITableViewCell
}
public class FetchedResultsDataSource: NSObject, UITableViewDataSource, NSFetchedResultsControllerDelegate {
public weak var tableView: UITableView?
@mombrea
mombrea / iOS-UploadImage.h
Created January 17, 2014 01:49
example of a multi-part form post in objective-c
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"REST URL PATH"]];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setHTTPShouldHandleCookies:NO];
[request setTimeoutInterval:60];
[request setHTTPMethod:@"POST"];
NSString *boundary = @"unique-consistent-string";
@asmaloney
asmaloney / Packaging_Example.sh
Last active September 14, 2023 14:45
This is an example of script to package up and create a DMG for a Mac OS X app. Details may be found here: http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
#!/bin/bash
# by Andy Maloney
# http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
# make sure we are in the correct dir when we double-click a .command file
dir=${0%/*}
if [ -d "$dir" ]; then
cd "$dir"
fi
@tomasbasham
tomasbasham / UIImage+Scale.m
Last active February 1, 2024 19:04
Scale a UIImage to any given rect keeping the aspect ratio
@implementation UIImage (scale)
/**
* Scales an image to fit within a bounds with a size governed by
* the passed size. Also keeps the aspect ratio.
*
* Switch MIN to MAX for aspect fill instead of fit.
*
* @param newSize the size of the bounds the image must fit within.
* @return a new scaled image.
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: