Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
Very simple question but the wording makes it hard to find answers on Google.
In a technical sense, is there literally no difference between calling a .js file and just having all of your javascript inside <script> tags? I'm just wondering if it can introduce any kind of scope issues.
Also, I'm absolutely useless at trying to get even basic stuff to appear/scale properly on pages. I'm currently working on [url]http://ericweb.gtxhosting.co.uk/counter/postal.php[/url], I used some examples I found off the web for the scaling of the countdown text but its all messed up. It works fine if the window is different sizes and you refresh the page, but when changing the size through dragging the scaling goes all funky and it doesnt return to its original size.
[QUOTE=Cushie;43458850]Very simple question but the wording makes it hard to find answers on Google.
In a technical sense, is there literally no difference between calling a .js file and just having all of your javascript inside <script> tags? I'm just wondering if it can introduce any kind of scope issues.
Also, I'm absolutely useless at trying to get even basic stuff to appear/scale properly on pages. I'm currently working on [url]http://ericweb.gtxhosting.co.uk/counter/postal.php[/url], I used some examples I found off the web for the scaling of the countdown text but its all messed up. It works fine if the window is different sizes and you refresh the page, but when changing the size through dragging the scaling goes all funky and it doesnt return to its original size.[/QUOTE]
As far as I know, there aren't (if your variables/functions are globally scoped,) and I think it also works the other way around.
js.js
[code]
var testVar = "Mumbletext";
[/code]
index.html
[html]
<html>
<head></head>
<body>
<script src='js.js'></script>
<script>
console.log(testVar); // Outputs content of testvar
</script>
</body>
</html>
[/html]
Does anyone know what the maximum allowed results returned from a single google analytics api query is? I'm working on a GA dashboard and if I go back too far in the query range, I get a no-result, but then if I make the range smaller by just 1 day, I get all the results.
I figure it's because of some sort of limit or quota that I'm hitting. Can anyone confirm? If so, where can I get my limit increased (maximum results per query)?
[QUOTE=Banana Lord.;43441402]I know it isn't a language and doesn't have a syntax, but every framework has its own patterns for development and I have absolutely no clue what CakePHP is doing, it's chaotic.[/QUOTE]
Read up on MVC. It's a [B]very[/B] common design pattern for web applications and it's very not chaotic when you understand it a bit better.
What's everyones proccess for putting a new version of something live?
This is the one thing that I haven't solved the problem of yet.
I've heard of people using Git to push a version onto the web, but I'm not sure on other techniques.
What's the industry standard?
[QUOTE=Shadow801;43473265]What's everyones proccess for putting a new version of something live?
This is the one thing that I haven't solved the problem of yet.
I've heard of people using Git to push a version onto the web, but I'm not sure on other techniques.
What's the industry standard?[/QUOTE]
There's not really an industry standard, but whatever you do should automate every step that you need to take when you deploy. There is no reason for you to ever have problems because a deploy step was skipped.
I use [url=http://capistranorb.com/]capistrano[/url] to deploy everything, so running a deploy for me consists of opening a shell session in the folder for the project I want to deploy and typing...
[code]bundle exec cap production deploy[/code]
This handles everything from keeping rolling backups of the last 5 deploys code to restarting the servers and running database migrations.
I can also substitute "production" for "staging" or whatever other environments I have set up. Cap is originally designed for use with ruby/rack/rails projects, but you can absolutely use it to deploy anything else as well.
You can totally use shell scripts or whatever to accomplish the same thing, but whatever you do it should definitely be automated.
I want a feed on one of my sites pages which displays the five latest posts. Whats the best way to refresh it in real time?
Currently Im at this:
[code]
$.ajax({
type: 'POST',
url: 'api_getrecent.php',
data: {},
success: function(dataa){
var $response =$(dataa)
var lastID = $response.filter("#api_lastRow").text();
var title = $response.filter("#title").text();
if(last == lastID){
//need to add this bit in
}
console.log(lastID);
console.log(title);
}
});
[/code]
That works fine, but how would I go about refreshing that for new posts to show up? Any ideas? Thanks!
[QUOTE=Chizbang;43475449]I want a feed on one of my sites pages which displays the five latest posts. Whats the best way to refresh it in real time?
Currently Im at this:
[code]
$.ajax({
type: 'POST',
url: 'api_getrecent.php',
data: {},
success: function(dataa){
var $response =$(dataa)
var lastID = $response.filter("#api_lastRow").text();
var title = $response.filter("#title").text();
if(last == lastID){
//need to add this bit in
}
console.log(lastID);
console.log(title);
}
});
[/code]
That works fine, but how would I go about refreshing that for new posts to show up? Any ideas? Thanks![/QUOTE]
Just out of curiosity, why are you using POST when you aren't sending any data?
[QUOTE=KmartSqrl;43474862]There's not really an industry standard, but whatever you do should automate every step that you need to take when you deploy. There is no reason for you to ever have problems because a deploy step was skipped.
I use [url=http://capistranorb.com/]capistrano[/url] to deploy everything, so running a deploy for me consists of opening a shell session in the folder for the project I want to deploy and typing...
[code]bundle exec cap production deploy[/code]
This handles everything from keeping rolling backups of the last 5 deploys code to restarting the servers and running database migrations.
I can also substitute "production" for "staging" or whatever other environments I have set up. Cap is originally designed for use with ruby/rack/rails projects, but you can absolutely use it to deploy anything else as well.
You can totally use shell scripts or whatever to accomplish the same thing, but whatever you do it should definitely be automated.[/QUOTE]
I've been using Grunt.js for a while now for automation of assets/clientside, which works really well. And my manager has just setup Atlassian Bamboo, which I'm hoping to start using now. My main issue is the files, when you are putting up a new version, what do you do with the old files? Do you just straight up push everything onto the server and overwrite what's old? Because that doesn't feel very safe. Or is it a case of, delete the entire directory and upload an entirely new version? You could bring it down for maintenance while this is happening I suppose, but I like to keep downtime as low as possible.
I feel like I'm missing something painfully obvious.
To anyone looking for an alternative to Capistrano specifically to be used with PHP there's [url=https://github.com/Anahkiasen/rocketeer]Rocketeer[/url].
[QUOTE=jetboy;43476618]To anyone looking for an alternative to Capistrano specifically to be used with PHP there's [url=https://github.com/Anahkiasen/rocketeer]Rocketeer[/url].[/QUOTE]
Laravel only though
Only technically, fortunately. Only 5-6 of the ~30 Illuminate components are required.
[QUOTE=jetboy;43476618]To anyone looking for an alternative to Capistrano specifically to be used with PHP there's [url=https://github.com/Anahkiasen/rocketeer]Rocketeer[/url].[/QUOTE]
Funny how there's a [URL="http://rocketeercms.com"]CMS called Rocketeer[/URL] too.
[QUOTE=Chizbang;43475449]I want a feed on one of my sites pages which displays the five latest posts. Whats the best way to refresh it in real time?
Currently Im at this:
[code]
$.ajax({
type: 'POST',
url: 'api_getrecent.php',
data: {},
success: function(dataa){
var $response =$(dataa)
var lastID = $response.filter("#api_lastRow").text();
var title = $response.filter("#title").text();
if(last == lastID){
//need to add this bit in
}
console.log(lastID);
console.log(title);
}
});
[/code]
That works fine, but how would I go about refreshing that for new posts to show up? Any ideas? Thanks![/QUOTE]
look into web sockets
[QUOTE=Shadow801;43475882]Just out of curiosity, why are you using POST when you aren't sending any data?
I've been using Grunt.js for a while now for automation of assets/clientside, which works really well. And my manager has just setup Atlassian Bamboo, which I'm hoping to start using now. My main issue is the files, when you are putting up a new version, what do you do with the old files? Do you just straight up push everything onto the server and overwrite what's old? Because that doesn't feel very safe. Or is it a case of, delete the entire directory and upload an entirely new version? You could bring it down for maintenance while this is happening I suppose, but I like to keep downtime as low as possible.
I feel like I'm missing something painfully obvious.[/QUOTE]
I push files to git. Then when I deploy capistrano connects to the server and pulls the latest code from git and sticks in in a folder that lives under a releases/ folder that has a timestamp for a name. So I will end up with something like releases/201410102515. A few other commands run, and when everything completes successfully one of the last steps of the deploy is to symlink a folder that sits beside the releases folder (called current) to make it point at the latest release. Then you just set up your web server to server files from that current directory. You end up with this structure:
[code]
releases/
2021528194
2021521259
2019521885
current/ (symlink to latest release folder)
[/code]
That way, if you need to, you can roll back to the last working release just by updating the symlink (cap has a task set up to do this so you don't have to yourself)
You're using getElementById while the element doesn't have an id attribute.
I am a bit bothered
I can't seem to figure out how to center the text in a submit button
[QUOTE=gokiyono;43484145]I am a bit bothered
I can't seem to figure out how to center the text in a submit button[/QUOTE]
css text-align: center ?
[editline]10th January 2014[/editline]
[QUOTE=bootv2;43481190]I'm pretty new to web development and am developing an authentication system.
Now I want to hash the clients passwords clientside, using an md5 hash script accessible through hex_md5("password").
What am I doing wrong in the following code?
In the end I'm going to need a variable called field_3md5 containing the md5 hash of field_3.
And, finally, I did of course include the md5 hashing javascript file in the body.
[editline]10th January 2014[/editline]
The reason everything is in quotes is because I'm sending this as text to the web browser client, using a c++ server.
So body gets sent and body is everything in quotes plus the <body></body>[/QUOTE]
Do you hash the passwords again on server with the "salt"?
Also md5 isn't encouraged to be used anymore.
[QUOTE=mdeceiver79;43485210]css text-align: center ?[/QUOTE]
[URL="http://jsfiddle.net/89FeE/"]Vertically[/URL]
[QUOTE=bootv2;43481190]I'm pretty new to web development and am developing an authentication system.
Now I want to hash the clients passwords clientside, using an md5 hash script accessible through hex_md5("password").[/QUOTE]
You should never trust the browser to encrypt passwords before sending to server.
Don't use MD5, and don't use SHA1 either. Both are almost equally easy to crack.
You shouldn't code your own encryption, unless you know cryptography and you're willing to possibly get hacked.
If you use PHP, and have PHP >= 5.5 you should use PHP's own functions. If you have PHP < 5.5, you can use [URL="https://github.com/ircmaxell/password_compat"]password_compat[/URL]. I don't know about Ruby though.
[QUOTE=TrinityX;43486437]You should never trust the browser to encrypt passwords before sending to server.
Don't use MD5, and don't use SHA1 either. Both are almost equally easy to crack.
You shouldn't code your own encryption, unless you know cryptography and you're willing to possibly get hacked.
If you use PHP, and have PHP >= 5.5 you should use PHP's own functions. If you have PHP < 5.5, you can use [URL="https://github.com/ircmaxell/password_compat"]password_compat[/URL]. I don't know about Ruby though.[/QUOTE]
He wants to do it clientside and server side by the sounds of it.
[QUOTE=mdeceiver79;43486501]He wants to do it clientside and server side by the sounds of it.[/QUOTE]
Then he should use SSL.
[QUOTE=gokiyono;43486365][URL="http://jsfiddle.net/89FeE/"]Vertically[/URL][/QUOTE]
vertical-align should work but in this case it doesn't, probably because it doesn't work on inputs.
You should replace the height with padding.
Im working on an AJAX news ticker and I have it checking the API page every second. The API page returns the title and the rowid of the latest article (So thats just 1 article). I have a timer in my Ajax JS file which GET's the results every second. Every second I add a new div for each article thats returned. Ofcorse, the code isnt going to automatically know if the article has already been added to my tickers display, so I need some logic to make sure that the same article doesnt show up again like so:
[code]
var last = null;
var here = 1;
$(document.body).fadeIn(3000);
function doIt(title){
var $response =$(title)
var lastID = $response.filter("#api_lastRow").text();
var title = $response.filter("#title").text();
var mahdiv = "#label-r"+here;
console.log(mahdiv);
if (lastID == $(mahdiv).attr('lastOne')){
}
else{
here = here+1;
$("<div id='paste-r"+ here + "'> <div id='icon-r'></div> <div id='label-r' lastOne='" + lastID + "'>" + $response.filter("#title").text() + "</div> </div>").appendTo("#recentb");
}
}
$.ajax({
type: 'GET',
url: 'api_getrecent.php',
data: {},
success: function(dataa){
setInterval(function(){doIt(dataa);}, 1000);
}
});
});
[/code]
For some reason, some how, its not working. Im missing something really simple and I cant put my finger on it somehow... Any ideas?
I am working on ruby and I was given the assignment to do this codegolf.
[url]http://codegolf.com/99-bottles-of-beer[/url]
[url]http://codegolf.com/competition/output/99-bottles-of-beer[/url]
I currently have
[ruby]
def f(i)
s=i>1?'s':''
b="#{i} bottle#{s} of beer"
end
w=" on the wall"
99.downto(2){|i|puts f(i)+w+", #{f(i)}."
puts"take one down, pass it around, "+f(i-1)+" #{w}.\n\n"
}
puts"Go to the store to buy some more. "+f(99)+" #{w}"[/ruby]
Which is 226 characters, my assignment requires that I go to 210 characters.
How would I shorten it more?
[QUOTE=01271;43492704]I am working on ruby and I was given the assignment to do this codegolf.
[url]http://codegolf.com/99-bottles-of-beer[/url]
[url]http://codegolf.com/competition/output/99-bottles-of-beer[/url]
I currently have
[ruby]
def f(i)
s=i>1?'s':''
b="#{i} bottle#{s} of beer"
end
w=" on the wall"
99.downto(2){|i|puts f(i)+w+", #{f(i)}."
puts"take one down, pass it around, "+f(i-1)+" #{w}.\n\n"
}
puts"Go to the store to buy some more. "+f(99)+" #{w}"[/ruby]
Which is 226 characters, my assignment requires that I go to 210 characters.
How would I shorten it more?[/QUOTE]
I think wrong Sub Forum :) But here you go:
[code]def f(i)"#{i} bottle#{i>1?'s':''} of beer"end
w=" on the wall"
99.downto(2){|i|puts f(i)+w+", #{f(i)}."
puts"Take one down, pass it around, "+f(i-1)+w+"\n\n"}
puts"Go to the store to buy some more. "+f(99)+w[/code]
Can you guys tell me what grunt is?
From what I can understand after using it is that it's some sort of alternative to jakefiles/cakefiles?
Is it used for deploying to a server?
I generate all my clientside assets on the server when I navigate to the requested asset page, and I cache it when it's deployed to the server.
I also use a node application called nodemon which monitors javascript files and restarts the server whenever files are changed.
How would grunt improve my workflow?
Anyone knows dart.
[code] if(querySelector('.right').className.contains('right')){
querySelector('.right').classes.add('center');
querySelector('.right').classes.remove('right');
}
else if(querySelector('.center').className.contains('center')) {
querySelector('.center').classes.add('left');
querySelector('.center').classes.remove('center');
}
else {
querySelector('.left').classes.add('right');
querySelector('.left').classes.remove('left');
}[/code]
Keep getting [code]Exception: The null object does not have a getter 'className'.
NoSuchMethodError : method not found: 'className'
Receiver: null
Arguments: []
Test (http://127.0.0.1:3030/PlexianSlider/web/plexianslider.dart:34:29)
Breaking on exception: The null object does not have a getter 'className'.[/code]
It says that its on the first else if
complete code:
dart:[URL]http://pastebin.com/ravzz7LA[/URL]
html:[URL]http://pastebin.com/mxthtsp4[/URL]
[QUOTE=Hentie;43496338]Can you guys tell me what grunt is?
From what I can understand after using it is that it's some sort of alternative to jakefiles/cakefiles?
Is it used for deploying to a server?
I generate all my clientside assets on the server when I navigate to the requested asset page, and I cache it when it's deployed to the server.
I also use a node application called nodemon which monitors javascript files and restarts the server whenever files are changed.
How would grunt improve my workflow?[/QUOTE]
It's a build system that simplifies doing various tasks such as linting, concatenation, testing, etc.
Does it matter if the doctype in <!doctype html> is lowercase? Emmet has this habit of making it lowercase and I always manually change it.
[QUOTE=Moofy;43510178]Does it matter if the doctype in <!doctype html> is lowercase? Emmet has this habit of making it lowercase and I always manually change it.[/QUOTE]
Nope, it's case insensitive. However if you're using XHTML then then it should be in uppercase otherwise the parser may return an error.
Sorry, you need to Log In to post a reply to this thread.