Skip to content

Instantly share code, notes, and snippets.

@lolgear
lolgear / git_format_commits_between_tags.sh
Created February 1, 2017 11:51
Output commits between two tags with format including date and sha and message
git log --format='%ad %h %B' 'TagName'..'HEAD' | perl -ne '/^\s+$/ or print;'
/// `ObjectBinding` used as a way to create a `Binding` from a `BindableObject`. In this case the ViewModel
/// complies with `BindableObject` which is then translated into a `Binding` which is what `Toggle` is expecting
/// NOTE: Since it's a `DynamicViewProperty`, after its value is changed, the body will be updated.
class ViewModel: BindableObject {
let didChange = PassthroughSubject<ViewModel, Never>()
var isEnabled = false {
didSet {
didChange.send(self)
@iwasrobbed
iwasrobbed / gist:5528897
Last active June 5, 2020 20:34
UICollectionView w/ NSFetchedResultsController & NSBlockOperation. Idea originated from Blake Watters (https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController/issues/13)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
@gimenete
gimenete / gist:53704124583b5df3b407
Last active July 31, 2020 16:20
Animated rootViewController transition
// put this in your AppDelegate
- (void)changeRootViewController:(UIViewController*)viewController {
if (!self.window.rootViewController) {
self.window.rootViewController = viewController;
return;
}
UIView *snapShot = [self.window snapshotViewAfterScreenUpdates:YES];
[viewController.view addSubview:snapShot];
self.window.rootViewController = viewController;
@sakrist
sakrist / screenshot.mm
Last active August 28, 2020 06:21
Getting screenshot on iOS OpenGL ES
- (UIImage*) takePicture {
int s = 1;
UIScreen* screen = [UIScreen mainScreen];
if ([screen respondsToSelector:@selector(scale)]) {
s = (int) [screen scale];
}
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
@arobb
arobb / sierra-virtualbox-install.md
Last active November 24, 2020 13:15
Install macOS Sierra in VirtualBox on macOS host

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
@matsuda
matsuda / NSData+AES.h
Created February 25, 2014 07:14
Objective-C code for encrypt and decrypt by AES-128 encryption.
/**
http://mythosil.hatenablog.com/entry/20111017/1318873155
http://blog.dealforest.net/2012/03/ios-android-per-aes-crypt-connection/
*/
@interface NSData (AES)
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key;
- (NSData *)AES128DecryptedDataWithKey:(NSString *)key;
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key iv:(NSString *)iv;
@acrookston
acrookston / README.md
Last active January 26, 2022 11:05
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@jpwatts
jpwatts / xcode-git-version.sh
Created May 11, 2011 16:42
This Xcode 4 build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset