Skip to content

Instantly share code, notes, and snippets.

View phynet's full-sized avatar
🤘
I said yeah.

Sofia Swidarowicz phynet

🤘
I said yeah.
View GitHub Profile
@phynet
phynet / parse-html-string.swift
Created October 5, 2017 15:44
parse html string to string in swift
import Foundation
import UIKit
@objc extension NSString {
class func parseHTMLString(stringHTML: String) -> NSString {
return try! NSAttributedString(
data: stringHTML.data(using: String.Encoding.unicode, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
#import "UIScreen+SizeScreenDevice.h"
#import "DeviceUtil.h"
//#warning [DeviceUtil hardware]
// pod DeviceUtil shows all iOS sizes...
typedef NS_ENUM(NSUInteger, DEVICE){
IPHONE4_4S,
IPHONE5_5S,
@phynet
phynet / raw-representable.swift
Created September 27, 2017 11:36
To use other value of enums rawValue: enum person -> person.RawValue is now person.string
extension RawRepresentable where RawValue == Int {
var number: Int {
return rawValue
}
}
extension RawRepresentable where RawValue == String {
var string: String {
return rawValue
}
@phynet
phynet / addColorString.swift
Last active August 9, 2017 07:53
Add color to a certain part of a string (or NSString)
func configureTextr() -> NSAttributedString{
let text = "first string"
let aviso = "second string"
let mainText = text! + " " + aviso!
let attributeText = aviso
let range = (mainText as NSString).range(of: attributeText!)
let attributedString = NSMutableAttributedString(string:mainText)
attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor.rentaliaLightBlue(withAlpha: 1), range: range)
return attributedString
@phynet
phynet / Golden
Created May 24, 2017 15:32 — forked from jaylyerly/Golden
Draw the Golden Spiral in Swift
let 𝜋 = M_PI
let ɸ = (1 + sqrt(5))/2
func drawTiles(tileCount: Int, height: Double, context: CGContext) {
let red = CGFloat(arc4random_uniform(100)) / 100.0
let green = CGFloat(arc4random_uniform(100)) / 100.0
let blue = CGFloat(arc4random_uniform(100)) / 100.0
context.setFillColor(red: red, green: green, blue: blue, alpha: 1.0)
let rect = CGRect(x: 0, y: 0, width: height, height: height) // CGFloat, Double, Int
@phynet
phynet / bridging-error.mkd
Last active August 13, 2020 20:35
implicit import bridging header in module is deprecated

now in swift 4 you just have to import a briding header into Test target and reference objc-class .h files there...using @testable import nameOfYourApp should work

In Swift there's a message in "Test Target" that states that the bridging header will be removed in newer versions of swift. I'm using mixed objc and swift clasess, but the UnitTest class is a swift file. Using @testable key was there in code

  @testable import YourProject

You fix it by adding in your Test area the bridging header with objc headers that your test will use:

@phynet
phynet / Log environment variables in xcode.mkd
Last active March 23, 2017 11:23
Log environment variables available in Xcode

To know all environment variables used for building in Xcode. Good to use with any run script use:

  1. Create a new Run Script Phase in Menu Build Phases option.
  2. Add export text inside
  3. Move the script after Target Dependcies
  4. Compile or Run
  5. Go to Navigation Pane (to the left) and select the Log navigator item (the last one in the series, looks like a bubble message)
  6. Check all the variables available in the message pane

Xcode Log env variables

@phynet
phynet / map-reduce-filter-flatMap.swift
Created March 19, 2017 16:54
Examples for flatMap, Map, Reduce, Filter in Swift
//reduce
//Use reduce to combine all items in a collection to create a single new value.
let numbers = [1, 3, 5, 7, 9]
//sum all values from the array (+)
let result = numbers.reduce(0, +)
//sum all values from the array (+) plus one
let result2 = numbers.reduce(1, +)
let result3 = numbers.reduce(1, *)
@phynet
phynet / server-ats-support.md
Last active March 2, 2017 14:49
ATS support

From Alejandro Ramírez

Does my server supports ATS?

 nscurl --ats-diagnostics https://m.foo.com/bar

The tool will run through several different combinations of ATS exceptions, trying a secure connection to the given host under each ATS configuration and reporting the result. The ATS configuration changes made by nscurl include:

• Turning on the “allow arbitrary loads” flag

• Dropping the minimum required TLS version to 1.1, then 1.0

@phynet
phynet / Type of Software Testing.mkd
Last active July 25, 2021 11:48
Different types of software testing

ACCEPTANCE TESTING

Testing to verify a product meets customer specified requirements. A customer usually does this type of testing on a product that is developed externally.

BLACK BOX TESTING

Testing without knowledge of the internal workings of the item being tested. Tests are usually functional.

COMPATIBILITY TESTING

Testing to ensure compatibility of an application or Web site with different browsers, OSs, and hardware platforms. Compatibility testing can be performed manually or can be driven by an automated functional or regression test suite.

CONFORMANCE TESTING