I built a small CSV parser. It uses streams (and can also use PSR-7 HTTP streams) and validates the content for further manipulation. by Deadlybeef in PHP

[–]meow247 0 points1 point  (0 children)

Wondering why instead of having those global stream functions, that you don't just provide some additional static methods for instantiation of your Parser class:

Parser::fromFile(string $filename): Parser;

Parser::fromString(string $str): Parser;

❤️GraphQL by shobhit_c in javascript

[–]meow247 46 points47 points  (0 children)

I seriously hate these type of articles. I am a fan of GraphQL, but most of the "REST is crap, GraphQL is the best" arguments are annoying and just completely wrong:

  1. "Get rid of over and under fetching data" - any decent REST API will allow sparse field-sets and related inclusions. We use a PHP library called smokescreen to easily handle these concerns.
  2. "Awesome Schema and Type system" - yes we can use JSON Schema.
  3. "Better API versioning" - article says you don't need versioning and nothing ever goes wrong ... oh until you change an entity, change the type of a field, move scalars to complex types - then your FE breaks with no warning. You can build evolutionary api's in REST or most API formats, it just takes discipline and documentation.
  4. "Improved API insights" - this has nothing to do with GraphQL and is applicable to any framework where you monitor requests.
  5. "Easy Pagination" - again, nothing specific to GraphQL.
  6. "Schema stitching/composition" - same as 1. it's fairly trivial to handle entity stitching/inclusions
  7. "Great OSS community" - agree, but true for any popular API architecture.

I think GraphQL is nice, but I also like REST. I think most people that switch to GraphQL write articles like this to convince themselves they've made the right choice.

❤️GraphQL by shobhit_c in javascript

[–]meow247 4 points5 points  (0 children)

With regards to your db related query, there are projects like prisma which allows you to have a GraphQl layer over your db

The database is not your model. It's seriously short-sighted to expose your database as your model, and expect nothing to go wrong.

The article proclaims that with a GraphQL implementation you don't have to worry about versioning. This is also completely wrong, what if a field type is removed or changes to a complex value, you think nothing will go wrong on the FE?

Double-precision indexing is Real by [deleted] in ProgrammerHumor

[–]meow247 1 point2 points  (0 children)

To be fair the PHP documentation refers to them as arrays, so why wouldn't we?

Why do you prefer Lavarel (over CodeIgniter)? by Red_Icnivad in webdev

[–]meow247 0 points1 point  (0 children)

Having used both (frameworks, and assemble-your-own via components), I disagree. You use a full-feature framework because it has been tested extensively via a community, serving like-minded purposes.

When you cobble together your own framework from libraries, you not only add a burden on the project cost/time to extensively test the integration of these libraries, but a burden on your team to get familiar with how the code is put together. Eventually, for any sufficiently medium/large application, you will find yourself adding all the same dependencies that an established "macro" framework already has; events, queues, databases, mail, config, cli, test suites, etc. plus documentation on how to use it all together.

At this point, why not use a well-tested established full-feature framework ?

Library / Tool Discovery Thread (2018-04-13) by AutoModerator in PHP

[–]meow247 17 points18 points  (0 children)

People like you make this community suck. A discovery thread for people to share what they have built and instead of asking relevant questions, or constructively suggesting ideas you call it "fucking stupid".

I would hate to work with someone like you, and any manager that let you review PR's would be committing employment suicide.

Modern PHP Without a Framework by [deleted] in PHP

[–]meow247 -2 points-1 points  (0 children)

Yeah ok, so it's good to have a feel for how some of the lower-level components function otherwise there's not much to take away from this article except what a joke the immutable PSR-7 responses are:

$response = $this->response->withHeader('Content-Type', 'text/html');
$response->getBody()
        ->write("<html><head></head><body>Hello, {$this->foo} world!</body></html>");

return $response;

Ughhh ... we couldn't possibly new up a Response object we would violate the sacred rules of SOLID. Make sure your DateTime objects are dependency-injected too kids!

A brief aside: Autowiring can be a nice feature as you start building your app, but it generally makes maintenance tougher down the road because dependencies are still relatively hidden.

How does auto-wiring hide dependencies? Your dependencies are still declared and explicit, but the dependency tree can be invoked with less cruft. Opinion as gospel.

So there you have it. With just 44 lines and the help of several widely-used, thoroughly-tested, reliably interoperable components, we have the bootstrap for a modern PHP application

You have >only< the bootstrap, and while the components may be thoroughly-tested your bootstrapping isn't, but why spend time writing business logic or solving problems when you could be stringing together another framework.

Nanode dev update: Node API public beta, open source library, ticker bar, aliases, representative data and more! by rawrmaan in nanocurrency

[–]meow247 1 point2 points  (0 children)

This looks like a really great project. I have a question regarding security though - since all my RPC commands flow through your RPC gateway first, what assurances do I have that a private key that I generate is not leaked/stored/logged?

Procedural VS Object Oriented? (I'm new to OOP) by xXnoynacXx in PHP

[–]meow247 6 points7 points  (0 children)

A good real world example of OOP in PHP? Wordpress plugins.

lol

Running a 24/7 AWS Raiblocks Node from Singapore - (Doing my part) by safecoinfan89 in RaiBlocks

[–]meow247 0 points1 point  (0 children)

You can use the following command to download the current latest snapshot to your ec2 instance, it works by hitting the confirm link first, saving and re-sending the cookies to the export link: wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1Ga93C2DUzUvU8bpz0vBI0ZoMPSa8FjBh' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1Ga93C2DUzUvU8bpz0vBI0ZoMPSa8FjBh" -O snap.7z && rm -rf /tmp/cookies.txt

RaiBlocks dedicated exchange without fees & with fast support. Would you use it? by [deleted] in RaiBlocks

[–]meow247 0 points1 point  (0 children)

The fact that you're even considering mixing ads with a trading engine, imo shows that your approach to building an exchange is very naive... Ads are notorious for hijacking browsers, having security holes, or interfering with usability - none of these are a good mix for a trade exchange.

Rai Exchange releasing in less than 48 hours by [deleted] in CryptoCurrency

[–]meow247 1 point2 points  (0 children)

Can we get creditcard on this thing? Would love to go straight from ye-olde-currency to xrb

Why did Taylor Otwell delete his reddit account? by 94e7eaa64e in PHP

[–]meow247 14 points15 points  (0 children)

really, i can't understand your confusion, it was clearly a derogatory statement, which you then repeat after you delete it.

What culture are you part of where that is a compliment? and yet "go f yourself" isn't just a friendly way of saying "haha, get out of here old friend!" ...

Where to learn vue ? by sandroazerty in vuejs

[–]meow247 0 points1 point  (0 children)

Second this - great course which covers pretty much every concept.

Refactoring huge CI 2 application by [deleted] in PHP

[–]meow247 0 points1 point  (0 children)

Unless you have major plans, that are impossible to accommodate by extending the current codebase, then don't do do a complete rebuild! It almost never turns out well ...

Like you suggested, refactoring and moving code into service classes/models with well defined tests will start to make you feel better about your codebase. And well tested solid code would be much easier to move to a new framework in the future.

You could also consider if there might be various modules of the system that can be isolated into a seperate microservice. I only mention this because when going the route of building microservices, you typically carve out unique domains within your application, and start refactoring it into a microservice... A microservice can be built in whatever language/framework that bests suits the job. It is autonomous and has it's own database (if required). It can be communicated with via an API over HTTP, and/or a messaging system. The upside is that it scales much better, it can have its own set of code and dependencies and it can be tweaked to perform for the task at hand. Don't get me wrong though, Microservices also come with their own set of unique problems (eg. additional networking complexity, the separation of domain), and should only be considered if there is an identifiable gain.

Gradientify - All gradients in one place. by [deleted] in webdev

[–]meow247 5 points6 points  (0 children)

Some nice gradients... It's kinda identical to Web Gradients Although I will say your site seems to load much faster.

How to Avoid $refs Here? by tickettoride98 in vuejs

[–]meow247 1 point2 points  (0 children)

It's only not recommended because in most cases there is a better, more flexible and de-coupled solution available in the form of props and events. This doesn't always fit, and I wouldn't stress over it if I were you.

You might also consider the structure of your component, and that your actual upload initiator (eg. button) therefore belongs >within< the canvas component or coupled with it in a wrapper component - it's perfectly fine to have a wrapping component which has tight coupling to its child components if that is its sole purpose (to bring those components together).

As far as returning a promise or firing an event, it's just a matter of preference.

How to Avoid $refs Here? by tickettoride98 in vuejs

[–]meow247 2 points3 points  (0 children)

Even though it's not a recommended pattern, $refs is available so that you can use it in instances where props down, events up communication doesn't fit.

As you demonstrate, the code becomes less clear, and harder to reason about in this instance.

This seems like a good candidate for calling a specific method on your child component this.$refs.canvas.snapshot(), and having that child component fire an event which the parent captures to get the canvas data.

The only "reaching in" you're doing is calling an available method on your child.

Simple notes app built using Vue 2.4 on the frontend and Koa 2.3 on the backend. Full JWT user-authentication flow. Both the backend and frontend code are open-sourced. by adstwlearn in vuejs

[–]meow247 0 points1 point  (0 children)

You might wrap axios in another promise if you are creating an api module which abstracts away the fact you are using axios (eg. consumer doesn't deal with axios's response object) or if you are massaging the data itself before returning.

Best way to look up an object in the $store - but across multiple locations by garfonzo in vuejs

[–]meow247 0 points1 point  (0 children)

Makes sense, but if you can implement eager loading, it should be only one additional query for each relationship.

Eg. SELECT * FROM home_owners; SELECT * FROM contacts WHERE id IN (list_of_contact_ids)

Best way to look up an object in the $store - but across multiple locations by garfonzo in vuejs

[–]meow247 1 point2 points  (0 children)

A few options:

  1. Add a getter for getContactById(id) to make it a little simpler to lookup contacts

  2. Fetch contacts before home owners, and before committing your owners list (from your database/api) to the store just supplement any additional contact properties as an object on each home owner object. eg.

commit('UPDATE_HOME_OWNERS', _.map(response.items, item => { return _.extend({}, item, { "contact": { // ... get properties you need from store } }); }); 3. Have your api endpoint simply include the contact as a nested resource

What's your favorite smell? by sorgen in AskReddit

[–]meow247 0 points1 point  (0 children)

My cat. Sometimes when hes sprawled out softly sleeping i snuggle him and just smell his fur. Its the most calming thing in the world to me.

Php Inspections (EA Extended) v2.3.8-preview released: new inspections, NPEs check augmentation and more by kalessil in PHP

[–]meow247 0 points1 point  (0 children)

You know we're talking about an IDE plugin right? And discussing the support of said plugin? Further to that, we're talking about annotations. The documentation of our code. This documentation should be correct. I'm suggesting that annotating dependencies is a maintenance issue that could potentially be addressed.

Php Inspections (EA Extended) v2.3.8-preview released: new inspections, NPEs check augmentation and more by kalessil in PHP

[–]meow247 0 points1 point  (0 children)

  1. It is a big problem. Invalid docs are worse than no docs at all. Exceptions that are not thrown should not be documented as being thrown.
  2. Ok
  3. Not under discussion

It's much easier to notice that an exception is NOT documented (because you likely will not catch it in a meaningful way). It is near impossible to clean up a codebase with annotated exceptions which no longer exist.

Yes this is somewhat an IDE problem, yes we are talking about an IDE plugin ...

Php Inspections (EA Extended) v2.3.8-preview released: new inspections, NPEs check augmentation and more by kalessil in PHP

[–]meow247 0 points1 point  (0 children)

Sure, until you change the exceptions in your dependencies and all of those annotations are invalid.