Skip to content

Instantly share code, notes, and snippets.

View w-i-n-s's full-sized avatar
🏠
Working from home

Sergey Vinogradov w-i-n-s

🏠
Working from home
  • Varna, Bulgaria
View GitHub Profile
@pietbrauer
pietbrauer / Makefile
Created April 26, 2015 10:03
Shutdown and reset all iOS Simulators
erase_sim:
./reset_sim.sh 2>/dev/null; true
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active May 2, 2024 08:41
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *info = @"http://codeafterhours.wordpress.com";
// Generation of QR code image
NSData *qrCodeData = [info dataUsingEncoding:NSISOLatin1StringEncoding]; // recommended encoding
CIFilter *qrCodeFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[qrCodeFilter setValue:qrCodeData forKey:@"inputMessage"];
@ozgurshn
ozgurshn / Networking.swift
Last active July 8, 2019 09:07
Networking Request in Xcode 8.0 Playground.
import UIKit
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let url = URL(string: "http://ip.jsontest.com/")!
let session = URLSession.shared()
let q = session.dataTask(with: url) { data, response, error in
do {
@shu223
shu223 / CustomActivity.swift
Last active November 4, 2020 17:59
Custom UIActivity in Swift 3
import UIKit
class CustomActivity: UIActivity {
override class var activityCategory: UIActivityCategory {
return .action
}
override var activityType: UIActivityType? {
guard let bundleId = Bundle.main.bundleIdentifier else {return nil}
@rd13
rd13 / .swift
Last active September 11, 2022 17:00
Copy database file from bundle to documents in Swift 3
func copyDatabaseIfNeeded() {
// Move database file from bundle to documents folder
let fileManager = FileManager.default
let documentsUrl = fileManager.urls(for: .documentDirectory,
in: .userDomainMask)
guard documentsUrl.count != 0 else {
return // Could not find documents URL
@khorbushko
khorbushko / PHPhotoLibrary+SaveImage
Created December 29, 2016 09:27
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
func save() {
@swhitty
swhitty / CGPathApply.swift
Created February 27, 2017 11:15
Bridges CoreGraphics.CGPathApplierFunction with a standard Swift closure
extension CGPath {
func apply(action: @escaping (CGPathElement)->()) {
var action = action
apply(info: &action) {
let action = $0!.bindMemory(to: ((CGPathElement)->()).self, capacity: 1).pointee
action($1.pointee)
}
}
}
@maltekrupa
maltekrupa / basic-auth.swift
Last active September 10, 2021 05:18
HTTP Basic Authentication using URLSession and URLCredentialStorage in swift 4 with xcode 9
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let credential = URLCredential(user: “username@gmail.com”, password: “password”, persistence: URLCredential.Persistence.forSession)
let protectionSpace = URLProtectionSpace(host: "example.com", port: 443, protocol: "https", realm: "Restricted", authenticationMethod: NSURLAuthenticationMethodHTTPBasic)
URLCredentialStorage.shared.setDefaultCredential(credential, for: protectionSpace)
let config = URLSessionConfiguration.default
@unnamedd
unnamedd / MacEditorTextView.swift
Last active April 16, 2024 10:18
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI