Skip to content

Instantly share code, notes, and snippets.

View Nikoloutsos's full-sized avatar

Konstantinos Nikoloutsos Nikoloutsos

View GitHub Profile
// swiftlint:disable file_length
fileprivate func compareOptionals<T>(lhs: T?, rhs: T?, compare: (_ lhs: T, _ rhs: T) -> Bool) -> Bool {
switch (lhs, rhs) {
case let (lValue?, rValue?):
return compare(lValue, rValue)
case (nil, nil):
return true
default:
return false
}
// swiftlint:disable line_length
// swiftlint:disable variable_name
// ❤️ https://github.com/krzysztofzablocki/Sourcery/blob/master/Templates/Templates/AutoMockable.stencil
{% for import in argument.autoMockableImports %}
import {{ import }}
{% endfor %}
{% for import in argument.autoMockableTestableImports %}
@testable import {{ import }}
{% endfor %}
{% macro swiftifyMethodName name %}{{ name | replace:"(","_" | replace:")","" | replace:":","_" | replace:"`","" | snakeToCamelCase | lowerFirstWord }}{% endmacro %}
// Generated using Sourcery 1.6.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
class MyFirstDayAtMagicalSchool {
//MARK: boom1 transformed to frog-prefix
func frog_boom1() {}
//MARK: boom2 transformed to frog-prefix
func frog_boom2() {}
//MARK: boom3 transformed to frog-prefix
func frog_boom3(str: String, int: Int) {}
// sourcery: MyFirstSpell
protocol BoomProtocol {
func boom1()
func boom2() -> String
func boom3(str: String, int: Int)
func boom4(args: String...)
}
{% for type in types.protocols where type|annotated:"MyFirstSpell" %}
class MyFirstDayAtMagicalSchool {
{% for method in type.allMethods %}
//MARK: {{method.shortName}} transformed to frog-prefix
func frog_{{method.name}} {}
{%endfor%}
}
{% endfor %}
{% for type in types.protocols where type|annotated:"MyFirstSpell" %}
{% for method in type.allMethods %}
// I found method {{method.shortName}}
{%endfor%}
{% endfor %}
class FooProtocolMock: FooProtocol {
//MARK: - foo1
var foo1CallsCount = 0
var foo1Called: Bool {
return foo1CallsCount > 0
}
var foo1Closure: (() -> Void)?
func foo1() {
// sourcery: AutoMockable
protocol FooProtocol {
func foo1()
func foo2() -> String
func foo3(str: String, int: Int) -> Int
}
// sourcery: AutoMockable
protocol FooProtocol {
func foo1()
func foo2() -> String
func foo3(str: String, int: Int) -> Int
}
@Nikoloutsos
Nikoloutsos / script for sending push notification to android phone
Created November 20, 2020 22:56
Send push notification from firebase to android device
const GOOGLE_API_KEY = "XXXXX";
const GOOGLE_GCM_URL = "https://fcm.googleapis.com/fcm/send";
$fields = array(
'to' => $device_token,
'sound' => 'default',
'priority' => 'high',
'data' => array("title" => $this-title,
"message" => $this->message // You may add more data
)