Random snippets of all sorts of code, mixed with a selection of help and advice.
How do I use mongoDB driver with C++ in Visual Studio 2022 vcpkg
10 April 2026 @ 11:30 pm
I'm having issues with Visual Studio not finding the mongocxx library. I've used vcpkg to install the driver and integrate it with Visual Studio. Steps I took include:
git clone https://github.com/microsoft/vcpkg.git
cd .\vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vcpkg install mongo-cxx-driver
Then going into Visual studio I try to use the library:
#include <mongocxx/v_noabi/mongocxx/instance.hpp>
(As for some reason mongocxx/instance.hpp doesn't show up as an option.)
Then I am met with these errors:
Severity Code Description Project File Line Suppression State Details
Error (active) E1696 cannot open source file "mongocxx/instance-fwd.hpp" CS499-DatabaseEnhancement-BlakeAllen C:\Users\issyr\vcpkg\installed\x64-windows\include\mongocxx\v_noabi\mongocxx\instance.hpp 19
Error (active) E1696 cannot open source file "mongocxx/logger-fw
Infinite sum involving a parameter
10 April 2026 @ 11:28 pm
How do I persuade SymPy to evaluate an infinite sum that I know SymPy should be able to do? For example, the following just gives back the unevaluated infinite sum:
a = Symbol('a',real=True)
Sum(1/(n**2+a**2),(n,1,oo)).doit()
However, I can trick SymPy by replacing the parameter a with an internal constant, e.g.
Sum(1/(n**2+exp(1)**2),(n,1,oo)).doit()
Since the expected result does not contain exp(1), I can pretend exp(1) is a parameter. I can check the result SymPy gives me by using exp(2), exp(3), etc, instead of exp(1). But this approach seems ridiculous. I feel like I'm missing something!
go/ast, insertion in file.Decls produces invalid code because of comment
10 April 2026 @ 11:27 pm
I want to create a new struct embedding original struct. But if original struct has comment, it gets placed in the middle of embed struct declaration.
Example code:
https://go.dev/play/p/8xqxpmNy2Qj
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
)
func main() {
src := `package demo
// Original comment
type Original struct {
Name string
}`
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "input.go", src, parser.ParseComments)
if err != nil {
panic(err)
}
original := "Original"
newName := "Embed"
// find original struct and insert before it
for i, decl := range file.Decls {
gen, ok := decl.(*ast.GenDecl)
if !ok || gen.Tok != token.TYPE {
continue
ggsave will accept systemfonts fonts in interactive mode but not in RScript
10 April 2026 @ 11:14 pm
I'm trying to apply custom fonts from the system (using the systemfonts library) to a plot made with ggplot2, and I want to be able to edit the program without messing around with the R console. However, ggsave causes the program to fail if it's not being run interactively. Modifying the program slightly to use png or agg_png (for identical output) instead of ggsave seemingly solves the problem, but I'd like to know why ggsave won't work with systemfonts in RScript and whether anything can be done about it.
Here's an example program:
library(tidyverse)
library(ragg)
library(systemfonts)
options(warn = 1)
mydata = tribble(
~type, ~quantity,
"Widgets", 1024,
"Gizmos", 826,
"Doodads", 1701
)
mydata |> ggplot() +
geom_bar(
stat = "identity",
aes(x
adding a float dictionary value to a variable that is a float
10 April 2026 @ 11:13 pm
Basically the dictionary I am using has a bunch of floats as the values to each key, I have everything down just my issue is that my variable is only saving the most recent value I pulled. I am sure that sounds confusing because I am not great at wording things so I will just provide my code. I am in the CS50 course so this is more just asking for a nudge in the right direction rather then a direct answer. I have also already tried using += instead of price = price + dict[char] it did not change anything really.
dict = {
"Baja Taco": 4.25,
"Burrito": 7.50,
"Bowl": 8.50,
"Nachos": 11.00,
"Quesadilla": 8.50,
"Super Burrito": 8.50,
"Super Quesadilla": 9.50,
"Taco": 3.00,
"Tortilla Salad": 8.00
}
help = 1
while help == 1:
try:
items = input("Items pls").lower().title()
itemlist = [""]
Swift - performBatchUpdates
10 April 2026 @ 10:56 pm
I noticed that when I update the size of a table cell, the table cell below sometimes seems to disappear. Could you please tell me how to fix this? Here's an example of such a layout. This behavior sometimes goes unnoticed for quite a long time, and sometimes almost constantly. I thought it was related to the cell and simplified it as much as possible, but even in this case, you can catch this behavior. What could be the cause?
I would be grateful for help, I've been dealing with this for a week now :(
enter image description here
class ViewController: UIViewController {
private var items: [String] = ["","","","","","","","","","","","","","","","","","","","","","
I cannot install unfree packages using nix-darwin
10 April 2026 @ 10:17 pm
Trying to use nix-darwin to install unfree packages. Current config looks like this:
{
description = "Example nix-darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
};
outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew }:
let
configuration = { pkgs, config, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
nixpkgs.config.allowunfree = true;
environment.systemPackages = with pkgs; [];
imports = [
./systemPackages.nix
./homebrew.nix
];
system.activationScripts.applications.text = let
env = pkgs.buildEnv {
name = "system-applications";
React context in external package not saving state
10 April 2026 @ 9:33 pm
I'm building an internal auth SDK that requires a configuration method to run before any of its other functionalities will work. I've put logs all over the place, and I've discovered that when I call that configuration method from my main project, it reaches the method in the package just fine, but then the useEffect that's supposed to respond to those states being set within the package goes off with the old state values. I'm at a loss for why this could be. I've ensured my context provider is at a high enough level in my main app, I've fiddled with the vite.config.ts file (which I currently suspect is the culprit), I've tried shuffling things around in the main app, I've tried removing the useCallback and useEffect hooks from the package and just used regular non-state-based operations (which still didn't work)... There are a bunch of other attempts I'm forgetting too. Here's everything I'm working with. In case it matters, the Auth SDK Packa
imges and text going outside the div box on window sizing smaller [closed]
10 April 2026 @ 8:21 pm
I have an issue where I simply want text and images to disappear at the edge of their containing div. Currently, when I shrink the window they scroll past the div.
Here are two images of what I'm dealing with. I'm not a CSS mavin, but I've tried things like overflow: hidden and things easily found on SO or web search. Things like word-wrap and break-word don't solve the issue of just wanting everything to disappear at the edge of the div.
I'm pretty sure there's a straightforward way to have the text and image disappear at the edge of the div like the edge of the window. Being able to resize the window is important to the site I'm developing I would like to learn the proper css so I can use this in several other places on the site.
I can't post images cause they are local on my machine. They simply show text clearly going past the div boundary and visible on the other side.
This is the current code, edited for brevit
the need to add a Content Providers / Developers (Indirect Users) as a system users
10 April 2026 @ 7:37 pm
For thesis of a graduation project for a mobile app i have to specific system users the app contains content like videos i am not sure to add Content Providers / Developers as a users of the app if they were not add how can we handle problems of content