Skip to content

Instantly share code, notes, and snippets.

View jimbrayrcp's full-sized avatar
😀

Jim Bray jimbrayrcp

😀
  • San Antonio, Texas
View GitHub Profile
@jimbrayrcp
jimbrayrcp / Dynamic Decimal (func) Extension.swift
Last active April 22, 2022 04:40
Dynamically removes trailing zeros from doubles in swiftui view text fields. To use a (let) type extension instead use: snippetslab://snippet/ABECB304-F4B9-451A-A47D-69602E7F56A6/
struct RowView: View {
var coin: Coins
var body: some View {
VStack() {
let _ = print("\((Double("\(coin.paymentThreshold)")!.dynamicDrecimalFormat())) ")
HStack(alignment: .bottom) {
Spacer()
Text("\((Double("\(coin.paymentThreshold)")!.dynamicDrecimalFormat())) ")
@jimbrayrcp
jimbrayrcp / Dynamic Decimal (let) Extension.swift
Last active April 22, 2022 04:40
Dynamically removes trailing zeros from doubles in swiftui view text field. To use a (func) type extension instead : snippetslab://snippet/5D3360F4-38A6-4504-8B98-86F441E1E931/
struct RowView: View {
var coin: Coins
var body: some View {
HStack(alignment: .bottom) {
Spacer()
Text("\((dynamicDrecimalFormat(dynamicDrecimal: Double(coin.paymentThreshold))))")
Text(coin.symbol ?? "")
.font(.footnote)
}
}
@jimbrayrcp
jimbrayrcp / Find Core Data File.txt
Last active April 14, 2022 21:14
Find the sql lite file path attached to a core data project. Open with SqlLiteBrowser downloaded from https://sqlitebrowser.org/. You will find the file within the folder path given just inside of the folder labeled with /YOUR-PROJECT-NAME/. ~ and. ~ then find the DB labeled YourProjectName.sqlite
func whereIsMySQLite() {
let path = FileManager
.default
.urls(for: .applicationSupportDirectory, in: .userDomainMask)
.last?
.absoluteString
.replacingOccurrences(of: "file://", with: "")
.removingPercentEncoding
print(path ?? "Not found")
@jimbrayrcp
jimbrayrcp / Flashing Messages (in method).py
Last active August 24, 2023 17:11
placing line break flash messages ~or~ multi line flash messages in a python flask html template
# EDIT THIS CODE TO YOUR SPECIFIC NEEDS
# THIS CODE REQUIRES SPECIFIC HTML CODE TO BE PLACED
# INSIDE THE TEMPLATE EXAMPLE FOUND BELOW
from flask import Flask, flash
def some_method():
@jimbrayrcp
jimbrayrcp / Find Matching Value from two lists.py
Created April 21, 2021 21:01
Python List Compensation to compare single list of numbers in two text files extracting the matching numbers into a single list
# # PYTHON LIST COMPENSATION
# compare single list of numbers
# in two text files extracting the matching numbers into a single list
# NOTE: in file1 & file2 the numbers are a single column in each list.
with open('file1.txt') as f:
file1 = [int(n) for n in f]
@jimbrayrcp
jimbrayrcp / Find Matching List Value in a dictionary.py
Created April 21, 2021 21:01
Find a matching value in a dictionary from values found in a list you can choose to match on the key or the value with the conditional test :: Python3.9
# COMBINING DICTIONARY AND LIST COMPREHENSION
# python 3.9,
# Find a matching value in a dictionary from values found in a list.
# you can choose to match on the key or the value with the conditional test
# depending the type of dictionary
a_list = [1, 2, 3]
b_dict = {1: "Bill", 2: "Joe", 3: "Oscar", 4: "Paul", 5: "Sally"}
new_dict = dict((key, value) for key, value in b_dict.items() if key in a_list)
@jimbrayrcp
jimbrayrcp / Dictionary & List Comprehension (pandas).py
Created April 21, 2021 21:01
pandas library, python 3.9, using the following format : dictionary_comprehension = {NEW_KEY: NEW_VALUE for (INDEX, ROW) in DATA.iterrows()} list_comprehension = [NEW_ITEM for ITEM in LIST]
# pandas library,
# python 3.9,
# using the following format :
# dictionary_comprehension = {NEW_KEY: NEW_VALUE for (INDEX, ROW) in DATA.iterrows()}
# list_comprehension = [NEW_ITEM for ITEM in LIST]
import pandas
new_dict = {
'letter': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
@jimbrayrcp
jimbrayrcp / main.py
Created April 16, 2021 00:28
return system info from pycharm
import sys
import os
import pkg_resources
from pprint import pprint
pprint({
'sys.version_info': sys.version_info,
'sys.prefix': sys.prefix,
'sys.path': sys.path,
@jimbrayrcp
jimbrayrcp / Text Field Character Count.swift
Created June 10, 2020 19:18
For Swift UI: a simple text field character counter with return value into another text field.
import SwiftUI
import Combine
class TextCountMgr: ObservableObject {
@Published var counted = "0"
@Published var text = "" {
didSet {
counted = String(text.count)
}
@jimbrayrcp
jimbrayrcp / Transparent Navigation Bar.swift
Last active July 11, 2023 01:52
Swift 5: iOS: 13.1 removes the navigation bar on a per-viewcontroller basis. Use this method if you want to show full screen image with no navigation bar obscuring your view. Title and Prompt can be added if desired
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Provide a clear background for the navigaion bar
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = true
}
override func viewWillDisappear(_ animated: Bool) {