Skip to content

Instantly share code, notes, and snippets.

View 98chimp's full-sized avatar

Shahin Zangenehpour 98chimp

  • Vancouver, BC, Canada
View GitHub Profile
import SwiftUI
struct ContentView: View {
@State var horizontal: Bool = true
@Namespace var namespace
var body: some View {
VStack(spacing: 40) {
if horizontal {
HStack { items }
// gist file for Creating Activity Rings in SwiftUI
// https://swdevnotes.com/swift/2021/create-activity-rings-in-swiftui/
//
// All code in one ContentView.swift file just for sharing
//
// Created by Eric on 05/09/2021.
//
import SwiftUI
@frankfka
frankfka / iOSActivityRingSwiftUI.swift
Created April 29, 2020 05:22
iOS Activity Ring in SwiftUI
import SwiftUI
import PlaygroundSupport
extension Double {
func toRadians() -> Double {
return self * Double.pi / 180
}
func toCGFloat() -> CGFloat {
return CGFloat(self)
#!/usr/bin/env swift
//
// faceExtraction.swift
// FaceITDetection
//
// Extracts faces detected in images
//
// Created by NovaTec GmbH on 16.08.17.
// Copyright © 2017 NovaTec GmbH. All rights reserved.
//

👊 ✋ ✌️

You are going to create a very simple rock paper scissors game. It will consist of three buttons, one for each of the moves you can play. Tap on one of these buttons to chose your move, then the iPhone will randomly choose a move and a you either win, lose, or 👔.

Screenshot of app

Rules of Rock Paper Scissors:

  • Each sign can beat one (and only one) other:
  • Rock smashes scissors.
@codediodeio
codediodeio / database.rules.json
Last active January 28, 2024 19:07
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@edmund-h
edmund-h / generateRandomDate.swift
Last active August 13, 2021 17:47
A function to create a random date in Swift 3
// credit to @eirnym, adapted this from their OBJC code: https://gist.github.com/eirnym/c9526a045556e4d8464b41a367843e3c
// generates a random date and time in the past, limited by daysBack (a number of days before today)
// also generates a random time to go with that date.
// original request: http://stackoverflow.com/questions/10092468/how-do-you-generate-a-random-date-in-objective-c
func generateRandomDate(daysBack: Int)-> Date?{
let day = arc4random_uniform(UInt32(daysBack))+1
extension UIImageView {
/// Loads image from web asynchronosly and caches it, in case you have to load url
/// again, it will be loaded from cache if available
func load(url: URL, placeholder: UIImage?, cache: URLCache? = nil) {
let cache = cache ?? URLCache.shared
let request = URLRequest(url: url)
if let data = cache.cachedResponse(for: request)?.data, let image = UIImage(data: data) {
self.image = image
} else {
self.image = placeholder
@vicc
vicc / string-truncate.swift
Last active May 4, 2020 02:33 — forked from jesskturner/string-truncate.swift
A little truncate function extension for the default String type (Swift 3 Ready)
extension String {
/**
Truncates the string to the specified length number of characters and appends an optional trailing string if longer.
- Parameter length: A `String`.
- Parameter trailing: A `String` that will be appended after the truncation.
- Returns: A `String` object.
*/
func truncate(length: Int, trailing: String = "…") -> String {
@vitorbritto
vitorbritto / rm_mysql.md
Last active May 14, 2024 13:12
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql