|
In JavaScript
I need the shortest possible code to generate the 99 bottles of beer on the wall song lyrics into a string (using "\n" as the line separator). The problem is making it grammatically correct while still keeping the code compact.
For a refresher:
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
...
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
I'm searching for the cleverest, most compact approach.
Any ideas?
|
|
|
|
|
It's your homework; you do it. Or maybe you could search for a website with that problem already written in many languages...
|
|
|
|
|
Course I can do it, I just want to see some new, clever approaches.
What, does nobody code for fun anymore? Here, i'll post mine.
|
|
|
|
|
Here's the one I made. 194 characters long. This is my first time code golfing, but I think i'm getting the hang of it.
for(var $=b=c=d='',_=99,a=' on the wall.';b=' bottle'+(~(_-2)?'s':d)+' of beer',_>~0;c=_--&&'\n\n') 99-_&&($+='.\nTake one down and pass it around, '+(_||'no more')+b+a),$+=_?c+_+b+a+', '+_+b:d;
console.log($);
modified 16-Jun-15 23:53pm.
|
|
|
|
|
|
|
How to bind image in jquery. am unable to bind image when i wrote the below code plz help me
jQuery(document).ready(function () {
$("#uploadEditorImage").change(function () {
var data = new FormData();
var files = $("#uploadEditorImage").get(0).files;
if (files.length > 0) {
data.append("HelpSectionImages", files[0]);
}
$.ajax({
url: "../Account/UploadFile/",
type: "POST",
processData: false,
contentType: false,
data: data,
success: function (response) {
jQuery("#selimgs_", top.document).attr('src', response);
},
error: function (er) {
}
});
});
});
|
|
|
|
|
Hi,
I have almost developed a website using Dot net, C#, Jquery, Javascript etc. Now, for having chat among visitors, we picked the AJAX code from https://code.msdn.microsoft.com/CSASPNETAJAXWebChat-c4c9b8fe and customized it...
When we see the demo in there, it successfully shows the chatboxes and implements the chats well... But we couldn't able to integrate it with our already built web application (Web forms and not MVC). Since we get no errors, its very hard to predict the issue clearly. Do I have to make some changes in web.config?
Getting a warning alone which is
Warning 1 The 'contract' attribute is invalid - The value 'PlayZone.Services.SessionPool' is invalid according to its datatype 'serviceContractType' - The Enumeration constraint failed. E:\Projects\PlayZoneJUNE04\PlayZone\Web.config 57 48 PlayZone
Actually, I took the code from MSDN and pasted it successfully. The problem seems to occur in the Web.Config's service region.
WEB.CONFIG's SERVICE
<services>
<service name="WebChat.Services.Transition">
<endpoint address="" behaviorConfiguration="Sever.Services.TransitionAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebChat.Services.Transition" />
</service>
<service name="WebChat.Services.SessionPool">
<endpoint address="" behaviorConfiguration="Sever.Services.SessionPoolAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebChat.Services.SessionPool" />
</service>
</services>
Here are the overall details
i) I downloaded Ajax based group chat, which was done following the procedures on the page https://code.msdn.microsoft.com/CSASPNETAJAXWebChat-c4c9b8fe#content.
ii) The sample alone as a separate site works fine... But when combined with my website code, it shows the warnings and the chat is not working.
iii) Our Dot net framework version is 4.5... but the web chat's framework on MSDN shows version 4 when run alone.
iv) Server - IIS (Local machine)
Hope this helps you to understand further. Thanks for your concern and have a nice day ahead.
|
|
|
|
|
And how all this related to JavaScript?
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I am getting a finding in my scan indicating that my code is vulnerable to JavaScript hijacking. My code dynamically generate all of the page content, including the Ajax ScriptManager. Because the content is not in the webpage as static markup it is my opinion that this is a false finding. Can someone review my code and either confirm or deny my belief and if I am incorrect recommend a proper implementation.
private void CreateControls(ControlCollection cc)
{
if (RadScriptManager.GetCurrent(_contextPage) == null)
{
RadScriptManager rsm = new RadScriptManager();
rsm.ID = "scriptManager";
cc.Add(rsm);
}
}
<pre>
|
|
|
|
|
That code is not enough, and is also not very much explaining what it does (at least the section shared). You should try to make sure that your website is safe, and that, no network request is left and allowed to make your server run executions without your intention.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I have this line in a .js file.
var nameChanged = require('../../templates/namechanged.hbs')
I searched the entire website and could not find a file namechanged.hbs.
Is it not even a file? Where should I look for this?
There are strangers on the Plain, Croaker
|
|
|
|
|
|
Will do.
Thank you.
There are strangers on the Plain, Croaker
|
|
|
|
|
I found what I needed.
The reference to the 'path' in the require statement referred to the index of the handlebar template associated with the 'path' in an object.
~18K lines down in the file was a handlebar template with an index. It was that index that I needed to find to locate the templating code.
Again, thank you for the help.
There are strangers on the Plain, Croaker
|
|
|
|
|
webkitfullscreenchange, mozfullscreenchange, fullscreenchange is not firing or working when i used it on the iPad So any but have any other alternative then help on this.
|
|
|
|
|
Try using the older webkitbeginfullscreen and webkitendfullscreen events.
History of the Fullscreen API[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank it working perfectly....
|
|
|
|
|
So why did you down-vote my answer?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i dont know i think by mistake i did that
|
|
|
|
|
I believe you can reverse it as well by upvoting it.
.AK.
|
|
|
|
|
Compensated.
.AK.
|
|
|
|
|
Thanks.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
i have to show the day and date when i click the calendar in javascript. i am developing application using kony.Thank you.
|
|
|
|
|
Kony is just the IDE, the date and time picker would be more like created using a JavaScript library, like jQuery UI etc. Which one of these are you using?
Somehow, which so ever is being used. You can easily get the values, if you would read the API for the library you are using. Unclear, please share the code or the library being used. 7
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|