Skip to content

Instantly share code, notes, and snippets.

@gojun077
gojun077 / TimelyPorfolio_Simple_RUT.R
Created October 14, 2011 09:27
from TimelyPortfolio blog--simple system for Russell Index
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")
@gojun077
gojun077 / BJ_deal_em_up_2of2.js
Created September 10, 2012 10:58
CodeAcademy - Getting Started with BJ - BJ Deal 'em up Sec 2/2, Ex 2/7
/*
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!
@gojun077
gojun077 / gist:3690407
Created September 10, 2012 11:23
CodeAcademy - Getting Started with BJ - BJ Deal 'em up Sec 2/2, Ex 3/7
/*
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
@gojun077
gojun077 / gist:3690482
Created September 10, 2012 11:48
CodeAcademy - Getting Started w/ BJ - BJ Deal 'em Up Sec 2/2, Ex 4/7
/*
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
@gojun077
gojun077 / gist:3690614
Created September 10, 2012 12:17
CodeAcademy - Getting Started with BJ - BJ Deal 'em Up Sec 2/2, Ex 5/7
/*
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
@gojun077
gojun077 / annoying(생략).js
Created September 11, 2012 07:50 — forked from Kilian/annoying.js
forked from Kilian's "How to be an asshole"
/**
* 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
@gojun077
gojun077 / gist:3697010
Created September 11, 2012 08:51
Example of anticopy JS from Daum Korea blogs
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
@gojun077
gojun077 / gist:3698442
Created September 11, 2012 13:25
CodeAcademy - Getting Started with BJ - BJ Deal 'em Up Sec 2/2, Ex 6/7
/* 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.
@gojun077
gojun077 / gist:3698520
Created September 11, 2012 13:35
CodeAcademy - Getting Started with BJ - BJ Deal 'em Up Sec 2/2, Ex 7/7
/* 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.
@gojun077
gojun077 / gist:3698550
Created September 11, 2012 13:40
CodeAcademy - Review of Functions in JS Sec 2/3, Ex 1/4
/*
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