Skip to content

Instantly share code, notes, and snippets.

View iMostfa's full-sized avatar
🤪
ⓘ 𝗢𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝘀𝘁𝗮𝘁𝗲𝗱 𝘁𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗳𝗮𝗹𝘀𝗲 𝗮𝗻𝗱 𝗺𝗶𝘀𝗹𝗲𝗮𝗱𝗶𝗻𝗴

iMostfa

🤪
ⓘ 𝗢𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝘀𝘁𝗮𝘁𝗲𝗱 𝘁𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗶𝘀 𝗳𝗮𝗹𝘀𝗲 𝗮𝗻𝗱 𝗺𝗶𝘀𝗹𝗲𝗮𝗱𝗶𝗻𝗴
View GitHub Profile
@iMostfa
iMostfa / AppDelegate.swift
Created February 7, 2020 15:18
Notifications Firebase
//In your app delegate, add the following
static var deviceID = String()
func messaging(_ messaging: Messaging, didRefreshRegistrationToken fcmToken: String) {
guard let newToken = InstanceID.instanceID().token() else {return}
AppDelegate.deviceID = newToken
connectToFCM()
}
@iMostfa
iMostfa / Combine.swift
Created August 20, 2020 19:48
flatMap without losing the value from upstream
import Combine
var moviessPublisher = ["James bond","abo elaraby","F.R.I.E.N.D.S","House Of Cards"]
.publisher
.eraseToAnyPublisher()
func rating(for movie: String) -> AnyPublisher<Int,Never> { //could be a restful api that takes movie name and return the rating
{
"watermark": {
"image": "MovielalaLogo",
"position": "topRight"
},
"topBar": {
"backgroundColor": ["#a60500b0", "#a60500a0"],
"elements": [
{
"type": "button",
@iMostfa
iMostfa / SimulatedAnnealing.swift
Last active April 30, 2021 20:44
Simulated Annealing for TSP
/// 1- Generate a random solution
func randomSolution(tspProblem: [[Int]]) -> [Int] {
var cities = Array(1...tspProblem.count)
var randomSoultion:[Int] = []
randomSoultion.append(1)
cities.removeAll(where: { $0 == 1})
for _ in 1 ..< tsp.count {
let randomCity = cities.shuffled().last!
import numpy as np
import matplotlib.pyplot as plt
from numpy.fft import fft, ifft
from pydub import AudioSegment
from playsound import playsound
from tkinter import *
from pydub.playback import play
import tkinter as tk
import numpy as np
import matplotlib.pyplot as plt
from numpy.fft import fft, ifft
from pydub import AudioSegment
from playsound import playsound
from tkinter import *
from pydub.playback import play
import tkinter as tk
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
# write your script here
# Navigate to DerivedData
cd /Users/vagrant/Library/Developer/Xcode/DerivedData/