1

Has anyone tried Mastodon yet? For those who don't know it's a federated, distributed and (currently) technology-orientated social network (well, rather a group of interoperable social networks) that's fully open source and ad-free. I've been impressed so far but as with every new network, whether it flies or not will depend on how many people join, contribute and keep the ball rolling.

1

A graph database alone isn't the right choice for a chat application. A message would be represented as an edge between two nodes (people) and too many edges will hurt performance.

Storing the actual social network portion of a chat app in one makes a lot of sense, though. It's the perfect use case for a graph database.

Something like OrientDB might make more sense. There's even a chat program in the use cases section of the documentation.

2

I've been following this with some interest. Bad practice to end with a verb?

I think the distinction is between an API and a web app. In a web app, /widgets/123/edit (obtained via a GET) should contain a form that allows you to edit Widget number 123. Submitting the form should send aPATCH to /widgets/123.

In the case of an API, you don't need an edit form so you can omit verbs from the route entirely.

2

It would appear that too many notifications are added to the feed for certain events, making it difficult to sort the wheat from the chaff.

Take the example of this annoying spammer creating a post:

Screen_Shot_2017-01-26_at_15_16_46.png

Aside from the fact he's a waste of oxygen, that's more than one whole screen of notifications for a post creation and quick edit (less than a minute after posting). Also, I don't see any replies, so perhaps the "replied to a post" notification is superflouous. Perhaps these could be condensed; do we need to know who started watching each post - it might make more sense to display that on the post page; "being watched by..."

Votes + Comments
That and now I want a Black Mirror "Block" mode.
1

D3 isn't the correct choice for in this situation; it's aimed at visualisation (as per the request in the original post). If you want to interact with scales by dropping different-weighted balls on them in anything but the simplest of interfaces, you need a physics engine. Matter-JS provides this and makes it really simple to get fantastic results.

Votes + Comments
Wow! matter.js is cool :)
1

Regarding PUT and PATCH, I looked and looked, and was unable to find a working tutorial on how to implement them in Nginx. Everything I read said that Nginx does not have support??

NGINX definitely supports them, as far as I know you don't need to enable anything. It should just work.

I just wrote (well, copied, pasted and amended) a tiny app in PHP (the first time I've ever tried PHP!) and it handled PUT like a boss.

1

I use snippets heavily. For non-work stuff, Github's gists are perfect. You can add multiple files to a single gist (which would help if some of the code you're pasting is spread across a model, controller and view), and everything's syntax highlighted.

Github allows gists to be embedded. Perhaps this would be a better approach than creating one from scratch. To build anything with that kind of functionality that people will actually want to use is a project in itself.

1

I'm no PHP expert, so forgive my ignorance.

If you test in a basic manner, rather than by using AJAX, what happens? By using your browser's inspector, you can see that doing:

$.ajax({
  url: "my_service",
  data: {f_date1: "yesterday", t_date1: "today"},
  success: function(msg) {
    console.debug("yay")
  }
});

will result in a GET request like this:

my_service?f_date1=yesterday&t_date1=today

If you paste that into a browser's URL bar (or better yet use something like HTTPie or Postman), you can make sure that you can access the query string properly. Once you know that works, and you know that jQuery's .ajax method does the same thing, you'll have a much better chance at solving your problem.

2

What probably happened is that your customer created an order, then while the above code was running they created another. As you're using max to work out which number to allocate and you've not yet saved the first record, both have the same id. Without knowing your transaction isolation level I can't say why your sequence looked correct.

Rule of thumb, for automatically generating numbers, use a sequence (known as auto increment in MySQL). Also, if your ids are meant to be unique, consider making that column a primary key; if not use a unique index.

3

It sounds like you aren't working to the strengths of the database. MySQL, unlike Oracle, PostgreSQL etc doesn't support arrays, and searching on text is unlikely to be optimal.

I don't know the context of the original query, so it's difficult to suggest a solution, but it could be something like this:

 Tags:
 - id: 1
   name: Programming
 - id: 2
   name: Databases
 - id: 3
   name: Web Development
 - id: 4
   name: Floristry
 - id: 5
   name: Kids TV

 Posts:
 - id: 1
   name: Making pages faster
   tags: [1, 2, 3]
 - id: 2
   name: CBeebies top ten
   tags: [5]

So, to find all posts about Web Development you'd look through all of the posts, filtering on the tags field for the inclusion of 5. In PostgreSQL, using the array type, we'd do something like this:

select * from posts;
┌────┬──────────────┬─────────┐
│ id │     name     │  tags   │
├────┼──────────────┼─────────┤
│  1 │ CBeebies     │ {5}     │
│  2 │ Fast Website │ {1,2,4} │
│  3 │ Programming  │ {4,6}   │
└────┴──────────────┴─────────┘
(3 rows)

Time: 0.282 ms
peter=# select * from posts where tags @> '{5}';
┌────┬──────────┬──────┐
│ id │   name   │ tags │
├────┼──────────┼──────┤
│  1 │ CBeebies │ {5}  │
└────┴──────────┴──────┘
(1 row)

That's fine, but that doesn't give you the benefits of using a relational database. What if someone deletes the Kids TV tag from the tags table? Well, our arrays (or strings full of comma separated values) will point to nothing. That's precisely what we ...

Votes + Comments
nice explanation, thanks for sharing!
3

Remember that UNION (and its cousins INTERSECT and EXCEPT) essentially require each of the provided queries to be run separately and the results collated. In this example (using PostgreSQL, but the same applies in MySQL), we can see exactly what's happening.

I have a small table with some users and their favourite colours:

peter=# select * from users;
┌────┬─────────┬──────────────────┐
│ id │  name   │ favourite_colour │
├────┼─────────┼──────────────────┤
│  3 │ Francis │ blue             │
│  4 │ Toby    │ blue             │
│  1 │ Joey    │ red              │
│  2 │ Dwayne  │ purple           │
└────┴─────────┴──────────────────┘
(4 rows)

Time: 0.400 ms

Now, let's say we want all users with a favourite colour of blue or red; if we use a UNION the following happens:

peter=# explain select name from users where favourite_colour = 'blue' union select name from users where favourite_colour = 'red' ;
┌───────────────────────────────────────────────────────────────────────────┐
│                                QUERY PLAN                                 │
├───────────────────────────────────────────────────────────────────────────┤
│ HashAggregate  (cost=35.33..35.39 rows=6 width=58)                        │
│   Group Key: users.name                                                   │
│   ->  Append  (cost=0.00..35.31 rows=6 width=58)                          │
│         ->  Seq Scan on users  (cost=0.00..17.62 rows=3 width=58)         │
│               Filter: ((favourite_colour)::text = 'blue'::text)           │
│         ->  Seq Scan on users users_1  (cost=0.00..17.62 rows=3 width=58) │
│               Filter: ((favourite_colour)::text = 'red'::text)            │
└───────────────────────────────────────────────────────────────────────────┘
(7 rows)

Time: 3.868 ms

As you can see, the query plan involves

  • two sequental scans (Seq Scan) that each perform a Filter,
  • an Append operation which is actually performing the UNION,
  • plus Group Key and HashAggregate steps, from which the resulting recordset can be ...
1

[QUOTE=Jx_Man;584701]i already installed ruby and in ruby directory contain fxri and Scite.
well, i m do small ex in fxri...
what is Scite for? what different about fxri and Scite? why i can't compile code in Scite?
i find compile in tools of Scite but it was disable.
example i write code in Scite :
[code=ruby]5.times { print "Odelay!" }[/code]
when i tried to compiled i can't do this perform. there are compile, Build,Go etc in tools option that i cannot perform to click, it was disable. i m confused.
But this code running great in fxri. so why i can't do compiled in Scite?
please help

Thank you.[/QUOTE]

Did your source file definitely have a .rb extension? Did anything at all appear in the output window?

Votes + Comments
Thank You For Directing friend :)