Alright database people I need some advice. Our factory is using some complicated MAC address state machine to keep track of which MAC addresses are assigned to which unit and it's become a big error prone headache. What would be a good solution to maintain a database of currently assigned MAC addresses and to generate new ones across multiple work stations?
|
|
# ? Jan 15, 2019 17:19 |
|
|
# ? May 31, 2024 02:19 |
|
Popete posted:Alright database people I need some advice. Our factory is using some complicated MAC address state machine to keep track of which MAC addresses are assigned to which unit and it's become a big error prone headache. How much development are you willing to do? Can you cloud host it, or does it need to be on prem? What languages are you familiar with?
|
# ? Jan 15, 2019 19:21 |
The Fool posted:How much development are you willing to do? Can you cloud host it, or does it need to be on prem? What languages are you familiar with? Probably don't want to spend a lot of time working on this. The factory asked us software developers for suggestions on an implementation and one of us may get assigned to this but probably for no more than a week. I'm an embedded software developer so I spend %90 of my time working in C, but I've worked a decent amount in Java and more recently Python. I'm unfamiliar with SQL but I'm sure someone else here has more familiarity. This would be hosted on our work servers ideally and the factory desktops (Windows) that would be used to assign a MAC address could pull from it.
|
|
# ? Jan 15, 2019 21:08 |
|
My first thought would be to roll a django site with sqlite, using django's auto-generated admin site as a template for the basic ui.
|
# ? Jan 15, 2019 21:55 |
|
Centralized data store with guaranteed atomicity. A Redis with an incrementing key would probably be enough, but you might want to be a little more elaborate.
|
# ? Jan 15, 2019 21:55 |
Thanks, those are both good suggestions and I'll dig into them further. Would there be a way to guarantee uniqueness in the database? We want to avoid accidentally assigning the same MAC address to two units.
|
|
# ? Jan 15, 2019 22:16 |
|
Super easy with Django to set a constraint: https://docs.djangoproject.com/en/dev/ref/models/fields/#unique
|
# ? Jan 15, 2019 22:23 |
|
What's the recommended way to implement an action on a resource when designing an API? For example, I want to have an action that will delete (or alternatively, set end_date to now()) the resource, as well as create a new resource that is identical to the specified resource except with start_date set to now(). My first inclination is to have the API end point be something like POST to /{userId}/resourceType/{resourceId}/theAction. I know this isn't really RESTful, but it seems simpler than trying to do this in a strictly RESTful manner. Also, another API design question: when dealing with a fetching data for a specific user, is it best to include the userID in the API endpoint, or to infer the user from the authentication?
|
# ? Jan 17, 2019 05:01 |
|
Splinter posted:What's the recommended way to implement an action on a resource when designing an API? For example, I want to have an action that will delete (or alternatively, set end_date to now()) the resource, as well as create a new resource that is identical to the specified resource except with start_date set to now(). My first inclination is to have the API end point be something like POST to /{userId}/resourceType/{resourceId}/theAction. I know this isn't really RESTful, but it seems simpler than trying to do this in a strictly RESTful manner. EDIT: I can't read.
|
# ? Jan 17, 2019 05:09 |
|
Splinter posted:What's the recommended way to implement an action on a resource when designing an API? For example, I want to have an action that will delete (or alternatively, set end_date to now()) the resource, as well as create a new resource that is identical to the specified resource except with start_date set to now(). My first inclination is to have the API end point be something like POST to /{userId}/resourceType/{resourceId}/theAction. I know this isn't really RESTful, but it seems simpler than trying to do this in a strictly RESTful manner. I wouldn’t worry about it being fully “RESTful” so much as “can I document this and does it meet design requirements?” You need to determine how exactly the API will be used. If a user is only ever going to get user information about themselves, then you can infer the user from whatever auth method you’re assuming. More typically you’d have the option to get information about any given user provided you have the authority to do so, which can be useful if you need to get multiple users in a programmatic way. This assumes you have some endpoint to get all userIDs, either in total or to some specific group.
|
# ? Jan 17, 2019 14:14 |
|
Splinter posted:What's the recommended way to implement an action on a resource when designing an API? For example, I want to have an action that will delete (or alternatively, set end_date to now()) the resource, as well as create a new resource that is identical to the specified resource except with start_date set to now(). My first inclination is to have the API end point be something like POST to /{userId}/resourceType/{resourceId}/theAction. I know this isn't really RESTful, but it seems simpler than trying to do this in a strictly RESTful manner. You’ll probably get a different answer from everyone, so here’s mine! 1. Use POST because your request isn’t idempotent. 2. Put the user ID in the endpoint. If you want to have a variation in the endpoint that means "do thing for the currently-logged-in user", that’s ok too.
|
# ? Jan 17, 2019 15:12 |
|
Splinter posted:What's the recommended way to implement an action on a resource when designing an API? For example, I want to have an action that will delete (or alternatively, set end_date to now()) the resource, as well as create a new resource that is identical to the specified resource except with start_date set to now(). My first inclination is to have the API end point be something like POST to /{userId}/resourceType/{resourceId}/theAction. I know this isn't really RESTful, but it seems simpler than trying to do this in a strictly RESTful manner. We do these as /{userId}/resourceType/{resourceId}:theAction to make it clear that "theAction" is a custom method (as opposed to normal CRUD operation) rather than a subresource
|
# ? Jan 17, 2019 15:21 |
|
The standard way to satisfy the "everything must be a resource" nazi ideology when faced with a complex but atomic action, is to take the verb you would use to describe the action and try to turn it into a plural noun. In your case it sounds like you're effectively replacing the old element, so the best resource nazi name might be POST /{userId}/resourceType/{resourceId}/replacements. POST /{userId}/resourceType/{resourceId}/restarts is another option. Because English is the way it is you often just end up with a verb with an -s on the end. However, trying really hard to make everything "RESTful" in that manner is basically just a waste of brain power. What's important is choosing a name for the action that feels intuitive, and where you don't feel the urge to replace the name every time you look at it. I like the sound of the ":action" suffix approach, although I've never used it myself.
|
# ? Jan 17, 2019 15:40 |
|
Hey dudes. I've been working on a proj and the past few commits are down a rabbit hole I can't wake myself out of. Want to revert a few commits without losing everything. History shows that entering terminal commands from the first StackOverflow article I find results in bad things happening if Git is involved. Git is a dark art. Probably need to get the current code in a sep branch. This is a collaborate proj with a few other users, but no one else has modified any commits since what I'm reverting to. What's the word? edit: Solved. Copy+Pasted raw text from Github into current files. Dominoes fucked around with this message at 06:35 on Jan 20, 2019 |
# ? Jan 20, 2019 06:14 |
|
Dominoes posted:Hey dudes. I've been working on a proj and the past few commits are down a rabbit hole I can't wake myself out of. Want to revert a few commits without losing everything. First rule of git is make all changes in branches.
|
# ? Jan 20, 2019 14:31 |
|
dupersaurus posted:First rule of git is make all changes in branches. Correct. You should have a local master branch that only contains code you're happy with. Each new thing you start work on should start by pulling from the remote to the master branch, then creating a new local "feature branch". Work in the local branch until you're happy with it, then make a pull request from that branch to the remote. Once the pull gets accepted you can pull it into your master from the remote, and delete your local feature branch. Your described situation can happen even with the above though, if you get partway into your feature branch and then muck it up. In which case you can just check out a second feature branch from the first one (causing them to both have both the good and bad changes), then revert the bad changes in one of them (or reset its HEAD to be before the bad commits, if they're the most recent commits).
|
# ? Jan 20, 2019 16:45 |
|
Much apprec. I've never done a collaborative proj before, but that makes sense as the best way to do it now. Would also make it easier to deal with my worry that if I don't commit/push often enough, it'll break someone else's WIP they haven't yet submitted a PR for.
|
# ? Jan 20, 2019 16:55 |
If you've made some changes on master you wanted to have on a branch, what you can do is mark the current head of master as that branch, then point master back at the previous "good" commit.
|
|
# ? Jan 20, 2019 17:08 |
|
Dominoes posted:Much apprec. I've never done a collaborative proj before, but that makes sense as the best way to do it now. Would also make it easier to deal with my worry that if I don't commit/push often enough, it'll break someone else's WIP they haven't yet submitted a PR for. A certain amount of this will happen anyways, so it's probably a good idea to come up with some interfaces you can use as boundaries with your fellow developers so you don't step on each other's toes.
|
# ? Jan 20, 2019 20:26 |
|
I didn’t see a separate thread on ansible, so posting this here. We are being tasked with automating something using ansible and python (don’t ask) My first thought is to replace a current n-step process for producing firewall rule dumps with hit counts. So, I have an ansible playbook using the asa_command module which connects to each firewall and executes the following commands: term pager 0 show access-list | i x.x.x.x\x20 where x.x.x.x is the IP address, and the trailing “\x20” is a space to make sure that searches for 192.168.1.10 don’t also pick up 192.168.1.100-109 This works, and when I run the playbook with the -vvvv option, I can see the results. My problem is, how do I get the output(s) from the command(s) into a state where I can then use the output in a python script to parse the rules and produce an excel spreadsheet. I know how to do the excel part in python, I just need to know how I can get the output from ansible in a way that python can use it. The results of the commands are stored in a variable called stdout_lines TIA
|
# ? Jan 22, 2019 05:29 |
|
Would a callback plugin work? https://docs.ansible.com/ansible/latest/plugins/callback.html
|
# ? Jan 22, 2019 15:57 |
|
The Fool posted:Would a callback plugin work? Quite probably! Thanks!
|
# ? Jan 22, 2019 21:19 |
|
Can anyone suggest a way I can open .dbc files? I think they are FoxPro 6 files but I'm not sure and I don't have access to a MSDN subscription to download this ancient application. Does anyone know of another way to look at the data inside?
|
# ? Jan 25, 2019 05:33 |
|
It was a long time ago, but I was able to get something going with python and a free trial of some paid ODBC deal. It was annoying IIRC.
|
# ? Jan 25, 2019 16:09 |
|
Agrikk posted:Can anyone suggest a way I can open .dbc files? Maybe try LibreOffice? Some googling around indicates Base can do stuff with DBF files, but that may just be table structure, not sure if that or Calc can do the DBC. This of course would be on an application basis and not programmatically. If you have .NET it looks like there's an OLEBD driver for it so you could do a simple harness CRUD/extract: https://social.msdn.microsoft.com/F...m=csharpgeneral
|
# ? Jan 25, 2019 18:57 |
I have a Java project that will be populating an object by cherry-picking the needed pieces of data from a few existing REST services. Is there a preferred design pattern to go about doing this?
|
|
# ? Jan 31, 2019 16:31 |
|
Due to poor life choices I am trying to implement CSS styling to a windows WPF based application. Most of it's pretty straightforward but I'm having a hard time wrapping my head around how CSS gradients ( both linear and gradient ) are implemented. For example, it appears as though CSS premultipled alpha for gradients when compared to SVG or WPF. This CSS code code:
produces this while similar SVG or WPF code code:
I'm thinking that I'm going to need to generate my own gradients to match CSS but the CSS specs I've looked at don't give enough detail to really implement anything. The Chromium source contains how they generate gradients but without any context of that code I wasn't able to make much sense of it. Does anyone know a good reference or straight forward source in any language for CSS gradient implementations? I can probably get the premult alpha linear gradients working but the radial gradients definitely get crazy when compared to what's available in most graphics frameworks.
|
# ? Jan 31, 2019 18:53 |
|
This SO post seems to answer the question. Basically CSS handles transparency in gradients differently (better) than SVG. As for the gradient calculation its just linear RGB interpolation for both. Can you not layer and have the gradient go cleanly from red to green by itself?
|
# ? Jan 31, 2019 19:54 |
|
I believe CSS colors are specified in sRGB space. try converting to linear, blending, and then converting back to sRGB.
|
# ? Jan 31, 2019 19:57 |
|
Suspicious Dish posted:I believe CSS colors are specified in sRGB space. try converting to linear, blending, and then converting back to sRGB. Isn't that browser specific? I haven't touched gradients in a while but when I did I seem to remember having to roll one way for IE and another for Chrome/FF Kind of irrelevant to OP I guess because they're doing WPF but still curious.
|
# ? Jan 31, 2019 21:06 |
|
I'd like to write something to automate scanning in CD album liner notes and turning them into PDFs. I'm most familiar with Java, but also have experience with Python, Javascript, and Matlab. I tried the scanning library from Asprise, but it couldn't get any capabilities from my combo printer/scanner/copier, neither over network nor USB. Would another language make my life easier? Or perhaps there's a better Java library?
|
# ? Jan 31, 2019 21:30 |
|
Scaramouche posted:Isn't that browser specific? I haven't touched gradients in a while but when I did I seem to remember having to roll one way for IE and another for Chrome/FF I'm willing to believe that IE has poorly though out color management, yes. But the latest CSS spec says that colors are specified in sRGB space. Which means that linearly blending their values does not work. I believe both Firefox and Chrome convert to linear to do any blending.
|
# ? Jan 31, 2019 22:03 |
|
Thanks for the responses. My post might have been a little confusion - I know how the linear gradients are different - what I was looking for was a 'readable' implementation of CSS standard gradients for reference so I can create my own implementation. The linear ones are pretty straightforward - I've already gotten my code to support some of the crazy patterns here. The radial gradients are where things get difficult determining exactly what they are doing via inspection ( aka playing around in codepen ).
|
# ? Feb 1, 2019 00:01 |
|
Farchanter posted:I have a Java project that will be populating an object by cherry-picking the needed pieces of data from a few existing REST services. Is there a preferred design pattern to go about doing this? What do you mean design pattern? You're kind of implementing a facade pattern just by nature of what you're doing. You'll probably want some DI via Guice. Other than that, I'm a fan of Paul Graham's take on the subject: quote:When I see patterns in my programs, I consider it a sign of trouble. The shape of a program should reflect only the problem it needs to solve. Any other regularity in the code is a sign, to me at least, that I'm using abstractions that aren't powerful enough-- often that I'm generating by hand the expansions of some macro that I need to write.
|
# ? Feb 1, 2019 04:49 |
|
Helicity posted:What do you mean design pattern? You're kind of implementing a facade pattern just by nature of what you're doing. You'll probably want some DI via Guice. Other than that, I'm a fan of Paul Graham's take on the subject: One thing that's nice about modern DI frameworks is that a lot of what you would call a pattern in another language (like singleton, decorator, factory) just ends up being a matter of calling your DI's register method with different options.
|
# ? Feb 1, 2019 07:02 |
|
Bruegels Fuckbooks posted:One thing that's nice about modern DI frameworks is that a lot of what you would call a pattern in another language (like singleton, decorator, factory) just ends up being a matter of calling your DI's register method with different options. Yeah, if you have a class called HttpClientSingletonFactory you're probably doing things in a needlessly complex way. Just ask Guice for a single instance of something. On more thinking, I'd personally just have main class for DI binding, a service that does the actual facade work, and then a gateway to help talk to each backend. That's fairly idiomatic Java without going into some sort of hellhole like https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
|
# ? Feb 1, 2019 13:23 |
|
This is probably really simple, but I'm not great at regex. I'm looking for a regex that matches a string which
The follow regex is almost what I want, but doesn't match a single letter: ^[\w][\w-]*[\w]$ Should match: "a", "1", "a1", "a-1", "aa--11--bb--22" Should not match: "", "-", "a-", "-a" My googling has resulted in lots of results concerning matching the same character at the beginning/end of a string. epswing fucked around with this message at 14:04 on Feb 2, 2019 |
# ? Feb 2, 2019 13:54 |
|
epalm posted:The follow regex is almost what I want, but doesn't match a single letter: ^[\w][\w-]*[\w]$ Just match the single letter separately: ^\w[\w-]*\w$|^\w$
|
# ? Feb 2, 2019 14:04 |
|
Nippashish posted:Just match the single letter separately: ^\w[\w-]*\w$|^\w$ Oh... right. Thanks!
|
# ? Feb 2, 2019 14:12 |
|
|
# ? May 31, 2024 02:19 |
|
Or you can do ^\w([\w-]*\w)?$ (one character at the start, optional group of the other stuff ending with a character, line ends) Also might be worth testing them on your input to see if one is faster, it's possible to write single regexes that are way slower than just splitting them up into multiple tests
|
# ? Feb 2, 2019 15:22 |