Skip to content

Instantly share code, notes, and snippets.

View ShabanKamell's full-sized avatar
🏠
Working from home

Shaban Kamel ShabanKamell

🏠
Working from home
View GitHub Profile
@emmanuelkehinde
emmanuelkehinde / DropdownSelector.swift
Created May 9, 2021 11:57
Reusable Dropdown selector using SwiftUI
import SwiftUI
struct DropdownOption: Hashable {
let key: String
let value: String
public static func == (lhs: DropdownOption, rhs: DropdownOption) -> Bool {
return lhs.key == rhs.key
}
}
@zach-klippenstein
zach-klippenstein / SegmentedControl.kt
Last active May 3, 2024 11:15
iOS-style segmented control in Compose
import android.annotation.SuppressLint
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.gestures.forEachGesture
import androidx.compose.foundation.gestures.horizontalDrag
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
@CassiusPacheco
CassiusPacheco / data_result.dart
Last active December 13, 2023 03:14
Dart's DataResult<S> inspired by my Swift enum implementation and Avdosev's Dart Either implementation
// The code below was inspired by my swift implementation https://gist.github.com/CassiusPacheco/4378d30d69316e4a6ba28a0c3af72628
// and Avdosev's Dart Either https://github.com/avdosev/either_dart/blob/master/lib/src/either.dart
import 'package:equatable/equatable.dart';
abstract class Failure extends Equatable implements Exception {
@override
String toString() => '$runtimeType Exception';
@override
@arthurpalves
arthurpalves / ios-deploy.yml
Last active July 5, 2022 12:20
Sample of Github Actions workflows for iOS that falls under our "Branching strategy" category. These are workflows whose triggers are changes in or towards certain branches.
name: ios/deploy
#
# GOOD TO KNOW
#
# This workflow is supposed to:
# 1. Help ensure the quality of the code changes; and
# 2. Deploy a variant of this application depending on
# which branch was changed.
#
@diamantidis
diamantidis / 1_SFSymbols.scpt
Last active December 8, 2023 22:46
How to use AppleScript to generate an enum for the SF Symbols
activate application "SF Symbols"
tell application "System Events"
tell process "SF Symbols"
-- Click the “list” radio button.
click radio button 2 of radio group 1 of group 3 of toolbar 1 of window 0
tell outline 1 of scroll area 1 of splitter group 1 of window 0
select (row 1 where value of static text 1 of UI element 1 starts with "All")
@piotrek1543
piotrek1543 / PalindromeCreator.java
Created May 16, 2020 19:34
The coding challenge solution to Coderbytes task. Have the function PalindromeCreator(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters
/**
* Have the function PalindromeCreator(str) take the str parameter being passed and determine if it is possible to create a palindromic string of minimum length 3 characters by removing 1 or 2 characters. For example: if str is "abjchba" then you can remove the characters jc to produce "abhba" which is a palindrome. For this example your program should return the two characters that were removed with no delimiter and in the order they appear in the string, so jc. If 1 or 2 characters cannot be removed to produce a palindrome, then return the string not possible. If the input string is already a palindrome, your program should return the string palindrome.
* <p>
* The input will only contain lowercase alphabetic characters. Your program should always attempt to create the longest palindromic substring by removing 1 or 2 characters (see second sample test case as an example). The 2 characters you remove do not have to be adjacent in the string.
* Examples
* Input: "mmop"
* Output: not possible
* Input
@trilliwon
trilliwon / How to turn off the shutter sound when capture? AVFoundation.swift
Created December 21, 2019 05:08
How to turn off the shutter sound when capture? AVFoundation
class PhotoCapture {
// here some stuff for capture image, such as capture session, configurations, photo output
// More detail : https://github.com/trilliwon/ArtCamera/blob/master/Camera/Controllers/PhotoCapture.swift
}
// MARK: - AVCapturePhotoCaptureDelegate
extension PhotoCapture: AVCapturePhotoCaptureDelegate {
func photoOutput(_ output: AVCapturePhotoOutput, willCapturePhotoFor resolvedSettings: AVCaptureResolvedPhotoSettings) {
AudioServicesDisposeSystemSoundID(1108)
}
@ErikHellman
ErikHellman / LoginScreenWithCompose.kt
Created December 16, 2019 17:51
A simple demo of using Jetpack Compose to build a Login screen
package se.hellsoft.jetpackcomposeintro
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.Composable
import androidx.compose.Model
import androidx.compose.state
import androidx.compose.unaryPlus
import androidx.ui.core.*
import androidx.ui.foundation.shape.border.Border
@arturdev
arturdev / URLRequest+Multipart.swift
Last active February 21, 2023 18:59
URLRequest with multipart support
//
// URLRequest+Multipart.swift
//
// Created by Artur Mkrtchyan on 1/16/19.
// Copyright © 2019 arturdev. All rights reserved.
//
import Foundation
import MobileCoreServices
@danielt1263
danielt1263 / RetryingTokenNetworkService.swift
Last active June 12, 2023 14:54
The TokenAcquisitionService automatically retry requests if it receives an unauthorized error. Complete with proof that it works correctly.
//
// TokenAcquisitionService.swift
//
// Created by Daniel Tartaglia on 16 Jan 2019.
// Copyright © 2022 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift