Skip to content

Instantly share code, notes, and snippets.

View cemolcay's full-sized avatar
🎼
🎶

Cem Olcay cemolcay

🎼
🎶
View GitHub Profile
@cemolcay
cemolcay / BlockTapView
Created February 25, 2015 08:02
uiview with tap gesture action
#import <UIKit/UIKit.h>
typedef void(^tapAction)(UITapGestureRecognizer *tap);
@interface BlockTapView : UIView
@property (copy) tapAction blockTapAction;
- (instancetype)initWithFrame:(CGRect)frame andAction:(tapAction)action;
@cemolcay
cemolcay / UIViewController+NavigationBarScrollingTitleView
Created February 27, 2015 10:13
Registers scroll view and label to navigation bar. Title attachs the navigation bar if scrolled out of screen
private var UIViewControllerRegisteredLabel: UInt8 = 0
private var UIViewControllerScrollTitleLabel: UInt8 = 1
extension UIViewController {
private var registeredLabel: UILabel? {
get {
return objc_getAssociatedObject(self, &UIViewControllerRegisteredLabel) as? UILabel
} set (value) {
objc_setAssociatedObject(self, &UIViewControllerRegisteredLabel, value, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
@cemolcay
cemolcay / transperentUINavigationBar
Created May 12, 2015 10:21
transparent uinavigationbar
navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.translucent = true
navigationController?.navigationBar.backgroundColor = UIColor.clearColor()
@cemolcay
cemolcay / SaveManager.swift
Last active December 12, 2019 19:46
NSUserDefaults Save Manager
// MARK: - Manager
class SaveManager {
// MARK: Singleton
private static let instance = SaveManager()
class func sharedInstance () -> SaveManager {
@cemolcay
cemolcay / KVOManager.swift
Created August 15, 2016 18:29
NSNotificationCenter wrapper in swift
import Foundation
enum KVOManagerNotificationType: String {
case StickerBought = "com.mojilala.Stickers.Keyboard.StickerBought"
}
class KVOManager: NSObject {
static let sharedManager = KVOManager()
func addObserver(
@cemolcay
cemolcay / renameFilesByStringSwap.sh
Created August 16, 2016 00:00
$ Rename files in a folder by replacing strings
for f in *.png; do mv "$f" "${f/ReplaceThisText/WithThisText}"; done
@cemolcay
cemolcay / NoiseMap.swift
Created November 13, 2016 16:56
Having fun with GKNoiseMap procedurally generated tile maps
//: Playground - noun: a place where people can play
import UIKit
import SpriteKit
import GameplayKit
enum NoiseTileType: CustomStringConvertible {
case ocean
case grass
case mountain
@cemolcay
cemolcay / ArcTextLayer.swift
Created January 22, 2017 22:03
Draws a curved string on a CALayer with angle, radius and text that you give.
import UIKit
// swift port of stackoverflow answer
// http://stackoverflow.com/a/31301238/2048130
extension CGFloat {
/** Degrees to Radian **/
var degrees: CGFloat {
return self * (180.0 / .pi)
}
@cemolcay
cemolcay / NSBezierPath port
Created February 1, 2017 10:48
UIBezierPath methods missing on NSBezierPath for swift 3
public struct NSRectCorner: OptionSet {
public let rawValue: UInt
public static let none = NSRectCorner(rawValue: 0)
public static let topLeft = NSRectCorner(rawValue: 1 << 0)
public static let topRight = NSRectCorner(rawValue: 1 << 1)
public static let bottomLeft = NSRectCorner(rawValue: 1 << 2)
public static let bottomRight = NSRectCorner(rawValue: 1 << 3)
public static var all: NSRectCorner {
return [.topLeft, .topRight, .bottomLeft, .bottomRight]
@cemolcay
cemolcay / TensorflowNOT.py
Created June 28, 2017 07:22
NOT logical problem with Tensorflow
from __future__ import absolute_import, division, print_function
import tensorflow as tf
import tflearn
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
# Logical NOT operator
X = [[0.], [1.]]