Skip to content

Instantly share code, notes, and snippets.

View Akhrameev's full-sized avatar

Pavel Akhrameev Akhrameev

  • Rhino
  • Yerevan, Armenia
View GitHub Profile
class UDvars {
var AppLaunch: Int = UserDefaults.standard.object(forKey: "AppLaunch") as? Int ?? 0 {
didSet {
UserDefaults.standard.set(AppLaunch, forKey: "AppLaunch")
}
}
var Bool: Bool = UserDefaults.standard.object(forKey: "Bool") as? Bool ?? false {
didSet {
@Akhrameev
Akhrameev / UIImageMetalExtensions.swift
Last active October 23, 2020 10:28 — forked from akesson/UIImageMetalExtensions.swift
[iOS] Extension for creating UIImage from Metal texture
// http://blog.human-friendly.com/drawing-images-from-pixel-data-in-swift
// https://github.com/FlexMonkey/MetalReactionDiffusion/blob/1ea9aa4a841d20e0b247505fdf716cd5fe1a01fd/MetalReactionDiffusion/ViewController.swift
public struct PixelData {
var a:UInt8 = 255
var r:UInt8
var g:UInt8
var b:UInt8
}
@Akhrameev
Akhrameev / CatWithSpeechBubbleView.swift
Created June 3, 2025 09:50
UIKit Cat in SwiftUI for live preview
import SwiftUI
import UIKit
// 1. Custom UIKit View: Cat with Speech Bubble
class CatWithSpeechBubbleView: UIView {
var message: String = "UIKit ❤️ SwiftUI" {
didSet {
setNeedsDisplay()
}
@Akhrameev
Akhrameev / compress_pdf.py
Created December 2, 2025 14:46
The Code Behind "The Grayscale Paradox". Full story in my LinkedIn article.
import os
import subprocess
import shutil
import sys
import argparse # The standard library for parsing command-line arguments
# --- Configuration ---
# The template for the output subdirectory. It will now include the mode (color/grayscale).
OUTPUT_SUBDIR_TEMPLATE = 'compressed_{dpi}dpi_{mode}'
# --- End of Configuration ---