Skip to content

Instantly share code, notes, and snippets.

View pouriaalmassi's full-sized avatar

Pouria Almassi pouriaalmassi

View GitHub Profile
@preble
preble / AssertUnwrap.swift
Created September 16, 2020 23:55
This is Nate's idea, something I use on every project. Sometimes you need to accommodate an optional that shouldn't be optional.
public extension Optional {
/// Stop in the debugger in debug builds if self is `.none`.
///
/// Example usage:
///
/// guard let value = maybeValue.assertUnwrap() else { return "bogus value" }
///
func assertUnwrap(_ message: @autoclosure () -> String? = nil, file: StaticString = #file, function: String = #function, line: UInt = #line) -> Wrapped? {
switch self {
@IsaacXen
IsaacXen / README.md
Last active November 3, 2024 04:19
(Almost) Every WWDC videos download links for aria2c.
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@flyfloor
flyfloor / gist:5ebc3cbeb1c89438444e9582748c175b
Created September 5, 2016 02:58
alfred use iterm2 as default terminal
-- This is v0.6 of the custom script for AlfredApp for iTerm 2.9+
-- Please see https://github.com/stuartcryan/custom-iterm-applescripts-for-alfred/
-- for the latest changes.
-- Please note, if you store the iTerm binary in any other location than the Applications Folder
-- please ensure you update the two locations below (in the format of : rather than / for folder dividers)
-- this gets around issues with AppleScript not handling things well if you have two iTerm binaries on your system... which can happen :D
on alfred_script(q)
if application "iTerm2" is running or application "iTerm" is running then
@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
@jverkoey
jverkoey / shouldAutorotate_nonintrusive.m
Last active August 29, 2015 13:57
Implementing UINavigationController/UITabBarController support for shouldAutorotate without subclassing or extending.
// Add this to your app delegate.
// Neither `UINavigationController` nor `UITabBarController` have the slightest decency to ask their
// visible view controller whether IT would like to rotate and just go on and do whatever the hell
// they please. This'll show 'em.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topViewController = window.rootViewController;
do {
// Navigate modal controllers.
@markd2
markd2 / someObject.m
Created May 23, 2013 13:44
Implementation of doSome:for:, ripe for disassembly. Look at the disassembly of main() for the calls to objc_msgSend.
#import <Foundation/Foundation.h>
// clang -g -Wall -framework Foundation -o someObject someObject.m
@interface SomeObject : NSObject
- (void) doSome: (id) stuff for: (id) reasons;
@end // SomeObject
@owen-bnr
owen-bnr / ios-bootcamp-resources
Last active December 16, 2015 02:39
Resources for graduates of the Intro iOS bootcamp.
Demos from class:
https://dl.dropboxusercontent.com/u/7070943/iOS%20Demos.zip
Dave Verwer's iOS Weekly: http://iosdevweekly.com/. I like this newsletter a lot, even though I've usually seen the links by the time it comes out it often reminds me I want to bookmark them.
Blogs:
- Matt Gemmell's blog - Matt is a brilliant UI/UX evangelist with incredible wit (@mattgemmell)
- Mike Ash's Friday Q&A - Mostly nitty-gritties, but incredibly helpful (@mikeash)
- Cocoa, With Love (Matt Gallagher) - opinion pieces and how-tos, mostly (@mattgallagher)
- Cocoa Is My Girlfriend (Marcus Zarra and Matt Long) - Core Data and Core Animation experts (@mzarra and @perlmunger)
@ishaq
ishaq / KUtils.h
Last active October 11, 2019 22:15 — forked from jpwatts/xcode-git-version.sh
This Xcode build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository. To Use it, you 1) add the contents of `xcode-git-version.sh` to a "Run Script" build phase for your application target. 2) add a new value to your info plist called `FullVersion` …
#import <Foundation/Foundation.h>
@interface KUtils : NSObject
+ (NSString *)getVersionInfo;
@end
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)