Skip to content

Instantly share code, notes, and snippets.

View kafran's full-sized avatar
🏠
WFH

Kolmar Kafran kafran

🏠
WFH
View GitHub Profile
@kafran
kafran / keybase.md
Created July 14, 2023 18:31
keybase.md

Keybase proof

I hereby claim:

  • I am kafran on github.
  • I am kafran (https://keybase.io/kafran) on keybase.
  • I have a public key ASCJv9SJ3qWI58rLwTSMBNjmJJIsJy9wuf4TlNklej_V-Qo

To claim this, I am signing this object:

@kafran
kafran / ApiKey.swift
Created May 3, 2023 13:25
Using iCloud for storing keys and then pushing into keychain of device.
import CloudKit
import Foundation
import Locksmith
/**
API Key used by this app is fetched from CloudKit. This class manages fetching and saving it into Keychain
*/
class ApiKey {
private static let RECORD_NAME = <# RECORD_NAME_IN_CLOUDKIT #>
private static let KEY = <# KEY_NAME_IN_CLOUDKIT #>
import SwiftUI
// pre-create one instance of MeasurementFormatter for our format needs
// re-use as needed
extension MeasurementFormatter {
static private let formatter: MeasurementFormatter = {
let formatter = MeasurementFormatter()
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.minimumFractionDigits = 2
@kafran
kafran / CVPixelBufferPixelFormatNames.swift
Created January 23, 2023 20:56 — forked from skyebook/CVPixelBufferPixelFormatNames.swift
Easily get the pixel format name of a CVPixelBuffer
public func CVPixelBufferGetPixelFormatName(pixelBuffer: CVPixelBuffer) -> String {
let p = CVPixelBufferGetPixelFormatType(pixelBuffer)
switch p {
case kCVPixelFormatType_1Monochrome: return "kCVPixelFormatType_1Monochrome"
case kCVPixelFormatType_2Indexed: return "kCVPixelFormatType_2Indexed"
case kCVPixelFormatType_4Indexed: return "kCVPixelFormatType_4Indexed"
case kCVPixelFormatType_8Indexed: return "kCVPixelFormatType_8Indexed"
case kCVPixelFormatType_1IndexedGray_WhiteIsZero: return "kCVPixelFormatType_1IndexedGray_WhiteIsZero"
case kCVPixelFormatType_2IndexedGray_WhiteIsZero: return "kCVPixelFormatType_2IndexedGray_WhiteIsZero"
case kCVPixelFormatType_4IndexedGray_WhiteIsZero: return "kCVPixelFormatType_4IndexedGray_WhiteIsZero"
@kafran
kafran / MyCoredataObject+CoreDataProperties.swift
Created December 5, 2022 23:10 — forked from novinfard/MyCoredataObject+CoreDataProperties.swift
[Auto increment in Core Data] How to implement auto-increment in core data while saving it #coredata
import Foundation
import CoreData
extension MyCoredataObject {
@nonobjc public class func createFetchRequest() -> NSFetchRequest<MyCoredataObject> {
return NSFetchRequest<MyCoredataObject>(entityName: "MyCoredataObject")
}
@NSManaged public var sortId: Int64
from airflow.utils import db
from airflow.models import Connection
import csv
outfile = open('myconnections.csv', 'w')
outcsv = csv.writer(outfile)
with db.create_session() as session:
connections = session.query(Connection).all()
@kafran
kafran / gist:7ba2500591b84eb5641df9f8a90dd4c2
Created May 30, 2020 00:33 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@kafran
kafran / tmux-cheatsheet.markdown
Created April 26, 2020 04:24 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@kafran
kafran / extract_har.py
Last active November 3, 2023 20:04
Python 3 script to extract images from HTTP Archive (HAR) files
import json
import base64
import os
# make sure the output directory exists before running!
folder = os.path.join(os.getcwd(), "imgs")
with open("scr.har", "r") as f:
har = json.loads(f.read())
@kafran
kafran / abnt-changed.cbx
Created August 18, 2018 20:45
Modificação no abnt.cbx para desambiguação
--- /home/kafran/Downloads/biblatex-abnt-3.1/latex/cbx/abnt.cbx
+++ /home/kafran/Downloads/biblatex-abnt-3.1/latex/cbx/abnt-changed.cbx
@@ -70,12 +70,12 @@
{\namepartgiveni}%
{\namepartprefix}%
{\namepartsuffixi}}%
- {\usebibmacro{name:given-family}%
+ {\usebibmacro{name:family-given}%
{\iftoggle{sccite}%
{\textsc{\MakeLowercase{\namepartfamily}}}%