Skip to content

Instantly share code, notes, and snippets.

View Bashta's full-sized avatar
🎯
Focusing

Erison Veshi Bashta

🎯
Focusing
  • Vlore
View GitHub Profile
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.
//
// UserRouter.swift
// GithubSearch
//
// Created by Er on 12/16/16.
//
import Alamofire
enum Router: URLRequestConvertible {
func dealCards() {
for _ in deck.cards {
for player in players {
player.addCard(card: deck.drawCard())
if deck.cards.count == 0 {
return
}
}
}
}
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)
static func showCameraRollFrom<T: UIViewController where T: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>>(viewController: T) {
}
extension NSDate {
func startOfDay(calendar: NSCalendar) -> NSDate {
return calendar.startOfDayForDate(self)
}
func endOfDay(calendar: NSCalendar) -> NSDate? {
let components = NSDateComponents()
components.day = 1
components.second = -1
return calendar.dateByAddingComponents(components, toDate: startOfDay(calendar), options: NSCalendarOptions())
@Bashta
Bashta / 0_reuse_code.js
Created July 25, 2016 15:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//
// PortionProgress.swift
// PortionProgress
//
// Created by Erison Veshi on 7/24/16.
// Copyright © 2016 Bashta. All rights reserved.
//
import UIKit
- (void)myInitialization
{
//do your stuff
}
- (id)initWithFrame:(CGRect)aRect
{
self = [super initWithFrame:aRect];
if (self)
let userProfileRequestParams = [ "fields" : "id, gender, name, picture, about"]
let userProfileRequest = FBSDKGraphRequest(graphPath: "me", parameters: userProfileRequestParams)
let graphConnection = FBSDKGraphRequestConnection()
graphConnection.addRequest(userProfileRequest, completionHandler: { (connection: FBSDKGraphRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
}
graphConnection.start()