Skip to content

Instantly share code, notes, and snippets.

View hamada147's full-sized avatar
🎯
Focusing

Ahmed Moussa hamada147

🎯
Focusing
View GitHub Profile
@hamada147
hamada147 / ViewController.swift
Last active June 18, 2020 22:23
How to check in UISlider function which Button is selected
/**
* be sure that the slider's continuous property is also set.
* On the other hand, if you don't want the event to fire as the user is sliding and only when they finish sliding,
* set continuous to NO (or uncheck in IB)
*/
class ViewController: UIViewController {
@IBOutlet weak var slider: UISlider!
override func viewDidLoad() {
super.viewDidLoad()
@hamada147
hamada147 / ViewController.swift
Last active December 27, 2021 10:22
Handle Select Cells in Collection View
class ViewController: UIViewController, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// Check whether there is any selected cell or not
if collectionView.indexPathsForSelectedItems?.count ?? 0 > 0 { // if there is an already selected cells
// check if selected cell indexPath is one of the indexPathsForSelectedItems
if collectionView.indexPathsForSelectedItems!.contains(indexPath) {
// if yes, deselect it
collectionView.deselectItem(at: indexPath, animated: true)
} else {
// if no, not specified what to do here => personal suggestion would be to update the selected cells
CreateComplaintRequest(departmentID=2, typeID=1, subject=543, message=234, postedFiles=[PostedFile(fileName=IMG_20200308_125515.jpg, mimeType=image/jpeg, bytesArray=/9j/4QG1RXhpZgAATU0AKgAAAAgABwEQAAIAAAAaAAAAYgEAAAQAAAABAAAEOAEBAAQAAAABAAAH
gAEyAAIAAAAUAAAAfAESAAMAAAABAAEAAIdpAAQAAAABAAAAlwEPAAIAAAAHAAAAkAAAAABBbmRy
b2lkIFNESyBidWlsdCBmb3IgeDg2ADIwMjA6MDM6MDggMTI6NTU6MTYAR29vZ2xlAAAQgp0ABQAA
AAEAAAFdgpoABQAAAAEAAAFlkpIAAgAAAAQxMzkAkpEAAgAAAAQxMzkAkpAAAgAAAAQxMzkAkgoA
BQAAAAEAAAFtkgkAAwAAAAEAAAAAiCcAAwAAAAEAZAAAkAQAAgAAABQAAAF1kAMAAgAAABQAAAGJ
oAMABAAAAAEAAAeApAMAAwAAAAEAAAAAoAIABAAAAAEAAAQ4kgIABQAAAAEAAAGdkgEACgAAAAEA
AAGlkAAABwAAAAQwMjIwAAAAAAAAARgAAABkAJiWgDuaygAAABOIAAAD6DIwMjA6MDM6MDggMTI6
NTU6MTYAMjAyMDowMzowOCAxMjo1NToxNgAAAAEpAAAAZAAAGfMAAAPo/+AAEEpGSUYAAQEAAAEA
AQAA/9sAQwACAQEBAQECAQEBAgICAgIEAwICAgIFBAQDBAYFBgYGBQYGBgcJCAYHCQcGBggLCAkK
CgoKCgYICwwLCgwJCgoK/9sAQwECAgICAgIFAwMFCgcGBwoKCgoKCgoKCgoKCgoKCgoKCgoKCgoK
@hamada147
hamada147 / test.swift
Created November 29, 2019 16:00
Using Swift JSONSerialization along with JSONDecoder
struct OccType: Codable {
var id: Int = 0
var type: String = ""
var createdAt: String? = nil
var updatedAt: String? = nil
var image: String? = nil
enum CodingKeys: String, CodingKey {
case id, type
case createdAt = "created_at"
@hamada147
hamada147 / Book.swift
Created August 7, 2019 00:30
Explaining how to work with XML in iOS with Swift 4.2
class Book {
var bookTitle: String = String()
var bookAuthor: String = String()
}
@hamada147
hamada147 / detect incognito mode.js
Created May 19, 2019 22:32
detect incognito mode (private browsing).js
var fs = window.RequestFileSystem || window.webkitRequestFileSystem;
if (fs == null || fs == undefined) {
console.log("check failed");
}
fs(window.TEMPORARY, 100, function() {
console.log("Not in Incognito mode");
}, function() {
console.log("In Incognito mode");
});
/**
*
* @author Ahmed Moussa
*/
public class JavaApplication1 {
String name;
int age;
public JavaApplication1() {
<?php
$soap_request = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dood="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/DooDecompReceiveOrderExternalComposite" xmlns:mod="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/model/" xmlns:mod1="http://xmlns.oracle.com/apps/scm/doo/processOrder/model/">
<soapenv:Header />
<soapenv:Body>
<dood:process>
<dood:OrchestrationOrderRequest>
<!--Optional:-->
<mod:SourceTransactionIdentifier>moussa.ahmed95@gmail.com</mod:SourceTransactionIdentifier>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dood="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/DooDecompReceiveOrderExternalComposite" xmlns:mod="http://xmlns.oracle.com/apps/scm/doo/decomposition/receiveTransform/receiveSalesOrder/model/" xmlns:mod1="http://xmlns.oracle.com/apps/scm/doo/processOrder/model/">
<soapenv:Header />
<soapenv:Body>
<dood:process>
<dood:OrchestrationOrderRequest>
<!--Optional:-->
<mod:SourceTransactionIdentifier>moussa.ahmed95@gmail.com</mod:SourceTransactionIdentifier>
<mod:SourceTransactionSystem>OPS</mod:SourceTransactionSystem>
<mod:SourceTransactionNumber>100006</mod:SourceTransactionNumber>
@hamada147
hamada147 / Utils.swift
Last active November 11, 2018 09:49
Add ++ & -- operators to Int in Swift 4
infix operator ++
infix operator --
extension Int {
/// decress the value by one
///
/// - Parameter num: value to decress
static prefix func --(_ num: inout Int) -> Int {
num -= 1