Traevel 216 Light Poster

I don't know why it does that. You can try checking the content of pathItems and see if it actually contains anything, but I don't know if you can do that from within the program you're writing the script in. I have no experience in writing scripts with Adobe.

Traevel 216 Light Poster

this.age = (this.age * increment) + this.age;

So if I am 40 and the increment is 5 I would be (40 * 5) + 40... talk about time flying. Why not just add increment to age?

Also, as a rule of convention: Person Kail = new Person the variable name Kail should be lowercase kail.

Traevel 216 Light Poster

What is the content of fillrmv[i] ? Maybe it doesn't have a property filled.

Is this scripting for Adobe Illustrator btw? Because I have no idea where you get things like app.activeDocument.pathItems from.

Traevel 216 Light Poster

Change var fillrmv = curDoc.pathItems[0]; to var fillrmv = curDoc.pathItems; because you want it to be all the items and not just the first one. And change for (i=0;i>fillrmv.length;i++) { to for (i=0;i<fillrmv.length;i++) { because you want it to run for all the items (< instead of >).

diafol commented: Patience +1 :) +15
Traevel 216 Light Poster

I don't think you need fillrmv at all. Unless you want to store the .length in there or something.

Traevel 216 Light Poster

Yes, but, from that page:

All it takes is the right configuration (to send mail using a local or a remote server)

So make sure that you include those configurations when you notify your tutor. Or it won't work on their machine.

You don't need PEAR (it only makes things easier and has more options) but you do need to specify an SMTP if you're running your page from localhost. If you're running it on an online host it will depend on their settings.

Traevel 216 Light Poster

Well even the official PHP mail page makes references to the PEAR package and encourages its use. Down in the comments there are some people who tinker with the php.ini and sendmail.ini to get it to use google smtp, but your tutor wouldn't have those either. If possible I would try to send him/her the entire package of your code, including any libraries.

Traevel 216 Light Poster

Correct me but isn't that what the code is doing ?

It's not.

if (app.activeDocument.pathItems[0].filled.length == true) {

This is saying, if the length of the "array" of the filled property (which might be an array according to JS, it doesn't know better) equals true, then execute the statement. If that length happens to be 1 (which it is because it's not an array and only has 1 element) the statement will be true because in JS 1 equals true. It basically becomes if (1 == true) {.

for (i=0;i>fillrmv;i++) {

This literally means: start with a variable i that equals 0. As long as i is larger than fillrmv (which is a boolean value mind you) then keep increasing i with 1.

var fillrmv = curDoc.pathItems[0].filled = false;

Here you are saying that fillrmv should be set to the value of curDoc.pathItems[0].filled which should be set to false;
So you are setting the first element's filled property in curDoc.pathItems to false. But fillrmv is also set to false.

I think the main issue here is that JavaScript is very "relaxed" when it comes to variables. In other languages you would get errors that help you out, but JS allows for a lot of weird things. You normally can't put a boolean in a for loop, comparing a number to a boolean usually results in a mismatch. However, JS just assigns a truth value to the number (using vague rules that are very difficult to …

Traevel 216 Light Poster

Are you sure you are allowed to send mail from your server? Localhost can't on its own and most hosts block it. Maybe look into using an smtp server with PHP to send mails, for instance, with your google account.

PS, to the mod that edited OP's snippet: feel free to censor my post as well.

Traevel 216 Light Poster

Not so much what you're doing wrong is explained in the videos but why it doesn't blow up when you do that. Because in most languages it will blow up and won't let you do that.

What I'm doing wrong

I think the start of your issue is this bit:

var fillrmv = curDoc.pathItems[0].filled = false;

It's pretty much always a bad idea to assign variables this way. In JavaScript it's sort of ok, because here there are no references, but in a lot of languages this would mean that fillrmv is a reference to filled which is set to false. If you then changed filled to true you'd expect fillrmv to stay false (and in JavaScript it does) but it would actually refer to filled and be true.

and set each object in the array to false

In order to do that you'd set fillrmv to the length of the pathItems array. Then inside your for loop you would say something like:

curDoc.pathItems[i].filled = false;

You can retrieve the length of an array by calling the length property. For instance:

var arr = ['one', 'two', 'three'];
for (var i = 0; i < arr.length; i++) {
    arr[i] = 'changed_'+i;
}

Edit: Keeping my answer slightly on the vague side because it looks a bit like homework, if it's not let us know.

Traevel 216 Light Poster

if (app.activeDocument.pathItems[0].filled = true) {

A single = is used to assign a value, a double == or triple === is used to check a value. So basically in this statement you are assigning true to filled instead of checking whether filled is true.

Also, in your for loop for (i=0;i>fillrmv;i++) { you are saying to continue as long as i is larger than fillrmv, but in var fillrmv = curDoc.pathItems[0].filled = false; you're assigning a boolean value to fillrmv. This is where "silly" JavaScript kicks in. Under water it's assigning truth values to things. If you ask JavaScript "is 1 larger than false" it will say "yep". If you ask it "is 1 smaller than false" it will say "nope". (because '0' is 'falsy' and '1' is 'truthy' and true is "larger than" false)

For a good laugh I recommend this (slightly dated) video about some funny quirks JavaScript has.

For an explanation on why JavaScript is so quirky I strongly suggest this video.

One of the things it explains is why, in JavaScript, this:

function() {

}

...is the only correct way and this:

function()
{

}

is a wrong way.

And many more things that are just a little different in JavaScript.

Traevel 216 Light Poster

I don't any edit button on the post?

If you could edit it would still be a risk. Google will have indexed the page by now so people can still view the cached versions. If it's a database that's runned by the university maybe contact someone from tech support and see if they can change the password for you.

Traevel 216 Light Poster

You can't send e-mail from localhost without an smtp server running and a lot of (free) hosts have it disabled by default. The free ones usually require a tiny payment to enable email as a way to discourage spammers.

Also, change your mariadb user name and password because you seem to have posted them:

$username = "s100042374";
$pass = "081292";
Traevel 216 Light Poster

That happens a lot when you give them cookies right before bed time. It's something to do with the sugar, rookie parent mistake.

Also check for running processes that cause nightmares, preventing a good night's sleep. You can check by running powercfg -requests from an admin command prompt.

Traevel 216 Light Poster

Do you mean Java or JavaScript? Both is yes by the way.

I'm guessing you mean JavaScript, have a look at the jQuery library and specifically its XML functions. It also supports Ajax calls to get to that text file, though you might want to open up a new question if you hit any issues so that knowledgeable people can help you deal with them. They might not always find it if it's not tagged with JavaScript.

It's easier to get a PHP host than a Java host, but you could have a look at OpenShift. Last time I read they offered a small free option, but I'm not sure if they still do that.

In Java you would basically load the XML into an object. A Vogella tutorial is usually a good place to start when learning the basics.

Traevel 216 Light Poster

You can edit within the hour, after that it's locked.

The only other guess I had was that the splitting had gone wrong, but since you've printed those variables that's probably not it. If you change columns = line.split() (which splits on space) to columns = line.split('|') you would have all the columns in the proper place, but you've already worked that bit out by adjusting and recombining the columns.

Traevel 216 Light Poster

I don't know if I can answer, but it would help others as well if you could post an example of a line that you're trying to parse.

In the documentation page regarding strptime it states that %p is locale dependent.

Locale’s equivalent of either AM or PM.
AM, PM (en_US);
am, pm (de_DE)

Other than that I have no new ideas, sorry.

Traevel 216 Light Poster

Hi,

Until someone who knows Python gets here...

ValueError: time data '01:11 PM' does not match format '%I:%M%p'

Perhaps it's because 01:11 PM has a space and %I:%M%p doesn't. Maybe try %I:%M %p?

Because from the official page:

dt.strftime("%A, %d. %B %Y %I:%M%p")
'Tuesday, 21. November 2006 04:30PM'

Traevel 216 Light Poster
<button type="button" onclick="Light()"> Change Image!</button> 

You're calling Light() but the method is now light(). Also you might have to change all the image url's to their full path (i.e. http://localhost/myproject/img/start.png). If they are local files you could use the image url's diafol posted. Be sure to read his post, that's the way to do it properly.

For instance, where I live the lights don't turn amber when you can start driving again (only when you're about to stop). With his solution you could adjust the code to my situation simply by removing the corresponding image from the array.

Traevel 216 Light Poster

Hi,

In JavaScript a single = is used to assign a value and a double == is used to check a value. Also the term then can be removed entirely. You also have an error in the image tag itself, style= "width:304px;height:500px; <onclick="light()"> should just be style= "width:304px;height:500px;">. You already have the onclick attribute. Lastly, the original image has stop.png as a source but you check for Stop.png in your function.

If I change your JavaScript to the following (note the == when checking and the = when assigning)

function light() {
  if (document.getElementById("Img").src == "Stop-Amber.png") {
    document.getElementById("Img").src = "Stop.png";
  } else if (document.getElementById("Img").src == "Go.png") {
    document.getElementById("Img").src = "Stop-Amber.png";
  } else if (document.getElementById("Img").src == "Amber.png") {
    document.getElementById("Img").src = "Go.png";
  } else if (document.getElementById("Img").src == "Stop.png") {
    document.getElementById("Img").src = "Amber.png";
  }
}

the sequence I get is

  • Stop
  • Amber
  • Go
  • Stop-Amber
  • Stop
  • etc.

Also, you might have to change the img url's to their full paths. I tried this in a JSFiddle and had to change all the image paths to https://fiddle.jshell.net/_display/Amber.png for it to work.

Considering this is probably a homework assignment, here are some general pointers.

  • Function names should begin with a lowercase letter, following camelCase.
  • Even though JavaScript has automatic semi-colon insertion (leading to both hilarious and frustrating problems) you should add them to let the parser know where your statement ends.
  • Giving an image the id Img will work, but it's not very useful when you have several. Try …
diafol commented: Excellent example of what Daniweb is all about. Hats off to you. +15
cereal commented: +1 +14
Traevel 216 Light Poster

You can do it in vanilla JavaScript if you want. There is a getElementsByClassName function, similar to the familiar getElementById, that returns an array of the elements with that class name.

Something along the lines of

var elements = document.getElementsByClassName("command");
for(var i = 0; i < elements.length; i++) {
  elements[i].innerHTML = "changed";
}

In jQuery the same action would be something like

$(".command").html("changed");

It's easier to do in jQuery, but marginally slower in terms of performance. It would depend on the rest of your JavaScript code whether or not it would be worth to use a library, but if this is the only part I wouldn't bother with it.

Traevel 216 Light Poster

The engine is repl.it
Is there a better engine.

That one uses the same one as Firefox (SpiderMonkey), Node.js uses the one Chrome does (V8). You can even compare the two on that site I see. (For what it's worth, IE and Edge use the Chakra engines, Safari uses WebKit).

It's best to use code that compiles on all engines since your users will likely be on Firefox, Chrome, Safari or Edge as well. As you have noticed that isn't always as easy as it sounds.

rproffitt commented: Web developers, second verse! +6
Traevel 216 Light Poster
function unicoding(str) {
  for (i = 0; i < str.length; i ++) {
    console.log(String.charCodeAt(i))
  }
  return str;
}

You're not using the str variable but String, which should give you a type error.

2015-11-07--1446935403_476x330_scrot.png

Change it to str.charCodeAt(i).

My guess is that the engine you're using is interpreting String.charCodeAt(0) as String.charCodeAt('0') and giving you the unicode for 0, 1, 2, 3, 4 etc. which are the values of i given those str lengths you supplied. But, as you can see in the screenshot it won't compile on all JavaScript engines.

Traevel 216 Light Poster

What you are calculating is the population standard deviation which, for 1-10, is 2.87228. The sample standard deviation for 1-10 is indeed 3.02765. For a sample deviation you need to divide by N - 1 instead of N. I'll leave it up to you to implement that. (hint: N is the length of your list of arguments)

A few general pointers about your code:

      intMath.myArray = new ArrayList<>(10);
            for (int i = 0; i < 10; i++) {
            intMath.myArray.add(1);
         intMath.myArray.add(2);
         intMath.myArray.add(3);
         intMath.myArray.add(4);
         intMath.myArray.add(5);
         intMath.myArray.add(6);
         intMath.myArray.add(7);
         intMath.myArray.add(8);
         intMath.myArray.add(9);
         intMath.myArray.add(10);
            }

That means you're adding 1-10 ten times, i.e. 100 numbers. You have access to the i variable, so use it to populate the ten numbers correctly. One way or another it will mess up your calculations (i.e. when you implement N-1). You need to change it so there's only one intMath.myArray.add left in the loop.

Always program to an interface and encapsulate your variables. So public ArrayList<T> myArray; should be private List<T> myArray;

There is no need for stdev to be static, especially since you already define an instance on line 10. So instead use intMath.stdev(intMath.myArray) on line 27 and remove the static keyword; you should also use List here, and optionally final.

public <T extends Number> double stdev(final List<T> a) 

Lastly, you're using stdev = Math.pow(stdev, .5); to calculate the square root. However, java.lang.Math has a sqrt method just for that:

stdev = Math.sqrt(stdev); 

Edit: keep in mind that you hardcoded 1-10 but by correctly implementing …

kayleigh0411 commented: Thank you! +0
Traevel 216 Light Poster

Well, both have bootstrap. The first one has the "image" <form> in a <table>, the second one doesn't. The first one just has TestPage, because it's not in a <title></title>. The second one has a large "Upload page" text but that's it.

2015-09-29--1443545345_581x379_scrot.png

I don't see a "not working".

If you do mean the difference between a table alignment and a bootstrap alignment, then perhaps you can use this tutorial to apply a bootstrap layout to your form without using tables. Specifically the section entitled horizontal form layout, which resembles your original table version the most.

Obviously I had to remove the <?php include("img-upload.php");?> since you didn't post that. Perhaps the "non working" bit is in there. If it is, elaborate on what's not working.

Traevel 216 Light Poster

It's in the zip.

2015-04-17--1429300746_779x460_scrot.png

If you have a lot of different file types to work through, perhaps Apache Tika is an alternate solution to your problem. It uses POI and many others, but combines them into a single API for mimetype detection and metadata/content extraction.

Alternatively, if you're using Maven you can just add

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.11</version>
</dependency>

for POI or

<dependency>
    <groupId>org.apache.tika</groupId>
    <artifactId>tika-app</artifactId>
    <version>1.7</version>
</dependency>

for Tika.

No need for manual downloads that way. You can read up on Maven in Eclipse here.

Traevel 216 Light Poster

Java has GUI's yes.

1.) keep a list of all the movie available.

In what?

3.) On the program itself. Call VLC to play the movie.

That's possible in VB.NET, Java and even in web.

4.) Online capability is not needed.

Then why consider web?

It seems like you want to keep everything local. Web and local can cause problems, which may require workarounds, and since you're not mentioning any web languages I'd reckon you're better off with one of the other two. Why not pick the one you're best at?

Traevel 216 Light Poster

Well, disabling JavaScript for starters.

But also altering your page through the browser, creating my own version of the page and having it send data to yours, or even bypassing the front-end altogether and just send data to the server. Never let the server trust what's coming in.

Assume the data that reaches the server can be wrong, and validate at a point where it can't be changed anymore. Right before it goes into the database for example.

Traevel 216 Light Poster

Any JavaScript validation is vulnerable. Use server side validation on all fields before allowing it.

Traevel 216 Light Poster
$.ajax({
    type: "POST",
    url: "a.php",
    data: postData,
    success: function(data){
        window.open("a.php");
    }
}); 

Instead of doing something with the response you open a.php again but without sending any data.

If you just want a different button to do the submitting you can use submit().

Traevel 216 Light Poster

What if you added it as none to the transparent div and as auto to the elements in the transparent div that need clicking?

I don't know why internet explorer would allow it when the others don't.

Traevel 216 Light Poster

In the sense of "I have a cinema app and I want IMDB's movie data for the films playing" or more like "let's see what the NSA is up to these days"? (don't scrape us, we'll scrape you!)

2015-01-21--1421827025_100x30_scrot.png

Nice try NSA, nice try.

In all seriousness, some sites (like this one) provide public API's for their data.

cereal commented: lol! +13
Traevel 216 Light Poster

You can use pointer-events:none in the css of that transparent div to "ensure" it won't be the target of mouse events.

Ensure between air-quotes because it will depend on what's below the div. Also, it won't work in old IE (but what does).

Traevel 216 Light Poster

It does yes, but at a larger cost.

To compare:

SELECT * FROM `person` ORDER BY RAND() LIMIT 1
Query took 1.1831 sec

It's still managable I suppose, depending on how often you need to use it.

Traevel 216 Light Poster

Get a random number between 0 and the amount of records using count x rand, then use LIMIT offset, amount.

So for instance, let's say the random number is 5.

SELECT * FROM foo LIMIT 5,1

would give you the 6th row (starts at 0). You could also just select the ID if you need it.

On a table with 1.1M records:

 SELECT CAST((COUNT(*)*RAND())-1 AS UNSIGNED) FROM `person`
 Query took 0.1211 sec

 SELECT * FROM `person` LIMIT 521541, 1
 Query took 0.1884 sec

Managable I'd reckon.

pixelsoul commented: Good suggestion +8
Traevel 216 Light Poster

Ah ok, I just noticed you use $table.html('<table>'), $table.html('<tr>'); and so on. You're overriding its contents? From the API:

When .html() is used to set an element's content, any content that was in that element is completely replaced by the new content

Considering $table.html('</table>') is the last one, that would be what's printed. Assuming $table is indeed correctly referring to <table class="table" width="100%">. That's what I meant with perhaps give it an id. It only has a class, so even if you do find it, any other table with that class would also be selected.

Traevel 216 Light Poster

[
Nome: Interior;
IdDireta: 2;

Nome and not name?

if (p === "Name") {

var _this = this, $div = _this.$div, opts = _this.settings, $table = $div.find(opts.tableSelector);

What is this? your $table is this.$div.find(this.settings.tableSelector) and $div = this.$div?

It only has a class <table class="table". Try an id or something simpler to check, this construct is overly complicated for debugging.

Traevel 216 Light Poster

$("#degree_name_id").focus(); will set focus in jQuery.

document.getElementById("degree_name_id").focus(); will set focus the old fashioned way.

Traevel 216 Light Poster

Are you hosting it yourself? Check ports and whether the host allows remote access to a MySQL database. Also check you have the proper user privileges in place (GRANT).

Traevel 216 Light Poster

I'm a thirteen year old programmer.

From your linkedin you posted on your profile:

2015-01-15--1421325895_590x143_scrot.png

You "enrolled" when you were 9? You'd think there would have been something in the news about that.

Regardless of the age (and truth), why hang around here asking if you're a genius, go build a space station or something. No one will question you if you're on the news floating around in space. But they will if you run around saying "I'm a genius right?" on a forum.

Traevel 216 Light Poster

If you're new you should be willing to learn and follow tutorials. What's the point in one of us converting your format for you? You're not saying you're having a problem with a small part of the conversion, but with everything. How can we ever help with that, teach you PHP from scratch?

Using mysqli you could try something like:

$id = 5; 

$sql = "SELECT id, cat FROM articles WHERE cat = (SELECT cat FROM articles WHERE id = ? LIMIT 1)";

$stmt = $conn->prepare($sql);

if($stmt === false) {
  trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

$stmt->bind_param('i',$id);

$stmt->execute();

$stmt->bind_result($id, $cat);

while ($stmt->fetch()) {
  echo $id . ' = ' . $cat . '<br>';
}

$stmt->close();

Which is all taken from that exact same tutorial. It should print all id's and cat's of the articles that have the same category as the article with id number 5 (this includes 5 itself). If you don't have articles, or categories or unique id's it will go wrong.

Also, it needs error handling, if you keep it like this things will hit the fan at some point.

Traevel 216 Light Poster

Anything you can tell about the inner workings of that object?

Because if I try something like:

        var Object = function(){
            this.Status = {
                Name : "foo"
            };
        };
        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Or

        var Object = function(){
            this.Status = new Status();
        };

        var Status = function(){
            this.Name = "foo";
        };

        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Nothing seems the matter.

Traevel 216 Light Poster

Read Taywin's last part again:

I do not want to modify your script because it is using bad format already

If he gave you the answer before you modified the code to a proper mysqli or PDO format it would stay bad code. You might have your category issue fixed, but tomorrow something else will cause a problem, and the next day another, and so on.

His advice to fix the format of your code now while you're still working on the basics is one I fully agree with.

I suggest you rewrite your code from mysql syntax to mysqli syntax as the two are rather similar.

So replace mysql_query with mysqli_query and so on. Also, it would be safer to use prepared statements and not just put variables directly in the query. For a more in depth explanation on using mysqli you could read a tutorial.

From the tutorial:

$sql='INSERT INTO customers (firstname, lastname) VALUES (?,?)';

$firstname = 'John';
$lastname = 'Doe';

$stmt = $conn->prepare($sql);
if($stmt === false) {
  trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

/* Bind parameters. TYpes: s = string, i = integer, d = double,  b = blob */
$stmt->bind_param('ss',$firstname,$lastname);

/* Execute statement */
$stmt->execute();

See how that is different from what you have now. That is why an answer on how you have it now won't help you, or anyone else reading this post later looking for answers.

Traevel 216 Light Poster

That's because you used a 0 (zero) and not an O.

Traevel 216 Light Poster

Are you sure you are creating a new map each time?

Keep in mind you're adding a reference to the map, not a snapshot of the map itself. If you change the map the reference in the list will simply point to the changed version.

Traevel 216 Light Poster

You didn't get an answer in VB.NET and I doubt you'll get one in here. That's like asking how to build a car. Be more specific.

Traevel 216 Light Poster

By "fails", what do you mean?

What comes to mind is the blocking nature of an alert(). It blocks execution while awaiting your click. Removing the alert would remove the block.

It's going fine here in a test. It hides the divs, loads a text file and shows the div regardless of the alert being present.

Traevel 216 Light Poster

You could use RTP/RTCP over UDP for streaming. If memory serves me right VLC even has (some sort of) support for it.

Traevel 216 Light Poster

If you want to use it as a database, have you considered using sqlite?

From what I gather its usage is fairly straightforward in Python.

Traevel 216 Light Poster

I've merely dabbled in ASP.NET, wrestling with its quirks and most notably Entity Framework and the use of existing databases. It would have been nice if during my first steps I had known the darn thing added a pluralizing "s" to my non-english tables resulting in one of the most nonsensical data models I've ever had the horror.. I mean honor of designing.

Old personal frustrations aside, perhaps this recent post describing the setup of Identity 2.0 without Entity Framework (I'm assuming it's DB First since it builds on his previous post where he used EF and DB first with Identity 1.0) will be of some help for further research. It seems like a lot of hoops requiring lots of jumps to even get a barebones system going.

Good luck with your efforts.

PS bring an axe just in case

pritaeas commented: Thanks. +14