This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ColorContext { | |
@available(iOS 13.0, *) | |
init(_ traitCollection: UITraitCollection, | |
defaultMode: Mode = .light, | |
defaultElevation: Elevation = .base, | |
defaultAccessibilityContrast: AccessibilityContrast = .normal) { | |
mode = { | |
switch traitCollection.userInterfaceStyle { | |
case .light: return .light | |
case .dark: return .dark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Takes as input something like https://scontent-mad1-1.xx.fbcdn.net/v/t1.0-9/37899360_1857828550996984_1194250836729921536_o.jpg?_nc_cat=0&oh=04a7e8328932298e0f6eeec0764cd5b0&oe=5BD2D7EB | |
function flatBoletim(boletim) { | |
const innerAssign = (target, ...sources) => { | |
sources.forEach(source => { | |
Object.keys(source).forEach(key => target[key] = Object.assign(target[key] || {}, source[key])) | |
}) | |
return target | |
} | |
const semesters = boletim.reduce((obj, current) => Object.assign({}, obj, {...current}), {}) | |
const entries = Object.entries(semesters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The goal is to create all letters using only !, [], {}, (), + and typeof | |
// Suggestions are welcome. | |
// Let's decrease the sizes! | |
// Big thanks to https://github.com/RedSparr0w, https://github.com/aemkei/jsfuck, and https://github.com/alcuadrado/hieroglyphy | |
const js = { | |
A: '(+![]+[][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]', | |
B: '(+![]+(![ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.toSafeProxy = function() { | |
const getter = (target, name, receiver) => { | |
const value = target[name] | |
if (value == null) { | |
return nullProxy(value) | |
} else if (typeof value === 'object') { | |
return value.toSafeProxy() | |
} else if (typeof value === 'function') { | |
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
image = Image.open('img.png').convert("RGBA") | |
pixels = image.getdata() | |
new_pixels = list(map(lambda item: (255, 255, 255, 0) if item[0] < 250 and item[1] < 250 and item[2] < 250 else item, pixels)) | |
image.putdata(new_pixels) | |
image.save("img2.png", "PNG") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Year { | |
noPadding = "y", | |
twoDigits = "yy", | |
fourDigits = "yyyy" | |
} | |
enum Quarter { | |
number = "Q", | |
zeroPaddedNumber = "QQ", | |
qAndNumber = "QQQ", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
struct EqualsMultiple<T: Equatable> { | |
let values: [T] | |
} | |
extension EqualsMultiple: ExpressibleByArrayLiteral { | |
typealias ArrayLiteralElement = T | |
init(arrayLiteral elements: T...) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PlaygroundSupport | |
enum PromiseState<T> { | |
case pending | |
case fulfilled(T) | |
case rejected(Error) | |
var isPending: Bool { | |
switch self { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
all_symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" | |
url = "http://protext.herokuapp.com/?text=" + all_symbols | |
request = requests.get(url) | |
parsed_html = BeautifulSoup(request.text, "html.parser") | |
all_keys = list(all_symbols) | |
all_values = list(parsed_html.find('h1').text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cartography | |
final class <#Name#>View: UIView { | |
init() { | |
super.init(frame: .zero) | |
self.buildViews() | |
} | |
required init?(coder aDecoder: NSCoder) { |
NewerOlder