Skip to content

Instantly share code, notes, and snippets.

View ivangodfather's full-sized avatar
🍂

Ivan Ruiz ivangodfather

🍂
View GitHub Profile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>django.core.exceptions.ValidationError: [&#x27;No data returned!&#x27;] // Werkzeug Debugger</title>
<link rel="stylesheet" href="?__debugger__=yes&amp;cmd=resource&amp;f=style.css"
type="text/css">
<!-- We need to make sure this has a favicon so that the debugger does
not accidentally trigger a request to /favicon.ico which might
change the application's state. -->
{"AAPL":{"logo":{"url":"https://storage.googleapis.com/iexcloud-hl37opg/api/logos/AAPL.png"},"quote":{"symbol":"AAPL","companyName":"Apple, Inc.","primaryExchange":"NASDAQ","calculationPrice":"close","open":116.07,"openTime":1603200601220,"openSource":"official","close":117.51,"closeTime":1603224000705,"closeSource":"official","high":118.98,"highTime":1603238395210,"highSource":"15 minute delayed price","low":115.63,"lowTime":1603201026194,"lowSource":"15 minute delayed price","latestPrice":117.51,"latestSource":"Close","latestTime":"October 20, 2020","latestUpdate":1603224000705,"latestVolume":123867223,"iexRealtimePrice":117.41,"iexRealtimeSize":90,"iexLastUpdated":1603227094136,"delayedPrice":117.17,"delayedPriceTime":1603269926945,"oddLotDelayedPrice":117.49,"oddLotDelayedPriceTime":1603223999479,"extendedPrice":null,"extendedChange":null,"extendedChangePercent":0,"extendedPriceTime":null,"previousClose":115.98,"previousVolume":120639337,"change":1.53,"changePercent":1.319,"volume":0,"iexMarketPercent":1
struct ContentView: View {
var body: some View {
TabView() {
Text("Hello")
.onAppear {
print("multiple times called")
}
Text("Other")
}
import SwiftUI
import CoreData
struct RandomView: View {
var body: some View {
Text("Hi")
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
doSomething()
}
struct MyView: View {
@State var name = ""
init(..., name: String = "") {
self.name = name // Error
// In some cases i want to provide a name and assign it to my @State.
}
var body: some View {
import Combine
var cancellables = Set<AnyCancellable>()
let test = [1, 2, 3, 4].publisher
.delay(for: .seconds(2), scheduler: DispatchQueue.global())
.print()
.share()
test.sink { value in
func randomNum() -> AnyPublisher<Int, Never> {
return AnyPublisher<Int, Never> { seed in
seed.success(Int.random(in: 1...10))
}
}
func arrayWith(n: Int, k : Int) -> [Int] {
let elements = (1...n).map { $0 } // We only allow 1,2,3.... till n
var output = [Int]()
repeat {
output.removeAll()
for _ in 0..<n {
let validNumbers = elements.filter { $0 + output.reduce(0,+) <= k }
if let random = validNumbers.randomElement() {
output.append(random)
} else {
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
import SwiftUI
import Combine
import SwiftUI
import SwiftUI
extension View {
func badge(num: Int) -> some View {
return self.overlay(
ZStack(alignment: .topTrailing) {
Circle()
.fill(Color.red)
.frame(width: 24, height: 24)