Skip to content

Instantly share code, notes, and snippets.

View adriansergheev's full-sized avatar

Adrian Sergheev adriansergheev

View GitHub Profile
import SwiftUI
import Charts
struct FacilityResponse: Codable {
let id: String
let name: String
let timeZone: String
let hasConsumption: Bool
let hasProduction: Bool
let measurements: Measurements
@adriansergheev
adriansergheev / quarterHourCharts.swift
Created August 4, 2025 08:27
quarter-hour-charts-swift
import SwiftUI
import Charts
struct EnergyReading {
let timestamp: Date
let kWh: Double
}
struct EnergyBarChartView: View {
@State private var energyData: [EnergyReading] = {
@adriansergheev
adriansergheev / current_selected_installed_xcode.md
Created April 1, 2025 08:02 — forked from dive/current_selected_installed_xcode.md
How to get the current selected Xcode and list installed

How to get the current selected Xcode and list installed

Current Selected Xcode

xcode-select

This is the most common way to get the path to the selected instance:

xcrun xcode-select --print-path
@adriansergheev
adriansergheev / AppDefault.swift
Created July 19, 2024 15:14 — forked from jasdev/AppDefault.swift
Swift nonmutating Example
import Foundation
enum AppDefault {
case APIServer, runMode, homeDirectory, reactHost
var stringValue: String? {
get {
return NSUserDefaults.standardUserDefaults().stringForKey(String(self))
}
@adriansergheev
adriansergheev / reverse-ssh-tunnel-vps-to-pi.md
Created May 21, 2024 08:57 — forked from rfairley/reverse-ssh-tunnel-vps-to-pi.md
Connecting to a Raspberry Pi through a VPS using a reverse SSH tunnel

Connecting to a Raspberry Pi through a VPS using a reverse SSH tunnel

SSH (Secure Shell) to a host existing in an internal network through a reverse-tunneled SSH connection to an externally accessible VPS (Virtual Private Server). This setup is described where the internal host is a Raspberry Pi, but can be generalized for any host on the internal network that runs an OpenSSH server.

  internal network                                                   Internet                                       home network
                                              ||                                                         ||
 ------------------                           ||                          ------------------             ||             ------------------
|                  | reverse SSH tunnel (VPS $tunnel_port to Pi port 22) |                  |            ||            |                  |
|   Raspberry Pi     ==================================================>         VPS          ===================

Intro

Prerequisites/Background (Inspired from Functional Programming)

Data - data is inert and does not change by itself.

Example:

  • immutable struct
  • immutable data received from an API service, for example JSON, recorded logs etc.
@adriansergheev
adriansergheev / Count lines of code in Xcode project
Created August 20, 2021 14:59 — forked from Tokuriku/Count lines of code in Xcode project
Count lines of code in SWIFT Xcode project
1. Open Terminal
2. cd to your Xcode project
3. Execute the following when inside your target project:
find . -name "*.swift" -print0 | xargs -0 wc -l
import PlaygroundSupport
import Foundation
import Combine
// MARK: - Network Controller
protocol NetworkControllerProtocol: class {
typealias Headers = [String: Any]
func get<T>(type: T.Type,
url: URL,
@adriansergheev
adriansergheev / Best in Class iOS Checklist
Created August 2, 2020 13:40 — forked from DreamingInBinary/Best in Class iOS Checklist
This is a public checklist updated every year after the latest version of iOS and iPadOS are shipped. It's a boiled down version of a "Best in Class" app checklist created by Jordan Morgan.
# A Best in Class Checklist
A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10.
> To use this, create a Github Issue in your own repo, and simply copy and paste this text.
## iOS Core Technology
_Things any iOS app can benefit from_
- [ ] iCloud Sync
- [ ] [Core Spotlight integration](https://github.com/DreamingInBinary/Spend-Stack/issues/120)