Skip to content

Instantly share code, notes, and snippets.

View yannisalexiou's full-sized avatar
🎯
Focusing

Yannis Alexiou yannisalexiou

🎯
Focusing
View GitHub Profile
@yannisalexiou
yannisalexiou / JSONDecode+JSONMapping.swift
Created December 19, 2023 14:26
Simple JSON decoding using protocol and default implementation. With this you can separate the decodable logic from repository and api client
public enum DecodeError: Swift.Error {
case connectivity
case invalidData
}
protocol JSONDecodable {
static func jsonDecode<D: Decodable>(
_ data: Data,
from response: HTTPURLResponse
) throws -> D
@yannisalexiou
yannisalexiou / DelayedCompletionHandler.swift
Created December 19, 2023 14:23
A Swift protocol for adding customizable delayed completion to asynchronous operations, supporting generic result types.
protocol DelayedCompletionHandler {
// Define a generic method for delayed completion
func delayedCompletion<T>(
_ result: Result<T, Error>,
_ completion: @escaping (Result<T, Error>) -> Void
)
}
extension DelayedCompletionHandler {
// Generic function with a generic result type
@yannisalexiou
yannisalexiou / LoopingThroughFileReader.js
Last active May 7, 2019 05:45
This is a way to loop through FileReader by using th recursive function that reads the blob file.
var foo = new Blob(["Lorem ipsum dolor sit amet, consectetur adipiscing elit."], {
type: 'text/plain'
});
var bar = new Blob(["Sed tristique ipsum vitae consequat aliquet"], {
type: 'text/plain'
});
var arrayOfBlobs = [foo, bar];
var arrayIndex = 0;
@yannisalexiou
yannisalexiou / ChromeDinosaurGameCheat.js
Last active March 12, 2019 18:24
Chrome Dinosaur Game Cheat
//The below line of code let you pass all the obstacles on Chrome's Dinosaur Game, by jumping above them
//1. Open DevTools by pressing F12
//2. Start the game
//3. Paste and Run this line of code on DevTool's Console
Runner.instance_.tRex.config.GRAVITY = 0
//Return to the game and press jump (press SPACE)
//Now Dinosaur is above the game screen and you pass all the obstacles.