|
Rocko Bonaparte posted:Yeah, my question needs some work. I'll elaborate tonight. I think it's something like facades and adapters, but I omitted some information. You know that you don't need an Official GoF-Approved Word to build the thing you need, right?
|
# ? Apr 17, 2015 03:56 |
|
|
# ? May 19, 2024 20:16 |
|
GrumpyDoctor posted:You know that you don't need an Official GoF-Approved Word to build the thing you need, right? I have a Captain Actually McPedantic I was dealing with. I mentioned creating a bridge and then it started.
|
# ? Apr 17, 2015 04:03 |
|
I hope this is a simple, stupid question, but I'm pretty inexperienced with JavaScript and JQuery, and I'm not having much luck getting exactly what I need with Google. Hopefully, it'll be a nice, easy softball for someone to start off their day with. I have a JQuery $(document).ready method that sets a callback for a widget to an anonymous function defined in the callback argument. So far, so good. Now, I need a named function that I can call from a couple of places - once in the $(document).ready method, and then I also need to invoke it from that anonymous callback method. This function will probably involve an AJAX call to get data to populate a pulldown list. My problem is that every example I see uses anonymous functions. How and where do I make an actual, named function? Does the function def go inside of the $(document).ready method or outside of it? Can this function be a JQuery construct, or does it have to be a pure JS method? And if it has to be JavaScript, do I need to put it in a JS-specific HTML tag, or can it live in the same <script> element as the $(document).ready definition? Here's what I basically have: code:
|
# ? Apr 17, 2015 15:48 |
|
Peristalsis posted:Basically, the question is how and where to I create populate_my_other_widget_with_ajax_call? JavaScript code:
You can define a function just about anywhere. If it's inside another function, functions defined outside that function won't be able to see it because it's basically the same thing as JavaScript code:
jQuery 'constructs' are JS objects with properties that are functions. When the browser evaluates the scripts on a page, it logically just concatenates them all and runs the code in that order (unless there's an async or defer attribute on a non-inline script, but that's a special case and not widely used AFAIK https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) so nothing really needs to be in its own element.
|
# ? Apr 17, 2015 17:18 |
|
Paging Nippashish. I've built my Viterbi decoder (I think - it runs, at least), but it's tagging everything "OTHER". Do you know of any common mistakes I should check out?
|
# ? Apr 21, 2015 13:22 |
|
I'm new to Excel and programming in general and I'm trying to make a macro for updating a sheet based on an update in another sheet. If anyone would be willing to help me with this I would appreciate this greatly!
|
# ? Apr 21, 2015 14:23 |
|
Munkeymon posted:
I'm a bit late with this, but thanks for the info. You're right that I don't know much about JavaScript and JQuery. I've mostly avoided them thus far in my career, but I have to do some Ajax stuff for my current project, and I'm trying to muddle through them as best I can, until I can make some time to learn them better. The code organization for them always just seems off somehow, so I'm never sure if I'm missing something, or if I'm just looking at bad examples.
|
# ? Apr 21, 2015 15:16 |
|
This question concerns implementing Common Random Numbers in a simulation model (coded in Python, but I think the question is language agnostic). The simulation is a small supply chain which has 4 factories producing goods and where I would like to be able to compare inventory policies. The amount of raw material used each day at each factory is a random variable (so 4 numbers drawn from the random number stream). The inventory policy at each factory determines when new raw material will be ordered so that the factory does not run out of raw materials, and the time it takes the raw material to arrive at the factory is a random variable (a single number drawn from the random number stream). In order to implement common random numbers I need to make sure that the amount of raw material used at each factory each day is the same regardless of the policy being used, however I cannot think of a way to ensure this happens using a single random number stream: under different policies the random number used as the time it takes a reorder to arrive at the factory can be a different random number in the random number stream. For example, if under policy_1 raw material is not reordered until day 6 at Factory 1, but under policy_2 it is reordered on day 4, and assuming that no other factories reorder, then under policy_1 the random number used as the time it takes a reorder to arrive is the twenty-fifth number in the random number stream, but under policy_2 it is the 17th. Thus it appears I need five random number streams (one for the amount of raw material used, and one each for the amount of time it takes a reorder to arrive at the factory). Am I missing something?
|
# ? Apr 21, 2015 17:50 |
|
Peristalsis posted:I'm a bit late with this, but thanks for the info. You're right that I don't know much about JavaScript and JQuery. I've mostly avoided them thus far in my career, but I have to do some Ajax stuff for my current project, and I'm trying to muddle through them as best I can, until I can make some time to learn them better. The code organization for them always just seems off somehow, so I'm never sure if I'm missing something, or if I'm just looking at bad examples. It's a screwy language dressed up to look like the ones you're probably used to so, yeah, if you're expecting it to act like Java or C# you're going to be very confused. Also there's an excellent chance the examples are terrible, too - that's why I linked the article explaining scope. I can dig up some other beginner stuff from when we brought on a junior dev the other year if you want. I should probably do a big write-up on coming to JS from the C#/Java world because that's a transition I made the hard way. Actually, doing it on IE 6 means I probably did it the really hard way
|
# ? Apr 21, 2015 18:17 |
|
hooah posted:I've built my Viterbi decoder (I think - it runs, at least), but it's tagging everything "OTHER". Do you know of any common mistakes I should check out? Run through a small example by hand and make sure your decoder gets the same answer.
|
# ? Apr 21, 2015 22:53 |
|
Nippashish posted:Run through a small example by hand and make sure your decoder gets the same answer. Ok, I think part of the problem is that I'm not dealing with log probabilities properly. For the small example, I decided to just use as a training sentence "<ENAMEX TYPE="PERSON">Pierre Vinken</ENAMEX> , <TIMEX TYPE="DATE:AGE">61 years old</TIMEX> , will join the <ENAMEX TYPE="ORG_DESC:OTHER">board</ENAMEX> as a nonexecutive <ENAMEX TYPE="PER_DESC">director</ENAMEX> <TIMEX TYPE="DATE:DATE">Nov. 29</TIMEX> . ". Then for testing, I just used "Pierre Vinken , 61 years old .". My problem with the probabilities is how to treat things that don't happen. For instance, in the first step, PERSON is the only tag that should have any meaningful value for tag_sequence_log_prob (log2(1/1) = 0). However, since the other tags don't happen after start in the training, they're also coming out to 0, but for a different reason. I know about smoothing in theory, and I think that's what I need to do, but I don't really understand how to apply it.
|
# ? Apr 21, 2015 23:56 |
|
Jose Cuervo posted:Thus it appears I need five random number streams (one for the amount of raw material used, and one each for the amount of time it takes a reorder to arrive at the factory). Am I missing something? Using a unique random number stream for each factory's time-to-arrive doesn't seem anything like using common random numbers. Surely you just need two streams, one for each purpose the random numbers get used for?
|
# ? Apr 22, 2015 01:58 |
|
Jabor posted:Using a unique random number stream for each factory's time-to-arrive doesn't seem anything like using common random numbers. Surely you just need two streams, one for each purpose the random numbers get used for? What I am concerned with achieving is (from the Wikipedia link): code:
The only way I can think of to guarantee that the same time-to-arrive is used in both (or really in all) policies is to have a unique random number stream for each factory's time-to-arrive.
|
# ? Apr 22, 2015 03:10 |
|
hooah posted:I know about smoothing in theory, and I think that's what I need to do, but I don't really understand how to apply it. The simplest form of smoothing is just to add 1 to all of your counts. If you saw the sequence <START> <PERSON> 10 times then just pretend you saw it 11 times, and that means if you saw the sequence <START> <END> 0 times then you pretend you saw it 1 time and now you don't need to try to work with log(0).
|
# ? Apr 22, 2015 08:57 |
|
Jose Cuervo posted:What I am concerned with achieving is (from the Wikipedia link): Ah, sure. What's your objection to having a different random number stream for each of these purposes?
|
# ? Apr 22, 2015 14:13 |
|
Jabor posted:Ah, sure. Absolutely no objection. My next question is how to successfully implement this. I need s = 5 unique random number streams for each simulation replication r. I also need to use the same s = 5 unique random number streams for the r-th simulation replication of the p-th policy. In Python I could initialize a single random number stream using r (the index of the simulation replication). Then the first of the s unique random number streams would be initialized using the first s draws from that random number stream: Python code:
|
# ? Apr 22, 2015 16:08 |
|
I think I'm looking for something like a distributed publish/subscribe framework that works well in Python, but could also cooperate with C, C#, and Java. I mean, I might be wrong. We have a bunch of experiments here that different groups need to use for different purposes. So some of them have to do extra things at key points in the experiments--usually to facilitate equipment. One way to do this is something like the Strategy pattern, where we just break the experiments up by their phases. However, I did not necessarily want to refactor all the experiments to fit that paradigm, and we might hit some strain in how the strategy is defined. So I was thinking of just having some events that are put in around the key points. Some of these event callbacks would have to be blocking; they'd have to wait for the listeners to complete their reaction to the event before moving forward. Is that a common enough thing in publish-subscribe frameworks? The distributed requirement is not for running across multiple computers, but just for running across multiple processes. I'm trying to get various agents to work with each other without having to couple them up. I'm currently trying to see if Redis will do this. So I would be curious if there is something better, or if I'm on drugs and should reconsider the whole notion.
|
# ? Apr 22, 2015 21:56 |
Redis will probably do what you want, in one form or another. Also look at ZeroMQ, it's not quite the same but it gives you some abstracted IPC in a socket-like way, I believe it has both unicast and multicast.
|
|
# ? Apr 22, 2015 22:05 |
|
Nippashish posted:The simplest form of smoothing is just to add 1 to all of your counts. If you saw the sequence <START> <PERSON> 10 times then just pretend you saw it 11 times, and that means if you saw the sequence <START> <END> 0 times then you pretend you saw it 1 time and now you don't need to try to work with log(0). I'd totally forgotten about add-one smoothing, which was pretty easy to implement. However, now the problem is how to make the algorithm recognize multi-word entities. This appears to be what the "chunk" part of the HMM chunk tagger they're referring to means, but I don't understand how they did it.
|
# ? Apr 23, 2015 13:00 |
|
Rocko Bonaparte posted:Some of these event callbacks would have to be blocking; they'd have to wait for the listeners to complete their reaction to the event before moving forward. Is that a common enough thing in publish-subscribe frameworks? You mean RPC? Yeah, I'd say so: https://www.rabbitmq.com/tutorials/tutorial-six-python.html
|
# ? Apr 23, 2015 15:31 |
|
Akumu posted:I just got a mysterious e-mail that only included a Base64 encoding of a 24-digit decimal number. Is that a format that any particular thing comes in? I got an identical email, but the decimal number was longer. I looked for patterns briefly and then decided it was just a broken spam bot.
|
# ? Apr 23, 2015 21:34 |
|
2015-04-23T20:31:12.486Z What standard is a datetime of that format?
|
# ? Apr 23, 2015 21:42 |
Thermopyle posted:2015-04-23T20:31:12.486Z ISO 8601
|
|
# ? Apr 23, 2015 21:48 |
|
Thermopyle posted:2015-04-23T20:31:12.486Z ISO 8601
|
# ? Apr 23, 2015 21:49 |
|
thx
|
# ? Apr 23, 2015 21:52 |
|
What's a good resource for learning about windows system programming? I've been doing unix basically my whole career, and things are feeling very strange. ETA: I'm doing cross-platform things and in particular have c++ libraries that need to work everywhere, and have to write windows-only client applications to use those and other sdks.
|
# ? Apr 23, 2015 21:55 |
I've personally found Microsoft's own online documentation (MSDN Library) decent, although I'm sure it's not something that works for everyone. I've never had any books on Windows programming. Some general pointers: - You are not getting around working with UTF-16 strings at some level, perhaps unless you never need to touch the filesystem or UI at all. Plan for re-implementing any file access to call Windows' native APIs, and they all want UTF-16 Unicode strings. - Learn at least the basics of COM, you don't need to master it but at least learn the semantics of IUnknown and CoCreateInstance. - Keep in mind that there isn't a true common C++ ABI on Windows, C++ libraries built with different compilers won't necessarily link. In particular, mixing Microsoft and GCC is risky. - IPC and RPC will also be very different, if you need to do that consider whether you can rely on a 3rd party library to abstract it. - Making native GUIs for Windows with C++ can be painful, doing it in .NET land is generally a much better idea. However integrating native C++ libraries with .NET will require either having a pure C interface for the C++ code, or exposing it as a COM interface, or using some sort of IPC and running the C++ component out of process, or porting the C++ library to compile for .NET. That's obviously decisions to make early.
|
|
# ? Apr 23, 2015 22:21 |
|
Munkeymon posted:You mean RPC? Yeah, I'd say so: https://www.rabbitmq.com/tutorials/tutorial-six-python.html Probably. Having toyed with 0MQ a little, I see I'm asking for a lot. In my head, I was hoping for an independent service that would route all the messages. So I did not want to force the testbench software to have to connect to a port that an experiment set up. I wanted both sides to reach out to a central service and get mated up there. Afterwards, I'm thinking of something RPC-like behavior, but the experiments don't really need to know they're doing RPC calls. They're just indicating they're about to do something, and sometimes letting themselves block on it. Wait for the next post where I further qualify that too, until I've realized just how big of a problem I'm walking into.
|
# ? Apr 24, 2015 00:10 |
|
Rocko Bonaparte posted:Probably. Having toyed with 0MQ a little, I see I'm asking for a lot. In my head, I was hoping for an independent service that would route all the messages. So I did not want to force the testbench software to have to connect to a port that an experiment set up. I wanted both sides to reach out to a central service and get mated up there. Afterwards, I'm thinking of something RPC-like behavior, but the experiments don't really need to know they're doing RPC calls. They're just indicating they're about to do something, and sometimes letting themselves block on it. Wait for the next post where I further qualify that too, until I've realized just how big of a problem I'm walking into. Designing a distributed architecture is never a trivial task. While there's no right answer it's hard to really know where to get started without a more thorough description of your requirements. That said, RabbitMQ is great.
|
# ? Apr 24, 2015 03:50 |
|
Rocko Bonaparte posted:Probably. Having toyed with 0MQ a little, I see I'm asking for a lot. In my head, I was hoping for an independent service that would route all the messages. So I did not want to force the testbench software to have to connect to a port that an experiment set up. I wanted both sides to reach out to a central service and get mated up there. Afterwards, I'm thinking of something RPC-like behavior, but the experiments don't really need to know they're doing RPC calls. They're just indicating they're about to do something, and sometimes letting themselves block on it. Wait for the next post where I further qualify that too, until I've realized just how big of a problem I'm walking into. RabbitMQ, the project whats docs I linked to, is an independent service that you can configure to route messages in different ways including pub/sub and RPC patterns. Your testbench software could just sit idly listening for messages (subscriber) from your experiment (publisher) and the Rabbit server would handle routing.
|
# ? Apr 24, 2015 15:16 |
|
nielsm posted:I've personally found Microsoft's own online documentation (MSDN Library) decent, although I'm sure it's not something that works for everyone. I've never had any books on Windows programming. If you want to know how stuff works behind the scenes, read (or skim) the Windows Internals book, it's pretty great.
|
# ? Apr 24, 2015 17:17 |
|
Does the linear complexity of DFS/BFS depend on nodes being marked as visited? If it does, does the complexity change to |V|*|E| or something quadratic?
|
# ? Apr 25, 2015 15:39 |
|
If the nodes aren't marked as visited then they will never finish.
|
# ? Apr 25, 2015 15:47 |
|
Well, if you know the nodes ahead of time and put them into a queue you can avoid that.
|
# ? Apr 25, 2015 16:29 |
|
I'm not quite sure what you mean by that. Which nodes are being put into the queue? In what order are they being put in? How are you using the queue?
|
# ? Apr 25, 2015 16:48 |
|
I'm trying to figure out if students' algorithms for 2-coloring a graph are linear time. Most of them do something like BFS or DFS, but most don't mark nodes as visited. Here's an example:pre:Q <- V // Put all vertices in a queue x = Q.pop_back while(!Q.empty) for each vertex y in x.adjacencylist if x.color == y.color return false x <- Q.pop_back return true
|
# ? Apr 25, 2015 16:55 |
|
That runs in O(V+E) time, but it doesn't color the graph. It merely verifies that it is colored.
Dr. Stab fucked around with this message at 17:11 on Apr 25, 2015 |
# ? Apr 25, 2015 17:03 |
|
Right, I was just unsure of the running time. Thanks.
|
# ? Apr 25, 2015 17:07 |
|
I'm just a little confused because that's not BFS or DFS. If they needed to actually do one of those to generate a 2-coloring, you couldn't just visit the nodes in an arbitrary order.
|
# ? Apr 25, 2015 17:14 |
|
|
# ? May 19, 2024 20:16 |
|
Dr. Stab posted:I'm just a little confused because that's not BFS or DFS. If they needed to actually do one of those to generate a 2-coloring, you couldn't just visit the nodes in an arbitrary order. I'm just the grader.
|
# ? Apr 25, 2015 17:25 |