• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

takriel

Member

Thank you very much, this helped a lot!

I think I'm right on the verge of getting it done, however, there's one thing that doesn't seem to work:

I have defined the function as follows:

function getRandomInt(0, 3) {
return Math.floor(Math.random() * (3 - 0 + 0.999999)) + 0;
}

but node.js will only give a syntax error message saying that the bolded 0 is an unexpected number. Any advice on what's wrong here?
 

Staab

Member
I have defined the function as follows:

function getRandomInt(0, 3) {
return Math.floor(Math.random() * (3 - 0 + 0.999999)) + 0;
}

but node.js will only give a syntax error message saying that the bolded 0 is an unexpected number. Any advice on what's wrong here?

The function needs to be defined as taking parameters, as in how you wrote it initially.
Code:
function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min + 0.999999)) + min;
}
min and max are your parameters and they exist solely for the function (getRandomInt is your function), which can then take any number you want it to as parameters when you call the function (the function does nothing until you call it).

When you do call the function, during the assignment of the variable guessword, your function then takes your parameters into account (as in you tell it, min is 0 and max is 3) by writing getRandomInt(0,3) :
Code:
var guessword = guesswords[[B]getRandomInt(0,3)[/B]];
If it's clearer, you could also write it like this :
Code:
var mychosennumber = getRandomInt(0,3);
var guessword = guesswords[mychosennumber];
You roll the dice (with the function), it turns up a 0,1,2 or 3 and you assign that number to the variable mychosennumber, which in turn gets input inside your array (guesswords) which selects the word in position 0,1,2 or 3 and assigns it to the guessword variable.
 

takriel

Member
The function needs to be defined as taking parameters, as in how you wrote it initially.
Code:
function getRandomInt(min, max) {
      return Math.floor(Math.random() * (max - min + 0.999999)) + min;
}
min and max are your parameters and they exist solely for the function (getRandomInt is your function), which can then take any number you want it to as parameters when you call the function (the function does nothing until you call it).

When you do call the function, during the assignment of the variable guessword, your function then takes your parameters into account (as in you tell it, min is 0 and max is 3) by writing getRandomInt(0,3) :
Code:
var guessword = guesswords[[B]getRandomInt(0,3)[/B]];
If it's clearer, you could also write it like this :
Code:
var mychosennumber = getRandomInt(0,3);
var guessword = guesswords[mychosennumber];
You roll the dice (with the function), it turns up a 0,1,2 or 3 and you assign that number to the variable mychosennumber, which in turn gets input inside your array (guesswords) which selects the word in position 0,1,2 or 3 and assigns it to the guessword variable.

Got you, thanks very much again!
 
What do you do if you're working with somebody else's code base for a project and the style is all over the place? Obviously I'm not rewriting their code, but do you tell them it needs work?
 
What do you do if you're working with somebody else's code base for a project and the style is all over the place? Obviously I'm not rewriting their code, but do you tell them it needs work?

If I know that person or group and have a good working relationship with them, then I might bring it up. Otherwise, I do as I'm tasked to do and make my code as clean and easy to follow as possible, but the rest of the code base is on them. If I see some glaring issue (correctness, vulnerability, etc.), then I would certainly have no problem mentioning it.
 
What do you do if you're working with somebody else's code base for a project and the style is all over the place? Obviously I'm not rewriting their code, but do you tell them it needs work?

Tell them to start using clang-format, institute a code review policy, start blocking their patches if they're not properly formatted, and then either get promoted because you demonstrated leadership, or fired because you weren't a cultural fit (then use the fact that you instituted code reviewing as a sign of your leadership when applying for a new job, and get a higher salary because of it)
 
Tell them to start using clang-format, institute a code review policy, start blocking their patches if they're not properly formatted, and then either get promoted because you demonstrated leadership, or fired because you weren't a cultural fit (then use the fact that you instituted code reviewing as a sign of your leadership when applying for a new job, and get a higher salary because of it)
Haha rolling the dice there.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
Tell them to start using clang-format, institute a code review policy, start blocking their patches if they're not properly formatted, and then either get promoted because you demonstrated leadership, or fired because you weren't a cultural fit (then use the fact that you instituted code reviewing as a sign of your leadership when applying for a new job, and get a higher salary because of it)

There's upper management written all over you! :)
 

Two Words

Member
Regarding your second paragraph, you're going to find that you'll need to go into checkSeats() anyway upon input, as your data could have changed. Other users could have reserved or cancelled, and that could change your total number of available contiguous seats by the time any other user finalizes his or her selection. Certainly, running some checks up front to limit the inputs can be of value, but it doesn't absolve you of the need to check afterwards.

In more general terms of your first paragraph, I view it like this: if you have a public method, that method should verify (or delegate the task of verifying) the inputs for logical correctness. I don't care if another public method elsewhere has validated those same inputs -- by nature of the method being public, anybody can call it, so you can't guarantee input vectors. The last thing you want is your code to blow up because you didn't take a moment to validate against a null or a negative number or some other invalid argument. Your private methods should then not need to worry about validation (unless, of course, validation is their job) (this is assuming your code is well designed and that you trust yourself to give yourself good values -- and by "yourself," I really mean the class, not the author of it).

At the same time, if you're calling into a public method and you haven't already validated the inputs you're using (such as, you got them from a user or even a database), then validate before even calling. Look at it as if you're consuming a library, ignoring for a moment that you might have been the author of it. If you know that the library could potentially bomb because of what you pass it, you want to validate what you're passing. The last thing you want is for your program to fail unexpectedly, and quite often a source of failure is invalid data.

It might sound as if I'm saying have validation code all over the place, repeatedly, and I'm really not. If your program is well designed, your validation will be isolated. I simply advocate that the code being consumed validate arguments before working with them, and the consuming code validate parameters before sending them, particularly when the source of those parameters can't be trusted (as in, the data came from an external source).

In code terms, if you have a method that looks like (examples provided in C#/.NET):

Code:
public int Divide(int numerator, int denominator)
{
     if (denominator == 0) throw new ArgumentException("Denominator cannot be 0.");
     return numerator / denominator;
}

This is public method that will blow up with a particular input. If you're consuming that method, you do not want to provide that input! So you validate beforehand

Code:
int numerator = GetNumeratorFromSomewhere();
int denominator = GetDenominatorFromSomewhere();
int quotient;

if (denominator > 0)
{
     quotient = someObject.Divide(numerator, denominator);
}

This is what I mean by validation on both sides. You don't want to accept bad arguments, but you also want to be good citizen and not send them.


That makes sense. This particular program was not using OOP, but I can see how it applies to both ends.
 

Ambitious

Member
I feel like buying a few new books:

Steve McConnell: Code Complete: A Practical Handbook of Software Construction
Apparently, this one is included in pretty much every "Books every Software Developer/Engineer/Programmer/... should read" list.

Bill Karwin: SQL Antipatterns: Avoiding the Pitfalls of Database Programming
Someone mentioned this one in a Stack Overflow answer. Sounds like an interesting read.

Martin Fowler: Patterns of Enterprise Application Architecture
I can't remember how this ended up in my shopping basket, but I do remember that it was recommended in a university lecture I'm attending this semester.

Cay S. Horstmann: Java SE 8 for the Really Impatient
Any opinions on this one? I'm mainly working with Java at university, but I'm ashamed to admit that I've kinda never bothered to check out SE 8. I know that there are lambda expressions and streams, but I've never had a closer look.
 

Two Words

Member
Here is something I don't get about Classes. I get understand the problem of stale data. If you have a Rectabgle class, you can have attributes like length and width. Our book is teaching us that you don't want to have an area attribute because it depends on the other attributes and can easily become stale. But couldn't you have an area attribute with a setArea function that is called inside both the setLength and setLength function? That way whenever the length or width is changed, the area is automatically recalculated? Does the problem of stale data become not as easily resolved in larger programs?
 

poweld

Member
Here is something I don't get about Classes. I get understand the problem of stale data. If you have a Rectabgle class, you can have attributes like length and width. Our book is teaching us that you don't want to have an area attribute because it depends on the other attributes and can easily become stale. But couldn't you have an area attribute with a setArea function that is called inside both the setLength and setLength function? That way whenever the length or width is changed, the area is automatically recalculated? Does the problem of stale data become not as easily resolved in larger programs?

You could do this, and it would probably work. However, I think the idea here is that the attributes that define a rectangle are its length and width. An attribute like area is derived from these properties, so it follows that they would be dynamically generated by a method.

Another reason is for concurrency. Say you did update the length and then update the area as two instructions in the updateLength method. If updateLength is called, the length is updated, and then another thread accesses the object and requests the dimensions and area of the rectangle, the numbers might not add up.
 
Here is something I don't get about Classes. I get understand the problem of stale data. If you have a Rectabgle class, you can have attributes like length and width. Our book is teaching us that you don't want to have an area attribute because it depends on the other attributes and can easily become stale. But couldn't you have an area attribute with a setArea function that is called inside both the setLength and setLength function? That way whenever the length or width is changed, the area is automatically recalculated? Does the problem of stale data become not as easily resolved in larger programs?

Take a look at what you just did, though. In exchange for what is basically an easily understood getter

Code:
double getArea() 
{
     return width * length;
}

You have added a burden to two other places that makes them perform the same calculation

Code:
void setWidth(double value)
{
      width = value;
      setArea(width * length);
}

void setLength(double value)
{
      length = value;
      setArea(width * length);
}

Code expressed once is much more preferable to code expressed twice. ;) But you also have to trust that everything that could write to the width or length members is going through your functions, not something operating on the variable itself (otherwise, those places would also need to call your setArea method).

You should see that it's much easier to just let your area be a calculation that is performed when needed, not whenever you mutate the other state of the object. Is there a counter to this? Yes! What if you're performing the mutation extremely rarely, and the calculation extremely often? What if you're performing it often enough that you can actually measure a performance degradation that is worth eliminating? That's when you might opt to go a different direction, and surely other circumstances might prompt you to make a similar change.
 

poweld

Member
I feel like buying a few new books:

...

Cay S. Horstmann: Java SE 8 for the Really Impatient
Any opinions on this one? I'm mainly working with Java at university, but I'm ashamed to admit that I've kinda never bothered to check out SE 8. I know that there are lambda expressions and streams, but I've never had a closer look.

FWIW, I haven't read this book, but another book of his, Scala for the Impatient. It was a great primer and would recommend it again, so if it's like that for Java8, then it's probably worth it.
 

Two Words

Member
If the area of the rectangle is never stored in the rectangle, isn't that no longer bundled with the object, then? As in, the object itself doesn't retain its area. Instead, the area of he object can only be expressed in some brief moment and then lost once the program moves on into a different scope. Is this kind of issue common with stale variables?
 

injurai

Banned
If the area of the rectangle is never stored in the rectangle, isn't that no longer bundled with the object, then? As in, the object itself doesn't retain its area. Instead, the area of he object can only be expressed in some brief moment and then lost once the program moves on into a different scope. Is this kind of issue common with stale variables?

A stale variable would be you set the value based on something. That something then changes and the variable remains the same. One reason why pointers are used is that you just reference the actual thing, but then you may get issues with race conditions.
 

Slavik81

Member
If the area of the rectangle is never stored in the rectangle, isn't that no longer bundled with the object, then? As in, the object itself doesn't retain its area. Instead, the area of he object can only be expressed in some brief moment and then lost once the program moves on into a different scope. Is this kind of issue common with stale variables?
That probably isn't an issue. You can just ask for the area again whenever you need it again.
 
Guys,

I have this specific issue that I think/hope can be solved by programming :) In short I have a monthly boring task that takes me between 2-4 hours each month and I would like to automatize it.

I have a list of names that I have written with special characters äåö and such. Each month I get a list of the same names but without special characters and with some strange arrangement or errors (like surname first than first name or letters missing). Each month I have to go trough the list and correct this stuff.

I do it mostly by copying the correct names but sometimes just writing a letter myself. Sadly this is done on a webpage and not in Excel or something and each name has a "window" for itself and there is no list.

So I would like to learn enough about programming to be able to automatize things like this. I guess it shouldn't be too complicated. Problem is I don't know where to start. So if any of you fine gentlemen would point me in the right direction I'll be sure to come back and share my success story with you lot :p
 

injurai

Banned
Guys,

I have this specific issue that I think/hope can be solved by programming :) In short I have a monthly boring task that takes me between 2-4 hours each month and I would like to automatize it.

I have a list of names that I have written with special characters äåö and such. Each month I get a list of the same names but without special characters and with some strange arrangement or errors (like surname first than first name or letters missing). Each month I have to go trough the list and correct this stuff.

I do it mostly by copying the correct names but sometimes just writing a letter myself. Sadly this is done on a webpage and not in Excel or something and each name has a "window" for itself and there is no list.

So I would like to learn enough about programming to be able to automatize things like this. I guess it shouldn't be too complicated. Problem is I don't know where to start. So if any of you fine gentlemen would point me in the right direction I'll be sure to come back and share my success story with you lot :p

I actually used to do this exact thing. However I was given an XML file and had to automate scripts that fixed errors or formatting issues. Basically put it into our internal format.

I had the benefit of inheriting some some XML libraries to parse through it. But for each line I had to write code to sort through all the possible problems.

I would have no clue how to go about pulling down the information and then manipulating the forms. Others, maybe the web developers could help you on that front. If you can get it into some file, then you can pretty much pass it to any language of your choosing to then process.

For the actual text manipulation I would recommend using regular expressions. They can be daunting at first (no more than a couple well rested sessions to learn them though), but just ask back here when you're ready to cross that bridge. Many languages offer regular expressions in their standard library. You could likewise use tools like sed, grep, awk, or perl. But I can clarify more on those options later.

First thing first is having you elaborate on how you must submit these changes and how they are presented to you before you begin your task of manually changing them.
 

poweld

Member
Guys,

I have this specific issue that I think/hope can be solved by programming :) In short I have a monthly boring task that takes me between 2-4 hours each month and I would like to automatize it.

I have a list of names that I have written with special characters äåö and such. Each month I get a list of the same names but without special characters and with some strange arrangement or errors (like surname first than first name or letters missing). Each month I have to go trough the list and correct this stuff.

I do it mostly by copying the correct names but sometimes just writing a letter myself. Sadly this is done on a webpage and not in Excel or something and each name has a "window" for itself and there is no list.

So I would like to learn enough about programming to be able to automatize things like this. I guess it shouldn't be too complicated. Problem is I don't know where to start. So if any of you fine gentlemen would point me in the right direction I'll be sure to come back and share my success story with you lot :p

Unfortunately it sounds like this is a task that is not very easy to automate. From the sounds of it, it requires a fair amount of intuition and knowledge of how names work. I don't have time to get into more detail at the moment, so maybe someone else can shed more light on why this is not simple - or perhaps I'm mistaken and you can elaborate on the task.
 
Guys,

I have this specific issue that I think/hope can be solved by programming :) In short I have a monthly boring task that takes me between 2-4 hours each month and I would like to automatize it.

I have a list of names that I have written with special characters äåö and such. Each month I get a list of the same names but without special characters and with some strange arrangement or errors (like surname first than first name or letters missing). Each month I have to go trough the list and correct this stuff.

I do it mostly by copying the correct names but sometimes just writing a letter myself. Sadly this is done on a webpage and not in Excel or something and each name has a "window" for itself and there is no list.

So I would like to learn enough about programming to be able to automatize things like this. I guess it shouldn't be too complicated. Problem is I don't know where to start. So if any of you fine gentlemen would point me in the right direction I'll be sure to come back and share my success story with you lot :p

Is it completely new names each month and if not, are the names always messed up the same way? If both are the case, you could correct the names once, save the list and then basically do a search/replace that replaces the messed up names with the fixed ones. For the rest of them, you'd have to go through the list manually.

Is the list automatically generated? Also, at least part of the problem (special characters missing) sounds like an encoding issue that might be fixed by using a sensible encoding (UTF-8).

As far as automating a task that is done in a web browser, there's Selenium, which is basically a programmable remote control for your browser. In your use case it sounds like you probably want to fetch the text from a bunch of text fields, accumulate it in a list, then process it and enter it back into the fields. That's a pretty simple task in terms of browser automation, it sounds like the more interesting/difficult part is figuring out how the names are messed up and fixing that.
 
I'll try to elaborate a bit more, sadly I can't show you any screen grabs yet as I haven't got the damned lists yet.

Anyhow I get a list of transactions. Now I have to open each and every one on the list. When I open one transaction I get a new window (not a browser new window) with a few fields. I only need to fill out 2 of them. One is always the same and the other one changes each quarter.

And lastly the field with a name. It could say

akesson jarni. But I need it to be Järni Åkesson.

Now the "wrong" one is always the same, it is how they wrote it the first time and I'm stuck with that. I have a list of corrected ones that I made for myself. So in theory I could just do a search for "akesson jarni" and just replace it with the correct one. Maybe have a script and bind it to a hotkey

seclect text from field where the marker is
compare it to a list with predefined names (they are always the same but they are many)
replace with correct name


Now like I said I have no idea how any of this works except for maybe logic of it. I use Firefox or Safari for dataentry and have the list with corrected names in both PDF and Excel.

What I do now is:

1. Open the transaction (mouse click)
2. Put cursor in a field, change value, tab, tab, tab to next field and change value
3. Tab to name field
4. See the name and figure out what it should be
5. Go to second monitor and do Ctrl+F and search for correct name
6. Mouse drag over the correct name to select it, CTRL+C
7. Back to Firefox, highlight the whole name and CTRL+V
8. Press on the next transaction

Really boring, so I really want to automatize it if possible and learn a bit of programming while am at it (always wanted to do some light programming)
 
Is it completely new names each month and if not, are the names always messed up the same way? If both are the case, you could correct the names once, save the list and then basically do a search/replace that replaces the messed up names with the fixed ones. For the rest of them, you'd have to go through the list manually.

Is the list automatically generated? Also, at least part of the problem (special characters missing) sounds like an encoding issue that might be fixed by using a sensible encoding (UTF-8).

1. Always the same names, and if a new comes up it will continue to do so

2. We get the list uploaded into this web application from some company and "it is not fixable"... I tried contacting them a few times. Nobody on the other side wanted to help
 
Hmm, okay. So, that sounds totally doable, except for the part where a window opens that is not a browser window. That sucks, because Selenium only knows how to do browser things. I don't really have experience with that, I know there's something in Java that can automate moving your mouse and clicking on things, but that requires that the window is at the same exact position everytime you open it. I think this might be where something like AutoHotkey might come in handy.
 
Hmm, okay. So, that sounds totally doable, except for the part where a window opens that is not a browser window. That sucks, because Selenium only knows how to do browser things. I don't really have experience with that, I know there's something in Java that can automate moving your mouse and clicking on things, but that requires that the window is at the same exact position everytime you open it. I think this might be where something like AutoHotkey might come in handy.

Probably would need to write a chrome extension. That would be a good place to start looking. That means learning Javascript.

The way it could work is that it looks at the URL to see if it matches the URL used by these windows that pop up. If so, it would then dig into the DOM model of the document to find the text fields and do the replacement. The first time you would enter the fixes manually. Your chrome extension would remember the corrections and serialize them. The next time you get the list, when it opens the window it would see the URL like i said earlier, find the entry for the "wrong" value, look up in the serialized data store to see if that value has been fixed, if so it would automatically replace and click the next button. It could repeat this until it got to an entry it had never seen a correction for. Then you enter this one by hand and it will save it again. Etc
 

injurai

Banned
Probably would need to write a chrome extension. That would be a good place to start looking. That means learning Javascript.

The way it could work is that it automatically tries to do a replacement based on the URL (I'm assuming the URL never changes), and if it detects that the URL matches it would then dig into the DOM model of the document to find the text fields and do the replacement. The first time you would enter the fixes manually. Your chrome extension would remember the corrections and serialize them. The next time you get the list, when it opens the window it would see the URL like i said earlier, find the entry for the "wrong" value, look up in the serialized data store to see if that value has been fixed, if so it would automatically replace and click the next button. It could repeat this until it got to an entry it had never seen a correction for. Then you enter this one by hand and it will save it again. Etc

Could automate post requests too.
 

kitzkozan

Member
I have a small problem that should be no trouble for most people here (sorry, beginner here :p ). I'm in the middle of completing a couple of programs in C and there's one where I need to use a Do...while loop. So far so good, but I need to make a sum out of integers which alternate between negative and positive ( it goes like -2 + 4 - 8 + 16 - 32 + 64).

I did check briefly around the web, but wondering what's the trick to alternate between negative and positive integers while adding them to a sum.
 

Chris R

Member
Looks like you need to store a copy of your current value along with the sum, then multiply the current value by -2 and add it to the sum.
 
I have a small problem that should be no trouble for most people here (sorry, beginner here :p ). I'm in the middle of completing a couple of programs in C and there's one where I need to use a Do...while loop. So far so good, but I need to make a sum out of integers which alternate between negative and positive ( it goes like -2 + 4 - 8 + 16 - 32 + 64).

I did check briefly around the web, but wondering what's the trick to alternate between negative and positive integers while adding them to a sum.

Keep a sum and a current_term outside the loop. Each time through, multiply the current_term by -2 and add it to the sum
 

alatif113

Member
I have a small problem that should be no trouble for most people here (sorry, beginner here :p ). I'm in the middle of completing a couple of programs in C and there's one where I need to use a Do...while loop. So far so good, but I need to make a sum out of integers which alternate between negative and positive ( it goes like -2 + 4 - 8 + 16 - 32 + 64).

I did check briefly around the web, but wondering what's the trick to alternate between negative and positive integers while adding them to a sum.

Code:
int sum = 0;
int term = -2;

while (condition) {
sum += term;
term *= -2;
}
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Hey all, I have a question that I thought would be simple, but has turned into a real pain in the butt. Well, two of them, one involving a fading caption box in a slide show (but I'll table that one for now).

My main question that I'm hoping somebody can answer is how to have previous and next buttons in a horizontal web page. I have anchor points and when the user scrolls, the page snaps to those points on the page. It works perfectly with just the mouse wheel.

But how do I have buttons that go back and forth between the points? The buttons should stay visible while the rest of the page scrolls beneath, so just hyperlinking to the points won't work.

Any help would be super appreciated. Google and my own knowledge has failed me here.
 
Hey all, I have a question that I thought would be simple, but has turned into a real pain in the butt. Well, two of them, one involving a fading caption box in a slide show (but I'll table that one for now).

My main question that I'm hoping somebody can answer is how to have previous and next buttons in a horizontal web page. I have anchor points and when the user scrolls, the page snaps to those points on the page. It works perfectly with just the mouse wheel.

But how do I have buttons that go back and forth between the points? The buttons should stay visible while the rest of the page scrolls beneath, so just hyperlinking to the points won't work.

Any help would be super appreciated. Google and my own knowledge has failed me here.

Use "position: fixed" for those buttons, maybe affixing them to top when user scrolls past them (see Bootstraps Affix-plugin for an example: http://getbootstrap.com/javascript/#affix)
 

WanderingWind

Mecklemore Is My Favorite Wrapper
I really appreciate the quick response. The buttons are there already, but I don't know how to get them to cycle to the previous or next anchor point on the site. I know I can hyperlink them to a single point, so I can shift between two points with ease. But I'm basically making a timeline and want to be able to just go to the previous and next anchor point.

If that makes any sense.
 

Ambitious

Member
FWIW, I haven't read this book, but another book of his, Scala for the Impatient. It was a great primer and would recommend it again, so if it's like that for Java8, then it's probably worth it.

I have actually read it too. His writing style is fine; I was just wondering whether someone was aware of a better resource.
 
I really appreciate the quick response. The buttons are there already, but I don't know how to get them to cycle to the previous or next anchor point on the site. I know I can hyperlink them to a single point, so I can shift between two points with ease. But I'm basically making a timeline and want to be able to just go to the previous and next anchor point.

If that makes any sense.

Oh, well. You add a class or other attribute for the current section. When you click the button, you find the next section from the current section and scroll to that. Remove the class from the old section and add the class to new section.

Very hasty example that skips a few corners: http://jsfiddle.net/qzy3qx7o/1/
 

WanderingWind

Mecklemore Is My Favorite Wrapper
Oh, well. You add a class or other attribute for the current section. When you click the button, you find the next section from the current section and scroll to that. Remove the class from the old section and add the class to new section.

Very hasty example that skips a few corners: http://jsfiddle.net/qzy3qx7o/1/

That's exactly what I'm trying to do (albeit with custom buttons, natch). I'm trying to work this in now. I really appreciate this one, thank you much.

EDIT: Okay, so it works in the fiddle, but for the life of me I can't even get it to work by itself, much less integrated into the page. http://gamesandbeer.com/buttons/Buttons.html What the heck am I doing wrong here?
 

wolfmat

Confirmed Asshole
That's exactly what I'm trying to do (albeit with custom buttons, natch). I'm trying to work this in now. I really appreciate this one, thank you much.

EDIT: Okay, so it works in the fiddle, but for the life of me I can't even get it to work by itself, much less integrated into the page. http://gamesandbeer.com/buttons/Buttons.html What the heck am I doing wrong here?

You didn't actually reference jquery. You should've added a script link to the head section.
Code:
<head>
    <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
[ .. ]
(Not sure this is the jquery you want. But anyway, the script isn't in the header, but you're using $, so that's an issue.)
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
What book would you guys recommend for studying data structures?

I've been through my algorithms and data structures class, but I want to learn more.
 

WanderingWind

Mecklemore Is My Favorite Wrapper
You didn't actually reference jquery. You should've added a script link to the head section.
Code:
<head>
    <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
[ .. ]
(Not sure this is the jquery you want. But anyway, the script isn't in the header, but you're using $, so that's an issue.)

Wow.

Dude. ....thanks man, really. Holy hell.

EDIT: Okay, so I got it to run independtly because wolfmat and Petrip are sort of the baddest dudes this side of Abraham Lincoln, but I can't get anything short of a single image to coexist with this. Do I need to separate my content and place each in the <div> tags? So, like my first slide's worth of content goes into the First Section div, next goes into second, etc, etc?

Obviously, I'm learning as I go, so if this is some simple stuff that I'm missing, please be easy on me. I really am looking up all the resources I know about and testing as best I can by breaking down the code and trying stuff out before asking here. Not trying to take advantage, but I am trying to learn.
 

wolfmat

Confirmed Asshole
Wow.

Dude. ....thanks man, really. Holy hell.
You're welcome.
Always check the web developer console (Firefox Mac: Cmd-Alt-K; Firefox Windows / Linux: Ctrl-Shift-K). Errors like these become obvious then. (Firebug disables it, so deactivate Firebug and reload if that's going on)
 

WanderingWind

Mecklemore Is My Favorite Wrapper
You're welcome.
Always check the web developer console (Firefox Mac: Cmd-Alt-K; Firefox Windows / Linux: Ctrl-Shift-K). Errors like these become obvious then. (Firebug disables it, so deactivate Firebug and reload if that's going on)

I had literally never heard of that until today. I did post another edit above, if you know what the hell I'm talking about.
 

wolfmat

Confirmed Asshole
I can't get anything short of a single image to coexist with this. Do I need to separate my content and place each in the <div> tags? So, like my first slide's worth of content goes into the First Section div, next goes into second, etc, etc?

Yes, that's usually how people structure HTML.

Something like
Code:
<div class="section" id="section1">
    <h1 class="section-header">First section</h1>
    <div class="section-content">poop content</div>
</div>
<div class="section" id="section2"> etcpp
 
What I do now is:

1. Open the transaction (mouse click)
2. Put cursor in a field, change value, tab, tab, tab to next field and change value
3. Tab to name field
4. See the name and figure out what it should be
5. Go to second monitor and do Ctrl+F and search for correct name
6. Mouse drag over the correct name to select it, CTRL+C
7. Back to Firefox, highlight the whole name and CTRL+V
8. Press on the next transaction

Really boring, so I really want to automatize it if possible and learn a bit of programming while am at it (always wanted to do some light programming)

Could automate post requests too.

^^^ Knows what's up.

Likely the best way to do this is to cut out the browser altogether, it's just making requests to a server anyway so all you need to do is simulate the same requests. There could be some gotchas to this depending on whether you need to authenticate with the application in some way etc. but a browser isn't magical, it's just making HTTP requests. You should read up on:

How HTTP works (this may not make much sense to begin with but you'll need it)
Pick a language and learn the very basics, I recommend Python, as it has a ton of very easy to use libraries for things like HTTP requests and HTML parsing.
Find a tutorial on using your language to make HTTP GET/POST requests.
Poke around in your web application and try to figure out what requests it's making to get the page, and what requests it's making to update the names.
Figure out how to parse the relevant data out of 1 of these pages.
Figure out how to post the correct data for 1 of these pages.
Hook it all together.

This is not a trivial project for a beginner by the way, but it's a great way to learn some programming, you'll pick up a lot of really useful stuff if you stick this out. Ask if you need more specific advice or help in here and good luck!
 
Anyone familiar with Smalltalk + Squeak?

Just on the week of Bloodbornes release my prof drops a java assignment and small talk, and we just started learning small talk a week ago ;_;. I'm working on my java assignment and I'm sure I'll get that done, but just preemptively asking about smalltalk because it honestly intimidates me, I've never used a non imperative language. The assignment in question is a tic tac toe game with a gui + an AI that always results in a draw.

I could do this easily enough in java but I barely have an idea of how to even start a gui in smalltalk (we went over a quinto example in class). Any comprehensive (free) online resources for small talk and how to make a game similar so I could study it?
 
Anyone familiar with Smalltalk + Squeak?

Just on the week of Bloodbornes release my prof drops a java assignment and small talk, and we just started learning small talk a week ago ;_;. I'm working on my java assignment and I'm sure I'll get that done, but just preemptively asking about smalltalk because it honestly intimidates me, I've never used a non imperative language. The assignment in question is a tic tac toe game with a gui + an AI that always results in a draw.

I could do this easily enough in java but I barely have an idea of how to even start a gui in smalltalk (we went over a quinto example in class). Any comprehensive (free) online resources for small talk and how to make a game similar so I could study it?
You've already linked to Squeak By Example, and honestly that's the most up to date, printed resource on Squeak Smalltalk that I'm aware of. Stephane Ducasse, the guy who later founded the Pharo Smalltalk project (a Squeak fork), has had an archive of printed Smalltalk resources, but many of those are not really a good fit for Squeak.

Squeak's another odd choice to teach. It is based on an open source build of Apple Smalltalk-80 from the mid-90s, yes, but since it was open sourced it was largely positioned as infrastructure for research projects by former Smalltalkers. Pharo is probably more beginner friendly, but I've seen first hand a Smalltalk-80 developer struggle as much as I to understand it.

I wish I could help you more. Digitalk Smalltalk/V and Smalltalk-80 were pretty easy to learn, but Squeak and Pharo have a ton of new, special purpose objects and projects that I just don't know where to begin.
 

Aureon

Please do not let me serve on a jury. I am actually a crazy person.
I'll try to elaborate a bit more, sadly I can't show you any screen grabs yet as I haven't got the damned lists yet.

Anyhow I get a list of transactions. Now I have to open each and every one on the list. When I open one transaction I get a new window (not a browser new window) with a few fields. I only need to fill out 2 of them. One is always the same and the other one changes each quarter.

And lastly the field with a name. It could say

akesson jarni. But I need it to be Järni Åkesson.

Now the "wrong" one is always the same, it is how they wrote it the first time and I'm stuck with that. I have a list of corrected ones that I made for myself. So in theory I could just do a search for "akesson jarni" and just replace it with the correct one. Maybe have a script and bind it to a hotkey

seclect text from field where the marker is
compare it to a list with predefined names (they are always the same but they are many)
replace with correct name


Now like I said I have no idea how any of this works except for maybe logic of it. I use Firefox or Safari for dataentry and have the list with corrected names in both PDF and Excel.

What I do now is:

1. Open the transaction (mouse click)
2. Put cursor in a field, change value, tab, tab, tab to next field and change value
3. Tab to name field
4. See the name and figure out what it should be
5. Go to second monitor and do Ctrl+F and search for correct name
6. Mouse drag over the correct name to select it, CTRL+C
7. Back to Firefox, highlight the whole name and CTRL+V
8. Press on the next transaction

Really boring, so I really want to automatize it if possible and learn a bit of programming while am at it (always wanted to do some light programming)

The CORRECT way is to cut the browser altogether.
However, with no programming experience, it'd take a solid month of work to even understand how to begin doing that. At the very, very least.

So, go tangentially: Use AutoHotKey or a similar product, and automate your mouse - a step at time. Lookup (4.) is going to be the hardest, because you need data access in some way.
 
Yes, that's usually how people structure HTML.

Something like
Code:
<div class="section" id="section1">
    <h1 class="section-header">First section</h1>
    <div class="section-content">poop content</div>
</div>
<div class="section" id="section2"> etcpp

Even better with semantic elements

Code:
<section>
  <h1>Main section</h1>
  <section>
      <h2> Poop section </h2>
      <div> just some poop content</div>      
  </section>
</section>

And so on.

There's an semi-active web development here for all your web dev / design problems. Not that they couldn't belong in here too, but why-not-both.gif
 

Ambitious

Member
Anyone familiar with Smalltalk + Squeak?

Just on the week of Bloodbornes release my prof drops a java assignment and small talk, and we just started learning small talk a week ago ;_;. I'm working on my java assignment and I'm sure I'll get that done, but just preemptively asking about smalltalk because it honestly intimidates me, I've never used a non imperative language. The assignment in question is a tic tac toe game with a gui + an AI that always results in a draw.

I could do this easily enough in java but I barely have an idea of how to even start a gui in smalltalk (we went over a quinto example in class). Any comprehensive (free) online resources for small talk and how to make a game similar so I could study it?

Funny coincidence. I'm in a similar situation. We have to do two assignments: For the first, we're free to choose any object-oriented language, but the second has to be in Smalltalk using Squeak. And both assignments are actually games too.
 

maeh2k

Member
Hmm, okay. So, that sounds totally doable, except for the part where a window opens that is not a browser window. That sucks, because Selenium only knows how to do browser things.

It's not clear to me, what kind of window opens. Are we sure it's not just some modal dialog on the webpage? Before knowing exactly what happens, I wouldn't dismiss Selenium just yet.
 
Top Bottom