Skip to content

Instantly share code, notes, and snippets.

struct AppView: View {
@ObservedObject var navigation: AppNavigation
var body: some View {
CustomTabBar(selection: $navigation.selectedTab) {
feedTab() // ] returns the feed SwiftUI view
searchTab() // ⎤
liveTab() // ⎥ return views of UIViewControllerRepresentable
notificationsTab() // ⎥
profileTab() // ⎦
struct AvatarButton: View {
let user: User
@EnvironmentObject private var navigation: AppNavigation
var body: some View {
Button {
navigation.commit(.profile(user.id)) // "open profile" action
} label: {
AsyncImage(url: user.avatarUrl)
}
@avielg
avielg / viewtree.py
Last active June 19, 2024 21:17
SwiftUI View Tree Graph
#!/opt/homebrew/bin/python3
import re
import glob
import os
import graphviz
##################################################################################
######### USAGE #########
@avielg
avielg / mario.py
Created December 16, 2016 12:47
mario.py
# coding: utf-8
from objc_util import *
from ctypes import *
libobjc = CDLL('/usr/lib/libobjc.dylib')
#NSObject = ObjCClass('NSObject')
LSAppilcationWorkspace = ObjCClass('LSApplicationWorkspace')
@avielg
avielg / FCPrivateBatteryStatus.m
Created February 3, 2016 14:26
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@avielg
avielg / GBPlistDB.h
Created April 1, 2015 08:43
Helper class for managing an extremely light key-value based db in one or more plist files
//
// GBPlistDB.h
// SensiyaSDK
//
// Created by Aviel Gross on 3/30/15.
// Copyright (c) 2015 Globalbit. All rights reserved.
//
// Mostly a wrapper class for the code found here: http://stackoverflow.com/a/6697423/2242359
#import <Foundation/Foundation.h>
@avielg
avielg / gist:9995351
Last active August 29, 2015 13:58 — forked from RoySegall/gist:9995115
public class singHadGadiaSong {
public static void singHadGadia(String[] characters, String[] actions, int n)
{
if (n >= characters.length)
return;
System.out.println("ואתא " + characters[n]);
for (int i = n - 1; i >= 0; i--) {
String prefix = (i == n - 1 ? "ו" : "ד");
System.out.println(prefix + actions[i] + " ל" + characters[i]);
}