These are chat archives for mithriljs/mithril.js

3rd
Jan 2018
Isiah Meadows
@isiahmeadows
Jan 03 00:31
@JAForbes So true...
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:45
Hey all, I have a Flems.io-based crisis. Who wants a super-irritating puzzle to solve?
I'm really selling it, I know
spacejack
@spacejack
Jan 03 03:46
may as well just post it... no guarantees :)
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:49
I was helping a junior co-worker with a little carousel widget, and I very smartly had her sandboxing in flems. Then she started a for loop and it crashed, and no browser will allow her to extract her code.
Pretty impressive.
The harshness of the lock-up, I mean.
I'll buy a few beers for anyone who can just extract the .js and .css
spacejack
@spacejack
Jan 03 03:50
Maybe @porsager has a tool for that given the url
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:52
:+1: yeah, I pinged him first. I'm guessing he's asleep
Thanks for looking, regardless :smile:
spacejack
@spacejack
Jan 03 03:52
Run it in FF with the dev tools open
It'll let you stop it. I'm able to select/copy the sources
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:52
ok...
NICE!
Isiah Meadows
@isiahmeadows
Jan 03 03:54
BTW, Flems has an option in the upper right to stop automatic execution - I've used it more than once. :wink:
spacejack
@spacejack
Jan 03 03:55
@CreaturesInUnitards that work for you?
https://tinyurl.com/yc6uc9v3 <- has the JS commented out
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:55
I'm not able to copy the source...
oh NICE!
wait, that URL is invalid
spacejack
@spacejack
Jan 03 03:56
oops
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:57
@spacejack ROCK STAR! I owe you a few beers
spacejack
@spacejack
Jan 03 03:57
heh
Didn't firefox work for you?
It ran a couple seconds then the browser asked me if I wanted to stop the script
Scotty Simpson
@CreaturesInUnitards
Jan 03 03:58
I was able to stop the script, but I couldn't get to any of the sources
Mac thing maybe?
Dunno, doesn't matter. Jamie has stopped whining, so my night is SAVED. Thanks a ton!
spacejack
@spacejack
Jan 03 03:59
hehee: for ( var i=0; i<allItems.length; )
kinda silly you can lock up the browser with that
Scotty Simpson
@CreaturesInUnitards
Jan 03 04:01
yeah, she says she was in the middle of typing the rest
spacejack
@spacejack
Jan 03 04:01
oh lol!
pitfalls of auto-executing code editors
one more reason not to use for
Scotty Simpson
@CreaturesInUnitards
Jan 03 04:02
confirmed: just did it myself
Isiah Meadows
@isiahmeadows
Jan 03 04:09
@spacejack @CreaturesInUnitards You might want to note this.
Scotty Simpson
@CreaturesInUnitards
Jan 03 04:10
@isiahmeadows NICE! Doesn
*doesn't help when you're already locked up, though :stuck_out_tongue_winking_eye:
Thanks!
Isiah Meadows
@isiahmeadows
Jan 03 04:11
But it does help when you are recovering. I've had infinite loops crop up before, and just temporarily disabled updates. Keep in mind Flems doesn't update the URL until after a successful run, so that also helps.
By successful, I mean it loosely - thrown errors count as successful. If it doesn't terminate or even execute, then it doesn't count as successful.
@porsager You might want to leave a comment in relevant code ensuring the above if you haven't already, so it doesn't make people's lives impossible if things go wrong. :arrow_up:
Scotty Simpson
@CreaturesInUnitards
Jan 03 04:18
@isiahmeadows Outstanding! As always: thank you!
Isiah Meadows
@isiahmeadows
Jan 03 04:19
:+1:
Kevin Morotn
@TheSkyNet
Jan 03 07:29
what you all think of my new portfolio site its a WIP portfolio
Stephan Hoyer
@StephanHoyer
Jan 03 08:02
@tivac I'm happy to help with i18n stuff. Always looking for new ideas and improvements for translate.js.
BTW: We use translate keys as source strings, like
m('h2', t('dashboard.header.label'))
Barney Carroll
@barneycarroll
Jan 03 09:12
Hi @TheSkyNet on mobile the menu icons arearranged vertically, and the article cards have more left margin than right
Also you've typoed the 'magento' tag as 'magneto' ;)
Stephan Hoyer
@StephanHoyer
Jan 03 10:11
Common mistake. Done this all the time, when I worked with magento. We even considered creating a JS-shopping-cart framework called "magneto" :see_no_evil:
Barney Carroll
@barneycarroll
Jan 03 10:11
You could've done well out of that!
robinchew
@robinchew
Jan 03 10:21
hellody, wondering if there's a better way of incrementing a value in a stream. Something better than:
number = stream(0)
number(number() + 1)
I'm thinking something like:
number.update(n => n +1 );
Stephan Hoyer
@StephanHoyer
Jan 03 10:32
maybe inc = s => s(s() + 1) and then inc(number)
or number = number.map(n => n +1)
but than you have a new stream that depends on the old one
aren't the docs wrong here?
also for fantasy-land/map
Barney Carroll
@barneycarroll
Jan 03 10:38
Barney Carroll
@barneycarroll
Jan 03 10:51
@StephanHoyer the docs are typo'd for map, referencing of in the signature table
Stephan Hoyer
@StephanHoyer
Jan 03 10:51
yes, already fixed that
but I think the fl-of is also a little off
Barney Carroll
@barneycarroll
Jan 03 10:52
How so?
It should be static, not on the instance?
Stephan Hoyer
@StephanHoyer
Jan 03 10:52
stream = Stream["fantasy-land/of"](value)
yep
it also works on the instance tho
which is weird
Oh snap
It's documented for both, the instance and the factory
Stephan Hoyer
@StephanHoyer
Jan 03 10:58
I think the one on the instance is not needed to conform to fl-applicative spec
Dominik Dumaine
@Bondifrench
Jan 03 12:53
Kevin Morotn
@TheSkyNet
Jan 03 13:19
@barneycarroll thanks i've been working on the menu should look way nicer now
and yes there will be typos :) im prone to them :+1:
robinchew
@robinchew
Jan 03 13:36
thanks for the stream ideas
Stephan Hoyer
@StephanHoyer
Jan 03 13:36
@Bondifrench sounds like a serious issue :(
Scott
@ProtonScott
Jan 03 15:47
Hey guys has m.module been replaced with something?
Stephan Hoyer
@StephanHoyer
Jan 03 15:48
just m(myModule)
Scott
@ProtonScott
Jan 03 15:48
I ask only cause I’m looking at some older posts from lhorie about using velocity with mithril
That’s what i thought
Thanks @StephanHoyer
Are you the same @StephanHoyer that did the node render add on for mithril?
Scott
@ProtonScott
Jan 03 16:02
Just wanted to lend my thanks
Isiah Meadows
@isiahmeadows
Jan 03 16:31
@Bondifrench Not as bad as this, which 1. isn't even new, and 2. is trivially exploitable with system privileges (if you can gain system privileges, you don't even have to try). The only mitigation here is the high technical knowledge required, and/or BIOS systems implementing an update to set a breakpoint (which is a lot of computers that need patched). Note that they tested AMD processors as well as Intel.
For one, they demonstrated a PoC backdoor that mucks with hardware signature verification.
Patrik Johnson
@orbitbot
Jan 03 16:33
@ProtonScott if you're reading 0.2 blog posts and don't happen to be familiar with the 1.x api, the original migration guide might be good to keep handy
Isiah Meadows
@isiahmeadows
Jan 03 16:38
@Bondifrench Oh, and that presentation demonstrates the use of a backdoor via WebAssembly, and it's not something browsers can reliably patch.
Scott
@ProtonScott
Jan 03 16:57
@orbitbot thanks man!
Quick question if I may
Can attributes be functions that assign attributes based on a value? Eg {className: function(value){ if value === x return arr.classname}}?
Pseudo code obviously
But that’s the idea
Barney Carroll
@barneycarroll
Jan 03 17:01
@ProtonScott where are you expecting the value to come from?
Scott
@ProtonScott
Jan 03 17:02
JSON that gets processed after an m.request
@barneycarroll JSON that gets processed after an m.request. So my view function returns formatted lists that I would love to color based on on a comparator to one of the keys in that JSON
I have all the logic sorted out except this one piece: I could just render then color everything based on this since everything is already keyed but it’d be more alwfficient to do it somewhere in the render process I think
I’ve had some trouble with lifecycle methods attaching properly since I’m calling m.render and not m.mount for some reason
Scott
@ProtonScott
Jan 03 17:15
Hmm I’m gonna try another approach that might work better
Scotty Simpson
@CreaturesInUnitards
Jan 03 17:19
@ProtonScott you need to actually call the function. Then yes, that’s a pretty typical pattern
Sorry, I mean wrt your className example
Stephan Hoyer
@StephanHoyer
Jan 03 17:45
@ProtonScott yep, thanks
Barney Carroll
@barneycarroll
Jan 03 18:15
@ProtonScott what you want to do is make the results of the request available to the view and re-render when it resolves
Every part of the view is rendered at the same time
If you use m.mount, m.request will automatically redraw the component (which could just be a view that returns what you previously passed to m.render
That expression you're currently putting in a function can just be assigned to the class/className directly
Fred Daoud
@foxdonut
Jan 03 19:16
My apologies for this OT question: is anyone into cubing (Rubik's Cube) and has a recommendation for a stickerless speed cube?
Carl Mungazi
@CarlMungazi
Jan 03 23:29
Evening all. Was doing some reading today on simulating classes in JS vs using prototypal inheritance. Knocked up a very rudimentary and crude example using Mithril to demonstrate different ways of creating components this way. Felt good to use Mithril after months of doing Vue stuff :laughing:
Rasmus Porsager
@porsager
Jan 03 23:38
@CreaturesInUnitards Glad you got it sorted out ;) I've been wanting to think of something clever for those half-written for-loops and auto-reload.. Maybe pause auto reload if the cursor is inside parens of a for-loop :-P hehe..
@isiahmeadows not sure, what would you want me to leave a comment about specifically?
I've also been thinking about only updating the url after a successful load of the code.. That way a stuck for-loop could be fixed by a simple refresh... gotta try that out, and see how it works..
Isiah Meadows
@isiahmeadows
Jan 03 23:41
@porsager Basically, make sure to note the potential for the body to dive into an endless loop, in which you don't want to update the URL.
You more or less already got the gist of my idea independently of me just now, though. :smile:
Rasmus Porsager
@porsager
Jan 03 23:41
haha.. yeah I see :D I think that's a good solution! thanks!
Isiah Meadows
@isiahmeadows
Jan 03 23:42
It's already the case, though - I was just recommending dropping a comment in to know not to change it.
I'll note that you should allow saving runtime errors, though. Anything that's not a SyntaxError and terminates should be saved, even if it throws. (This is useful for testing Mithril bugs, BTW.)
Rasmus Porsager
@porsager
Jan 03 23:45
Yeah, definitely ! I'd also save syntax errors.. Maybe do a clamp on 400-5000ms with iframe load in between for saving...
Isiah Meadows
@isiahmeadows
Jan 03 23:46
Okay. That would also make sense. So basically, just save after termination.
Oh, and I do feel debouncing the iframe load would be useful for other reasons - it's a massive CPU drain while editing.
Rasmus Porsager
@porsager
Jan 03 23:47
It's currently at 400ms
Isiah Meadows
@isiahmeadows
Jan 03 23:47
Oh okay.
Rasmus Porsager
@porsager
Jan 03 23:48
Haven't noticed high cpu myself besides for a freaky safari bug...
Isiah Meadows
@isiahmeadows
Jan 03 23:48
So could you clarify what you mean by "put a clamp" in it?
I'm kind of lost.
Rasmus Porsager
@porsager
Jan 03 23:48
I mean minimum 400 ms debounce, or max 5000 wait for execution..
So if it finishes before 400ms it's still debounced, but if it's not done before 5seconds it'll save anyway (could be lost network connection not loading script etc..)
Isiah Meadows
@isiahmeadows
Jan 03 23:49
Oh okay. I would rather just wait until they quit typing, since it's likely to error when they're in the middle of typing.
Rasmus Porsager
@porsager
Jan 03 23:49
Yeah, that's before reloading the iframe, which currently has a 400ms debounce.. you think it's too short?
Isiah Meadows
@isiahmeadows
Jan 03 23:50
Yes, just a little.
Maybe 100ms more, and you should be good.
A lost network connection should have zero effect on your app beyond page accessibility unless remote resources are involved.
Rasmus Porsager
@porsager
Jan 03 23:51
No but if I want to wait for the iframe to load before updating the url, network connection, slow unpkg etc, could affect it, which is why i wanted the max for 5 seconds..
I'll try to up the debounce on typing to 500ms
Isiah Meadows
@isiahmeadows
Jan 03 23:54
If you find a script fails to load, you could just choose to abort everything. You could load scripts one at a time in sequence and know if things went wrong network-wise by if onload/onerror fires. That would also give you better knowledge and control over script execution, and you could make a better judgement call on whether to save. You could also use postMessage to know when user scripts themselves finishes executing.
Granted, I suspect you already have something in place to detect errors (to log them). You could alter that to know when execution stops.
Rasmus Porsager
@porsager
Jan 03 23:55
Yeah, I'm currently doing that, but I'd still like to save if there's a timeout on one of those scripts..
Isiah Meadows
@isiahmeadows
Jan 03 23:56
Okay.
Rasmus Porsager
@porsager
Jan 03 23:57
It's the difference of losing 5 seconds of typing vs. 2 minutes.. I know it's nitpicking and probably and extreme edge case, but might as well do it..
Isiah Meadows
@isiahmeadows
Jan 03 23:59
True.