Skip to content

Instantly share code, notes, and snippets.

View almatri's full-sized avatar

Musa Almatri almatri

View GitHub Profile
class MyButton: UIButton {
var action: (() -> ())?
override init(frame: CGRect) {
super.init(frame: frame)
sharedInit()
}
required init?(coder aDecoder: NSCoder) {
//
// GradientView.swift
// Aura
//
// Created by Egor Sakhabaev on 23.07.17.
// Copyright © 2017 Egor Sakhabaev. All rights reserved.
//
import UIKit
@fmo91
fmo91 / AnalyticsManager.swift
Created February 23, 2017 03:44
Sample implementation of AnalyticsManager. See the blogpost in Medium
import Foundation
final class AnalyticsManager: AnalyticsService {
// MARK: - Properties -
// The list of services added to this class as observers.
internal private(set) var services = [AnalyticsService]()
// MARK: - Singleton -
static let instance = AnalyticsManager()
@sbishopwta
sbishopwta / gist:82b1726bc50992583dde04693de0515e
Created September 9, 2016 16:00
Swift 3 - Load JSON file
let filePath = Bundle.main.pathForResource("YOUR_FILE_NAME", ofType: "json", inDirectory: nil)
if let filePath = filePath {
do {
let fileUrl = URL(fileURLWithPath: filePath)
let jsonData = try Data(contentsOf: fileUrl, options: .mappedIfSafe)
let json = try? JSONSerialization.jsonObject(with: jsonData)
} catch {
print(error)
fatalError("Unable to read contents of the file url")
@alhazmy13
alhazmy13 / temp.md
Last active July 24, 2016 06:30
Run PHP script in background
  • Create a daemon configuration script under /etc/init ( NOT /etc/init.d ):-

nano /etc/init/mybot.conf

code sample:

description "MyBot Daemon"
author "alhazmy13"
start on startup
stop on shutdown