Skip to content

Instantly share code, notes, and snippets.

View mehdin13's full-sized avatar

Mehdi Negahban mehdin13

View GitHub Profile
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active July 4, 2024 21:53
Install v2ray on Bridge:(Ubuntu +18 via systemd) - Upstream (Ubuntu +18/CentOS +7 via docker)

پنل x-ui

پنل تحت وب مدیریت V2ray و ساخت کاربر و مدیریت سرور

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
 -v $PWD/cert/:/root/cert/ \
@IanKeen
IanKeen / Storage.swift
Last active June 11, 2024 08:35
PropertyWrapper: Storage to extend support for more types using `@AppStorage`
@propertyWrapper
struct Storage<T: AppStorageConvertible>: RawRepresentable {
var rawValue: String { wrappedValue.storedValue }
var wrappedValue: T
init?(rawValue: String) {
guard let value = T.init(rawValue) else { return nil }
self.wrappedValue = value
}
init(wrappedValue: T) {
#!/bin/bash
set -e
# !!!ONLY FOR MACOS!!!
# This script helps you to bypass VPN for specific CIDRs and domain names by adding a direct route to the default gateway for them.
# It also can be used to setup a killswitch. When killswitch is enabled, Only IP traffic to the VPN server (and other bypassed CIDRs) is allowed, All other packets would be dropped.
# Killswitch is powered by MacOS internal packet filter (PF) firewall.
# How to use?
@tadeha
tadeha / MapViewController.swift
Last active July 20, 2022 14:47
🗺Map View with Bottom Components for each Marker // Using Google Maps and written in Swift 5
//
// MapViewController.swift
//
// Created by Tadeh Alexani on 7/14/19.
// Copyright © 2019 Tadeh Alexani. All rights reserved.
//
import UIKit
import GoogleMaps
@SergLam
SergLam / UIDevice+Ext.swift
Created June 14, 2019 11:02
Detect iOS device model
public extension UIDevice {
enum DeviceModelName: String {
case undefined
case iPodTouch5
case iPodTouch6
case iPhone4
case iPhone4s
case iPhone5
@SergLam
SergLam / UIImageView+Ext.swift
Created April 17, 2019 12:44
Round image view with gradient border color
import UIKit
extension UIImageView {
func addCircleGradiendBorder(_ width: CGFloat) {
let gradient = CAGradientLayer()
gradient.frame = CGRect(origin: CGPoint.zero, size: bounds.size)
let colors: [CGColor] = [UIColor.supSoftGreenThree.cgColor, UIColor.supSoftGreenTwo.cgColor,
UIColor.supSoftGreen.cgColor, UIColor.supTea.cgColor,
UIColor.supAquaMarineTwo.cgColor, UIColor.supAquaMarineThree.cgColor,
@makzan
makzan / ViewController.swift
Created April 9, 2019 05:13
Demo on uploading image to PHP from Alamofire
//
// ViewController.swift
// Upload Image Example
//
import UIKit
import Alamofire
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@vikaskore
vikaskore / RecordAudioViewController.swift
Last active April 30, 2024 11:05
Record and Play audio in iOS Swift
//
// RecordAudioViewController.swift
// Samples
//
// Created by VikasK on 11/02/19.
// Copyright © 2019 Vikaskore Software. All rights reserved.
//
import UIKit
import AVFoundation
@UmairSharif99
UmairSharif99 / DownloadAndSaveAudioFile.swift
Last active July 21, 2024 18:08
Function to download audio file from url and save it in documents directory
func downloadAndSaveAudioFile(_ audioFile: String, completion: @escaping (String) -> Void) {
//Create directory if not present
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let documentDirectory = paths.first! as NSString
let soundDirPathString = documentDirectory.appendingPathComponent("Sounds")
do {
try FileManager.default.createDirectory(atPath: soundDirPathString, withIntermediateDirectories: true, attributes:nil)
print("directory created at \(soundDirPathString)")
@lpbas
lpbas / FadeView.swift
Last active July 24, 2024 05:07
Fade a UIView in iOS using Gradient (Swift Extension)
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What The Fuck You Want
// To Public License, Version 2, as published by Sam Hocevar. See
//
// http://sam.zoy.org/wtfpl/COPYING
//
// for more details.
//