Skip to content

Instantly share code, notes, and snippets.

View xNekOIx's full-sized avatar
🇺🇦

Konstantin Bychkov xNekOIx

🇺🇦
View GitHub Profile
@sma
sma / AutoLocalize.h
Created August 8, 2011 07:29
Automatically localize all strings in XIB files settable by IB
//
// AutoLocalize.h
// AutoLocalize
//
// Created by Stefan Matthias Aust on 05.08.11.
// Copyright 2011 I.C.N.H. All rights reserved.
//
#import <UIKit/UIKit.h>
@luca-bernardi
luca-bernardi / AVAsset+VideoOrientation.h
Created February 23, 2013 18:12
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait
@oleksii-demedetskyi
oleksii-demedetskyi / Traits.m
Created May 5, 2014 22:07
Example trait usage.
#import <Foundation/Foundation.h>
#define trait(NAME) protocol NAME;\
@interface id_##NAME @end \
typedef id_##NAME<NAME> NAME; \
@protocol NAME
#define trait_implementation(NAME) \
interface NAME##_impl : NSObject<NAME>\
- (NAME *) asTrait$;\
@staltz
staltz / introrx.md
Last active June 29, 2024 15:58
The introduction to Reactive Programming you've been missing
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern
@oleksii-demedetskyi
oleksii-demedetskyi / ServiceLocator.swift
Last active December 12, 2020 05:04
Service locator in swift
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
class ServiceLocator {
private var registry : [String: Any] = [:]
func registerService<T>(service: T) {
//: Playground - noun: a place where people can play
import UIKit
// Simple struct to be fullfilled from JSON
struct User {
let name: String
let age: Int
}
; ModuleID = 'main.m'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"
%0 = type opaque
%struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* }
%struct._objc_cache = type opaque
%struct._class_ro_t = type { i32, i32, i32, i8*, i8*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._ivar_list_t*, i8*, %struct._prop_list_t* }
%struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] }
%struct._objc_method = type { i8*, i8*, i8* }
//: [Previous](@previous)
import Foundation
// One per function
final class Stub {
let name: String
let cmp: (AnyCall, AnyCall) -> Bool
init(name: String, cmp: (AnyCall, AnyCall) -> Bool) {
self.name = name
@esavelyeva
esavelyeva / fs.to.playlist.script
Last active November 10, 2016 13:59
Go to http://bookmarklets.org/maker/ to generate the bookmarklet
//download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support
// data can be a string, Blob, File, or dataURL