Skip to content

Instantly share code, notes, and snippets.

View Kirow's full-sized avatar

Kirill Serebriakov Kirow

View GitHub Profile
@Kirow
Kirow / reverse-engineering-macos.md
Created October 22, 2024 09:44 — forked from 0xdevalias/reverse-engineering-macos.md
Some notes, tools, and techniques for reverse engineering macOS binaries
@Kirow
Kirow / MemoryLeak.swift
Created July 19, 2023 11:23
SwiftUI, LazyVStack, ObservedObject, Memory Leak
import Foundation
import SwiftUI
struct ReferenceCounter {
class Box {
weak var value: ViewModel.Element?
}
private var objects: [Box] = []
@Kirow
Kirow / different-results.swift
Last active September 12, 2019 15:20
GRDB Playgrounds
// To run this playground, select and build the GRDBOSX scheme.
import GRDB
import PlaygroundSupport
//models
public struct User: Codable, TableRecord, FetchableRecord, MutablePersistableRecord {
public static let databaseTableName: String = "user"
public static let log = hasMany(StateLog.self)
@Kirow
Kirow / GRDB-Cursor-Playground.swift
Last active July 31, 2019 12:11
playing with GRDB cursor
// To run this playground, select and build the GRDBOSX scheme.
import GRDB
import PlaygroundSupport
public struct User: Codable, TableRecord, FetchableRecord, MutablePersistableRecord {
public static let databaseTableName: String = "user"
public var id: Int64?
public var username: String
@Kirow
Kirow / InteractiveLabel.swift
Created June 11, 2019 11:17
Simple UILabel subclass with clickable text
public class InteractiveLabel: UILabel {
private struct InteractiveText: Equatable {
let range: Range<String.Index>
let defaultColor: UIColor
let highlightedColor: UIColor
let action: () -> Void
static func == (lhs: InteractiveText, rhs: InteractiveText) -> Bool {
return lhs.range == rhs.range
}
@Kirow
Kirow / CGRectAspectFit.m
Created October 23, 2018 14:05 — forked from lanephillips/CGRectAspectFit.m
Objective-C code to fit a CGRect inside or outside another CGRect while maintaining aspect ratio. The fitted rectangle is centered on the target rectangle.
CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget)
{
// first try to match width
CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit);
// if we scale the height to make the widths equal, does it still fit?
if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) {
return s;
}
// no, match height instead
return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit);
@Kirow
Kirow / Info.md
Created August 31, 2018 11:57
Convert to NSString for unescaped output
(lldb) po str
“{\n \”userId\”: 1,\n \”id\”: 1,\n \”title\”: \”sunt aut facere repellat provident occaecati excepturi optio reprehenderit\”,\n \”body\”: \”quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\”\n}”
(lldb) po NSString(string: str)
{
  “userId”: 1,
 “id”: 1,
@Kirow
Kirow / memo.md
Last active July 3, 2018 18:05
how to remove multiple tags at once

Delete remote

git push -d $(git tag -l "tag_prefix*")

Delete local

git tag -d $(git tag -l "tag_prefix*")

@Kirow
Kirow / HOME-END
Last active December 15, 2017 10:50
Hackintosh
remap home and end by creating ~/Library/KeyBindings/ and saving a property list like this as DefaultKeyBinding.dict:
cd ~/Library
mkdir KeyBindings
cd ~/Library/KeyBindings/
touch DefaultKeyBinding.dict
nano DefaultKeyBinding.dict
{
"\UF729" = moveToBeginningOfParagraph:; // home
@Kirow
Kirow / upcaupce.sql
Created April 14, 2016 10:47
SELECT UPC THAT COULD BE CONVERTED TO UPC-E
/* http://www.taltech.com/barcodesoftware/symbologies/upc
UPC-A Number Equivalent UPC-E Notes
0ab00000cdeX abcde0X Manufacturer code must have 2 leading digits with 3 trailing zeros and the item number is limited to 3 digits (000 to 999).
0ab10000cdeX abcde1X Manufacturer code must have 3 leading digits ending with "1" and 2 trailing zeros. The item number is limited to 3 digits.
0ab20000cdeX abcde2X Manufacturer code must have 3 leading digits ending with "2" and 2 trailing zeros. The item number is limited to 3 digits.
0abc00000deX abcde3X Manufacturer code must have 3 leading digits and 2 trailing zeros. The item number is limited to 2 digits (00 to 99).
0abcd00000eX abcde4X Manufacturer code must have 4 leading digits with 1 trailing zero and the item number is limited to 1 digit (0 to9).
0abcde00005X abcde5X Manufacturer code has all 5 digits.
0abcde00006X abcde6X The item nu