Skip to content

Instantly share code, notes, and snippets.

View ataetgi's full-sized avatar
🎯
Focusing

Ata Etgi ataetgi

🎯
Focusing
View GitHub Profile
@ataetgi
ataetgi / pre-commit
Created October 17, 2024 13:55 — forked from candostdagdeviren/pre-commit
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
#Path to swiftlint
SWIFT_LINT=/usr/local/bin/swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
count=0
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path
@ataetgi
ataetgi / Color+hexLiteral.swift
Created December 25, 2023 10:35 — forked from lucaswkuipers/Color+hexLiteral.swift
Color from Hex literal
import SwiftUI
extension Color: ExpressibleByIntegerLiteral {
public init(integerLiteral value: UInt32) {
let red = Double((value & 0xFF0000) >> 16) / 255
let green = Double((value & 0x00FF00) >> 8) / 255
let blue = Double(value & 0x0000FF) / 255
self.init(red: red, green: green, blue: blue)
}
}
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
/// Defines the possible errors
public enum URLSessionAsyncErrors: Error {
case invalidUrlResponse, missingResponseData
}
@ataetgi
ataetgi / cli-nsrunloop.m
Created December 23, 2023 23:28 — forked from syzdek/cli-nsrunloop.m
Creating an NSRunLoop for a command line utility.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop
@ataetgi
ataetgi / detweet.swift
Created December 23, 2023 23:22 — forked from mxcl/detweet.swift
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"