Skip to content

Instantly share code, notes, and snippets.

View necrowman's full-sized avatar
🏠
Working from home

Ruslan Yupyn necrowman

🏠
Working from home
View GitHub Profile
import Foundation
/*** How to create variables and constants */
var greeting = "Hello, playground"
var name = "Ted"
name = "Rebecca"
name = "Keeley"
let character = "Daphne"
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/necrowman/.gradle/caches/transforms-2/files-2.1/0037f3ef0376f5558a83f35172c94a4f/jetified-facebook-share-4.42.0/res/drawable/com_facebook_button_send_background.xml:27: AAPT: error: resource color/com_facebook_button_background_color_focused_disabled (aka com.robokit.heatlywaves:color/com_facebook_button_background_color_focused_disabled) not found.
@necrowman
necrowman / NSObject+FullDescription.h
Created February 14, 2019 13:33
Adding full description with properties list and their values... For Debugging Objective-C classes;
//
// NSObject+FullDescription.h
// DebuggingTools
//
// Created by Ruslan Yupyn on 2/14/19.
// Copyright © 2019 necrowman. All rights reserved.
//
#import <Foundation/Foundation.h>
func createURLWithComponents(with instance: String) -> URL? {
let urlComponents = NSURLComponents()
urlComponents.scheme = "https"
urlComponents.host = instance
urlComponents.path = "/some/path"
let key1 = URLQueryItem(name: "some_key", value: "some_value")
let key2 = URLQueryItem(name: "some_key_2", value: "123")
urlComponents.queryItems = [key1, key2]
@necrowman
necrowman / Lesson_062.swift
Last active December 4, 2017 18:26
Swift 4: LC - Sqrt(x)
// MARK: Sqrt(x)
/** Implement int sqrt(int x).
* Compute and return the square root of x.
* x is guaranteed to be a non-negative integer.
*
* ---------------------------------------------
* Example 1:
*
* Input: 4
@necrowman
necrowman / Lesson_061.swift
Created December 4, 2017 18:19
Swift 4: LC - Add Binary
// MARK: Add Binary
class Solution {
func addBinary2(_ a: String, _ b: String) -> String {
var minStr = a
var maxStr = b
if a.count > b.count {
minStr = b
maxStr = a
@necrowman
necrowman / Lesson_060.swift
Created December 4, 2017 09:46
Swift 4: LC - Plus One
// MARK: Plus One
class Solution {
func plusOne(_ digits: [Int]) -> [Int] {
var arr = digits
var newArr = [Int]()
var overClock = 0
let count = digits.count - 1
arr[count] = arr[count] + 1
for i in 0...count {
@necrowman
necrowman / Lesson_060.swift
Created December 3, 2017 21:37
Swift 4: LC - Length of Last Word
// MARK: Length of Last Word
class Solution {
func lengthOfLastWord(_ s: String) -> Int {
return s.isEmpty ? 0 : s.split(separator: " ").last?.count ?? 0
}
}
let s = Solution()
s.lengthOfLastWord("Hello World")
@necrowman
necrowman / Lesson_059.swift
Last active December 3, 2017 21:56
Swift 4: LC - Implement strStr()
// MARK: Implement strStr()
class Solution {
func strStr(_ haystack: String, _ needle: String) -> Int {
guard !needle.isEmpty else { return 0 }
if needle.count > haystack.count { return -1 }
for i in 0...(haystack.count-needle.count) {
let substr = String(Array(haystack)[i..<(i+needle.count)])
if substr == needle {
return i
@necrowman
necrowman / Lesson_058.swift
Created December 3, 2017 21:20
Swift 4: LC - Valid Palindrome
// MARK: Valid Palindrome
class Solution {
func isPalindrome(_ s: String) -> Bool {
let symbolsString = s.filter { ch in
return self.isCheckedSymbol(ch)
}
let symbols = symbolsString.lowercased().reversed()
return String(symbols) == String(symbols.reversed())
}