Skip to content

Instantly share code, notes, and snippets.

@akdsouza
akdsouza / gist:2b892f7c4bb9cad6ab64fea6d7fd74af
Created September 5, 2018 05:59 — forked from itsmattsoria/gistfil1.textile
Mac Terminal Cheat Sheet

SHORTCUTS

Key/Command Description
Tab Auto-complete files and folder names
Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + U Clear the line before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + W Delete the word before the cursor
Ctrl + T Swap the last two characters before the cursor
//
// MakeTransparentHoleOnOverlayView.swift
//
// Created by James Laurenstin on 2015-04-10.
// Copyright (c) 2015 Aldo Group Inc. All rights reserved.
//
import UIKit
class MakeTransparentHoleOnOverlayView: UIView {
extension AppDelegate {
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let audioCallIntent = userActivity.interaction?.intent as? INStartAudioCallIntent else {
return false
}
if let contact = audioCallIntent.contacts?.first {
import Intents
class IntentHandler: INExtension, INStartAudioCallIntentHandling {
func handle(intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartAudioCallIntent.self))
let response = INStartAudioCallIntentResponse(code: .continueInApp, userActivity: userActivity)
completion(response)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
INPreferences.requestSiriAuthorization { (status) in
if status == .authorized {
print("Siri access allowed")
} else {
print("Siri access denied")
import Foundation
import Intents
class DataManager {
static let sharedManager = DataManager()
static let sharedSuiteName = "group.com.akdsouza.SiriDemo"
let userDefaults = UserDefaults(suiteName: sharedSuiteName)
class IntentHandler: INExtension, INStartAudioCallIntentHandling {
func handle(intent: INStartAudioCallIntent, completion: @escaping (INStartAudioCallIntentResponse) -> Void) {
let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartAudioCallIntent.self))
let response = INStartAudioCallIntentResponse(code: .continueInApp, userActivity: userActivity)
completion(response)
}
func resolveContacts(for intent: INStartAudioCallIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) {
import Intents
class IntentHandler: INExtension, INStartAudioCallIntentHandling {
}
INPreferences.requestSiriAuthorization { (status) in
if status == .authorized {
print("Siri access allowed")
} else {
print("Siri access denied")
}
}
@akdsouza
akdsouza / AndroidOneColorImage.java
Created November 13, 2017 08:19 — forked from catehstn/AndroidOneColorImage.java
Android create one color image
/**
* A one color image.
* @param width
* @param height
* @param color
* @return A one color image with the given width and height.
*/
public static Bitmap createImage(int width, int height, int color) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);