|
Jabor posted:Write a grammar for your configuration language and use a parser generator to convert your input file into an AST, then write code to convert the AST into your final objects. This is the right answer.
|
# ? Jan 22, 2020 16:02 |
|
|
# ? May 30, 2024 11:09 |
|
Yeah. Even though I am well over my head with an interpreter right now, it doesn't occur to me when parsing is applicable elsewhere.
|
# ? Jan 22, 2020 17:07 |
|
Jabor posted:Write a grammar for your configuration language and use a parser generator to convert your input file into an AST, then write code to convert the AST into your final objects. While this is an excellent answer, and is appreciated, I don't know that I have the ability to properly compose an EBNF grammar for the entire configuration of a cisco firewall, and I wasn't able to locate an existing one on line. I think, in the interest of time, that I'm going to go with a dispatcher of a sort: C# code:
Edit After coding the dispatcher and parsing methods, the 270-line original loop with the massive if block is reduced to: C# code:
LongSack fucked around with this message at 21:25 on Jan 22, 2020 |
# ? Jan 22, 2020 20:16 |
|
LongSack posted:While this is an excellent answer, and is appreciated, I don't know that I have the ability to properly compose an EBNF grammar for the entire configuration of a cisco firewall, and I wasn't able to locate an existing one on line. Given what you just showed about the inputs, it would probably be overkill right now.
|
# ? Jan 22, 2020 21:52 |
|
Rocko Bonaparte posted:I am playing with ANTLR4 for my own stuff and I think it does a decent enough job. You'll be able to grab it through nuget in Visual Studio as well. I'll grant that deciding to use that or not will boil a lot down to whether you have the energy to get into that kind of thing right now or if the current project is bad enough without going any further. Yeah, the final version of the _dispatcherTable only contains 18 entries.
|
# ? Jan 22, 2020 22:36 |
|
Sometimes I work on a project that has multiple related repos on github. Sometimes a single feature requires related work on more than one repo. Does anyone have a way they like for tracking this work? Usually what I do is open a GH issue on each repo and then provide a link to the issues on the other repos. This works, but I don't like it because of the manual linking process.
|
# ? Jan 23, 2020 20:19 |
|
Thermopyle posted:This works, but I don't like it yeah this is every project management system ever.
|
# ? Jan 23, 2020 20:55 |
|
I'm having a really stupid python logging issue. I wrote a little flask and gunicorn app that I turned into a docker container, and it all works fine, but I'm setting up logging. I have the logging for gunicorn working fine, but I can't get the python app itself to log right. Basically I want two logfiles: service.log - > root python log, so it contains all the regular log output function.log - > second logfile that only contains activity from a specific function. I can get each to log the correct messages, but the messages are duplicated. I know it has to to with logging handlers and I read up on it and I think I know the issue, but I just can't get it to work. I'm a novice at python, so I'd like to learn how to fix this properly. I'm using python 2.7 (I'm going to port it to 3 next but for now it's 100% working and it's all offline so there's no security issues I have to worry about. First off, my app is basically: app.py code:
logger.py code:
Any pythonic goons have some tips?
|
# ? Jan 23, 2020 21:12 |
|
Why do you need both a regular file handler and a rotating one?
|
# ? Jan 23, 2020 21:49 |
|
Kilson posted:Why do you need both a regular file handler and a rotating one? I don't know! I wanted to make sure the log file rotates. I thought I'd have to specify handlers for each function I want to apply to the logfile.
|
# ? Jan 23, 2020 21:57 |
|
I have had a similar problem in the past that came down to misinterpreting the global nature of the logging module. My suspicions are that your first setup_logger call may be setting up from a pretty blank state, but the second one is actually tacking on to it instead of creating a separate one. I think that is how you get your duplicates. If you were to add a third call to setup_logger, you'd probably see one more repeat each time.
|
# ? Jan 23, 2020 22:45 |
|
Jerk McJerkface posted:I don't know! I wanted to make sure the log file rotates. I thought I'd have to specify handlers for each function I want to apply to the logfile. What happens if you get rid of the non-rotating one?
|
# ? Jan 23, 2020 22:46 |
|
Thermopyle posted:Sometimes I work on a project that has multiple related repos on github. A monorepo is the answer.
|
# ? Jan 24, 2020 00:14 |
|
Kilson posted:What happens if you get rid of the non-rotating one? I did that, and it's working. I'll post how it's fixed in case anyone else can benefit (I hate when I find a person asking the same question and they just answer "I fixed it" with no context. I had to make a few more tweaks: code:
The way it work is to first define the hanlder (either just a file, a rotating file) and then you can modify the handler after: code:
|
# ? Jan 24, 2020 04:39 |
|
I don't think I was right about the problem then. Oh well. I can't remember the exact circumstances where I had something like that happening before, but I vaguely remembered it having to do with two different things trying to set up logging state.
|
# ? Jan 24, 2020 07:46 |
|
Jerk McJerkface posted:logFile = logFilePath + "/" + log_file_name Tip - use os.path.join for this type of stuff code:
|
# ? Jan 26, 2020 18:42 |
|
Bob Morales posted:Tip - use os.path.join for this type of stuff Actually, use pathlib from the stdlib as of 3.4. Python code:
|
# ? Jan 26, 2020 20:29 |
|
I am really bad at thinking up projects to do and I would like to help out in open source. Also I am rather proficient at writing tests and I like to work in java 11+ or Kotlin. Can anyone point out a project that could use some help? (xposting to java thread)
|
# ? Jan 26, 2020 20:32 |
|
Keetron posted:I am really bad at thinking up projects to do and I would like to help out in open source. Also I am rather proficient at writing tests and I like to work in java 11+ or Kotlin. Can anyone point out a project that could use some help? (xposting to java thread) Make an art prompt generator
|
# ? Jan 26, 2020 20:44 |
|
Thermopyle posted:Actually, use pathlib from the stdlib as of 3.4. Thanks for the tips. My python is all self taught so it's a bit rough. Does that work in 2.7? I have a couple apps I'm on the process of moving to 3 but I'm not there yet.
|
# ? Jan 26, 2020 20:56 |
|
dupersaurus posted:Make an art prompt generator The generator is simple (I wrote a international bank account number generator for about 25 European countries, email and other data randomizers for a certain test framework because I like random test data) but the data tables would be harder. Also, this is not jvm material but much more suitable for a JS project. Seriously, I considered this but getting usable data is 95% if not more of the work, getting random data from a dataset and that the data still makes sense is really interesting as a problem. For example, take the catalogueoflife.org project. This is an as complete as possible list of data containing all known life forms. I tried to reach out to them to see if they were interested in adding an endpoint to the set that would return a set of random entries based on one or more query params. Sadly they did not reply. But I might try to get it up and running on my local machine. Just have to tweak it to prevent it from drawing only beetles or amoeba's or something. Keetron fucked around with this message at 21:54 on Jan 26, 2020 |
# ? Jan 26, 2020 21:46 |
|
Keetron posted:I am really bad at thinking up projects to do and I would like to help out in open source. Also I am rather proficient at writing tests and I like to work in java 11+ or Kotlin. Can anyone point out a project that could use some help? (xposting to java thread) Go back through all the personal and professional projects you've worked on and see which dependencies are the most common, go to their GitHub page, and look for beginner or easy issues to start contributing.
|
# ? Jan 26, 2020 23:18 |
|
Keetron posted:I am really bad at thinking up projects to do and I would like to help out in open source. Also I am rather proficient at writing tests and I like to work in java 11+ or Kotlin. Can anyone point out a project that could use some help? (xposting to java thread) When I feel this way I usually just search github for something that might be interesting / useful.
|
# ? Jan 26, 2020 23:24 |
|
Jerk McJerkface posted:Thanks for the tips. My python is all self taught so it's a bit rough. Does that work in 2.7? I have a couple apps I'm on the process of moving to 3 but I'm not there yet. No, you need python 3.4 or later.
|
# ? Jan 27, 2020 03:01 |
|
There's nothing wrong with using os.path.join, at least as long as you know you're constructing paths to be used on the same OS that the code is running on.
|
# ? Jan 27, 2020 03:35 |
|
Thermopyle posted:No, you need python 3.4 or later. True but pathlib2 should wrap for both. (I just looked this up because I didn't know about pathlib at all and had the same concerns.)
|
# ? Jan 27, 2020 18:38 |
|
I've got a peculiar "which programming language should I use for this?" with some restrictions in a slightly locked-down environment where there could be policy issues straying too far from my workplace's "official" system configurations I'd rather not have to go into lengthy back-and-forths with. There are a few processes, mostly either involving Microsoft Office or can be used with Microsoft Office. I want to do some more advanced stuff like being able to put together a custom UI to build some things with certain parameters. Like a form I can fill in for a room booking that would then automatically send a form email (via Outlook or some other means, we use Office 365), auto-update my calendar if possible, that sort of thing, basically automating a few things we're doing manually currently. Like a system-localized version of a web form, or something with buttons which would then run a series of DOS commands and manipulate things in Office or Excel. Think the GUIs people write as complements to command-line tools. Ideally it would be something Microsoft already has as part of Office 365, and if it could leverage some form of Office 365-provided online-hosted database, even if it's just an Excel sheet (we're not working with a lot of data overall), that would be great. The less system intrusive the better (e.g. if it's a non-Microsoft thing it'd be best if it was something self-contained that could be worked on as a portable app). I'm not against weird solutions like Excel Macros if that's legitimately a viable approach, either. If it were an even choice I'd go with something where my projects could be leveraged on MacOS as well, but this is very minor and if the best way to do things is all Windows that's totally fine. If my best approach is something else, I might just bring in a personal laptop to do the heavy lifting there or figure something out along those lines. I don't mind putting in the time to learn the skills (I did a lot of basic-ish stuff in C++ but that was a few decades ago now), I'm just overwhelmed by the sheer number of different programming languages, and if I'm putting in the time for my first programming language in a while I'd like some guidance into where I should even begin looking (even a programming book for the language in question if there's an appropriate one to consult and learn from). EDIT after spending a few hours investigating it's looking like working with Powershell is the way to do what I want. Would that be correct or is there a better option I should look towards? univbee fucked around with this message at 15:29 on Jan 30, 2020 |
# ? Jan 30, 2020 14:37 |
|
univbee posted:I've got a peculiar "which programming language should I use for this?" with some restrictions in a slightly locked-down environment where there could be policy issues straying too far from my workplace's "official" system configurations I'd rather not have to go into lengthy back-and-forths with. You could also make an outlook add-in with VBA, which would probably not be great either, or using c# which would be slightly better but have a much steeper learning curve (and probably require you to get the paid version of visual studio depending on the size of your company). There are also actual web apis for office 365 which would probably be the correct solution in 2020 but you might not be able to go that route in your situation. Aside from the actual apis, the more lazy solution in a situation where your company was actually authorizing what you're doing would be to make a website with a form where the server uses something like SMTP to connect to the outlooks server to send out meeting invitations .
|
# ? Jan 30, 2020 15:45 |
|
mystes posted:You could theoretically do this with powershell using COM to control outlook (unless that's disabled through a system policy) but I absolutely wouldn't recommend that. Also, I really have to ask if this whole thing is a good idea if you're in a "locked-down environment," because is your company really going to appreciate you emailing sketchy executables around and telling people to run them if that's what you intend? Thank you for the input. I definitely won't be emailing EXEs en masse, whatever I accomplish would be mostly for my own purposes, and maybe 1 or 2 other people at a later time depending on how things go. What I'm asking is definitely more of a long-term thing, I'm not expecting to put things into practice for a while, after putting in the time to properly understand how the programming language works, I definitely don't want to just blindly copy code from stack overflow that I don't understand what it does. I'll investigate your suggestions including the ones that are potentially "bad". Writing an Outlook add-in could actually be viable for at least some of the stuff I'm looking to do. I probably oversold the "locked down" nature of things a bit here. I have admin rights on my PC, for example, and am definitely free to do all sorts of scripting, we've just traditionally had a rough time getting the go-ahead for approval to install certain software from external vendors, and in quite a few cases we've found solutions that are at least "good enough" within Office 365, for which there's a blanket "you can do whatever you want with what Office 365 provides so long as you're not sending sensitive information to the wrong place" policy, if that makes sense.
|
# ? Jan 30, 2020 16:03 |
|
i'm trying to find some open source projects to dig around in and contribute to that aren't just things like libraries or add-ons to existing tools. i want to find things that serve a purpose to the user which isn't development related. any places to look for this?
|
# ? Feb 2, 2020 02:32 |
|
The best place to start is with something you actually use, otherwise you just won't care enough or the human need behind the changes you make
|
# ? Feb 2, 2020 02:44 |
|
large_gourd posted:i'm trying to find some open source projects to dig around in and contribute to that aren't just things like libraries or add-ons to existing tools. i want to find things that serve a purpose to the user which isn't development related. any places to look for this? rt4 has the most accurate advice, but also I just visited this page today, I'm sure a lot of these projects would appreciate some help. https://github.com/awesome-selfhosted/awesome-selfhosted
|
# ? Feb 2, 2020 04:16 |
|
I've been requested to port the RPART package from R into Stata, is that even possible? I'm looking at the Mata documentation now, and it looks like it's close enough to C that you could do it, but is there any sort of package management in Stata at all? https://cran.r-project.org/web/packages/rpart/index.html
|
# ? Feb 2, 2020 22:19 |
|
I want to use the HTK toolkit on Windows. http://htk.eng.cam.ac.uk/docs/inst-win.shtml The HTK directory is on my path, so when I open up a console I can execute a command like HList successfully. The weird thing is that when I change my Python environment using anaconda (i.e. activate), and try the same command, it is no longer recognized as an internal command, as if it's not on the path anymore. Also, when I deactivate the Python environment and try to execute a HTK command I get the same error. The only way it works again is to open up a new console and not change the Python environment. Any idea what the reason for this is?
|
# ? Feb 4, 2020 08:53 |
|
I'm guessing that anaconda is screwing around with your path in order to accomplish its changes, and it's not respecting your existing path settings.
|
# ? Feb 4, 2020 09:23 |
|
Python and its environment/path fuckery is going to drive me to a killing spree one day. Is your path the same before/after running activate/deactivate (try echo %PATH% before and after) ? Is there possibly a naming conflict between the HTK files and something in your python path? Speculating slightly here, but did you install Anaconda for all users or just for a single user?
|
# ? Feb 4, 2020 11:43 |
|
In theory anaconda should only add to the path when activating, leaving previous entries in place. But maybe it's different on Windows.
|
# ? Feb 4, 2020 14:37 |
|
Are you using CMD or PowerShell? activate always seemed to work fine through the original command prompt, last I saw they were still trying to get it to work in PS (even though it's been the default Windows terminal for years) and people were posting hack scripts and everything Try it in cmd.exe if you aren't already is what I'm saying, might work!
|
# ? Feb 4, 2020 17:08 |
|
Hey bros. Do you think it'd be fun/feasible to make a computer-generated fake financial or sports news site? Fake comments too? Mix and match details in templates, throw in key words etc. Maybe use SVM or ANN once more basic approaches are exhausted? Do you think some of these sites are already AI-written? *Fake news as in generic commentary, not outright lies. Dominoes fucked around with this message at 18:54 on Feb 4, 2020 |
# ? Feb 4, 2020 18:51 |
|
|
# ? May 30, 2024 11:09 |
|
you mean like that weird subreddit full of bots talking to themselves which got old after like a week
|
# ? Feb 4, 2020 19:27 |