Skip to content

Instantly share code, notes, and snippets.

– What do we want?
– zoreslav.khimich@gmail.com
– When do we want it?
– taBnip-ribfo7-quqfax
@zrxq
zrxq / ContentView.swift
Created June 3, 2022 17:06
SwiftUI Scroll View scroll offset
import SwiftUI
struct OffsetPreferenceKey: PreferenceKey {
typealias Value = CGFloat
static var defaultValue: CGFloat = 0
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = nextValue()
}
}
@zrxq
zrxq / sumobot.js
Last active September 25, 2017 21:14
Прошивка для сумобота тип Б
var keypress = require('keypress');
var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
var board = new five.Board({
port: new EtherPortClient({
host: "10.0.1.8",
port: 3030
}),
@zrxq
zrxq / CropVideo.m
Created March 27, 2014 20:08
Crop video to square with a specified side respecting the original video orientation
@import MobileCoreServices;
@import AVFoundation;
@import AssetsLibrary;
// ...
- (void)cropVideoAtURL:(NSURL *)videoURL toSquareWithSide:(CGFloat)sideLength completion:(void(^)(NSURL *resultURL, NSError *error))completionHander {
/* asset */
@zrxq
zrxq / .lldbinit
Last active February 7, 2024 11:21
Execute lldb command and open its output in Sublime Text
comma script import ~/lldb/subl.py
comma script add -f subl.subl subl
@zrxq
zrxq / objc-run.sublime-build
Created January 12, 2014 15:38
Sublime text build system for Objective-C files (via objc-run, see https://github.com/iljaiwas/objc-run)
{
"cmd": ["/usr/local/bin/objc-run", "$file"],
}
@zrxq
zrxq / DatePickingCell.h
Created May 29, 2013 13:37
UITableViewCell + UIDatePicker
#import <UIKit/UIKit.h>
@interface DatePickingCell : UITableViewCell
@property (strong, nonatomic) UIDatePicker *datePicker;
@end
@zrxq
zrxq / gist:5363610
Last active February 3, 2016 15:35
CGRect inset with UIEdgeInsets
inline static CGRect CGRectEdgeInset(CGRect rect, UIEdgeInsets insets) {
return CGRectMake(CGRectGetMinX(rect)+insets.left, CGRectGetMinY(rect)+insets.top, CGRectGetWidth(rect)-insets.left-insets.right, CGRectGetHeight(rect)-insets.top-insets.bottom);
}
@zrxq
zrxq / gist:5362898
Last active December 16, 2015 02:29
contentCenter CGRect for a CALayer from a resizable UIImage (resizableImageWithCapInsets)
inline static CGRect CGRectCenterRectForResizableImage(UIImage *image) {
return CGRectMake(image.capInsets.left/image.size.width, image.capInsets.top/image.size.height, (image.size.width-image.capInsets.right-image.capInsets.left)/image.size.width, (image.size.height-image.capInsets.bottom-image.capInsets.top)/image.size.height);
}
@zrxq
zrxq / UIViewController+ZWDModalOverlay.h
Created February 2, 2013 05:10
Modal overlay views with orientation support
//
// UIViewController+ZWDModalOverlay.h
//
// Created by Zoreslav Khimich on 28/01/2013.
// Copyright (c) 2013 zrxq. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIViewController (ZWDModalOverlay)