Skip to content

Instantly share code, notes, and snippets.

View dneprDroid's full-sized avatar

Aleksandr Ovechko dneprDroid

View GitHub Profile
@dneprDroid
dneprDroid / VideoPreviewView.swift
Last active July 13, 2023 14:43
VideoPreviewView - video capture and preview (swift 3)
// swift 3
import UIKit
import AVFoundation
class VideoPreviewView: UIView {
private var videoOutput: AVCaptureMovieFileOutput?
private var captureSession: AVCaptureSession?
private var previewLayer: AVCaptureVideoPreviewLayer?
@dneprDroid
dneprDroid / MainNavigationProtocol.swift
Last active July 13, 2017 19:38
MainNavigationProtocol.swift
import UIKit
protocol MainNavigationProtocol: class {
var cached:Bool? {get set}
static var storyboardName: String {get}
}
extension MainNavigationProtocol where Self : UIViewController {
@dneprDroid
dneprDroid / Localization+IBInspectable.m
Last active September 26, 2017 16:34
IBInspectable Localization in Storyboards.
// MARK : Localization+IBInspectable.h
@interface UILabel(Localization)
@property (nonatomic, weak) IBInspectable NSString *localizationId;
@end
@interface UIButton(Localization)
@property (nonatomic, weak) IBInspectable NSString *localizationId;
@end
@dneprDroid
dneprDroid / checkpoint2proto.py
Last active August 18, 2023 06:21
Tensorflow checkpoint (*.ckpt) to proto (*.pb) model conversion: checkpoint2proto.py
import os, argparse
import tensorflow as tf
from tensorflow.python.tools import freeze_graph as freeze_tool
def freeze_graph(sess, input_checkpoint_path):
saver = tf.train.Saver() # or your own Saver
saver.restore(sess, input_checkpoint_path)
absolute_model_dir = 'absolute_model_dir1111'
graph_file_name = 'tf-model_graph'
@dneprDroid
dneprDroid / import_localization.py
Last active March 23, 2018 22:14
Import localization strings from xls (Excel) file (for ios and android).
print('Usage (where PATH is .xlsx file): python import_localization.py <PATH> <LANG_COLUMN_NAME>')
# python import_localization.py spreadsheet-3.xlsx "Eng Value"
try:
import pandas as pd
except:
print('Install pandas!!!!')
print('Try: pip install pandas')
raise
@dneprDroid
dneprDroid / RxAutosuggest-RxSwift.swift
Created April 23, 2018 09:08
RxAutosuggest for RxSwift
import RxSwift
class RxAutosuggest<Model> {
//MARK: Types
typealias QueryCache = (items: [Model], query: String)
typealias Sort<T> = (T, T)->Bool
typealias SortGenerator = (_ query: String)->Sort<Model>
@dneprDroid
dneprDroid / DragDropImageView.m
Created May 10, 2018 21:31
DragDropImageView for Mac OS.
//
// DragDropImageView.h
// TFVideo
//
// Created by user on 2/1/18.
// Copyright © 2018 AlexO. All rights reserved.
//
#import <AppKit/AppKit.h>
@dneprDroid
dneprDroid / DI.swift
Last active May 22, 2018 21:22
Simple DI - Swift4
import Foundation
class A : DInjectEntity { }
class B : DInjectEntity {
var a:A!
}
class C : DInjectEntity { }
@dneprDroid
dneprDroid / UITextField+MaxTextLength.swift
Last active May 30, 2018 20:28
UITextField+MaxTextLength Swift 4
import UIKit
private var _UITextField_maxTextLength = "_UITextField_maxTextLength"
extension UITextField {
@IBInspectable
var maxTextLength:Int {
get {
return objc_getAssociatedObject(self,
@dneprDroid
dneprDroid / KernelRegistration.cpp
Created June 15, 2018 07:38
Tensorflow KernelRegistration.cpp
#include <tensorflow/core/framework/op.h>
#include <tensorflow/core/framework/op_kernel.h>
#include <tensorflow/core/framework/shape_inference.h>
using namespace tensorflow;
using namespace register_kernel;
struct KernelRegistration {
KernelRegistration(const KernelDef& d, StringPiece c,