This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(quantmod) | |
require(PerformanceAnalytics) | |
getSymbols("^RUT",from="1896-01-01",to=Sys.Date()) | |
signal<-ifelse(runMax(RUT[,2],7)/runMin(RUT[,3],7)-1- | |
ROC(RUT[,4],n=20,type="discrete")<0.02,1,0) | |
perf<-merge(lag(signal,k=1)*ROC(RUT[,4],type="discrete",n=1), | |
ROC(RUT[,4],type="discrete",n=1)) | |
colnames(perf)<-c("System","Russell 2000") | |
charts.PerformanceSummary(perf,ylog=TRUE, | |
main="Quick Untested Russell 2000 System") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
2. Functionify Dealing | |
Nice! We are officially on our way! | |
Another important rule of thumb for bigger projects is to break | |
code down into functions, instead of throwing all your code | |
together into one place. This allows you to keep everything | |
organized and reuse code later on. This saves you lots of work! | |
So let's put dealing inside its own function calleddeal. That way, | |
we can use it later when we want to ask for more cards. So efficient! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
3. What’s the Score? | |
Great! We can deal out cards but what are we going to do with them? | |
The game won't be any good unless we have a way to score the hands. | |
For blackjack, that is relatively simple because the score is usually | |
just the number of the two cards added together. For example, a 10 of | |
spades and a 6 of hearts is worth 16 points. | |
For our design it's a little more complicated because card 30 is actually | |
the 4 of clubs, and shouldn't be worth 30 points. But remember our rule of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
4. More Score | |
To improve the score function we will need code to convert from the | |
numeric value of the card (1 through 52) to its actual value (ace through king). | |
We will need a new function, which we will call getValue. | |
Look at the score function on line 16. Notice we now return | |
getValue(card1) + getValue(card2) instead of just card1 + card2. | |
This getValue function will eventually be used to take a card |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
5. Improving getValue | |
Now that we have getValue in its own function, we can add some more code | |
there to make our scoring function more accurate. | |
Right now getValue returns the number of the card itself, so score | |
effectively returns card1+ card2 and we haven't really improved anything. | |
For example with card 30, which represents the 4 of clubs, we are giving |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Annoying.js - How to be an asshole to your users | |
* | |
* DO NOT EVER, EVER USE THIS. | |
* | |
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com) | |
* Visit https://gist.github.com/767982 for more information and changelogs. | |
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ | |
* for the introduction and weblog | |
* Check out https://gist.github.com/942745 if you want to annoy developer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.oncontextmenu = new Function ('return false'); //block right-click | |
document.ondragstart = new Function ('return false'); //block drag and drop | |
document.onselectstart = new Function ('return false'); //block text select | |
document.body.style.MozUserSelect = 'none'; //block text select on miscellaneous browsers | |
//Below is a js library containing various anti-copy schemes | |
http://s1.daumcdn.net/cfs.tistory/v/0/blog/plugins/PreventCopyContents/js/functions.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 6. Don't Forget the Face Cards | |
Awesome! So we now have a somewhat realistic scoring function, | |
but we aren't quite there yet. We know that within a suit, cards | |
11, 12, and 0 represent a jack, queen, and king respectively. | |
Right now we count those as worth 11, 12, or 0 points, but in | |
real Blackjack all face cards are worth 10 points. Somehow in | |
our scoring function we need to check if we have a face card, | |
and make sure we only assign 10 points in that case. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 7. You're such an ace | |
We have one last special card to take care of, and that is | |
the ace. In real Blackjack, aces are worth either 11 or 1, | |
whichever helps your hand out more. | |
For now, let's again simplify by pretending aces are always | |
worth 11. | |
Modify getValue to check if we have an ace, and return 11 | |
points if we do. An ace is represented by a 1 in our game. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1. A Function with 2 Parameters | |
Functions can have zero, one or more parameters. You can | |
think of these as input that the function receives, and | |
then uses to do something. | |
The code example shows a trivial function multiply function | |
that takes two numbers as arguments and returns their product. | |
Do you remember how volume is defined? Complete the definition |
OlderNewer