Skip to content

u/yaazz

In this archive from Mar 2014 to Jan 2024

0
posts
397
comments
0
media
1.7k
score

Hi Hazgui, before submitting something like this I suggest

  • creating a readme.md file at the root of the codebase that explains what problems this code solves, and why it is useful to someone

  • replace the placeholder Wordpress doc block with something that explains what this plugin is used for and why it is useful.

You also might get more help by posting this to the Wordpress subreddit instead of this one.

Best of luck with your open source software.

15 points

Hi Colin, I was actually reading the source code for CommonMark a few months ago and remember seeing your name in there a lot.

Thanks a lot for this! I'll take a look and at the very least maybe I can learn from the regex and reuse it for my purposes

2 points

Hi nyamsprod, congrats on the release and thanks for supporting the community.

Question for you since you clearly know a lot about URIs. What would you say is the best way of extracting a URI substring from a larger string?

By that I mean you have a string that may or may not contain a URI, how would you go about detecting and returning this URI substring?

5 points

With Java and C++ experience (especially if it was web based Java) you shouldn’t have much trouble getting into PHP. I originally came to PHP from a mixture of C/C++ and I immediately felt right at home with the language.

There’s a lot of global methods that have the same names as their C based equivalent which I found pretty helpful.

If you’re looking for something OO heavy, I’d recommend checking out Symfony. If you’re more interested in something closer to Rails, I’d recommend checking out Laravel. Both frameworks are excellent it really comes down to how you want to build something which is better.

4 points

Cool project.

It might be good to create a small "sample.txt" file that contains a small sample of the training data.

If anyone is curious what the training data looks like, they can just look at the sample.txt file instead of nearly crashing their computer loading the full training file like I did!

6 points

Docker runs in a virtual machine on Mac meaning it is actually very slow compared to running natively/valet.

The local docker version is only ever going to have one user though so it doesn’t really matter that much and the productivity increase is more than worth it.

2 points

PHPStorm team, You have a great product most of the time, but as soon as you force me to change my UI I will start looking for an alternative.

The current UI is perfectly fine and every change you have ever made to it has made it worse. Please stop trying to optimize for a problem that doesn't exist and continue focussing on shipping features that make my job easier instead of making it harder.

39 points

I’ve build a route optimizer for a bus system before. Internally it used dykstras algorithm (https://en.m.wikipedia.org/wiki/Dijkstra%27s_algorithm) to determine the shortest path. The tricky part was figuring out the correct heuristic for what is considered “best path”.

For example, one problem the algorithm had was it could shave seconds/minutes off your A-B route all you had to do was transfer across four busses, but if you just stayed on the current bus, you would get there at almost exactly the same time haha.

2 points

That’s a cool way of handling this problem but not very useful in my case as the XML documents I work with are not a standard structure that you know about ahead of time. Is there any plans to add in wildcard support for variable sections of a document?

Example #[STR(‘/first/second/*/fourth’)]

3 points

While your method here certainly works, you could very easily accomplish this abstraction with a bog standard PHP class, no external library needed. The less external dependencies you have, the less work required to maintain an application, so I always try to avoid using them when I can.

Or, since you’re already pulling in composer libs, you could also just pull in a templating library and make this even simpler without having to do any of the steps listed here

10 points

You know what’s worse than thinking/realizing your code is crap? Thinking your code is amazing and that it cannot be improved in any way.

These are the two traits I’ve seen in every best and worst programmer I’ve ever met. A good general rule that I follow is that if you can’t go back to a project you worked on a few years back and be completely ashamed of the work you did then you are no longer improving

3 points

Action classes work by using the laravel IOC (dependency injection) to automatically load the class, along with any dependencies that action might have, by specifying the dependencies in the constructor of your action.

Sometimes, you might see that an action class might have another action class as a dependency, which might have its own actions as dependencies, etc. This means that the laravel IOC has to traverse through multiple levels of code files as well as all dependencies of those code files in order to instantiate your action.

The Laravel IOC works pretty well but isn’t exactly the speediest process in the world. Not a big deal when instantiating a couple things in a controller method, but performance can really can really add up if it needs to start traversing complicated scenarios.

Thankfully there’s an easy solution. Just use the bind method of the service container to tell the IOC exactly how to load these actions. That way the expensive traversal process can be bypassed completely.

https://laravel.com/docs/8.x/container#binding-basics

If I remember later on when I’m at a keyboard, I’ll post an example of what I mean

7 points

Action classes can call service methods internally giving you the best of both worlds!

Side note: If you wanna use actions make sure you tell the IOC how to load them using a provider as I’ve seen them get pretty performance heavy.

4 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.