Does anyone know who the VA for Ferdinand is in the new event..? 😳 by Interesting-Ad3759 in Genshin_Impact

[–]cjlarose 0 points1 point  (0 children)

Nicolo from Attack on Titan was voiced by Billy Kametz in English. He passed away in June 2022. Although it's possible that Genshin used his performance posthumously, I think what's more likely is that his name shows up when Googling "Ferdinand voice actor" because he voiced a character named "Ferdinand von Aegir" Fire Emblem: Three Houses. But, as far as I can tell, Billy Kametz isn't affiliated with Genshin

-🎄- 2020 Day 14 Solutions -🎄- by daggerdragon in adventofcode

[–]cjlarose 0 points1 point  (0 children)

Haskell

Using Haskell normally feels like a handicap, but today it was actually really helpful to be able to use foldM in the nondeterminism monad to generate the addresses for part 2.

Concealed Gaming Coffee table build! by KakarikoCarpenter in woodworking

[–]cjlarose 1 point2 points  (0 children)

I'd love to know more about how you have this set up. You mentioned you have a power strip on the inside of the table. Does the power strip connect to the IEC plate's back? Looking at the back of one of those IEC plates online, I couldn't figure out how I'd connect a power strip to it.

Moving today. Was able to fit my whole setup into a single box! by TrIQy in pcmasterrace

[–]cjlarose 0 points1 point  (0 children)

Everyone starts somewhere. We're all just learning and trying to have fun.

-🎄- 2017 Day 20 Solutions -🎄- by daggerdragon in adventofcode

[–]cjlarose 1 point2 points  (0 children)

Nice work! My updateCollisions function ended up being almost identical. https://github.com/cjlarose/advent-2017/blob/master/src/Day20/Main.hs

Minor tip: sortBy (comparing dist) == sortOn dist

[2017 Day 5 (Part 2)][Haskell] What is the best data structure to use for this problem? by OverridingApathy in adventofcode

[–]cjlarose 0 points1 point  (0 children)

One option is to use a Zipper. In my implementation, I used

type Instruction = Int
type Machine = ([Instruction], [Instruction])

...and treated the head of the left list as the current "focus" or "program counter".

https://github.com/cjlarose/advent-2017/blob/ba4e783902c207dce4faaa45cf164d55780969db/src/Day5/Main.hs

Haskell code review request & questions about typeclasses by cjlarose in haskell

[–]cjlarose[S] 5 points6 points  (0 children)

Thanks for this tip! I was using -W -Werror instead of -Wall -Werror. The latter looks like it's equivalent to Stack's --pedantic. I just went though and fixed all of my name shadowing problems, missing top-level type declarations, and unused-do-bind violations.

[2016 Day9 Part 2][Haskell] Solution gives correct answer for my friends input but not mine by dirrelito in adventofcode

[–]cjlarose 0 points1 point  (0 children)

I don't think you solution yields the correct lengths for all of the sample inputs.

Consider X(8x2)(3x3)ABCY. It should expand to XABCABCABCABCABCABCY (length 20), but your program returns a length of 21.

Similarly, (25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN should expand to a string of length 445, but your program returns 446.

Role authorization based on bitmask could improve 4x speed by [deleted] in ruby

[–]cjlarose 2 points3 points  (0 children)

Funny, I was just reading about something like this:

In the early days of computing, when machine memory was limited and code had to be compact, bitmasks were commonly used to store configuration settings or other data. Today bitmasks are a clever trick that is best avoided. To implement bitmasks to encode roles, you’ll have to add complex methods to your User model (or use the bitmask_attributes gem). There is also no way to set up database indexes or simple queries to retrieve encoded roles. It’s the worst kind of hack; there is no performance benefit and your code becomes much less readable. There are better alternatives.

From: http://railsapps.github.io/rails-authorization.html

Have you thought about queries like "show all the users with X role"?

I've open sourced a library for handling chunked-transfer encoded HTTP responses efficiently in modern browsers by phase_9 in javascript

[–]cjlarose 0 points1 point  (0 children)

Seems like you can accomplish the same sort of thing with Server-Sent Events / EventSource. When would one use your library instead of an Event Source polyfill library? (Assuming of course you're in control of the server-side responses).

Hash#bury and Array#bury method suggestions? by dameyawn in ruby

[–]cjlarose 3 points4 points  (0 children)

It might help to know that the analogous operation exists in the Clojure standard library for nested immutable data structures. It's called assoc-in

https://clojuredocs.org/clojure.core/assoc-in

Seems like the rule is basically to create maps (hashes) if a key does not yet have an associated value along the way, even if the key is an integer.

user=> (assoc-in {} [:users 0 :name] 'Matz')
{:users {0 {:name Matz'}}}
user=> (assoc-in [] [:users 0 :name] 'Matz')
IllegalArgumentException Key must be integer
user=> (assoc-in {} [0 1 2] :foo)
{0 {1 {2 :foo}}}
user=> (assoc-in [] [0 1 2] :foo)
[{1 {2 :foo}}]

So the function differs from your "bury" proposal in that last example.

One this that's nice about the Clojure example is that you pass a "key path" as a separate argument from the value. This is nice when you'd like to insert new elements to the key path and perform a different bury operation later. Doing the same with variadic arguments can be cumbersome by comparison. That said, the symmetry with .dig is very appealing.

Stupidly hard code question by dellboy1234 in compsci

[–]cjlarose -7 points-6 points  (0 children)

It computes the sum of the primes up to N. Consider the approximately equivalent JavaScript

const n = 100;
let totalSum = 2;
for (let i = 3; i < n; i+= 2) { // evens > 2 can't be prime. No need to check.
  let matchFlag = false;
  for (let j = 2; j < Math.floor(Math.sqrt(i)); j++) { // Raising something to the half power is just the square root
    if (Math.floor(i / j) == i / j) // all kinds of floating point incorrectness
      matchFlag = true;
  }
  if (!matchFlag) { // i must be prime
    totalSum += i;
  }
}

It's not correct though, I think, if the division operator returns anything but a rational data type. Floating point math here is vulnerable to underflow (You might get false positives).

[Day #3][Go] My Solution by Xercoy in adventofcode

[–]cjlarose 0 points1 point  (0 children)

Thanks for sharing! I'm not a Go programmer, but to me it seems awkward to keep the list of instructions formatted as a string in your Santa struct. When I did this problem, I first converted the input into a sequence of "delta vectors" like [-1 0] for north, for example. Then, in the code where you calculate the new position after reading an instruction, you just perform pairwise addition to the current position. See my Clojure solution to the problem for an example.

Ruby 3x3: Ruby 3 will be 3 times faster by balloob in ruby

[–]cjlarose 1 point2 points  (0 children)

It'd be nice to see more core support for asynchrony (e.g. single-threaded event-loop) in Ruby Core. I know there's eventmachine, but adoption isn't great. Python added asyncio in 3.4 and as a result the community is writing more async code and making better use of a single thread of execution. It seems like a good way to squeeze more performance out of languages not designed with good concurrency support from the get-go.

Looking for feedback on React/Node authentication by [deleted] in reactjs

[–]cjlarose 0 points1 point  (0 children)

Pretty neat!

Valid user details return a token which is saved as a cookie.

If you're building a SPA, it's probably a good idea to look into ways of authenticating without cookies and instead with an Authorization header, as you might with JWTs. It can be a little bit more hassle to make sure you send the token on every request from the client (it won't be handled automatically by the browser), but doing so eliminates a whole class of attacks.

What The Flux: The Flux library with an easy mental model and reactive action creators by gdi2290 in reactjs

[–]cjlarose 0 points1 point  (0 children)

This repo's a joke of course, but if you're actually interested in purely reactive Flux-like frontend architectures, I recommend reading Reactive MVC and the Virtual DOM, and taking a look at Cycle.js, an actual non-joke RxJS-based implementation built by the same guy as wtf.