Skip to content

Instantly share code, notes, and snippets.

View amine2233's full-sized avatar

Amine Bensalah amine2233

View GitHub Profile
@amine2233
amine2233 / PillButtons.swift
Created June 11, 2024 18:24 — forked from metasidd/PillButtons.swift
Pill Buttons - Mail App iOS 18 - SwiftUI
//
// PillButtons.swift
//
// Created by Siddhant Mehta on 6/11/24
// Twitter: @metasidd
//
// Feel free to reuse, or remix.
import SwiftUI
@amine2233
amine2233 / RenameGitBranch.md
Created May 19, 2024 08:25 — forked from danieldogeanu/RenameGitBranch.md
How to rename your Git master branch to main.

To rename your Git master branch to main, you must do the following steps:

  1. Navigate to your repository in the command line and issue the following commands: - git branch -m master main - git push -u origin main

  2. Change your default branch on GitHub by going to your GitHub repository in your browser, and navigate to Settings > Branches and click on the dropdown and switch from master to main and click Update (this will only show if you have two or more branches). The main branch is now your default branch.

  3. Update the tracking of the branch from your command line with the following command: - git branch -u origin/main main

@amine2233
amine2233 / unzip.swift
Created July 4, 2022 08:41 — forked from kristopherjohnson/unzip.swift
zip(), zip3(), unzip(), and unzip3() for Swift
// Given array of 2-tuples, return two arrays
func unzip<T, U>(array: [(T, U)]) -> ([T], [U]) {
var t = Array<T>()
var u = Array<U>()
for (a, b) in array {
t.append(a)
u.append(b)
}
return (t, u)
}
@amine2233
amine2233 / changelog.sh
Created June 16, 2022 09:15 — forked from developernotes/changelog.sh
Display a simple changelog between the last two tags in a Git repository
#! /usr/bin/env sh
firstTag=$(git tag | sort -r | head -1)
secondTag=$(git tag | sort -r | head -2 | awk '{split($0, tags, "\n")} END {print tags[1]}')
echo "Changes between ${secondTag} and ${firstTag}\n"
git log --pretty=format:' * %s' ${secondTag}..${firstTag}
@amine2233
amine2233 / install-brew.sh
Created May 18, 2022 19:41 — forked from kevinkarwaski/install-brew.sh
Install Brew and set up for Standard OSX User
#!/usr/bin/env bash
# This script installs brew and chowns the right directories needed to run
# brew as a standard user. Your user should be the owner of /usr/local which
# gets set during the installation of brew. The global homebrew cache directory
# group should be set to 'staff' which is not set during a brew install. This
# script fixes that.
# To begin, you MUST execute this script with your user account while it has
# admin privileges. Once the script completes, you can change your

Example of generated code

internal extension Color {
  // Assets.xcassets
  static var midnightBlue : Color { Color("midnightBlue", bundle: BundleToken.bundle) }
}

internal extension Image {
// Assets.xcassets
@amine2233
amine2233 / Convert .mov or .MP4 to .gif.md
Created March 11, 2022 13:45 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@amine2233
amine2233 / FormattedTextField.swift
Created March 9, 2022 17:32 — forked from darrarski/FormattedTextField.swift
SwiftUI FormattedTextField - TextField with custom display/edit formatters
import SwiftUI
public struct FormattedTextField<Formatter: TextFieldFormatter>: View {
public init(_ title: String,
value: Binding<Formatter.Value>,
formatter: Formatter) {
self.title = title
self.value = value
self.formatter = formatter
}
@amine2233
amine2233 / Published.swift
Created March 2, 2022 06:41 — forked from n8chur/Published.swift
An example implementation of @published from Swift's Combine framework along with an "immutable" variant.
import Combine
/**
An observable, mutable property.
Replays the current value when subscribed.
*/
@propertyWrapper
struct Published<Output>: Publisher {
typealias Failure = Never