Skip to content

Instantly share code, notes, and snippets.

Erison Veshi Bashta

Block or report user

Report or block Bashta

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pre_push
#!/bin/sh
#
if [ -e ".updated_build_number" ] ; then
rm ".updated_build_number"
fi
View post_commit
#!/bin/sh
#
if [ ! -e ".updated_build_number" ] ; then
touch ".updated_build_number"
perl -i -pe 'BEGIN{undef $/;} s/\t<key>CFBundleVersion<\/key>\n\t<string>\K(\d+)/$1+1/em' ./xxxx/xxxx/Info.plist
git add ./xxxxx/xxxxx/Info.plist
git commit --amend
View DamageUpload.swift
func uploadDamageImage(imageData: Data, completion: @escaping UploadDamageImageCompletion) {
let url = "\(Config.shared.getBaseUrl())/api/images/damages"
print("Uploading damage image")
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(imageData, withName: "image", fileName: "dmg_image", mimeType: "image/jpg")
}, to: url,
method: .post,
encodingCompletion: { result in
View BookingStateUpdate.swift
private func updateState() {
// Make sure all the information is available
guard let rentalState = rentalState else {
self.state.value = .Unknown
return
}
let isPaymentInProgress = (paymentInProgress ?? false)
// Save whether address details should be shown before updating state
View BookingState.swift
enum BookingState: Int, Comparable {
// Booking states, mapped from backend state together with check-in/out status and
// payment progress.
//
// NOTE: Should also include review status, which is currently not yet implemented
// on the backend.
case Started = 0
case CheckOutStarted = 1
@Bashta
Bashta / SnappCameraView.swift
Last active Jun 28, 2019
Basic implementation of camera scanner for rectangles.
View SnappCameraView.swift
//
// SnappCameraView.swift
// EdgeDetection
//
// Created by er on 11/4/17.
// Copyright (c) 2017 Erison Veshi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
View DictionarySize.swift
let size = chacheDictionary.keys.reduce(0) { (result, key) -> Int in
return result + malloc_size(Unmanaged.passRetained(key as AnyObject).toOpaque()) + malloc_size(Unmanaged.passRetained(chacheDictionary[key] as AnyObject).toOpaque())
}
print(size)
//500bytes per obj in median.
View Router.swift
//
// UserRouter.swift
// GithubSearch
//
// Created by Er on 12/16/16.
//
import Alamofire
enum Router: URLRequestConvertible {
View TestDeal.swift
func dealCards() {
for _ in deck.cards {
for player in players {
player.addCard(card: deck.drawCard())
if deck.cards.count == 0 {
return
}
}
}
}
View Reachability.swift
import Foundation
import SystemConfiguration
public class Reachability {
class func isConnectedToNetwork() -> Bool {
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
You can’t perform that action at this time.