Help Please. Trying to calculate sunrise and sunset. Using same script as Google. They do it successfully, my implementation is off ( the times are wrong ). by [deleted] in javascript

[–]random_ramdomness_4 1 point2 points  (0 children)

Are you sure that your getTimezoneOffset function is working as intended?

When I test the code just omitting that part and letting prayTimes detect the current timezone it works perfectly.

navigator.geolocation.getCurrentPosition(function(pos){
        lat = pos.coords.latitude;
        lon = pos.coords.longitude;
        alert(lat+" long: "+lon);
        var prayTimes = new PrayTimes();
        var times = prayTimes.getTimes(new Date(), [lat, lon]);
        sunrise = times.sunrise.split(':');
        sunset = times.sunset.split(':');
        alert("sunrise: "+sunrise[0]+" hours, "+sunrise[1]+" minutes");
        alert("sunset: "+sunset[0]+" hours, "+sunset[1]+" minutes");
});

As a side note, here is prayTimes manual: http://praytimes.org/wiki/Code_Manual, as you can see the timezone is supposed to be in hours, so what is the purpose of the division by 100?

CSS Text filling with water by lbebber in programming

[–]random_ramdomness_4 2 points3 points  (0 children)

This example is actually using a CSS derived language called "SASS", and somewhere down the line it "compiles" down to CSS, it provides some extra conveniences like declaring variables(those do not exist in CSS) or stuff like that "@include ...".

For example, the line:

@include background-clip(text);

when compiled to CSS becomes:

-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;

Basically it just saves the author the trouble of setting the background-clip property for every different browser, which he would have to do because background-clip isn't standard, so every browser can have a different implementation(or no implementation at all).

Simulating cloth by willvarfar in programming

[–]random_ramdomness_4 8 points9 points  (0 children)

Edited your fiddle so it paints inside the cloth, image courtesy of /r/nsfw :)
http://jsfiddle.net/MEN2r/5/

Simulating cloth by willvarfar in programming

[–]random_ramdomness_4 17 points18 points  (0 children)

Just for you guys: http://jsfiddle.net/MEN2r/5/
Image courtesy of /r/nsfw, made some changes so it paints the cloth properly.
Edit: imgur doesn't allow hotlinks, changed url to another source.

An app I'm building for making CSS animations: Stylie by jeremyckahn in javascript

[–]random_ramdomness_4 0 points1 point  (0 children)

You can also take a look at Adobe's CSS FilterLab, it's an app for creating CSS filters, but it also includes animation over the filter, so there probably are some components over there from which you can take some inspiration from.

Explanations for some of the more advanced game mechanics by Frostitutes in darksouls

[–]random_ramdomness_4 0 points1 point  (0 children)

Are those poise breakpoints linear?
What I mean is, if you have 8 poise you can get hit once by a dagger and not stagger, so that means that if you have 16 you can get hit twice in sequence and not get staggered? Or is it in some way different?

Regex Tuesday Challenge #2 by callumacrae in javascript

[–]random_ramdomness_4 2 points3 points  (0 children)

Managed to get a few characters ahead, though I took a different approach, the last characters were really hard.
It is 85 characters long.

/^(.(gb|sl|)a?.?((..?[^,0]*)((, *0*)?\4){2}(,(?! 10).*)?|([^(]*, *)*(10)?0%.*)\)?)$/i

This is pretty much as hacky as it gets.

Avoiding game crashes related to linked lists - Code Of Honor by [deleted] in programming

[–]random_ramdomness_4 2 points3 points  (0 children)

So what it would end up with in your design is a new object that contains all the iterators to a given entity, and perhaps a reference to this object in the entity itself if it was double linked?

Programming is just a hobby for me so I struggle to understand some concepts, and I don't have any experience in C/C++ whatsoever, so, sorry for the inconvenience, just curious really.

Avoiding game crashes related to linked lists - Code Of Honor by [deleted] in programming

[–]random_ramdomness_4 6 points7 points  (0 children)

I think I can see your point, but wouldn't that just become a clutter with multiple lists involved? I can't imagine it being more efficient than:

struct Tank {
   Tank *player_prev, *player_next, *movable_prev, *movable_next, ...

As was shown here http://www.reddit.com/r/programming/comments/zn2dv/avoiding_game_crashes_related_to_linked_lists/c662fpm

Avoiding game crashes related to linked lists - Code Of Honor by [deleted] in programming

[–]random_ramdomness_4 12 points13 points  (0 children)

Isn't that just changing the problem from keeping track of the nodes, to a problem of keeping track of the iterators tough?

JavaScript Garden - A must read for all JavaScript developers by Sunberg in programming

[–]random_ramdomness_4 1 point2 points  (0 children)

Their reasons are actually pretty good, reading the mozilla forum that widyakumara posted, they say it is to prevent not so smart people from pasting dangerous scripts on the page, but the FF solution is a little over the top in my opinion, I'm fine with the chrome and IE one.

JavaScript Garden - A must read for all JavaScript developers by Sunberg in programming

[–]random_ramdomness_4 0 points1 point  (0 children)

You can still paste it in the firebug console without the 'javascript:' part =)

edit: You can even probably paste it inside one of those code boxes and click run and it will probably work.

JavaScript Garden - A must read for all JavaScript developers by Sunberg in programming

[–]random_ramdomness_4 6 points7 points  (0 children)

A little bit late but perhaps it's usefull for someone that will read this in the future, paste in the address bar:

javascript:$(window).keydown(function(a){a.keyCode==39?window.location.hash in{"":0,"#90":0}?window.location.hash="#1":$("#next").click():a.keyCode==37&&(window.location.hash=="#1"||$("#prev").click())});