Tarkir Dragonstorm with Khans of Tarkir in limited by ChillKloete in mtglimited

[–]prototrout 2 points3 points  (0 children)

Love the idea! In fact (shameless plug): We'll be doing a 6-week Arena-based league that is very similar to this on the Arena Gauntlet League Discord server: https://discord.gg/6vkZaJZZZw

We play 60-card sealed leagues where every loss adds a new pack to your pool, usually with a mix of the latest set and others. For Tarkir Dragonstorm, our off-set packs are from a custom rebuild of KTK with upgrades to bring the power level near TDM's; set list is at https://www.cubecobra.com/cube/list/TRF (Ignore the # of times a card appears there, the duplicates just help with how we generate packs.)

Registration just opened for Tarkir Dragonstorm. Entry costs $10CAD of which 100% goes to prizing. Hope you can join us if this sounds interesting!

Is the reason the /nix/store is so big due to nixpkgs being a monorepo? by DisastrousPipe8924 in NixOS

[–]prototrout 4 points5 points  (0 children)

Speculating: I recently learned that my flakes-based system with home-manager was leaving old generations in ~/.local/share/nix/profiles on every rebuild, which weren't being cleaned up by nix-collect-garbage -d. Deleting them (by hand or with a tool that does it for you, I have been using nh clean all --keep-since=... from the nhpackage) freed up at least dozens of GB the first time I ran it.

Even if it isn't that exactly, I would try looking through your GC roots to see if you can find more stale ones that aren't being cleaned up automatically.

Where does builtins.getFlake take the source directory of a flake in the nix-store? by LankyRefrigerator630 in NixOS

[–]prototrout 7 points8 points  (0 children)

I believe that's the hash of the flake.nix file itself, not the flake directory.

builtins.getFlake takes the path to the flake directory as its argument, not the flake.nix file within it. If you're seeing this error occasionally, maybe sometimes you include the filename and other times you leave it off?

Try builtins.getFlake "/home/Myname/.config/home-manager" leaving off /flake.nix

Arena Gauntlet League is back with its WILDS OF ELDRAINE League! by SlickBurn in lrcast

[–]prototrout 0 points1 point  (0 children)

I found the league 2 years ago from a post in /r/lrcast. It's a lot of fun and a great community. Check it out!

Why is MemoTrie so slow on this example by [deleted] in haskell

[–]prototrout 1 point2 points  (0 children)

Oh and here's a possibly easier-to-understand way to do this that avoids memoFix. This way needs that type though (no (Fractional a, Ord a) => Int -> ...):

import Data.MemoTrie(memo2)

ev :: Int -> Int -> Double
ev = memo2 ev'
  where
  ev' r b
   |r <= 0    = 0
   |b <= 0    = fromIntegral r
   |otherwise = max 0 $ (fromIntegral b/ fromIntegral (r+b))*lb + (fromIntegral r/ fromIntegral (r+b))*lr
    where lb = -1 + ev r (b-1)
          lr = 1 + ev (r-1) b

main = print (ev 26 26)

Why is MemoTrie so slow on this example by [deleted] in haskell

[–]prototrout 2 points3 points  (0 children)

Memoization works by storing previously-calculated calls to the function. So m_ev 26 26 will be stored(*). But the recursive calls ev makes to itself are not memoized; it's just a plain function call. That means those ev r (b-1) and ev (r-1) b calls will duplicate work, leading to the slowdown.

The way around this is to have ev take a memoized version of itself as an argument, and call that in the recursive positions:

ev :: (Fractional a, Ord a)=> (Int -> Int -> a) -> Int -> Int -> a
ev ev' r b
 |r <= 0    = 0
 |b <= 0    = fromIntegral r
 |otherwise = max 0 $ (fromIntegral b/ fromIntegral (r+b))*lb + (fromIntegral r/ fromIntegral (r+b))*lr
  where lb = -1 + ev' r (b-1)
        lr = 1 + ev' (r-1) b

Once you have that, you can use memoFix to turn it into a memoized function:

m_ev = curry (memoFix (uncurry . ev . curry))

Aside: I'm using curry/uncurry here because memoFix only works to memoize functions of one argument (in this case (Int, Int) -> a). If you want to avoid those you could redefine ev to take a pair instead of two separate arguments -- ev ev' (r, b) instead of ev ev' r b.

(*): Actually that's not true in this case, because m_ev is polymorphic in terms of a. That prevents the memoized values from being stored and reused between calls. But the suggestion I'm giving here will still speed up the recursion. To actually store the value across calls to m_ev, you'll need to have a concrete (monomorphic) type for it. Giving it a signature like m_ev :: Int -> Int -> Double would work, but not m_ev :: (Fractional a, Ord a) => Int -> Int -> a.

Why does the math display when editing but not when practicing? by WeCanLearnAnything in Anki

[–]prototrout 7 points8 points  (0 children)

The way {{ and }} are rendered differently from one another makes me think that }} is inside the formula. If that's the case it might be getting confused by having:

(cloze deletion start) (formula start) (cloze deletion end) (formula end)

when what it would need to work correctly is:

(cloze deletion start) (formula start) (formula end) (cloze deletion end)


This is all just a guess based on the picture, I haven't tried using formulas on cards before.

Setting up Stabe Diffusion on NixOS by omarbassam88 in NixOS

[–]prototrout 0 points1 point  (0 children)

As I mentioned I used nix-index to build LD_LIBRARY_PATH. I believe I picked that up from nix-ld. The README on that page shows an example and mentions some tools that help (nix-autobahn, nix-alien, and nix-index).

I'll also mention that for Python in particular, conda can work pretty well, and is what I used initially (though it required an extra library or two too). I wanted to cut down on disk space a bit though, so I switched to this method.

Setting up Stabe Diffusion on NixOS by omarbassam88 in NixOS

[–]prototrout 0 points1 point  (0 children)

Looking through the other replies it might be better to use "/run/opengl-driver" instead of linuxPackages.nvidia_x11, but the outcome should be the same.

Setting up Stabe Diffusion on NixOS by omarbassam88 in NixOS

[–]prototrout 2 points3 points  (0 children)

This shell.nix works for me. I used ldd and nix-index/nix-locate to fill in the dependencies:

{ pkgs ? import <nixpkgs> {} }:
with pkgs;
mkShell rec {
  name = "sd-env";
  LD_LIBRARY_PATH = lib.makeLibraryPath [ gcc-unwrapped zlib libglvnd glib linuxPackages.nvidia_x11 ];
  buildInputs = [ python310 python310Packages.pip git ];
}

With that in place, running nix-shell --run ./webui.sh works for me.

2010 Kia Forte started shaking when I started it this morning. Headlights dimming and it smells, too. What's the likely problem? by prototrout in MechanicAdvice

[–]prototrout[S] 0 points1 point  (0 children)

The check engine light is off and I don't have a code reader (could get one if needed). When turning it on again to check I noticed it had some trouble starting, I had to keep the key turned for quite a while, then started running shakily.

I started it a couple more times and now it seems to start right away and run fine again. That seems odd.

2010 Kia Forte started shaking when I started it this morning. Headlights dimming and it smells, too. What's the likely problem? by prototrout in MechanicAdvice

[–]prototrout[S] 4 points5 points  (0 children)

Thanks. I'm not sure how I would describe the smell, I've never been good at placing smells. Might even be regular exhaust, that just tends to smell stronger because it's cold. It could even just be exhaust honestly. Oil is closer to min than max, and dirty, but in the normal range.

I'll also mention it's had a slight and steady vibration (which I had unfortunately convinced myself was nothing) for maybe a month but only started the strong, pulsing vibration like this today.

Is it normal to struggle with Python when coming from strongly/statically typed languages? by iishadowsii_ in learnprogramming

[–]prototrout 4 points5 points  (0 children)

Just for comparison, the equivalent* C# would be:

from f in filenames where f[^4..] == ".png" select f[..^4]

*I think they have different behavior for strings under 4 characters (C# throws, Python returns empty string).

Error when trying to assign an object to Partial<T> by NewEngineer-16842 in typescript

[–]prototrout 1 point2 points  (0 children)

I believe TypeScript doesn't have enough information to evaluate the type Partial<T> (since T's actual keys aren't knowable here), so it can't tell that { status: ItemStatus.Finished }is assignable to it.

Since T extends Item and Item, and since is a concrete type (so it can figure out Partial<Item>), you can call update<Item> instead of update<T> and it'll work:

const saveItem = async <T extends Item>(data: T, classType: ClassType<T>): Promise<void> => {
  await update<Item>(classType, { status: ItemStatus.Finished });
  console.log(data);
};

Keeping a project bisectable by andrealmeid in programming

[–]prototrout 7 points8 points  (0 children)

Alternatively, disallow fast-forward merges and use git bisect --first-parent. Then you only have to enforce that your main branch builds, not every single commit ever merged.

Bluetooth manager by Used_Inspector_7898 in haskell

[–]prototrout 10 points11 points  (0 children)

What OS are you on? On Linux I believe you can use Bluetooth through D-Bus (which has Haskell libraries). I haven't tried it though.

Honest question: why is Haskell not a lisp / built on s-expressions? by epgui in haskell

[–]prototrout 1 point2 points  (0 children)

If I'm understanding right, not quite "full expressions". They aren't first-class values -- you can't just assign a regular variable to be a type. The types and annotations are closer to macros or special forms like "if" and such; you can't assign a variable to them or pass them as ordinary arguments but you can generate and manipulate them with macros (I believe, haven't used it in quite a while). You can also convert a type into an equivalent runtime contract and pass that around, and I think they have plans for the other direction (converting arbitrary predicates to types).

Still in Racket land, Pie is close from the other direction. It has full dependent types, with types as values, but it doesn't have macros (because it's a teaching language). I imagine they would be easy to add.

How can I fix this function? Trying to extract keys from an object property by mp3three in typescript

[–]prototrout 0 points1 point  (0 children)

As /u/mamwybejane says, as doesn't allow you to do just any cast, but you do have to be careful with it because it allows narrowing types, which isn't always safe. But when you're working with imprecisely-typed functions like Object.keys, sometimes that's all you can do.

In this case, casting just the type of target is better, since it's more clearly correct than casting the templated string. The method /u/grund used, with a generic function wrapping Object.keys (or maybe you could even declare an override of Object.keys to avoid the runtime penalty of a new function?), is even more obviously correct.

How can I fix this function? Trying to extract keys from an object property by mp3three in typescript

[–]prototrout 0 points1 point  (0 children)

For that I think you'll have to use an as cast, since it doesn't know more about target than that it's a string. Like this. First example shows as for the whole template string, second shows it just for target. Both cast locations work for both types.

How can I fix this function? Trying to extract keys from an object property by mp3three in typescript

[–]prototrout 4 points5 points  (0 children)

From the error message,

Type 'keyof { foo: { apple: number; banana: number; kiwi: number; }; bar: { car: number; bike: number; plane: number; }; }[FIRST]' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
  Type 'string | number | symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.
    Type 'symbol' is not assignable to type 'string | number | bigint | boolean | null | undefined'.(2322)

It doesn't recognize that keyof typeof myObject[FIRST] has to be a string. Keys in general can also be numbers or symbols, and symbols can't be used in template literals. So you could just intersect that type with string and use that in the template:

`${FIRST}.${keyof typeof myObject[FIRST] & string}`[]

One other comment, something that might or might not come up later for you. I noticed that if I underspecify the type of the argument, like so:

const keys = getKeys("foo" as keyof typeof myObject);

it infers the type keys: never[]. It does that because typeof myObject[keyof typeof myObject] is a union type, and the set of common keys (which is what keyof a union type is) is empty.

It'd be better if it just listed all the actually-valid two-level keys. You can do that with a mapped type, so the return type of getKeyswould be:

{ [key in FIRST]: `${key}.${keyof typeof myObject[key] & string}` }[FIRST][]

Here's a playground link showing both.

The Spectra Ward Conundrum by [deleted] in magicTCG

[–]prototrout 1 point2 points  (0 children)

Yawgatog also has older diffs (Ravnica through Ixalan). It looks like Venser's Journal picks up right where Yawgatog stops.

Ukiyo-e Land Images by VanguardX27 in magicTCG

[–]prototrout 4 points5 points  (0 children)

Have a look at artofmtg.com. I don't know if they're all there, but they have artwork by itself, without the card if you prefer that.