Skip to content

Instantly share code, notes, and snippets.

View alkozin's full-sized avatar

Alexander Kozin alkozin

  • El Machine
  • Novosibirsk, Russian Federation
  • 18:34 (UTC +07:00)
View GitHub Profile
@nicholascross
nicholascross / WeakBox.swift
Last active April 2, 2024 13:42
Swift dictionary with weak references simple example
struct WeakBox<ItemType: AnyObject> {
weak var item: ItemType?
init(item: ItemType?) {
self.item = item
}
}
@codelynx
codelynx / Runtime.swift
Last active May 17, 2024 08:19
[Swift] To retrieve classes at runtime which conforms to a protocol or to retrieve subclasses of a given class
//
// Runtime.swift
// Swift Runtime [Swift 4]
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@aras-p
aras-p / preprocessor_fun.h
Last active May 18, 2024 08:55
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@0xced
0xced / XCDFakeCarrier.m
Last active March 5, 2023 22:07
Hack to choose the displayed carrier name in the iOS simulator
//
// Copyright (c) 2012-2015 Cédric Luthi / @0xced. All rights reserved.
//
#import <Foundation/Foundation.h>
#if TARGET_OS_SIMULATOR
static const char *fakeCarrier;
static const char *fakeTime;
@henrik
henrik / SearchBarStyler.h
Created June 12, 2010 19:21
Enable the Return key in a UISearchBar even when its text is empty.
// By Henrik Nyh <http://henrik.nyh.se> 2010-06-12 under the MIT license.
#import <Foundation/Foundation.h>
@interface SearchBarStyler : NSObject {
}
+(void)enableReturnKeyWithNoText:(UISearchBar *)searchBar;
@end