|
TasteMyHouse posted:If you mean the .NET class Mutex then I'd need more explanation.
|
# ? Aug 18, 2011 16:16 |
|
|
# ? Jun 8, 2024 21:23 |
|
TasteMyHouse posted:I don't quite get what you're saying here. The main thread is calling WaitFor(). How is it waiting for a result? How does it get notified? You have to split the flow of your main program between something that starts listening to the port and something that gets called when the data from the port meets whatever condition you require. In the (very sloppy untested quickie) example code below, WaitFor begins listening to the SerialPort and ProcessInput gets called back to when the regex hits a match. The nice thing about this setup is that the main thread isn't blocked at any time and everything is driven by the serialPort's DataReceived event. The bad thing is that the logic is split between the caller and callback methods which makes for hard to read code. The new Async system does all this crap under the hood and gives you a much nicer fall-through from one line of code to the next. code:
PDP-1 fucked around with this message at 16:35 on Aug 18, 2011 |
# ? Aug 18, 2011 16:33 |
|
I'm pretty new at this stuff so bear with me. I'm revamping my school's website and I'm at the point where I've got a good template for the whole site. This mainly entails a change to the first 150 or so lines of html for each page. What I'm looking for is a way to replace those lines with the code I've come up with in some kind of batch format so I don't have to go through every page and do it manually. HTML-Kit has a plug-in that does this but seemingly only for one word at a time. Does anything like this exist? Preferably for free. E: Nevermind, figured out that I could use a program called "Replace Text" and do about 4 smaller changes rather than changing the whole block of code. thecopsarehere fucked around with this message at 19:45 on Aug 18, 2011 |
# ? Aug 18, 2011 16:34 |
|
PDP-1 posted:You have to split the flow of your main program between something that starts listening to the port and something that gets called when the data from the port meets whatever condition you require. In the (very sloppy untested quickie) example code below, WaitFor begins listening to the SerialPort and ProcessInput gets called back to when the regex hits a match. I'm sorry if I wasn't clear, but I WANT the main thread to block. There might be tons of different things that I want to do sequentially, calling WaitFor each time. Like the following pseudocode... code:
|
# ? Aug 18, 2011 17:01 |
TasteMyHouse posted:I'm sorry if I wasn't clear, but I WANT the main thread to block. There might be tons of different things that I want to do sequentially, calling WaitFor each time. I would suggest writing it as an explicit state machine, taking the input asynchronously. That way you should be able to better deal with the device doing something unexpected. Basically, enumerate all steps in the ideal process. Every time you need to wait for anything from the device, you enter a new state. Give each state a number and, ideally, also a name. Draw a state diagram of the basic flow. Now, enumerate all the kinds of inputs you can receive from the device. For each transition in your current state diagram, label the actual input required to complete the transition. Then, for each state, figure out what would be sensible to do if any other possible input is received from that state. You may need to create new states for this. (Most of these would probably be error states.) You should now have a state diagram where you will be able to handle any situation that can occur. Now you can start writing code. Make sure to include your state diagram with your code in one way or another, as documentation. Otherwise, it will be really hard to follow! (That's the downside of this approach.)
|
|
# ? Aug 18, 2011 21:14 |
|
nielsm posted:I would suggest writing it as an explicit state machine, taking the input asynchronously. That way you should be able to better deal with the device doing something unexpected.
|
# ? Aug 18, 2011 21:23 |
TasteMyHouse posted:I wanted to avoid doing things entirely synchronously so that I could have the ability to send ^C -- I need the read to happen on a different thread from the writing so that reading doesn't block writing. That's exactly what I'm suggesting! Your state transitions would happen when an input from the device is matched, and while waiting for that to happen you'd be sitting in, well, whatever you want. However, the way I read your post above (which I quoted before) you were suggesting turning the asynchronous processing into a synchronous process.
|
|
# ? Aug 18, 2011 21:35 |
|
nielsm posted:That's exactly what I'm suggesting! Oh pfft I misread your "asynchronous" as "synchronous". The crux of what I'm looking for here is the "sitting in, well, whatever you want." -- right now I'm doing this: code:
code:
|
# ? Aug 18, 2011 21:54 |
|
I think this design doesn't make a whole lot of sense, but I'll leave that up to you and just tell you how to accomplish the synchronization correctly. The waiting thread should do this: code:
code:
|
# ? Aug 18, 2011 22:22 |
|
With all this talk about mutexes and manual synchronization, why not just use some sort of blocking queue for data in and one for data out and/or instructions like "shut down". You're going to have to solve the same problems a blocking queue does regardless so it'd be easier to use one from the start.
|
# ? Aug 18, 2011 22:43 |
|
rjmccall posted:I think this design doesn't make a whole lot of sense By all means, please tell me what you think would be better! quote:
I'd love to do that -- the problem is that I have no way of knowing if the serial port is done getting data. The partial lines I receive from the port can either be line-chunks that need to be concatenated with the next chunk that comes down the line, OR they could be the end of data, because shell prompts don't end in newlines. Therefore, I can't just match on known complete lines -- I have to match on partial lines as they come in, too. The simplest way to handle this was to have the data received callback perform the matching -- this means that there isn't a persistent thread performing the matching to retain a lock like you suggested. I could have a persistent thread performing matching, that waits on the data received callback to shove unprocessed data into a queue, but then I'd just have to solve the problem of THAT thread waiting. TasteMyHouse fucked around with this message at 22:55 on Aug 18, 2011 |
# ? Aug 18, 2011 22:47 |
|
TasteMyHouse posted:The simplest way to handle this was to have the data received callback perform the matching -- this means that there isn't a persistent thread performing the matching to retain a lock like you suggested. This is really a very minor problem; it means your callback basically does: code:
TasteMyHouse posted:By all means, please tell me what you think would be better! You really need the "here's what comes next" logic to be fully synchronized with the input stream. Either you write a state machine that's directly advanced by the receive callback, and the main thread just blocks until that finishes (using a simple Wait/Pulse setup), or you make the receive callback queue all the input up to be processed by a different thread (probably the main thread, and WaitFor would just pull chunks of input off a blocking queue like 1337JiveTurkey suggested). ETA: The queuing approach is much cleaner, but if it requires copying the input stream, then it might be an unacceptable bottleneck on performance. rjmccall fucked around with this message at 23:35 on Aug 18, 2011 |
# ? Aug 18, 2011 23:31 |
|
rjmccall posted:This is really a very minor problem; it means your callback basically does: AHH pff Okay, I get it now. When I read the documentation for Monitor.Wait, and it said "Releases the lock on an object and blocks the current thread until it reacquires the lock," I didn't realize that only a call to "Pulse" would allow it to reacquire the lock. This is the critical piece of understanding I was missing and now everything is simple. quote:But this just exposes an already-latent problem in your design where the data-received callback can get notified while the next regex hasn't been set yet, and then that data presumably just gets tossed and maybe the regex never matches. Good point. For now I'll change it from WaitFor(regex) to AskFor(string_to_write,regex). TasteMyHouse fucked around with this message at 00:15 on Aug 19, 2011 |
# ? Aug 19, 2011 00:10 |
|
Sorry for posting this here as I know people can care less about the whole Lulzsec The Jester hacker fight. I am just curious and have been unable to figure out exactly what this is. I am assuming it is a type of encryption. But, I only have had Basic 1 so far, heh. This is what the code looks like copy and pasted, on twitter, and in HTML. Any Ideas on what it is or how to make my own or read it? c̘͕͈̩͈2̼͔̺͚d̬̟͖c̱͈͈̜37̪͖a͍7̺̥d9̮̲̝̖d̞͕̣3̙̫̙̣2̤3̬8̠7̥̠͙7̗͇̞̼a1̩̼̜͙͓̣2͙̮̤̙̥7̥͓͔̠̩f2̰̜̰ḓ̙̤ͅ51̗͈̱͖7̻͇̦͖1̦͕͇c̫͈̲9͚d̯͓ Thanks!
|
# ? Aug 21, 2011 15:18 |
|
The Gloaming posted:Any Ideas on what it is or how to make my own or read it? Make your own? Freeware modules out there everywhere. Whats your language of choice?
|
# ? Aug 21, 2011 16:54 |
|
The Gloaming posted:I am just curious and have been unable to figure out exactly what this is. http://www.eeemo.net/
|
# ? Aug 21, 2011 16:56 |
|
an md5sum ?
|
# ? Aug 21, 2011 19:54 |
|
I refuse to get involved in cryptic messages when the author can't even manage to spell 'potato'. edit: If you're asking about building your own encryption scheme, you should use an existing one if it's for use with anything you value. Many, many people with much better qualifications and experience than you, me and I'm betting anyone in this thread have spent years building and attempting to break the algorithms we have today, such as RSA and AES. That said if you don't want to use it for anything critical then it's a decent project to learn a few things. Back when I used IRC a lot (and was still in school) I made a very simplistic mIRC channel encryption script which relied on a pre-shared one time pad and, since the OTP was used over and over again (hence fairly easy to break) an algorithm which shuffled the word order of sentences to defeat basic sentence analysis. It wouldn't keep GCHQ busy for more than 5 minutes but was fine for discussing raiding strategies for browser-based MMORPGs. rolleyes fucked around with this message at 20:36 on Aug 21, 2011 |
# ? Aug 21, 2011 20:23 |
|
rolleyes posted:I refuse to get involved in cryptic messages when the author can't even manage to spell 'potato'. it looks like it is a cropped screenshot in which case the word may have been "potatoes"?
|
# ? Aug 21, 2011 20:26 |
|
Thanks wound up learning a lot more than I set out to. I am assuming it is some code using that eeemo.net app or a new type of "1337 speak" from what I have Googled about it. Just a more complicated version of the scrambler apps that people use to make MMO names with weird characters. As for building my own; I brought up the idea at the programmers club at school and everyone seems to be fine with what is already out there. Probably for the best as from what you all have said this is WAY above my level.
|
# ? Aug 22, 2011 22:52 |
|
The Gloaming posted:Thanks wound up learning a lot more than I set out to. I am assuming it is some code using that eeemo.net app or a new type of "1337 speak" from what I have Googled about it. Just a more complicated version of the scrambler apps that people use to make MMO names with weird characters. Well as I said if you're not securing anything of value then it can be a good project to learn a few things. As you've mentioned a club you could all come up with your own schemes then try to break each other's, there's plenty of info on basic cryptanalysis out there.
|
# ? Aug 22, 2011 22:58 |
|
Hello all! I've been wanting to learn some programming so I decided I would download the newest version of VB from Microsoft and start messing around with it. It is what I used when I was a junior in high school 8 years ago so I figured it would be easier to step into vs. other languages. That being said I'm trying to come up with what I imagine to be a very simple program that, when you click a button, displays a MsgBox that contains a random list of 14 names that are entered into the code. I have to admit I have not taken baby steps at all so what I've come up with is a hodge podge of code that I don't necessarily understand but here is what I've got. As you can see this code randomizes the names and selects one, I want a list of all names randomized. code:
I thank you all for your help. p.s. can anyone recommend a VB tutorial website? C# would be cool too.
|
# ? Aug 23, 2011 00:34 |
|
MsgBox takes a single string as input, right? and you want to display all of your names, in random order, right? So what you're going to have to do is concatenate those strings into one big string, and do that in random order, then feed that big string to the messagebox.
|
# ? Aug 23, 2011 01:12 |
|
Use a local collection class instead of that array list stuff. The built in methods on it are much easier to use.
|
# ? Aug 23, 2011 02:00 |
|
I am hoping to design a site for people looking to share pictogram illustrations used for communication by children with intellectual disabilities. I am trying to find the right CMS for what I am looking to accomplish. I want people to be able to get accounts and upload their own pictograms. Being able to choose a license and the ability to tag pictograms and put them into user defined lists would be great. Secondly, I want anyone to be able to download pictograms in various printable formats (jpg/png/pdf) with predefined or custom captions without an account. I've looked at a bunch of image gallery CMSes and plugins for Wordpress, Drupal, etc. but I haven't been able to find something that will accomplish what I am trying to do. Does anyone know a CMS or plug-in that can do this?
|
# ? Aug 23, 2011 02:47 |
|
rikatix posted:p.s. can anyone recommend a VB tutorial website? C# would be cool too. http://en.wikipedia.org/wiki/Bytecode http://en.wikipedia.org/wiki/Common_Intermediate_Language As for tutorials, there are no stand out examples in my mind. Plenty out there, hit up google
|
# ? Aug 23, 2011 18:41 |
|
rikatix posted:p.s. can anyone recommend a VB tutorial website? C# would be cool too. As it sounds like you're new to software development, if you do go with C# as Graviton suggested and have a little money to spare I would recommend this book. It will start you from absolute basics (or show you where to skip to if you already know certain concepts) and so might seem like slow going, but you'll get a good understanding of the language concepts before diving into GUI applications and such. I'm not saying it's perfect because it isn't* but it's a very good starting point for someone new to the game, and all of the examples and techniques it teaches work with the Express edition of Visual Studio so you don't need to lay out for software. *Probably its main failing is that the chapter on LINQ tries to do too much by going beyond the syntax and attempting to explain the underpinnings and makes a bad job of it, but then LINQ is an entire book all by itself so can be investigated afterwards if you really want to get into things like expression trees.
|
# ? Aug 23, 2011 18:53 |
|
I'm a webdesigner with a good deal of experience in javascript and I vaguely vaguely touched on Perl ages ago, but am cracking open my Llama book this weekend. Anyway, the company I work for has some really really outofdate junk doing really important things on the backend and as a way to prove myself more useful (and hopefully help myself get my neck back into the programming way of things for a perl/javascript dev job opening up soon), I've been checking out some of the backend stuff to make a list of "poo poo that needs fixed." And I came across this odd chunk of programming code. I don't know what language this syntax belongs to. Anyone with better knowledge wanna school me or is this some proprietary programming language for some godforsaken reason: <<FOR::BEGIN(DOW)::>> <<FOR::END(DOW)::>> <-- This runs a for loop with DOW being a variable meaning Day of Week.... which is a variable declared as a range of dates... and if statements are made like this: <<::VAR::<<var_name>>:print:somethingthatgetsprintedifthevarexists::ENDVAR>> I've never seen anything like it, anyone want to help? pathetic little tramp fucked around with this message at 04:25 on Aug 24, 2011 |
# ? Aug 24, 2011 04:21 |
|
pathetic little tramp posted:<<::VAR::<<var_name>>:print:somethingthatgetsprintedifthevarexists::ENDVAR>> I can't tell you what language it is but it looks suspiciously like a (n ugly) hand-rolled templatey language.
|
# ? Aug 24, 2011 05:55 |
|
which has been extended far beyond its original capabilities by people who had no idea what they were doing so basically php but even worse
|
# ? Aug 24, 2011 06:20 |
|
Thirding that, if you value your sanity try not to get involved with maintaining things written with it and certainly don't volunteer to build new stuff with it. Even if there's documentation (which as you're asking the question I'm guessing there isn't) it's going to be a whole can-o-worms. If people are looking to you to get fixes done then I'd suggest moving to something else - even if you go with PHP then at least it's a standard language so someone else can look at the code later and be able to maintain it. rolleyes fucked around with this message at 08:48 on Aug 24, 2011 |
# ? Aug 24, 2011 08:46 |
|
I guess I could be more helpful. Better template languages: jinja, liquid, mustache (all have ports for many languages so poke around).
|
# ? Aug 24, 2011 09:10 |
|
We have a thrown-together C# application that basically invokes a bunch of little applications, in sequence, on a whole bunch of input files. The problem is that sometimes the little applications crash, and the entire program then sits there waiting for a user to click "ok go away" in the unhandled exception popup. We want it to just skip those cases and continue. I'm sure there's a trivial way to deal with this but I just don't know it.
|
# ? Aug 24, 2011 20:54 |
|
Wait, is the exception occurring in your application or in one of the little applications?
|
# ? Aug 24, 2011 21:59 |
|
One of the little ones.
|
# ? Aug 24, 2011 22:12 |
|
Are the Little applications .NET? if they are, just add them to the master program as assemblies and use them internally instead of as subprocesses; then you can catch whatever exceptions happen however you want. If they're not, all I can think of is a time-out that kills the process if it doesn't return after n milliseconds
|
# ? Aug 24, 2011 22:37 |
|
If you have programmatic access to the little applications you can also improve the exception handling so it reports success/failure state instead of out and out throwing an exception, but I'm guessing you don't.
|
# ? Aug 24, 2011 23:29 |
|
The little programs are ours, and while the ideal solution is "just don't make them crash" I don't know why I didn't just think to wrap each of them (internally) with a try/swallow as a stopgap solution.
|
# ? Aug 24, 2011 23:38 |
|
I am not sure if this is the right thread, but it seems like a good catch-all. I graduated with a CS degree 6 years ago and I have been doing user support ever since. I have not programmed a thing since college. Things are looking bleak at work, and I really want to get back into programming anyway, so I would really like to scrape the rust off, but I am not sure where to start. As bad as it sounds (I know, do it because you love it...) I want to start where I can make the quickest transition out of user support and into something else. The only languages that I studies in school were C and C++. I have heard good things about Java marketability, and I am interested in mobile app development, so those are a couple of places that I was thinking about starting. Am I better off getting a book to pick up the fundamentals? Are there good iTunes U courses out there that I can download and follow? I would love a kick in the right direction.
|
# ? Aug 25, 2011 15:56 |
|
|
# ? Jun 8, 2024 21:23 |
|
Mobile app development will be primarily in Java (for Android) and Objective C (for iOS). As for trying to get a programming job -- check out the "How do I linked list?" thread
|
# ? Aug 25, 2011 16:03 |