Here I made it in HTML5/Canvas (only tested in Chrome):
http://fiddle.jshell.net/toxicFork/dhsBL/show/light/
The source can be found here:
http://jsfiddle.net/toxicFork/dhsBL/
It was a lot of fun to make :D
PS: If anyone wants to convert the source to java and then use it on the Android SDK then they could make a widget I guess, that'd be really cool.
Here's a version I made last time something similar was posted:
http://jsfiddle.net/2NqPw/5/embedded/result/
It normalizes the hour, minute, and second across the 240 hex values in each channel, so you get (very nearly) the full range of color.
edit: updated to have a short transition between colors, hopefully get the text and background more distinct, and vertically center the text
If you don't know about it yet, let me introduce you to a webdev's best friend... press F12 and use the dev tools to point to the element and see how they did it.
Then go into the head section within the dev tools, and open their css and js files, and look for elements with the same classes and/or ids. You can also see the css files used in the dev tools next to the element in cases of multiple css files and needing to figure out where that style is applied.
You can then use a free code playground like JSFiddle.net (which I prefer) or CodePen.io and use what you find to try and replicate it or change it to your needs.
It's really a great way to learn.
You can even link the jsfiddle or codepen page you are working on, as well as an image (like you used here in this post) or a website where it's located, and ask in forums like here for help in getting your code where it needs to be.
even more infuriating considering how easy it is nowadays to make the text disappear (when you start typing) and the property is supported on all major and current broswers.
<input placeholder="" />
this, if anyone is interested, is a really cool programming project. lemme see...
TIME! 12 minutes http://jsfiddle.net/ad5qG/7/
ONLY LOOK if you've already finished
edit: made code shorter in order to improve illegibility
edit 2: is x really necessary in his source code? sheesh
For those wondering what he's talking about at the end, "No Johns" is a popular saying in the Smash community that means no making excuses for losing. Doesn't matter if your hands were too sweaty, controller was acting up, sun's in your eyes, or whatever else.
Probably going to get buried, but I don't think the numbers in that tweet are correct.
According to the official score sheet, OKC made 8 3PA in the 1st half and HOU made 14 3PA in the 2nd half. So there were only 22 attempts at the basket where no 3PT were made.
I did a simulation of 10 million trials of both teams shooting the same numbers of shots they attempted in the game at each basket. Given the teams' current 3PT%, chances are about 1 in 10000 of zero baskets made at the "cursed" basket. Unlikely, but definitely not impossible.
You can check my work here: http://jsfiddle.net/N4d3B/ The numbers represent the number of times there were zero makes at each basket. Basket2 is the "cursed" basket. It has a much higher probability of zero makes than the other basket simply because there were less shots attempted at that basket.
Right now, this is crazy insecure. Because it does not verify the WebSocket origin, any website you visit on the Internet can run arbitrary commands on your computer! Proof of concept: if you are running Butterfly and visit this JSFiddle, it will create a file called /tmp/I_TOUCHED_YOUR_FILESYSTEM and update its timestamp. It could just as well delete all your files, steal your Bitcoin wallet or such.
To author: You should verify the "Origin:" header of the WebSocket connection and make sure the connection is coming from localhost. More info.
edit It's fixed now.
villagers cows for
dies alone villager of
of sunset iron
fleeing an as sky
the endermen an of trap
the elevate that
mine swamp cow dirt that
when diamond and sheep of sands
creepers live as when
air endermen an
skeletons and when and rocks
elevate that of
light sleep alone are
cow that awakens village
that dieing zombie
Edit: This is way too much fun: http://jsfiddle.net/dr2hH/embedded/result/
Edit 2: Now with a "story", too (I actually think I like the haikus on their own better): http://jsfiddle.net/eYJFs/43/embedded/result/
Edit 3: The best one I've found:
mountain and terror
skeletons that skeleton
dieing over this
And in vanilla JavaScript without namespace pollution:
http://jsfiddle.net/e4f3yL1a/6/
Different version using "color" (allows text to be highlighted while hidden, but only works on text):
http://jsfiddle.net/e4f3yL1a/5/
Edit: Fixed namespace polluting.
That's as close as I'm willing to spend time getting the JS to play this back...
Something's not right - I think the images are not evenly spaced... And maybe my math is off...
Turn the stall to a lower value to watch it run faster, and to about 60 to watch it in "real time".
TL;DR: On a 7x7 board, each of the extreme corners (if chosen) each win ~15% of the time, blocks to either side (but not diagonal) of the corners ~3%, and the center is a distant third.
If anyone sees any problems with my algorithm, certainly let me know - I based it off the wiki and a total guess at the likelihood of grass spreading, although the spread rate doesn't affect it too much. I put the sim up on jsFiddle if anyone wants to play with it/fork it.
Also, I'm not trying to ruin the game - on the contrary, I love the idea. As I said in the writeup, this could be used to tweak the rules/weights, design more balanced boards, etc. For example, just banning the three blocks on each corner would make it a much less game-able game (and therefore more fun, I think).
Thanks to Phinq for the original post, and kayozz, 1cipere, and especially samineru for asking questions and inspiring my investigation.
Updates:
v1.1: Now you can import/export boards - just copy/paste the text from/to the box. Also fixed a bug with initial position for non-square boards (thanks, erom!)
v1.2: Fixed the algorithm thanks to Lurker_IV's knowledge, added base64-based board saving to a short(ish) permalink.
v1.2b: Fixed the algorithm again per second_last_username's comments. It slowed things down a lot, I have some ideas on how to cheat a bit without affecting the outcome, but that can happen tomorrow.
>I lost because I am too good.
Edit: I added a bunch more fragments (and fixed one that was missing an "is"). We should crowdsource this for more and more. Also:
>I lost because Ridley is too large.
Edit: Added more. More! More!
@pecet - the idea is that you can spin up an environment for testing out queries that can then be shared on your favorite Q/A site. Anyone can view the environment you setup, and modify your queries to help you work out a SQL problem. It's basically the same use-case as http://JSFiddle.net, but oriented toward database developers.
BTW - I'm the author of http://sqlfiddle.com
What exactly did he say about CO2 levels, maybe I missed a part? He seemed to agree that humans are changing CO2 levels and that this is having an effect, he just says that climate scientists overweigh the significance of this. There's still plenty of research being done into the exact influence of CO2 levels on global temperature.
From the introduction to the above paper: "There are few field experiments on the responses of whole terrestrial ecosystems to elevated CO2 (Mooney et al., 1991) and to climate change, e.g., soil warming (Van Cleve et al., 1990; Melillo et al., 1995)."
You're right, during the first part he was mostly talking about deuterium isotopes (oxygen) from which temperature change was reconstructed.
I just grabbed the official Vostok ice core data from the National Oceanic and Atmospheric Administration.
Here's the resulting chart for the past 10000 years. Looks the same as the one he was talking about.
For the people claiming Randall was making easily disprovable claims, please provide some links to reputable sources. I'm happy to run the numbers and confirm.
Citation
Petit, J.R., et al., 2001,
Vostok Ice Core Data for 420,000 Years, IGBP PAGES/World Data Center
for Paleoclimatology Data Contribution Series #2001-076.
NOAA/NGDC Paleoclimatology Program, Boulder CO, USA.
Just remember to leave a button to collapse or expand everything. I know a few people who would be pretty ticked off if they couldn't see the full story without clicking everywhere.
Also, as a web developer myself I would like to note that this telescopic text is just a hop and a skip beyond the html5 details/summary tag and with a little javascript it can be imitated trivially. The site's implementation using span tags and custom classes is probably the best way to go for now given browser support, but well, this is /r/futurology.
function twoTwo() { var Hͫ̆̒̐ͣ̊̄ͯ͗͏̵̗̻̰̠̬͝ͅE̴̷̬͎̱̘͇͍̫̠̱̩̭̤͈̾ͦ͊͒͊̓̓̐̑̎̋ͮͩ̒͑̾͋͘Ç̳͕̯̭̱̲̣̠̜͋̍O̴̦̗̯̹̼ͭ̐ͨ̊̈͘͠M̶̝̠̭̭̤̻͓͑̓̊ͣͤ̎͟͠E̢̞̮̹͍̞̳̣ͣͪ͐̈T̡̯̳̭̜̠͕͌̈́̽̿ͤ̿̅̑Ḧ̱̱̺̰̳̹̘̰́̏ͪ̂̽͂̀͠ = arguments.callee.name.length; var ლಠ益ಠლ=(function P0() {return arguments.callee.name})() .split('').filter(function(chr) {return /[A-Z0-9]/i.test(chr)}) .reduce(function(a, b) {return a.charCodeAt(0) + b.charCodeAt(0)}) >> Hͫ̆̒̐ͣ̊̄ͯ͗͏̵̗̻̰̠̬͝ͅE̴̷̬͎̱̘͇͍̫̠̱̩̭̤͈̾ͦ͊͒͊̓̓̐̑̎̋ͮͩ̒͑̾͋͘Ç̳͕̯̭̱̲̣̠̜͋̍O̴̦̗̯̹̼ͭ̐ͨ̊̈͘͠M̶̝̠̭̭̤̻͓͑̓̊ͣͤ̎͟͠E̢̞̮̹͍̞̳̣ͣͪ͐̈T̡̯̳̭̜̠͕͌̈́̽̿ͤ̿̅̑Ḧ̱̱̺̰̳̹̘̰́̏ͪ̂̽͂̀͠; return ლಠ益ಠლ }
Aaaaannnnd now with LAN scanning!
Party like it's Java applet socket!
The best part? Even if you disable WebRTC in chrome:flags, it still works, without asking any permissions!
<marquee> <table><tr><td></td></tr><tr><td></td> <td><b color="red"><blink>Don't talk shit about Berkeley</b></blink></td> </tr></table> </marquee>
I'm the other bloke, I forked it so that I could change it to have sorting on the remaining time. You'll have to give it a couple of seconds to calculate the time when you first open it.
I did mine in JavaScript (using JSFiddle, so there's nothing to download):
-Full-screen result.
(might be slow if the window is too big, since the canvas will automatically resize to fit the window.)
Use WASD or the Arrow keys to move.
I'll throw in a limited comparison of #lisp
and #haskell
IRC channel conversation messages (excluding joins/parts/etc.):
http://jsfiddle.net/uomax0cu/11/embedded/result/
#fsharp
is in there, but I only have a few months worth of data. I don't have data for any other languages. If you have such data for Python, Ruby, Scala, etc. that would be neat to add.
Here's a really simple untested DogeON parser in Javascript. I cheated by simply tokenizing the DogeON, replacing the keywords with JSON equivalents, and then calling JSON.parse. Use at your own risk!
Edit: oops, forgot to check for escapes in strings, and need to convert nottrue, notfalse, nullish
Edit 2: Version 2very-1 Just added fix for string escape, nottrue, nullish, many whitespace handling
Edit 3: Version 3very-1 - Handles new grammar constructs and keyword changes. such yes, many no. and also empty? so very wow!
Edit 4: Use this guy's instead, it's a lot better: https://github.com/paulminer/JSON-js/blob/master/dson2.js
This is the complete wrong way of doing this.
The correct method is using anchors and the :target psuedo class: http://jsfiddle.net/path411/msna9c9f/
This allows you to retain meaningful html, and I believe will support screen readers significantly better.
Your example is a terrible cost to sacrifice to fit into the "no js" circlejerk. I think people should learn some basics of front-end before trying to declare it unnecessary.
Are you familiar with "shadow casting"? (This is probably one of the better explanations of the technique and here's an interactive demo with JS source).
Shadow casting is similar to ray casting, but it has much better performance (in certain situations it's actually algorithmically optimal, since it processes every visible block only once and not a single block that isn't visible). I've only seen it used in 2D worlds, for example in roguelikes, but it can be generalized to 3D (although I have no idea how much that would complicate the algorithm).
Monte Carlo simulation has been written. You can see it and modify it here: http://jsfiddle.net/cyphern/jV5WV/6/
Sample output with 60 card deck, 4 good cards, 20 cards drawn, 30 cards milled and 1,000,000 iterations:
Without milling:
0 good cards: 187345 times ( 18.7345%)
1 good cards: 405586 times ( 40.5586%)
2 good cards: 304102 times ( 30.4102%)
3 good cards: 93025 times ( 9.3025%)
4 good cards: 9942 times ( 0.9942%)
With milling:
0 good cards: 186606 times ( 18.6606%)
1 good cards: 405513 times ( 40.5513%)
2 good cards: 304310 times ( 30.431%)
3 good cards: 93813 times ( 9.3813%)
4 good cards: 9758 times ( 0.9757999999999999%)
In the example, they're using standard HTML elements, but everything is styled with CSS.
Check out the forms in Twitter Bootstrap.
[Edit] Also, for the love of Talos, don't buy little snippets of code like that. A basic understanding of HTML and CSS will go a long way. I made this in ~5 minutes.
Cool trick, but what stuck out to me was that the calculations can be greatly simplified:
(x / 2) – ((x * 0.57735) / 2))
= (x * 0.5) – (x * 0.288675)
= x * 0.211325
Edit: as evenstevens points out since you are not mixing units you can just use straight percentages:
http://jsfiddle.net/PjK84/87/
Uses width: 57.735%
for .hexagon and right: 21.1325%
for the pseudo elements.
Like this sloppy ass code I made in 5 minutes?
edit: I spent a little more time on the css magics to make it even betterer, jsfiddle is pretty damn fun game.
edit2: forgot to update the link after updating css...
It was a disappointing game with an exceptionally toxic community
/r/wildstar has been one of the top 5 fastest collapsing subreddits for months now
Yesterday it was 492,061 out of 492,061
http://redditmetrics.com/r/WildStar
http://jsfiddle.net/4L4g5k97/6/embedded/result/
http://i.imgur.com/CNivHjC.png
Interesting, I didn't know that CompileBot existed. Let me try to compile right now a simplified version of some code I once wrote here:
+/u/CompileBot JavaScript
var d = new Date(); var yr = d.getUTCFullYear() - 1970, mt = d.getUTCMonth() + 1, fd = d.getUTCDate() - 1; var hr = d.getUTCHours(), mn = d.getUTCMinutes(), sc = d.getUTCSeconds(), ms = d.getUTCMilliseconds(); if (mt >= 2 && (yr % 4 === 0 && (yr % 100 !== 0 || yr % 400 === 0))) {fd += 1;} switch (mt) { case 1: fd += 0; break; case 2: fd += 31; break; case 3: fd += 59; break; case 4: fd += 90; break; case 5: fd += 120; break; case 6: fd += 151; break; case 7: fd += 181; break; case 8: fd += 212; break; case 9: fd += 243; break; case 10: fd += 273; break; case 11: fd += 304; break; case 12: fd += 334; break; } var ft = (hr / 24) + (mn / (24 * 60)) + (sc / (24 * 60 * 60))+ (ms / (24 * 60 * 60 * 1000)); var dt = (fd + ft).toFixed(5); var output = yr + "T" + dt + "M"; print(output);
any chance you could just add a class to the <td> instead? Javascript seems like the wrong tool to use.
Either way, i think it's something like this (untested, just typing this in reddit)
var table = document.getElementById("yourtable"); //your table's ID
var cells = table.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
var status = cells[i].innerHTML;
if ( status == "offline" ) {
cells[i].className = 'offline';
} else {
cells[i].className = 'online';
}
}
Then with css you just specify some colours for .online and .offline
edit: normally i'd use jQuery for this, as the code would be shorter, but i did it in plain js with this being /r/javascript
edit2: dumped it in jsfiddle, it just works: http://jsfiddle.net/x5zse/1/ (took me a while to find the 'no library' option)
http://wiki.guildwars2.com/wiki/Chat_link_format/0x03_codes
edit: not all chat codes listed here are correct! use this tool to make codes for yourself. see this comment for info.
I have put your code up into this jsFiddle sample so its easier to show/modify. I also added some basic bounds checking for the ball.
You had a typo in one of your function calls, which invalidated the entire script. ctx.clearRec should be ctx.clearRect.
If you are using Chrome, press the F12 key to enter the development tools and you can see errors like this pop out in the script.
Edit: As a side note, if you are going to be doing canvas work, you may be interested in checking out the jQuery jCanvas plugin for easier syntax/cross browser support.
I'm not sure what your end goal is from the description. Maybe you are looking for something like jsFiddle or jsBin
Just from what you've said, it looks like you are doing it wrong. You should be developing on your local machine (local websever) with some kind of revision control (like git or svn) and only upload to the server when you are finished (or at a stable release).
This is an extremely over-engineered solution. You can do it simply with a single element and some box-shadows on the ::after
pseudo-element.
Here's an example I whipped up http://jsfiddle.net/z8Lqphrg/
If only I could be so grossly incandescent!
a { visibility:collapse; }
a input[type="checkbox"] { visibility:visible; }
a input[type="checkbox"]:after { margin-left: 20px; content: "0-3 Months"; white-space: nowrap; text-decoration: underline; }
a input[type="checkbox"]:checked:after { color: red; }
Working example: http://jsfiddle.net/7hbugrs2/1/
Edit: Added typing mistake (probably?).
For those still interested in how it's calculated and how it differs from the original formula: http://jsfiddle.net/j6FLe/68/
It's much more balanced than the original one, as it multiplies range/mage by 2 instead of 1.5, meaning that you can be 138 and have a mage or ranged based combat level, where before the only way to do this was via melee.
I think they just mentioned that's how much we spent on corporate welfare, it then went on to discuss flat tax proposals, cutting military spending, etc.
It does beat around the bush as far as exact numbers go honestly, but politicians in general love to do that to make their ideas sound more attactive. I think when I throw around 40% flat tax and stuff some more conservative readers spit their coffee on their monitors. So I think it's more obfuscation than anything else. It's not much different than Obama going around in 2008 talking about change and using catch phrases like "yes we can" without really going into the details of his proposals and stuff like that.
Quite frankly, I support a similar proposal (UBI with flat tax), but what we'd be looking at in practice is a flat tax of around 30-45%, depending on the exact benefits, other government spending, collection efficiencies, etc.
To give the $800/month benefit, let's say $10k a year, roughly. With 2.6 trillion in other government spending (assuming barebones government + universal healthcare), that would be a 32% flat tax or so under perfect condition sif given to 230 million adults.
And this is the reason having this in code is so great, now I just updated the csv part of it to include January and February to date, and voila we have the scale of the B-R5RB fight compared to the rest of New Eden:
Forked version of the jsFiddle with B-R5RB data
Edit: in before "but wasn't B-R5RB at 11T ISK?"... this contains the base construction value of super capitals, not market value like everything else, plus, some of the value was also in other systems like GXK, I-NG, ..
Nice work. A couple minor mistakes - it is actually possible to send xdomain XHR requests - SOP just dictates you can't read the response. See the "Simple Requests" section of mozilla's docs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
As for the JS var checks, good thinking! I wrote a lan scanner a while ago that is designed to make this exact thing easier, perhaps it will be useful to you (still a WIP):
Instead of fetching subreddit data on the backend you could use javascript client-side. Reddit's API supports JSONP.
If you do go that route, you could go a step further and make it single page app, which would greatly reduce load on your server and greatly increase performance in the eyes of the user.
Edit:
http://jsfiddle.net/9n0z2c39/ is a tiny demo of calling reddit's api in js.
There's a bug in your C code:
void main() { char *a;
a = malloc(2 * sizeof(char));
a[0] = 'j'; a[1] = 's';
printf(a);
free(a);
return; }
As you know, printf
requires a zero terminated string, and this code does not zero terminate the string. You just got lucky because JSFiddle uses a special C compiler that protects against errors like this to avoid crashing the site.
A more typical production C compiler may leave garbage in memory after the string, and printf
could either print that garbage, crash, or do something worse.
The code should be:
void main() { char *a;
a = malloc(3 * sizeof(char));
a[0] = 'j'; a[1] = 's'; a[2] = '\0';
printf(a);
free(a);
return; }
I wouldn't set the bullet image as you'll have less control over how that behaves across browsers. Instead, I'd just set the background for the list items, and then set each li's line-height equal to the height of the background image (43px in this case). You'll need to add padding-left in order to move the text away from the background image.
It's a simple javascript function:
window.onload = function() { document.getElementById('username').focus(); }
"username" is the id of the element you want to focus on. (And this will put it right in the input field.)
Here's an example on jsfiddle. (And this didn't work when I put the jsfiddle to 'onLoad' and only when I put it to 'onDomReady'. I wonder why that is.)
Great response :) thanks for the input everyone.
Here's an update with a more intuitive scroll http://jsfiddle.net/6ZuJZ/8/
I threw this together to test (and try cement) some tutorials I've been reading in my spare time at work over the last week. Its mainly been pattern's and namespacing tutorials, feel like I've got a grip of the basic patterns and developed a better undertanding of JS & JS objects!
He didn't give up 2/3 of the way. It works for all except the top floor, which is the only one that doesn't have 8 windows. You have to kind of imagine pushing against it from the left--it's basically Tetris (well, not exactly, but in that vain).
I was having a little trouble visualizing it in my head, as well, after running it half way, so I tossed together some code just to be sure it actually worked (probably not the best code ever).
Let's start with a few things:
1) Add this style: * { box-sizing: border-box; }
2) Remove postion: absolute; from body
3) Remove width: 100%; from body
That takes care of the horizontal scroll bar.
To make this a bit better:
1) Add margin: 0; to the body
2) Remove padding: 5px from #main
3) Study up on html5 elements.
4) Use a CSS reset and/or maybe a grid
If that's all then CSS is pretty well designed. The vertical-align and margin collapsing stuff is bad, the default box-sizing is a bit annoying etc. But I couldn't care less if it's "nowrap" or "no-wrap". Who cares?
But what did the OP mean with this?
> Partial collapsing of margins instead of weird rules to handle min/max-heights?
And about:
> Absolutely-positioned replaced elements should stretch when opposite offset properties (e.g. left+right) are set, instead of being start-aligned.
I think I don't understand what is meant here because you can do this: http://jsfiddle.net/9Ge2a/
In your example, the .each code is invoking a callback function for each div; the for loop is doing nothing. Not quite the same. To be more fair, they should both invoke the same callback for each iteration.
Furthermore, .each is actually referencing each div (as a jquery object) and making that available to the callback function as this, whereas the for loop is only accessing $div.length. Granted, depending on what you're trying to do within the loop, this may not be needed, but it demonstrates that .each is doing more than just the simple for loop.
With an updated fiddle, they seem to be roughly equal, on my computer anyway; you'd have to measure down to the millisecond to tell.
great write up thank you.
> $15k/yr apiece is a $300bil/yr program.
We can actually do $10k/year and be revenue neutral depending on how aggressive we are at cutting other programs.
But revenue neutral actually means a huge tax cut to nearly everyone, because everyone is getting the UBI ($10k above). So if we raise tax rates just a little, it can still be a tax cut for everyone earning below $50k or $80k, and increase the revenue available such that $15k per person is feasible.
For instance, a flat personal and corporate tax of 30%, (no EI premiums. CPP would be optional. But no deductions for capital gains and dividend income) allows for $15k/person affordability. Someone earning $50k per year from other sources, has effectively net 0 tax, and those earning $75k have about 10% tax bill ($7500), which is also a reduction from current levels.
US numbers: http://jsfiddle.net/3bYTJ/11/
Here is something I put together hastily. Only tested in Chrome.
This only applies if you are concerned with copying only the background... I am unsure of as to whether this is what you want.
This will fix it, but it's kind of dirty:
input { width: 100px; padding: 5px 10px; margin: 20px; }
input:hover { width: 79px; text-indent: -1px; padding-right: 30px; padding-left: 11px; }
Edit: Fiddle
Here's an updated fiddle that has the effect http://jsfiddle.net/y93dq623/3/
You had the correct css for the most part, but you only had one <li> tag that wrapped all of your <a> tags. You need an <li> for every element in your list, so once I added those everything else fit into place. Hope that helps!
Like this? I tried to make it as similar to the main-post-one as possible: http://jsfiddle.net/L2eyc62h/1/embedded/result/
EDIT: Better version: Thingy
There is a difference between using percentage and pixel values. Example: http://jsfiddle.net/95anjwdb/
If the height and the width are equal, you don't see any difference.
But if one side is larger, the border-radius: 50%;
will act differently. In that case, 50%
means "50% of that side". So the corner will actually be an ellipse.
If you use 10000px
, it will remain a circle. The very high value doesn't change anything because the maximum radius will always be half of the height (or of the smaller side) for some reason. In my example, a radius of 15px would be enough (because the div is 30px high). But if I applied the same border-radius to higher divs, I wouldn't want to update the value constantly. So I guess people use border-radius: 10000px
as default. As long as it works...
>It is a wonderful language that is extremely well suited to its purpose.
Wonderful, eh? I use it out of necessity, but it's still a shitty language with unpredictable behavior.
Not that they're the same, but people give PHP shit for being inconsistent in naming conventions, but at least basic mathematical operations are consistent. Run this code and at least it'll round consistently.
echo round(0.315,2)." ".round(0.295,2);
Since you already have the <h2> in a <div> use this: http://jsfiddle.net/qNPsP/
You need to have some of the css in both elements and add 2 properties in particular:
.banner { max-width: 440px; color: white; font-size: 28px; font-weight: normal; position: absolute; bottom: -10px; padding: 0 8px; left: 8px; }
.banner h2 { display: inline; /* VERY IMPORTANT -- this allows the gaps between lines / line-height: 1.8em; / IMPORTANT -- adjust to taste */ background: rgba(0,0,0,.5); } *edit: added the css in post
There are 3 options I know of:
ch
unit by the browser. Right now, it's not really a viable option.Here is an example for option #2: http://jsfiddle.net/F7cgm/
Instead of HTML comments you can of course also use server-side comments.
Putting a colon in a hostname specifies that a port comes after it. Since you didn't specify a port, it assumes the default port, and so removes it. Here are some more examples.
Also 256 tags override a class
But you still can't have 256 IDs to override an inline style sadly. Not that any of this would be practical in production… more info here on the discussion of the discovery.
First thing I need to comment on is all the 'if' statements. I'd look into either a 'switch' or an object where you can essentially put:
filter1 = myFilters[CCDCamera.FilterWheelName];
See fiddle... http://jsfiddle.net/R4QBZ/
I can't see anything too obvious, but you have a lot of if/else statements. One missing curly bracket is all it takes to break this.
I'd recommend stripping things down - get the socket working and pass in some default data. Set the Filters to defaults and go from there.
Once the socket is working, I'd suggest refactoring your code a bit as I stated above - create some lookups so you can easily manage your if/else statements by not having as many, or simply doing a lookup with a key.
Hope this helps some**. Good luck :)
** Wednesday hangovers are no fun.
Try this: http://jsfiddle.net/N5tFs/18/
First, I cleaned up your classes.
Second, To get the text in there I just added the text to the <li>, and set font-size to zero. Then I set it to the regular font-size on hover (and focus).
Instead of changing the height on hover, I added padding to the text, easier to keep it vertically centerd, but you should play around to get it to the best height.
You'll probably want to change the text to links; if so, change the animation to affect the LINK not the list item. It'll allow you to click the whole square, not just the text.
-ninja edit- Here's the same code with links http://jsfiddle.net/N5tFs/20/
Not everyone is Google or Amazon.
This may or may not be obvious, but in the majority of autocomplete scenarios, something as simple as indexOf will work fine:
function complete(search, strings) { return _.filter(strings, function(str) { return str.indexOf(search) == 0; }); }
[citation needed]
But since you can't provide one, I will.
Not minified: http://jsfiddle.net/hfuEs/4/
Minified with closure compiler: http://jsfiddle.net/VwCCK/3/
Minified with uglifyJS: http://jsfiddle.net/VjsMv/1/
Translating his code into javascript runs in about 140ms in chrome. I've slowed it down a bit so it doesn't rape your comp, but this is what the algorithm looks like: http://jsfiddle.net/ctrlfrk/zThj5/7/
Anonymous functions and self-calling functions are different things. An anon-func is a function without a name or reference callable later on in the code.
For instance, a named function may call it's self: http://jsfiddle.net/aHALz/1
Functions can call themselves because of how javascript works. A function definition is executable code that returns to something. The code is executed by the second set of parens.
For instance, you could assign a variable to a function
var foo = function(bar){alert(bar)};
And then call it like this:
(foo)(bar)
Which is the same as
foo(bar)
Example: http://jsfiddle.net/aHALz/2/
This is because the var foo has been assigned a object, that object happens to be a function.
Just in case anyone wants a completely non-analytical way of looking at this, you can use a Monte Carlo simulation to estimate the results.
Here's a jsfiddle that simulates this case 10000 times: http://jsfiddle.net/bjjLjmbe/
Just click "Run" in the top menu.
You can tweak the health of the minion and the number of trials easily in the bottom left. You can see in the source and the results that once the minion is dead, all shots hit face, so there are no "impossible" outcomes.
Since this is a simulation, the results will be different on each run and won't be exactly the 11/16 you get analytically. But you can see that the results of each simulation are about 11/16, and the more trials you do the closer it gets.
Just for the hands-on people who don't actually want to flip coins all afternoon to help get a sense of why a result (11/16 times it dies!) that might not seem intuitive to all is still the correct answer.
You know, that got me to thinking, and I tried something...
As long as you aren't trying to fight a different type of specificity (e.g., spamming classes alone won't override an ID), it does seem that adding the same selector multiple times still bumps up the weight in the specificity battle.
<div class="outer"> <div class="inner">Green dotted border</div> </div>
with...
.inner.inner.inner { border: 3px dotted green; }
.outer > .inner { border: 3px solid red; }
gives a green dotted border, not a red solid one. (Tried on Ffx and Chrome.)
So you could fight someone's shitty over-specific
.main .content > .to .people .who .wrote .hideously .deeply .nested .less .files .because .it .looks .prettier > a big.fuck-you { ... }
with
a big.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you.fuck-you { ... }
> Pattern matching on a dynamically typed language is interesting -- I haven't looked in the source to see how it's done.
This is a toy language, but see line 409 (runnable example on the right). It's an interpreter, which simplifies things a bit, but it's not super complicated to generate specialized code for each pattern.
A lot of dynamic languages in the Lisp family have pattern matching, e.g. Racket and Clojure. Personally, I think all languages should have this feature.
Start with Javascript. Make a file called game.html
.
<button id="clicker">Click Me</button> <div id="counter">0</div>
<script> var clicks = 0; var clickerElement = document.getElementById("clicker"); var counterElement = document.getElementById("counter"); clickerElement.onclick = function() { clicks++; // Increment count counterElement.innerHTML = clicks; // Display the new count }; </script>
Open it in your browser. Live demo: http://jsfiddle.net/hn9d4Ljz/
Worry about Kongregate in the far future.
Pure CSS example. Javascript is just used to bring in a fancy font so the technique can be demonstrated.
p {
text-shadow:
-2px -2px 0 #FFF,
2px -2px 0 #FFF,
-2px 2px 0 #FFF,
2px 2px 0 #FFF;
font-family: 'Tangerine', serif; font-weight: bold; font-size: 65px;
color: #111;
margin: 0 0 0 0; }
hr { border: 0; border-bottom: 2px solid #111; position: relative; top: -22px; z-index: -1; }
First up, the text itself being underlined is represented by p { }. Webkit has a text-stroke option, but I prefer the 'hackier' stacked text-shadows for this. I hate vendor prefixes, so I hate -webkit-anything. But you can play with webkit-stroke if you want.
Chose a fancy font, made it big so the effect is obvious. Realistically this technique probably wouldn't look all that great with small text, but I didn't bother trying. You indicated a title, you get a title example.
the <hr> does the rest of the work. border: 0 followed immediately by border-bottom is a quick reset for hr elements, just to create the line style. You can adjust that as you please.
Obviously we want to raise the <hr> to intersect with the <p> line, but we also want it to go behind the <p>. Since the <hr> tag comes directly after the <p>, it's given z-index will appear higher than <p>. Since we're already giving it a position: relative, we can safely use z-index to drop it to 0 or -1.
In some cases, -1 is troublesome. If you find this to be the case, you can always use 1. Just put { position:relative; z-index: 2 } on the <p> element. z-index won't work without some position besides 'static', so keep that in mind.
Edit: Updated with a version that uses a single block element.
> L0L@ P374r J0K350n!!1! $p3nc|1ng $30k 0n R3c| c4m3r4z 2 r3c0rc| 47 48FP5! 3v3ry1 n0z c|3 hum4n 3y3 c4n 0nly c 30FPz M4X! Pluz c|3 K1n3c7 c4n r3c0rc| 3c| 1n 4k 4nc| 0nly c057z $100. L0L R3K7!!!****
http://jsfiddle.net/rnet85/jr32h84q/7/
online peasant translator
There may be a plugin for something like this, but you're probably better off just learning to style with CSS.
Although this is a list, styling the number of an OL can be very difficult. Better to use a list with various divs and images that you can style.
Here's a fiddle to get you started.
Good luck!
WD's and barbs trail monks in the top 1000. Looking at the highest ranked individuals is not wise, as outliers are very subject to variance.
That doesn't invalidate your point, however, as pretty much every class needs a buff against M6 DH. From the numbers, though, it appears to me that barbs and WD's need that buffing the most. Barbs and monks can be worked together, though, as they are both the only real melee classes.
On the issue itself, DH's enjoy their very clear advantage due to survivability reasons: they can kill stuff while not even in the room with the mobs. It would seem to me, then, that the way to fix up barbs and monks both would be to modify and buff Moratorium as follows:
The change of clear per attack instead of clear per kill would greatly improve the damage clearing ability; the release of all the damage as an area explosion would further incent melee players to use this gem. Note I said "area damage". This would allow players to spec area damage bonuses on their gear to further increase the damage Moratorium causes.
I'm not sure about the numbers, so I just left that as a mental exercise.
Edit: another idea would be to introduce an item that is synergistic with the new melee-based Moratorium. For example, "all healing increased by HH% if mobs are within YY yards." This would be synergistic as highly increased regen/LoH/LpK would increase your ability to clear big damage spikes that have been delayed by Moratorium....
+1 good idea
http://jsfiddle.net/embero/p77bfv2w/
jQuery is nice but we're in the 21st century now and you don't need jQuery in most cases. So I made a version with good ol' vanilla JavaScript.
In this example you've a simple resource called Scrap. Two kind of robots (Type-E and Type-Z) which gathers resources on their own.
This is a basic enough scenario to work right out of the box given the previous suggestions. I put together a jsFiddle that shows this working here: http://jsfiddle.net/fPb8K/
I made sure all the jQuery calls were referencing the ID of the element and I just call jQuery's .hide() and .show(). The only real differences are that I extracted the setTimeout into a function so the timer can be reset easily from the click handler, removed the onClick attribute from the image and changed the timer to 3 seconds.
If you're still having problems after seeing what I did to get this working, I would check to see if you might be getting some errors in the console or do some debugging to figure out what's going on.
Each rank requires more experience than the last. You get experience from kills and assists. To reach rank 37, you need about 12263 kills. To reach rank 50 you need about 55666 kills. That's about 4.5 times more kills than you have now, so it's likely that it will take you a lot more than another 126 hours to achieve 50. It's true that you will gain experience quicker now than you did at the beginning when you started playing, because you are better and get more kills per game, but there's no way you can do ~43000 kills in 126 hours. That's about 5.7 kills per minute the entire time.
To get these numbers I used this rank calculator provided in this post.
FYI I hit rank 50 at 965 hours and I did primarily TO, and I am almost always top 3 in the leaderboard, unless I play archer and not do the objective.
Short answer: jQuery.
Long answer: Have a look at jQueryUI Tooltip for the tooltips. They usually function by having you create a tooltip-div next to the element you want to have a tooltip on.
example: <button...><div class='tooltip'>
With JQuery hiding and showing elements on the page is even easier. Lets say, you have code that determines that a button has to be hidden. Assume also that the button has the ID example. Then all you have to is is call: $('#example').hide(); or $('#example').show();
Here you have a fiddle of my current implementation, using all of above techniques. Maybe you can learn something from it: http://jsfiddle.net/QEx2q/
Getting hung up on the formulas is usually a waste of time, unless you're a whiz with numbers.
Instead, write a simulation.
Or let me write one for you.
So in this particular case, with three dice, you're about 70% likely to get at least one four and one three. But now that I've written this simulation for you, you can plug in any number and get a good idea.
It's easy to declare what the problem is, and that's basically what it means to write a program.
EDIT: Here's another version that calculates the odds for 2, 3, 4, 5, 6, 7, and 8 dice at once.
EDIT EDIT: OK I went a bit crazy with this and I blogged about your question. http://bluetshirt.ca/blog/item/2014/06/numbers-gettin--you-down-run-a-simulation
1) jsfiddle! http://jsfiddle.net/ There are other similar sites.
2) I wouldn't teach anyone using tools that auto completed essential things. A student must learn to close their own tags before they should move on to tools that do that for them.
I only have a minute, so I apologize for the quick reply.
I don't know a library off the top of my head, but I know some exist that are purpose built to allow formatted html input.
Have you thought about maybe just using JSFiddle? It's almost exactly what you are looking for, but in my opinion maybe better for teaching because it may prevent bad habits from forming. It is simple enough for your beginning students, but is a tool that used in professional environments as well.
JSFiddle has four panes, ones for HTML, Javascript, CSS, and another to preview the results.
Demo: http://jsfiddle.net/5LKA8/
OP, just so you're aware - While all 3d methods are considered 'stereoscopic', most people these days think of the modern 'side-by-side' (SBS) style of 3D as 'stereoscopic'. This is what 3D TVs use. Basically it takes two slightly different images, places them next to eachother, then interweaves them together on the screen. If you're not wearing the glasses, it looks very messy, but you don't get any of the 'extra color' given by Red/Cyan style 3D.
Red/Cyan 3D like this is more accurately called 'anaglyph 3D'. Again, it is stereoscopic, but there's a lot of people who might argue that.
Yeah, the basic usage is when you want a column that isn't the left-most to appear first when collapsed. Check out this fiddle: in both situations the sidebar is horizontally on the left on large screens, but by using push + pull we can have the right column appear first in the source, and hence appear first vertically in the collapsed form.
If you just reordered the elements, you'll end up with a different horizontal order too.
Ok, 3.45 trillion budget, right?
Well, SSI would be funneled into UBI since it's essentially SSI for all, so that's $800 billion right there. Get rid of most welfare and that's about $400 billion. make some other miscellaneous cuts for $100-200 billion and you're down to about $2.1 trillion.
Use this calculator made by u/jaydurst, we have a $2.1 trillion budget other than UBI, we have 230 million eligible adults. Set the personal income and corporate tax rates to 40%. Perhaps adjust the income to around $11-11.5 trillion vs the $13.4-14 trillion total, to account for nontaxable income in that (it's unclear how much would be taxable, $11.5 trillion is a reasonable estimate though eliminating certain forms of government benefits and nontaxable employer benefits from the equation).
At a flat tax of 40% both on income and corporate profits, a 2.1 trillion budget, and 230 million eligible people, we can afford a basic income of around $14,500 to every adult in America. For reference, that's about $1200 a month, which is the average SSI payment today. People on SSI who make more than this could be grandfathered into their SSI plan, but newer people who are not on it nor are too young to be close to the retirement age will just recieve basic income.
The numbers work, at least in theory. Much more detailed than Bush's social security plan at least.
Still no name, but it works. The robots and upgrades don't have names either.
Most future changes will be balancing or layout. Let me know what you think of the current state of both. If you've played before, you should reset the game when you load.
If you find a bug, let me know what browser you're on as well.
Great article - now I wish HTML/CSS/JavaScript made things like this easier to achieve.
There's a great accompanying article for this that actually implements the code for some of these examples:
http://css-tricks.com/transitional-interfaces-coded/
These aren't so bad. But in a project I'm currently working on, I also wanted to have the ability for the user to reorder items in the list by dragging, and I wanted to smoothly animate the transitions. This turned out to be a total nightmare. Here's the only good implementation I was able to find (intuitive behavior, with no jittery animations or other nonsense):
http://stackoverflow.com/questions/5060357/jquery-sortable-with-animation/13416536#13416536
Seriously, give that guy an upvote - he deserves way more than what he's got right now. Here's a jsfiddle sample of that:
Works great - but look at what it takes to achieve this. The amount of code it takes, and the number of hacks it requires is baffling - in his implementation, he actually clones the list when the drag operation is started, and the original list gets hidden, and there's all sorts of trickery going on with z-indexes and floating elements and absolute positioning. It is no wonder that most developers simply don't bother. (And as a side note, if anyone is aware of a simpler implementation that functions equally well, please let me know.)
Well here's something to get you started.
www.buzzfeed.com/ryanhatesthis/10-potential-mass-shootings-that-were-stopped-by-someone-wit
I'm looking for post by an /r/progun poster where he attempted to compile this information.
I'll bring it by when I find it.
edit:
This isn't exactly what I was looking for but it's similar:
http://jsfiddle.net/jLqw7/embedded/result/
This guy compiled all the mass shootings with more than 5 victims over a period of 13 years and found that not a single one with more than 6 victims occurred in a place where citizens were allowed to be armed. Just more evidence that "~~defenseless target zones~~ gun free zones" are one of the more idiotic ideas anti-gun folks have had.
edit 2:
Ahh, I think this might be what I was looking for:
http://dailyanarchist.com/2012/07/31/auditing-shooting-rampage-statistics/
Here is a crude demo solution with 19 lines of code in native JS I just whipped up
Code is for sale.
EDIT: Made it shorter, better and more expensive!
Closed gitrepo, EULA and commercial license comming soon.
The most common / basic reason for big differences between rendering of CSS in different browsers is forgetting to include a doctype.
When you don't include a standard doctype, the browsers tend to default to what's known as "quirks mode", which renders the page differently to "standards mode"
Try adding the following doctype as the first line of your HTML file (this is the standard HTML5 doctype which is known to put most, if not all, browsers into standards mode):
<!DOCTYPE html>
(Note that there's no closing tag required here)
Trying to write code that targets specific browsers is generally considered bad practice, and there's likely a better solution to what you're trying to do.
If you still have issues, it will help us to help you if you provide a small example of what you're trying to do that renders differently in different browsers - you can use a site such as http://jsfiddle.net/ to "pastebin" your HTML and CSS code.
I forked with some minor modifications: http://jsfiddle.net/gUdGk/4/
Quick summary:
$this
for the click()
scope. This saves writing $(this)
frequently, and will save a call to $(...)
every time you are referring to the same object*tab_parent
and current_tab
to $tab_parent
and $current_tab
. This can help identify vars which are jQ objects when reading code.css(...)
calls and chained the .animate(...)
functionIn other scenarios, where you have var current_tab_content_id = $current_tab.attr('href')
followed later by $(current_tab_content_id).whatever
, you may find it more practical to set up a jQ object to refer to rather than referring to $(myVariable)
.
EG: var $current_tab_content = $($current_tab.attr('href'))
It is OK in your Fiddle example because each instance is only used once, but if used more than once it is akin to using $this
as above.*
* In many cases the performance gained by doing $this
is pretty negligible. However, it's useful where performance is important, and it's easier to read, write, and maintain as well.
Edit: As an afterthought (it's probably not that important at all), something you might consider when this kind of thing is used in a website is some "JavaScript is active" styling.
That is, by default your div.tab_content
s might be visible and not absolutely positioned. When your page is ready you might use JavaScript to add a "js" class to the <body>
, and you could in your stylesheet do body.js div.tab_content { display: none; position: absolute; etc...}
.
You've used href
and id
attributes as they should be. This way, if someone without JS comes along they can still use the menu and see all the content.
It is reasonably rare in most cases to find people with JS disabled, but it still happens from time to time.
Hope this made sense!
You should mention what isn't working in IE. Also, like buckbova mentioned, put code into a sandbox testing application like jsfiddle or dabblet.
The first problem is you're using doctype entirely wrong.Take a look here to see the different types available and how to use it. The HTML5 doctype is the current standard for newer sites, but if you're building for IE compatibility it might be better to go with one of the HTML 4.01 doctypes.
Take a look at the corrected code here. Don't use pipes for navigation divisions, use border-left. Don't use ids unless you have a good reason, same goes for calling the element name before the id (ie. ul#id-name). You were using border-left, but it was white. I feel like this would make more sense if we knew where the navigation was being used.
You might want something like this:
function require(files, callback) { var head = document.getElementsByTagName("head")[0];
var func = (function(files, callback){ var n = 0; return function() { if(++n == files.length) callback(); }; })(files, callback);
for (var i=0;i<files.length;i++) { var script = document.createElement("script"); script.src = files[i]; head.appendChild(script); script.onload = func; } };
Example of it in action: http://jsfiddle.net/SHaek/11/. So you would place your code in the callback function. Like so:
require(["position.js"], function() { var Sprite = function(x,y) { this.postion = new Position(x,y); }; });
When you set the parent to position: relative, then absolutely positioned elements inside will be relative to the parents top left corner. Here are some jsFiddle examples:
Triangle, pentagon, hexagon, octagon made in 2001 using the same approach (empty HTML elements) - http://tantek.com/CSS/Examples/polygons.html
Knocked up a little example of how - if you're going the HTML/CSS route - this hexmap can be made with less HTML by using pseudo-elements: http://jsfiddle.net/4Tq6K/
http://jsfiddle.net/an789d4s/embedded/result/ The bigger number at the bottom by play area (cm) is the cm per play area width. Also as a bonus how it is calculated is in this post https://www.reddit.com/r/osugame/comments/2kxfm8/absolute_sensitivity_calculator_for_mouse_players/