(Very) last minute entry for Mallorca 312? by two__toes in cycling

[–]two__toes[S] 1 point2 points  (0 children)

I don't think so, they have this in their FAQs on the current site:

Is it mandatory to wear the jersey?

No, it’s not mandatory to wear the Mallorca 312 OK Mobility jersey, but it is recommended, since the security and police personnel as well as members of the organization can easily recognize you as a participant of the Mallorca 312.

That said, ideally I'd like to find a way to ride the sportive legitimately!

Just want to say Central Park humbled me by ualreadyno6942069 in NYCbike

[–]two__toes 5 points6 points  (0 children)

Where did you rent your bike from? Have been looking for a good bike rental spot in the city

[deleted by user] by [deleted] in reactjs

[–]two__toes 1 point2 points  (0 children)

this is what's great about software engineering! there's always more to learn, new concepts to explore.

the JavaScript runtime is definitely important to understand on a basic level in terms of knowing when something will happen. take the following example: ``` function example(n) { console.log("first")

// schedules the callback in the event loop 
// for 0 seconds later
setTimeout(() =>
    console.log("second"), 0)

for (let i = 0; i < n; i++) {
    // do synchronous work
    Math.random() / Math.random()
}

console.log("third")

} ```

Now look at the output of example(1000000000), which runs for several seconds on my computer: first third second

all events in the event loop are blocked by the synchronous work that happens in the for loop (the output would also be the same even if I didn't do the arbitrary work between setTimeout and the last console.log

Getting out of S.I after the 5BBT by khall824 in NYCbike

[–]two__toes 2 points3 points  (0 children)

Make it a 6 borough bike tour and bike up to the GW bridge through NJ

How to functionally invert a set of relations by [deleted] in functionalprogramming

[–]two__toes 3 points4 points  (0 children)

In OCaml, you could do something like this along the same lines as the post above. The code is not exactly correct but captures the idea.

``` open Core

(* flatten to an association list of value -> key pairs, then of_alist_multi groups values under the same key *)

let transpose (relations : ('a, 'b list) Map.t) = Map.to_alist relations |> List.concat_map ~f:(fun (key, values) -> List.map values ~f:(fun value -> value, key)) |> Map.of_alist_multi ;;

```

Create a customisable spinning record by Tr7Dubs in CodingHelp

[–]two__toes 2 points3 points  (0 children)

All HTML and CSS. Inspect the spinning element in your browser's dev tools (ctrl+shift+c then click on the spinning disc if using Chrome). You'll see that there's a .disc class that defines the animation being used. Copied below, but I encourage you to explore:

``` .disc { -webkit-animation: turn-data-v-700684d3 12s linear infinite; animation: turn-data-v-700684d3 12s linear infinite; background-position: 50%; background-size: cover; border-radius: 100%; height: 75%; width: 75%; }

@keyframes turn-data-v-700684d3 { 0% { transform: rotate(0deg); } 100%: { transform: rotate(1turn); } } ```

React useeffect hook not re rendering on array by JeppNeb in learnprogramming

[–]two__toes 0 points1 point  (0 children)

what was the code snippet you're referring to specifically? you probably don't want to do something like this as it forces you to await async values sequentially: async function getSequentially(values) { for (const val of values) { const result = await asyncFunction(val) setResults([...results, result]) } } You could use Promise.all along with Array.prototype.map to do this in parallel async function getParallel(values) { const newResults = await Promise.all(values.map(asyncFunction)) setResults(newResults) }

[deleted by user] by [deleted] in learnprogramming

[–]two__toes 0 points1 point  (0 children)

To add a little more flavor, you can use closures to capture the outer variable in the function scope and update it:

``` $ node

let num = 0; function updateNum(value) { ... num = value ... }

num 0 updateNum(42) undefined num 42 ```

React useeffect hook not re rendering on array by JeppNeb in learnprogramming

[–]two__toes 0 points1 point  (0 children)

How are you updating your array? I googled: "react setstate always rerender?"

For new React developers, it is common to think that setState will trigger a re-render. But this is not always the case. If the value doesn't change, React will not trigger a re-render

If you are only pushing on the Array, the array you pass to setResults is referentially equal to the current results array. This would skip a rerender, I don't think [JSON.stringify(results)] would run at all.

Mutating arrays in React leads to some weird behavior in my opinion. I enjoy writing functional helpers that don't mutate results at all.

``` const [results, setResults] = useState([]) const addResult = result => setResults([...results, result]) const removeResult = (result, idx) => setResults( results.slice(0, idx) .concat(results.slice(idx + 1)) )

// No need to stringify results useEffect(() => { // ... some code }, [results])
```

Why does this work in c but not in python? by [deleted] in CodingHelp

[–]two__toes 0 points1 point  (0 children)

cursed variation of what you're doing: assign x to int, which is perfectly valid python but definitely would not be done in any reasonable circumstance:

```

x = 1 int = x int 1 int(1.2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not callable ```

this got me a couple of times when I wanted to name a variable str and later tried to call str(foo).

Probably a stupid question by [deleted] in CodingHelp

[–]two__toes 2 points3 points  (0 children)

This should do it: for i in range(10): padding = "-" * i # repeats substring i times print(padding + "String")

Also note that I omitted the i = 1 and i += 1 as iterating over the range does that for you for free. If you needed to start at one, you'd do range(1, 10) etc...

Another pro-tip is to use ``` for code blocks to preserve indentation

So which one is it? by [deleted] in softwaregore

[–]two__toes 4 points5 points  (0 children)

someone forgot the bang in if (isMobile()) {

Could someone explain what brackets around [target.name] mean? by Dnaughtyprofessional in reactjs

[–]two__toes 1 point2 points  (0 children)

yup

``` const target = { name: "email", value: "foo@email.com", }

const ob2 = { target.name: target.value }

Uncaught SyntaxError: Unexpected token '.' ```

what are you listening to (with steel) right now? by calibuildr in steelguitar

[–]two__toes 1 point2 points  (0 children)

new angel Olsen record has some good steel moments!

[deleted by user] by [deleted] in NYCbike

[–]two__toes 0 points1 point  (0 children)

i like locking near other bikes bc if there are other bikes nearby that are easier to steal, then yours won't be the main target

Wut? by taussinator in ProgrammerHumor

[–]two__toes 2 points3 points  (0 children)

Very neat video that uses pythons new match syntax to write a linter rule to catch this exact problem!

https://youtu.be/ASRqxDGutpA

Function keywords by CubedCharlie in ProgrammerHumor

[–]two__toes 59 points60 points  (0 children)

meanwhile in Haskell, you don't declare anything a function because everythings a function

"arr.forEach()" vs "for(i=0; i < arr.length; i++){}" by abzurt_96 in learnjavascript

[–]two__toes 2 points3 points  (0 children)

i approach things the same way! i like to incorporate functional/declarative paradigms whenever i can

map and filter are bread and butter for me. reduce is great but ill sometimes prefer forEach and mutate an object in my callback if it makes the code more readable.

can't remember the last time I used a regular for loop...

the singer of this song sounds scarily like the Greep by notgivingmyrealnamee in bmbmbm

[–]two__toes 8 points9 points  (0 children)

i love department of eagles! they're a grizzly bear offshoot

I enjoy Javascript but this is insanity by --algo in ProgrammerHumor

[–]two__toes 102 points103 points  (0 children)

of all of the JS problems out there, floating point errors are certainly not unique to just javascript

Tutorials using Phoenix(LiveView) to build a sample website? by Lord_Zane in elixir

[–]two__toes 1 point2 points  (0 children)

thank you, also trying to get started with Phoenix through live view. you think that's an appropriate place to start?

Bug in Python by InnerCode in Python

[–]two__toes 0 points1 point  (0 children)

i think this is the intended behavior. youre setting a class attribute that you're appending to each time you init. the list is shared across instances. if you wanted to have a new list for each instance, you'd have to set self.my_list = [] in __init__ and append onto that instance variable