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
// See http://mindsea.com/2012/12/18/downscaling-huge-alassets-without-fear-of-sigkill for details | |
#import <AssetsLibrary/AssetsLibrary.h> | |
#import <ImageIO/ImageIO.h> | |
// Helper methods for thumbnailForAsset:maxPixelSize: | |
static size_t getAssetBytesCallback(void *info, void *buffer, off_t position, size_t count) { | |
ALAssetRepresentation *rep = (__bridge id)info; | |
NSError *error = 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
module LambdasSVG where | |
import System.IO | |
import Data.String | |
import System.Random | |
writeSVG :: [String] -> String | |
writeSVG [] = error "No data to be written" | |
writeSVG xs = "<svg xmlns=\"http://www.w3.org/2000/svg\">" ++ foldr (++) "" xs ++ "</svg>" |
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
// | |
// MySynchronousOperation.swift | |
// operationqueues | |
// | |
// Created by Barbara Rodeker on 3/3/16. | |
// Copyright © 2016 Barbara M. Rodeker. All rights reserved. | |
// | |
// This program is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or |
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
require 'telegram/bot' | |
require 'google_places' | |
token = 'YOUR-TOKEN-FOR-BOT' | |
@googleClient = GooglePlaces::Client.new('YOUR-GOOGLE-PLACES-TOKEN') | |
Telegram::Bot::Client.run(token) do |bot| | |
bot.listen do |message| | |
if message.location | |
l = message.location |
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 how you could use standar user defaults for sharing app between your app and your extensions. | |
/// You should have groups capability enable in your app and extensions and use the same group name everywhere. | |
/// For more info see: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html | |
/// -initWithSuiteName: initializes an instance of NSUserDefaults that searches the shared preferences search list for the domain 'suitename'. For example, using the identifier of an application group will cause the receiver to search the preferences for that group. Passing the current application's bundle identifier, NSGlobalDomain, or the corresponding CFPreferences constants is an error. Passing nil will search the default search list. | |
if let defaults = UserDefaults(suiteName: "yourapp.group.name") { | |
defaults.set("VALUE", forKey: "KEY") | |
} |
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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// In iOS 8 and later, apps that use either local or remote notifications must register the types of user interactions the app supports. Apps can ask to badge icons, display alert messages, or play sounds. When you request any of these interaction types, the system checks the types of interactions the user has allowed for your app. If the user has disallowed a particular type of interaction, the system ignores attempts to interact with the user in that way. | |
// The user can change the notification settings for your app at any time using the Settings app. Because settings can change, always call the registerUserNotificationSettings: at launch time and use the application:didRegisterUserNotificationSettings: method to get the response. | |
let center = UNUserNotificationCenter.current() | |
center.requestAuthorization(opt |
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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// In iOS 8 and later, apps that use either local or remote notifications must register the types of user interactions the app supports. Apps can ask to badge icons, display alert messages, or play sounds. When you request any of these interaction types, the system checks the types of interactions the user has allowed for your app. If the user has disallowed a particular type of interaction, the system ignores attempts to interact with the user in that way. | |
// The user can change the notification settings for your app at any time using the Settings app. Because settings can change, always call the registerUserNotificationSettings: at launch time and use the application:didRegisterUserNotificationSettings: method to get the response. | |
let center = UNUserNotificationCenter.current() | |
center.requestAuthorization(opt |
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
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | |
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) | |
print(deviceTokenString) | |
//TODO: forward the token to your servers | |
// Optionally: registerNotificationCategories() | |
} |
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
// iOS 10 working way to fade in a blurred view (changing alpha in the container does not work on iOS 10) | |
let effectView = UIVisualEffectView() | |
effectView.frame = toast.bounds | |
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
view.addSubview(effectView) //replace view with whatever view you want to blur | |
UIView.animate(withDuration: 0.2) { | |
let blur = UIBlurEffect(style: .light) | |
effectView.effect = blur |
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
let effectView = UIVisualEffectView() | |
effectView.frame = view.bounds | |
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
view.addSubview(effectView) | |
let e = UIBlurEffect(style: .dark) | |
effectView.effect = e |
OlderNewer