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
import React, { ReactDOM, Component, PropTypes } from 'react'; | |
import {render} from 'react-dom'; | |
import { Router, Route, Link, browserHistory} from 'react-router' | |
/** React router hello world example **/ | |
class App extends Component { | |
render() { |
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
var Currency = React.createClass({ | |
propTypes: { | |
amount: React.PropTypes.number, | |
currencyCode: React.PropTypes.string, | |
decimalPlaces: React.PropTypes.number | |
}, | |
formatCurrency: function (x, decimalPlaces, decimalSeparator, groupSeparator) { | |
var parts = x.toString().split('.'); | |
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator); |
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
function formatCurrency(x, decimalPlaces, decimalSeparator, groupSeparator) { | |
var parts = x.toString().split("."); | |
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator); | |
if(parts.length > 1) { | |
parts[1] = parts[1].substring(0, decimalPlaces); | |
} else { | |
parts[1] = '000000000'.substring(0, decimalPlaces); | |
} | |
return parts.join(decimalSeparator); | |
} |
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
# All purpose minimalistic random generator | |
def random(params) | |
if(params.kind_of?(Array)) | |
return params[rand(params.size)] | |
end | |
if(params.kind_of?(Range)) | |
return (rand(params.end - params.begin) + params.begin).to_s | |
end | |
if(params.kind_of?(Integer)) |
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 'thread' | |
require 'date' | |
# Format number of hours, minutes and seconds since start time: | |
def elapsed_time_formatted(start_time) | |
end_time = DateTime.now | |
total_seconds = ((end_time - start_time) * 24 * 60 * 60).to_i | |
seconds = total_seconds % 60 | |
minutes = (total_seconds / 60) % 60 | |
hours = total_seconds / (60 * 60) |
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
(function (root, $$, _, Backbone) { | |
"use strict"; | |
/* | |
backgrid | |
http://github.com/wyuenho/backgrid | |
Copyright (c) 2013 Jimmy Yuen Ho Wong and contributors | |
Licensed under the MIT @license. | |
*/ |
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 'rubygems' | |
require 'filewatcher' | |
filenames = ["/Users/thomasf/ruby/roman_numerals_test.rb"] | |
FileWatcher.new(filenames).watch(0.5) do |filename| | |
print "\e[2J\e[f" | |
puts "Reloading #{filename}" | |
load(filename) | |
MiniTest::Unit.new.run_tests | |
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
require 'rubygems' | |
require 'minitest/autorun' | |
class RomanNumerals | |
def conv(str) | |
1 | |
end | |
end | |
class RomanNumeralsTest < MiniTest::Unit::TestCase |
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 'rubygems' | |
require 'minitest/autorun' | |
class RomanNumerals | |
def conv(str) | |
1 | |
end | |
end | |
class RomanNumeralsTest < MiniTest::Unit::TestCase |
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 'rubygems' | |
require 'filewatcher' | |
# Autorun minitests when one of these files is updated: | |
files = ["my_minitest_tests.rb","code_under_test.rb"] | |
puts "Update one of these files to start tests: " + files.join(", ") | |
FileWatcher.new(files).watch do |filename| | |
puts "Updated " + filename | |
load filename |
NewerOlder