Skip to content

Instantly share code, notes, and snippets.

View ahbou's full-sized avatar
shipping

Ahmed Bouchfaa ahbou

shipping
View GitHub Profile
@ahbou
ahbou / fresh-mac-setup.md
Created January 9, 2017 15:20 — forked from bernsno/cmal-fresh-mac-setup.md
Fresh Mac Setup

New Computer Setup

Last tested using Mac OS X 10.8 Mountain Lion

Before Wiping Original Install

  • Backup .ssh folder to avoid having to regenerate codes for services such as Heroku and Github.
{
af: { code: 'af', name: 'Afghanistan' },
ax: { code: 'ax', name: 'Åland Islands' },
al: { code: 'al', name: 'Albania' },
dz: { code: 'dz', name: 'Algeria' },
as: { code: 'as', name: 'American Samoa' },
ad: { code: 'ad', name: 'AndorrA' },
ao: { code: 'ao', name: 'Angola' },
ai: { code: 'ai', name: 'Anguilla' },
aq: { code: 'aq', name: 'Antarctica' },
@ahbou
ahbou / ReCodeSign
Created February 2, 2017 23:46 — forked from 0xc010d/ReCodeSign
Codesign an iOS app, with a different distribution certificate and mobileprovisioning file.
- Copy the delivered ipa into a directory to work in.
- export PlistBuddy="/usr/libexec/PlistBuddy" to get the PlistBuddy tool to your shell. If it is not added, all references to PlistBuddy
will need to be written as the full path.
- Take the delivered App.ipa and unzip it using the unzip command. This should produce a Payload directory containing the app and its
resources.
- Enter the command "codesign -d --entitlements :enterprise.plist Payload/PathToApp.app/" This pulls the entitlements out of the app, and
prints them to a plist, without a leading "blob" of data. Pay particular attention to the colon before the enterprise.plist file name.
@ahbou
ahbou / Storage.swift
Created September 17, 2017 10:23 — forked from saoudrizwan/Storage.swift
Helper class to easily store and retrieve Codable structs from/to disk. https://medium.com/@sdrzn/swift-4-codable-lets-make-things-even-easier-c793b6cf29e1
import Foundation
public class Storage {
fileprivate init() { }
enum Directory {
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
case documents
@ahbou
ahbou / ComposeView.swift
Last active July 12, 2019 03:30
iPhone X InputAccessoryView Fix
//
// ComposeView.swift
import UIKit
class ComposeView: UIView {
// ........
// Other layout code and methods
// ........
@ahbou
ahbou / WavPlayer.swift
Created October 12, 2017 08:18
Play .wav file in Swift
let ringtonePath = URL(fileURLWithPath: Bundle.main.path(forResource: "sound", ofType: "wav")!)
do {
let ringtonePlayer = try AVAudioPlayer(contentsOf: ringtonePath)
try AVAudioSession.sharedInstance().setActive(true)
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
ringtonePlayer.volume = 1.0
ringtonePlayer.play()
} catch {
print("Failed to initialize audio player \(error.localizedDescription)")
@ahbou
ahbou / HUD.swift
Last active October 28, 2019 09:14
Dead Simple HUD implementation in swift with a title and an Acitivity indicator
import UIKit
class HUD: UIView {
private lazy var backView: UIView = UIView(frame: bounds)
private let activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView(style: .whiteLarge)
private lazy var titleLabel: UILabel = {
let title = UILabel()
title.font = UIFont.boldSystemFont(ofSize: 16)
@ahbou
ahbou / UIWindow+Extension.swift
Created June 1, 2018 11:00
Animate UIWindow rootViewController switch
extension UIWindow {
func setRootViewController(_ rootViewController: UIViewController?, animated: Bool) {
guard let viewContoller = rootViewController else {
self.rootViewController = rootViewController
return
}
var snapShotView: UIView?
//
// UIView+RSKeyboardLayoutGuide.swift
// RSTouchUIKit
//
// Created by Daniel Jalkut on 12/23/18.
//
import UIKit
// Extends UIView to expose a keyboardLayoutGuide property that can be used to tie a view controller's content
@ahbou
ahbou / Log.swift
Created June 22, 2020 08:58
Swift logger with emoji
//
// Log.swift
//
//
import Foundation
class Log {
class func msg(message: String,
functionName: String = #function, fileNameWithPath: NSString = #file, lineNumber: Int = #line ) {