Skip to content

Instantly share code, notes, and snippets.

View Callonski's full-sized avatar

Carl Engene Callonski

View GitHub Profile
let request = NSMutableURLRequest(url: URL(string: "")!)
let session = URLSession.shared
request.httpMethod = "GET"
let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in
print("Response: \(String(describing: response))")
print(error.debugDescription)
if(error != nil)
{
return
// Enkelt animation
UIView.animate(withDuration: 1, animations: {
})
// Animera med funktion efter klar
UIView.animate(withDuration: 0.2, animations: {
// Animera
}) { _ in
// Klarkod
}
@Callonski
Callonski / Main thread
Created September 20, 2017 14:37
For UI elements update
DispatchQueue.main.async(execute: {() -> Void in
})
@Callonski
Callonski / Iap
Last active October 2, 2017 12:27
In app purchase
class ViewController: UIViewController, SKProductsRequestDelegate, SKPaymentTransactionObserver {
let productIdentifiers = Set(["20diamonds", "premium"])
var productsArray = Array<SKProduct>()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Userdefaults group
let defaults = UserDefaults(suiteName: "group.sharing")!
if(defaults.object(forKey: "sharedUrl") != nil)
{
urlLabel.text = defaults.string(forKey: "sharedUrl")
}
// Share
@IBAction func letsShare(_ sender: AnyObject) {
import CoreData
var people: [NSManagedObject] = []
func deleteFromCD()
{
guard let appDelegate =
UIApplication.shared.delegate as? AppDelegate else {
return
}
// info.plist
// AppDelegate
import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
@Callonski
Callonski / gist:6af23e33b8c740c7ba0d061764391c9e
Created February 28, 2018 08:49
Pepes Permission klass
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.util.Log;
// Transaction for atomic execution into all tables
database.runTransaction(async (err, transaction) => {
if (err) {
console.error("Error running transaction: " + err);
return;
}
if (profileExists) {
const deleted = await deleteProfile(retailUnit, partyUId, transaction);
console.log(`Deleted customer ${deleted} ${partyUId}`);
resource "google_compute_instance" "elastic-instance-1" {
name = "elastic-instance-1"
machine_type = var.machine_type
zone = var.region_zone_d
allow_stopping_for_update = true
tags = var.network_tags
boot_disk {
initialize_params {
image = var.gce_image
size = 200