Last active
August 29, 2015 13:56
-
-
Save kimh/8899670 to your computer and use it in GitHub Desktop.
Blog Post Sample Code
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
class Dashing.FizzBuzz extends Dashing.Widget | |
ready: -> | |
# ここは初期化時に実行したいエフェクトを書く | |
onData: (data) -> | |
$(@node).fadeOut().fadeIn() |
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
<h1 class="title" data-bind="title"></h1> | |
<div data-bind="value"></div> |
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
class FizzBuzz | |
FIZZ=3 | |
BUZZ=5 | |
def initialize | |
@current_num = 1 | |
end | |
def fizzbuzz | |
if fizzbuzz? | |
out = "fizzbuzz" | |
elsif fizz? | |
out = "fizz" | |
elsif buzz? | |
out = "buzz" | |
else | |
out = @current_num | |
end | |
go_next | |
out | |
end | |
private | |
def go_next | |
@current_num+=1 | |
end | |
def fizz? | |
(@current_num % 3) == 0 | |
end | |
def buzz? | |
(@current_num % 5) == 0 | |
end | |
def fizzbuzz? | |
(@current_num % (FIZZ*BUZZ)) == 0 | |
end | |
end | |
fb = FizzBuzz.new | |
SCHEDULER.every '5s', :first_in => 0 do | |
send_event('fizz_buzz', { value: fb.fizzbuzz }) | |
end |
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
.widget-fizz-buzz { | |
background-color: #444; | |
} |
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
<div class="gridster"> | |
<ul> | |
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="fizz_buzz" data-view="FizzBuzz" data-title="Fizz Buzz"></div> | |
</li> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment