This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
var isPalindrome: Bool { | |
let reversed = String( self.reversed() ) | |
for index in self.indices { | |
if self.lowercased()[index] != reversed.lowercased()[index] { | |
return false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Norsez Orankijanan on 17/5/2561 BE. | |
import UIKit | |
//MARK: a separate view controller for showing the search results works better with a storyboard or xib. | |
class ResultsTableViewController: UITableViewController { | |
var items = [String] () | |
let CELLID = "CELLID" | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/** | |
Extension to save/load a JSON object by filename. (".json" extension is assumed and automatically added.) | |
*/ | |
extension JSONSerialization { | |
static func loadJSON(withFilename filename: String) throws -> Any? { | |
let fm = FileManager.default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by norsez on 30/4/18. | |
import Foundation | |
struct RssItem { | |
var title = "unknown" | |
var categories: [String] = [] | |
var pubDate = "unknown" | |
var link = "http://" | |
var content = "<h1>Hello World</h1>" | |
var creator = "n.a." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loading post comments and likes by Norsez Orankijanan nor@telenordigital.com | |
# based on example by James Thornton, http://jamesthornton.com | |
# Facebook API Docs | |
# https://developers.facebook.com/docs/graph-api/using-graph-api#reading | |
# Get Your Facebook Access Token Here... | |
# https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me | |
# Before running this script... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Date { | |
static func ISOStringFromDate(date: Date) -> String { | |
let dateFormatter = DateFormatter() | |
dateFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dateFormatter.timeZone = TimeZone(abbreviation: "GMT") | |
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" | |
return dateFormatter.string(from: date).appending("Z") | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppKit | |
import AVFoundation | |
class MovieWriter: NSObject { | |
func writeImagesAsMovie(_ allImages: [NSImage], videoPath: String, videoSize: CGSize, videoFPS: Int32) { | |
// Create AVAssetWriter to write video | |
guard let assetWriter = createAssetWriter(videoPath, size: videoSize) else { | |
print("Error converting images to video: AVAssetWriter not created") | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func image(withRotation radians: CGFloat) -> UIImage { | |
let cgImage = self.cgImage! | |
let LARGEST_SIZE = CGFloat(max(self.size.width, self.size.height)) | |
let context = CGContext.init(data: nil, width:Int(LARGEST_SIZE), height:Int(LARGEST_SIZE), bitsPerComponent: cgImage.bitsPerComponent, bytesPerRow: 0, space: cgImage.colorSpace!, bitmapInfo: cgImage.bitmapInfo.rawValue)! | |
var drawRect = CGRect.zero | |
drawRect.size = self.size | |
let drawOrigin = CGPoint(x: (LARGEST_SIZE - self.size.width) * 0.5,y: (LARGEST_SIZE - self.size.height) * 0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sips -Z 640 *JPG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pod::Spec.new do |s| | |
s.name = 'BDDimGlassView' | |
s.version = '0.0.1' | |
s.license = 'BSD' | |
s.summary = 'Dim Glass bordered container for UIViews.' | |
s.description = 'description here.' | |
s.homepage = 'https://github.com/norsez' | |
s.author = {'Norsez Orankijanan' => 'norsez.github@gmail.com'} | |
#This is the revision of BitApp this app uses |
NewerOlder