Skip to content

Instantly share code, notes, and snippets.

View Akhu's full-sized avatar
🏠
Working from home

Anthony Da Cruz Akhu

🏠
Working from home
View GitHub Profile
//
// PlistManager.swift
// Unsplash SwiftUI
//
// Created by Anthony Da cruz on 09/12/2023.
//
import Foundation
struct ConfigData: Codable {
@Akhu
Akhu / UIView + Effect.swift
Created May 12, 2017 09:37
Some effect compilation to apply to UIView
extension UIView {
func round(roundValue:CGFloat? = nil) {
if roundValue != nil {
layer.cornerRadius = roundValue!
}else {
layer.cornerRadius = self.layer.bounds.width/2
}
layer.masksToBounds = true
@Akhu
Akhu / Rest API Authentication and Retrier+Alamofire.swift
Last active May 19, 2017 13:04
Sample on how to manage authentication of an oauth api with alamofire and swift
//
// Authentication.swift
//
// Created by Anthony on 04/05/2017.
// Copyright © 2017 Aboutgoods. All rights reserved.
//
import Foundation
import Alamofire
@Akhu
Akhu / InvertMask+Layer.swift
Created May 12, 2017 12:53
Simple way to invert a mask on a layer with swift / quartzcore / ios
func mask(withRect rect: CGRect, inverse: Bool = false) {
let path = UIBezierPath(rect: rect)
let maskLayer = CAShapeLayer()
if inverse {
path.appendPath(UIBezierPath(rect: self.bounds))
maskLayer.fillRule = kCAFillRuleEvenOdd
}
maskLayer.path = path.CGPath
@Akhu
Akhu / browserNotification.js
Created May 12, 2017 12:59
A vanilla JS sample of browser notification
// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe(notificationText,notificationTitle) {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
@Akhu
Akhu / Router+Alamofire.swift
Created May 19, 2017 13:03
Simple Router built with Alamofire based on their documentation
//
// Router.swift
//
// Created by Anthony on 28/04/2017.
// Copyright © 2017 Anthony Da Cruz. All rights reserved.
//
import Foundation
import Alamofire
@Akhu
Akhu / coremltools Python configuration
Created June 9, 2017 05:06
Python coremltools env
virtualenv -p /usr/bin/python2.7 env
source env/bin/activate
pip install tensorflow
pip install keras==1.2.2
pip install coremltools
@Akhu
Akhu / Xcode .gitignore
Last active April 21, 2018 13:37
Gitignore for Xcode iOS project
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
Index/
## Various settings
@Akhu
Akhu / Get Meta Tags .js
Created May 2, 2018 18:06
Getting meta tag on a web page
function getMetaTags() {
var metas = document.getElementsByTagName('meta');
var ogMetasKey = "og:";
for(var i = 0; i < metas.length; i++){
if(metas[i] !== undefined){
var currentMeta = metas[i];
if(currentMeta.getAttribute('property') !== null && currentMeta.getAttribute('content') !== null){
if(currentMeta.getAttribute('property').indexOf(ogMetasKey) !== -1) {
@Akhu
Akhu / Custom Codable .swift
Created May 11, 2018 09:46
A custom codable implementation, especially the test of if the value is double or string or anything and code / decode things
//
// ExtractedData.swift
// AGKitDemo-Template
//
// Created by Anthony on 20/03/2018.
// Copyright © 2018 AboutGoods. All rights reserved.
//
import Foundation