Skip to content

Instantly share code, notes, and snippets.

View alansvits's full-sized avatar
🧭
seeker

Stas alansvits

🧭
seeker
View GitHub Profile
@alansvits
alansvits / .gitconfig
Last active September 9, 2024 09:44
dotfiles excerpt
[core]
pager = delta
[interactive]
diffFilter = delta --color-only --features=interactive
[delta]
features = decorations
[delta "interactive"]
@alansvits
alansvits / x_layout.keylayout
Created August 20, 2022 16:06 — forked from haosdent/x_layout.keylayout
Mac OS X Keyboard layout file, works in 10.11
<?xml version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--
Data generated Wed Mar 23 01:35:41 2022
Generated by kluchrtoxml_64 build 203
-->
<!--Last edited by Ukelele version 351 on 2022-03-23 at 01:45 (GMT+8)-->
@alansvits
alansvits / index.js
Last active September 21, 2020 07:18
testing-npx
#!/usr/bin/env node
console.log("Testing npx: 1 2 3")
@alansvits
alansvits / GitHub-Forking.md
Created September 6, 2020 06:23 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@alansvits
alansvits / UISearchBar+Extention.swift
Created April 28, 2019 13:05
setTextFieldColor of searchBar
import UIKit
extension UISearchBar {
private func getViewElement<T>(type: T.Type) -> T? {
let svs = subviews.flatMap { $0.subviews }
guard let element = (svs.filter { $0 is T }).first as? T else { return nil }
return element
}
@alansvits
alansvits / custom string converteble.swift
Created October 21, 2018 16:37
String description of object properties
import Foundation
extension CustomStringConvertible {
var description: String {
var description: String = "\(type(of: self))("
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {
@alansvits
alansvits / prepare:for:sender.swift
Created October 20, 2018 16:47
Example prepare:for:sender
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
//TODO: - TODO
if segue.identifier == "ShowCityWeather" {
let controller = segue.destination as! CityDetailViewController
controller.cityName = self.selectedCity
controller.dataController = self.dataController
controller.getDetailWeather(selectedCity)
}
}
@alansvits
alansvits / checkConnectionToNetwork.swift
Created October 19, 2018 18:13
Check for internet connection with Swift
import SystemConfiguration
public class Reachability {
class func isConnectedToNetwork() -> Bool {
var zeroAddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
zeroAddress.sin_len = UInt8(MemoryLayout.size(ofValue: zeroAddress))
zeroAddress.sin_family = sa_family_t(AF_INET)
@alansvits
alansvits / isFirstLaunch.swift
Created October 19, 2018 18:10
How to detect first time app launch on an iPhone
func isAppAlreadyLaunchedOnce()->Bool{
let defaults = UserDefaults.standard
if let isAppAlreadyLaunchedOnce = defaults.string(forKey: "isAppAlreadyLaunchedOnce"){
print("App already launched : \(isAppAlreadyLaunchedOnce)")
return true
}else{
defaults.set(true, forKey: "isAppAlreadyLaunchedOnce")
print("App launched first time")
return false
@alansvits
alansvits / File path fo Documents directory.swift
Last active October 15, 2018 17:45
File path fo Documents directory
print(FileManager.default.urls(for: .documentDirectory, in: .userDomainMask))
Output: [file:///Users/YOUR_USER_NAME/Library/Developer/CoreSimulator/Devices/E724A933-DEA6-46D5-A470-F9DC2DA71791/data/Containers/Data
/Application/14B57C59-89E4-49C2-8DDF-12BD13683351/Documents/]