Skip to content

Instantly share code, notes, and snippets.

@wassim93
wassim93 / button-animation.html
Last active October 29, 2023 14:16
fill cup animation button tailwind
<button className="relative rounded-md overflow-hidden outline group">
<a href="#contact" className="relative z-10 block py-2 px-4 text-white transition-all duration-700 ">
Let's Talk
</a>
<span className="absolute top-0 left-0 h-full bg-[#915eff] w-0 transition-all duration-700 group-hover:w-full">
<div className="cup-fill animate-cup-fill"></div>
</span>
</button>
@wassim93
wassim93 / airports.json
Created December 16, 2021 20:58 — forked from tdreyno/airports.json
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
@wassim93
wassim93 / dateformatter.swift
Created August 23, 2021 02:30
Date Format in Swift
Wednesday, Sep 12, 2018 --> EEEE, MMM d, yyyy
09/12/2018 --> MM/dd/yyyy
09-12-2018 14:11 --> MM-dd-yyyy HH:mm
Sep 12, 2:11 PM --> MMM d, h:mm a
September 2018 --> MMMM yyyy
Sep 12, 2018 --> MMM d, yyyy
Wed, 12 Sep 2018 14:11:54 +0000 --> E, d MMM yyyy HH:mm:ss Z
2018-09-12T14:11:54+0000 --> yyyy-MM-dd'T'HH:mm:ssZ
12.09.18 --> dd.MM.yy
10:41:02.112 --> HH:mm:ss.SSS
@wassim93
wassim93 / decorator.kt
Last active December 16, 2021 21:01
Adding item decorator class to set space between recycler view items
// create a new class for the custom decorator
class MarginItemDecorator(private val horizontalSpacing:Int , private val verticalSpacing:Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
super.getItemOffsets(outRect, view, parent, state)
outRect.right = horizontalSpacing
outRect.left = horizontalSpacing
outRect.top = verticalSpacing
outRect.bottom = verticalSpacing
}
}
@wassim93
wassim93 / border_layout.xml
Last active May 12, 2021 10:34
add border to layout in android
Basically, you need to create a custom drawable and add it as a background to your layout. example:
Create a file called customborder.xml in your drawable folder:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp"/>
<padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/>
<stroke android:width="1dp" android:color="#CCCCCC"/>
</shape>
@wassim93
wassim93 / reusable alertview.swift
Created July 22, 2020 11:36
Reusable alert view controller with multiple types
import UIKit
//swiftlint:disable superfluous_disable_command identifier_name line_length
enum AlertType {
case ERROR, INFO, ONOFF_INFOCOUPON, NO_NETWORK, LOGOUT
}
class AlertViewController: UIViewController {
@IBOutlet weak var alertContainerWidthConstraint: NSLayoutConstraint!
@IBOutlet weak var saveBtnViewHeight: NSLayoutConstraint!
@wassim93
wassim93 / label text animation forward and backward.swift
Created July 9, 2020 11:34
text animation in label forward and backward swift
var countries = ["'Espagne","'Italie","aFrance"]
var cIndex = 0
var initStringLength : Int? = 0
override func viewDidAppear(_ animated: Bool) {
titleLabel.text = "#CetEteJeVisiteL"
initStringLength = titleLabel.text?.count
animateText(countries[cIndex])
}
@wassim93
wassim93 / round corner.swift
Last active August 23, 2021 02:31
round corner only for top left-right
//Pay attention to the fact that if you have layout constraints attached to it, you must refresh this as follows in your UIView subclass:
override func layoutSubviews() {
super.layoutSubviews()
roundCorners(corners: [.topLeft, .topRight], radius: 3.0)
}
extension UIView {
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
@wassim93
wassim93 / automatic scroll collectionview.swift
Last active September 28, 2022 10:07
automatic scroll collectionview swift
@IBOutlet weak var collectionView: UICollectionView!
// fill your datasource array with data
var datasource: [] = []
override func viewDidLoad() {
super.viewDidLoad()
startTimer()
}
@wassim93
wassim93 / keyboard handling.swift
Last active August 23, 2021 02:32
keyboard handling swift
override func viewWillAppear(_ animated: Bool) {
NotificationCenter.default.addObserver(self,selector: #selector(self.keyboardDidShow(notification:)),
name: UIResponder.keyboardDidShowNotification, object: nil)
NotificationCenter.default.addObserver(self,selector: #selector(self.keyboardWillBeHidden(notification:)),
name: UIResponder.keyboardWillHideNotification, object: nil)
}
override func viewWillDisappear(_ animated: Bool) {