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 UIKit | |
let scoresStringArray : [String] = ["Mike","Tom","Bily"] | |
let scoresDataArray = NSKeyedArchiver.archivedData(withRootObject: scoresStringArray) | |
//Save data | |
_ = Keychain.save(key: "scoresKey", data: scores) | |
//Load data | |
if Keychain.load(key: "scoresKey") != nil{ |
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
var win = Ti.UI.createWindow({ | |
backgroundColor: 'white', | |
top: 0, left: 0, right: 0, bottom: 0, | |
layout: "vertical" | |
}); | |
var button = Ti.UI.createButton({ | |
title: "click me" | |
}); | |
win.add(button); |
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 | |
func > (left: NSDate, right: NSDate) -> Bool { | |
return left.compare(right) == .OrderedDescending | |
} | |
extension NSCalendar { | |
func dateRange(startDate startDate: NSDate, endDate: NSDate, stepUnits: NSCalendarUnit, stepValue: Int) -> DateRange { | |
let dateRange = DateRange(calendar: self, startDate: startDate, endDate: endDate, stepUnits: stepUnits, stepValue: stepValue, multiplier: 0) | |
return dateRange |
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
using System.Security.Cryptography.X509Certificates; | |
using System.Security.Cryptography; | |
var abyPublicKey = AssemblyUtility.GetEmbeddedFileAsByteArray("WebServer.SslCertificate.cer"); | |
var abyPrivateKey = AssemblyUtility.GetEmbeddedFileAsByteArray("WebServer.SslCertificate.pvk"); | |
var certificate = new X509Certificate2(abyPublicKey, string.Empty, | |
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); | |
var cspParams = new CspParameters | |
{ |
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
var win = Ti.UI.createWindow({ | |
backgroundColor: '#333' | |
}); | |
var menuWidth = 200; | |
var container = Ti.UI.createScrollView({ | |
disableBounce: false, | |
horizontalBounce: true, | |
contentWidth: Ti.Platform.displayCaps.platformWidth + menuWidth |
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
// This is an example of use. | |
// Here we use the new Bearer Token thats make it possible to get tweets without user login | |
// More info on Bearer here: https://dev.twitter.com/docs/auth/application-only-auth | |
// Full Codebird API is here: https://github.com/mynetx/codebird-js | |
var Codebird = require("codebird"); | |
var cb = new Codebird(); | |
cb.setConsumerKey('CONSUMER_KEY', 'CONSUMER_SECRET_KEY'); | |
var bearerToken = Ti.App.Properties.getString('TwitterBearerToken', null); |
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
// | |
// Queue.swift | |
// NTBSwift | |
// | |
// Created by Kåre Morstøl on 11/07/14. | |
// | |
// Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks. | |
// should be an inner class of Queue, but inner classes and generics crash the compiler, SourceKit (repeatedly) and occasionally XCode. |
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
/** @jsx React.DOM */ | |
var LopMonHoc = React.createClass({ | |
getInitialState: function(){ | |
return {data: []} | |
}, | |
loadData: function(){ | |
$.ajax({ | |
url: '/daotao/lops', | |
success: function(data){ |
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
//By David Keegan | |
//InScopeApps.com | |
//http://inscopeapps.com/demos/flipbook/ | |
(function($){ | |
$.fn.flipbook = function(options){ | |
options = $.extend({ | |
'start': 0, //start frame | |
'end': 100, //end frame, must be greater then start | |
'step': 1, //number of frames to step over while animating |
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
// Adapted from Apple's Tech Note, [Modifying Image Metadata Without Recompressing Image](https://developer.apple.com/library/archive/qa/qa1895/_index.html). | |
import Cocoa | |
import ImageIO | |
let url = URL(fileURLWithPath: "/path/to/file.tiff") | |
guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { fatalError("Cannot create URL") } | |
guard var properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? Dictionary<CFString, Any> else { fatalError("Cannot get image properties") } | |
properties[kCGImageDestinationDateTime] = Date() |