Skip to content

Instantly share code, notes, and snippets.

View kashiash's full-sized avatar

Jacek Placek kashiash

  • Somewhere in space
View GitHub Profile
@kashiash
kashiash / CoreDataManager.swift
Created January 28, 2023 09:38 — forked from erdemildiz/CoreDataManager.swift
CoreDataManager cheatsheet
import CoreData
import UIKit
// ./NoteList.xcdatamodeld
class CoreDataManager {
static let sharedInstance = CoreDataManager()
private init() { }
@kashiash
kashiash / Slider+LogarithmicScale.swift
Created January 19, 2023 20:58 — forked from prachigauriar/Slider+LogarithmicScale.swift
SwiftUI Slider with Logarithmic Scale
extension Binding where Value == Double {
/// Returns a new version of the binding that scales the value logarithmically using the specified base. That is,
/// when getting the value, `log_b(value)` is returned; when setting it, the new value is `pow(base, newValue)`.
///
/// - Parameter base: The base to use.
func logarithmic(base: Double = 10) -> Binding<Double> {
Binding(
get: {
log10(self.wrappedValue) / log10(base)
},
@kashiash
kashiash / FormattedTextFieldView.swift
Created January 19, 2023 20:58 — forked from prachigauriar/FormattedTextFieldView.swift
Trying (and failing) to use formatters SwiftUI TextFields
import Foundation
import SwiftUI
struct FormattedTextFieldView : View {
@State private var double = 0.5
@State private var nsNumber: NSNumber = 0.5
static let numberFormatter: NumberFormatter = {
@kashiash
kashiash / AnyError.swift
Created November 27, 2022 20:45 — forked from nnsnodnb/AnyError.swift
How to upload jpeg image using URLSession.
import Foundation
struct AnyError: Error {
let error: Error
init(_ error: Error) {
self.error = error
}
}
@kashiash
kashiash / DateFormattingPlayground.swift
Created November 27, 2022 12:52 — forked from stinger/DateFormattingPlayground.swift
Functional date formatting
import Foundation
extension Date {
typealias FormattedString = (DateFormatter) -> String
func formatted(by format: String) -> FormattedString {
return { formatter in
formatter.dateFormat = format
return formatter.string(from: self)
}
@kashiash
kashiash / ConcurrencyFetcher.swift
Created November 27, 2022 12:50 — forked from stinger/ConcurrencyFetcher.swift
Swift Concurrency fetcher
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String), parserError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
case .apiError(let reason), .parserError(let reason):
return reason
}
@kashiash
kashiash / SplashScrollView.swift
Created November 27, 2022 12:50 — forked from stinger/SplashScrollView.swift
A simple Parallax Effect based paged ScrollView
//
// ContentView.swift
// Shared
//
// Created by Costantino Pistagna on 25/03/21.
//
import SwiftUI
struct ContentView: View {
@kashiash
kashiash / mongodb-cheat-sheet.md
Created February 28, 2022 19:05 — forked from devkiran/mongodb-cheat-sheet.md
MongoDB Cheat Sheet

1. Insert a single document

db.products.insertOne({ name: 'Product 1', price: 200 })

2. Insert multiple documents - Ordered

db.products.insertMany([{ name: 'Product 1', price: 200 }, { name: 'Product 2', price: 100 }])
@kashiash
kashiash / DB2 RunStat and ReOrg
Created February 7, 2022 19:54 — forked from kr153/DB2 RunStat and ReOrg
IBM DB2 RunStat and ReOrg
--ReOrg and RunStat for IBM DB2
--All Programs > IBM DB2 > DB2COPY1 (Default) > Command Line Tools > Command Window - Administrator
-- Connect to Database
db2 connect to <DATABASE NAME>
-- Generate output for RunStat on Tables
db2 -x "SELECT 'RUNSTATS ON TABLE ' || TRIM(TABSCHEMA) || '.' || TRIM(TABNAME) || ' AND INDEXES ALL;' FROM SYSCAT.TABLES WHERE TYPE = 'T' AND TABSCHEMA NOT LIKE 'SYS%' ORDER BY TABSCHEMA, TABNAME" > db2_runstats.sql.out
-- Use the genereated file for RunStat on Tables.
db2 -tvf db2_runstats.sql.out
using System;
using System.IO;
using DevExpress.Utils;
using DevExpress.XtraGrid;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.Model;
using DevExpress.Utils.Serializing;
using DevExpress.ExpressApp.Win.Editors;