The code below is not specific to any one Advent of Code problem, but instead is used by some or all of the problems.
defmodule AdventOfCode do
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"net" | |
"net/url" | |
"os" | |
"path" |
import Combine | |
import CoreData | |
extension NSManagedObjectContext { | |
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>) | |
-> ManagedObjectChangesPublisher<Object> | |
{ | |
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self) | |
} | |
} |
import SwiftUI | |
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) | |
struct LinkColoredText: View { | |
enum Component { | |
case text(String) | |
case link(String, URL) | |
} |
// If you run this in a playground in Xcode 12, you can see the difference in behavior in the live view. | |
import SwiftUI | |
import PlaygroundSupport | |
class Counter: ObservableObject { | |
@Published var count: Int | |
init(_ initialCount: Int) { | |
self.count = initialCount |
$argon2id$v=19$m=512,t=256,p=1$d3XjcqcR4lhyw3L25YD6zg$N8AG7sZMQC8CUvo1nAEwO3tkCedOf0uEpj7nafgiiKQ
defmodule UdsBlockExample do | |
def test_socket() do | |
{:ok, socket} = :gen_udp.open(0, [:local, {:active, false}]) | |
for i <- 0..100000 do | |
packet = ["#{i} hello " |> List.duplicate(100), "\n"] | |
:gen_udp.send(socket, {:local, "/tmp/test.sock"}, 0, packet) | |
receive do | |
{:inet_reply, _port, _ref} = msg -> |