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
// 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 |
import SwiftUI | |
private let linkDetector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) | |
struct LinkColoredText: View { | |
enum Component { | |
case text(String) | |
case link(String, URL) | |
} | |
import Combine | |
import CoreData | |
extension NSManagedObjectContext { | |
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>) | |
-> ManagedObjectChangesPublisher<Object> | |
{ | |
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self) | |
} | |
} |
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"net" | |
"net/url" | |
"os" | |
"path" |
{ | |
"version": "https://jsonfeed.org/version/1", | |
"title": "My Example Feed", | |
"home_page_url": "https://example.org/", | |
"feed_url": "https://example.org/feed.json", | |
"items": [ | |
{ | |
"id": "3", | |
"content_html": "<p>This is a test post with an image:</p><img src=\"https://i.imgur.com/VBnsOdM.jpg\">", | |
"url": "https://example.org/3" |
I hereby claim:
To claim this, I am signing this object:
var express = require('express'); | |
var app = express(); | |
var router1 = express.Router(); | |
router1.use(function (req, res, next) { | |
console.log('router1 middleware called.'); | |
next(); | |
}); | |
router1.get('/1', function (req, res) { |
function deansi(log) { | |
var ansi, text; | |
log = log.replace(/\r\r/g, '\r').replace(/\033\[K\r/g, '\r').replace(/\[2K/g, '').replace(/\033\(B/g, '').replace(/\033\[\d+G/g, ''); | |
ansi = ansiparse(log); | |
text = ''; | |
ansi.forEach(function(part) { | |
var classes = []; | |
part.foreground && classes.push(part.foreground); | |
part.background && classes.push('bg-' + part.background); | |
part.bold && classes.push('bold'); |
[operation setWillSendRequestForAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) { | |
[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; | |
}]; |