├── .gitignore ├── .rspec ├── .ruby-gemset ├── .ruby-version ├── .travis.yml ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app.json ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── chance.min.js │ │ └── pusher.min.js │ └── stylesheets │ │ ├── application.css.scss │ │ └── framework_and_overrides.css.scss ├── controllers │ ├── application_controller.rb │ ├── bets_controller.rb │ ├── cashouts_controller.rb │ ├── concerns │ │ └── .keep │ └── visitors_controller.rb ├── helpers │ └── application_helper.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── balance.rb │ ├── bet.rb │ ├── cashout.rb │ ├── cold_storage.rb │ ├── concerns │ │ └── .keep │ ├── secret.rb │ ├── transaction.rb │ └── user.rb ├── services │ └── create_admin_service.rb └── views │ ├── bets │ └── show.html.haml │ ├── devise │ ├── passwords │ │ ├── edit.html.erb │ │ └── new.html.erb │ ├── registrations │ │ ├── edit.html.erb │ │ └── new.html.erb │ └── sessions │ │ └── new.html.erb │ ├── layouts │ ├── _messages.html.haml │ ├── _navigation.html.haml │ ├── _navigation_links.html.erb │ └── application.html.haml │ └── visitors │ ├── _bets_table_rows.html.haml │ ├── _cashout_modal.html.haml │ ├── _deposit_modal.html.haml │ ├── _transaction_history_modal.html.haml │ ├── _verification_modal.html.haml │ ├── bet_table.html.haml │ ├── configure.html.haml │ └── index.html.haml ├── bin ├── bundle ├── rails ├── rake └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── devise.rb │ ├── devise_permitted_parameters.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── pusher.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ ├── devise.en.yml │ └── en.yml ├── routes.rb └── secrets.yml ├── db ├── migrate │ ├── 20140115101221_create_bets.rb │ ├── 20140116001104_create_secrets.rb │ ├── 20140930085512_cold_storage.rb │ ├── 20141002112057_create_cashouts.rb │ ├── 20141009160404_create_transactions.rb │ ├── 20141014133052_add_user_id_to_cashouts.rb │ ├── 20141017133717_add_block_to_coldstore.rb │ ├── 20141021062306_create_balances.rb │ ├── 20141022064014_add_sweep_block_to_cold_storage.rb │ ├── 20141029123750_devise_create_users.rb │ ├── 20141029123753_add_name_to_users.rb │ ├── 20141029154512_add_bitcoin_address_to_user.rb │ ├── 20141029160455_remove_mpk_from_cold_storage.rb │ ├── 20141030135705_remove_multiplier_from_bets.rb │ ├── 20141119122639_change_amount_to_integer.rb │ └── 20141217121140_add_unique_constraint_to_server_seed.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ ├── .keep │ ├── pirate_metrics.rake │ ├── scheduler.rake │ └── simulator.rake ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── humans.txt ├── images │ └── favicon.ico └── robots.txt ├── spec ├── factories │ ├── balances.rb │ └── users.rb ├── features │ ├── gambling │ │ ├── cashout_spec.rb │ │ ├── limits_spec.rb │ │ └── simple_gamble_spec.rb │ ├── users │ │ ├── sign_in_spec.rb │ │ ├── sign_out_spec.rb │ │ ├── user_delete_spec.rb │ │ └── user_edit_spec.rb │ └── visitors │ │ ├── home_page_spec.rb │ │ ├── navigation_spec.rb │ │ └── sign_up_spec.rb ├── models │ └── user_spec.rb ├── rails_helper.rb ├── spec_helper.rb └── support │ ├── capybara.rb │ ├── database_cleaner.rb │ ├── devise.rb │ ├── factory_girl.rb │ ├── helpers.rb │ └── helpers │ └── session_helpers.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/*.log 16 | /tmp 17 | 18 | # Ignore application configuration 19 | /config/application.yml 20 | 21 | # Ignore coverage tests 22 | /coverage 23 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require rails_helper 3 | -------------------------------------------------------------------------------- /.ruby-gemset: -------------------------------------------------------------------------------- 1 | bitdice 2 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-2.1.4 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | env: master_public_keys=xpub69GZWTQPtwQRriHyYuYJpDgAUrHHRD8ksBbQ61QpY1CbSUrcW7udYcZ1YLuLVtSQx9xW5QApiGidDfmFVLEz4Lep3AoCGD2HQmfvXwH1GMt 3 | script: xvfb-run bundle exec rake -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby '2.1.4' 3 | gem 'rails', '4.1.6' 4 | gem 'sass-rails', '~> 4.0.3' 5 | gem 'uglifier', '>= 1.3.0' 6 | gem 'coffee-rails', '~> 4.0.0' 7 | gem 'jquery-rails' 8 | gem 'turbolinks' 9 | gem 'jbuilder', '~> 2.0' 10 | gem 'sdoc', '~> 0.4.0', group: :doc 11 | gem 'spring', group: :development 12 | gem 'bootstrap-sass' 13 | gem 'devise' 14 | gem 'haml-rails' 15 | gem 'sendgrid' 16 | gem "font-awesome-rails" 17 | gem 'figaro' 18 | gem 'onchain' 19 | gem 'rqrcode' 20 | gem 'bootstrap-material-design' 21 | gem 'jquery-nouislider-rails' 22 | gem 'pusher' 23 | group :development do 24 | gem 'better_errors' 25 | gem 'binding_of_caller', :platforms=>[:mri_21] 26 | gem 'html2haml' 27 | gem 'quiet_assets' 28 | gem 'rails_layout' 29 | end 30 | group :development, :test do 31 | gem 'factory_girl_rails' 32 | gem 'faker' 33 | gem 'rspec-rails' 34 | gem 'sqlite3' 35 | end 36 | group :production do 37 | gem 'pg' 38 | gem 'rails_12factor' 39 | gem 'unicorn' 40 | end 41 | group :test do 42 | gem 'capybara' 43 | gem 'capybara-webkit' 44 | gem 'database_cleaner' 45 | gem 'launchy' 46 | gem 'simplecov' 47 | end 48 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.1.6) 5 | actionpack (= 4.1.6) 6 | actionview (= 4.1.6) 7 | mail (~> 2.5, >= 2.5.4) 8 | actionpack (4.1.6) 9 | actionview (= 4.1.6) 10 | activesupport (= 4.1.6) 11 | rack (~> 1.5.2) 12 | rack-test (~> 0.6.2) 13 | actionview (4.1.6) 14 | activesupport (= 4.1.6) 15 | builder (~> 3.1) 16 | erubis (~> 2.7.0) 17 | activemodel (4.1.6) 18 | activesupport (= 4.1.6) 19 | builder (~> 3.1) 20 | activerecord (4.1.6) 21 | activemodel (= 4.1.6) 22 | activesupport (= 4.1.6) 23 | arel (~> 5.0.0) 24 | activesupport (4.1.6) 25 | i18n (~> 0.6, >= 0.6.9) 26 | json (~> 1.7, >= 1.7.7) 27 | minitest (~> 5.1) 28 | thread_safe (~> 0.1) 29 | tzinfo (~> 1.1) 30 | addressable (2.3.6) 31 | arel (5.0.1.20140414130214) 32 | bcrypt (3.1.9) 33 | better_errors (2.0.0) 34 | coderay (>= 1.0.0) 35 | erubis (>= 2.6.6) 36 | rack (>= 0.9.0) 37 | binding_of_caller (0.7.2) 38 | debug_inspector (>= 0.0.1) 39 | bitcoin-ruby (0.0.6) 40 | bootstrap-material-design (0.1.3) 41 | bootstrap-sass (~> 3.0) 42 | bootstrap-sass (3.3.1.0) 43 | sass (~> 3.2) 44 | builder (3.2.2) 45 | capybara (2.4.4) 46 | mime-types (>= 1.16) 47 | nokogiri (>= 1.3.3) 48 | rack (>= 1.0.0) 49 | rack-test (>= 0.5.4) 50 | xpath (~> 2.0) 51 | capybara-webkit (1.3.1) 52 | capybara (>= 2.0.2, < 2.5.0) 53 | json 54 | chain-bitcoin-ruby (0.0.1) 55 | chain-ruby (2.0.1) 56 | chain-bitcoin-ruby (= 0.0.1) 57 | coderay (1.1.0) 58 | coffee-rails (4.0.1) 59 | coffee-script (>= 2.2.0) 60 | railties (>= 4.0.0, < 5.0) 61 | coffee-script (2.3.0) 62 | coffee-script-source 63 | execjs 64 | coffee-script-source (1.8.0) 65 | database_cleaner (1.3.0) 66 | debug_inspector (0.0.2) 67 | devise (3.4.1) 68 | bcrypt (~> 3.0) 69 | orm_adapter (~> 0.1) 70 | railties (>= 3.2.6, < 5) 71 | responders 72 | thread_safe (~> 0.1) 73 | warden (~> 1.2.3) 74 | diff-lcs (1.2.5) 75 | docile (1.1.5) 76 | erubis (2.7.0) 77 | execjs (2.2.2) 78 | factory_girl (4.5.0) 79 | activesupport (>= 3.0.0) 80 | factory_girl_rails (4.5.0) 81 | factory_girl (~> 4.5.0) 82 | railties (>= 3.0.0) 83 | faker (1.4.3) 84 | i18n (~> 0.5) 85 | ffi (1.9.6) 86 | figaro (1.0.0) 87 | thor (~> 0.14) 88 | font-awesome-rails (4.2.0.0) 89 | railties (>= 3.2, < 5.0) 90 | haml (4.1.0.beta.1) 91 | tilt 92 | haml-rails (0.5.3) 93 | actionpack (>= 4.0.1) 94 | activesupport (>= 4.0.1) 95 | haml (>= 3.1, < 5.0) 96 | railties (>= 4.0.1) 97 | hike (1.2.3) 98 | hpricot (0.8.6) 99 | html2haml (1.0.1) 100 | erubis (~> 2.7.0) 101 | haml (>= 4.0.0.rc.1) 102 | hpricot (~> 0.8.6) 103 | ruby_parser (~> 3.1.1) 104 | httparty (0.13.3) 105 | json (~> 1.8) 106 | multi_xml (>= 0.5.2) 107 | httpclient (2.5.3.3) 108 | i18n (0.6.11) 109 | jbuilder (2.2.5) 110 | activesupport (>= 3.0.0, < 5) 111 | multi_json (~> 1.2) 112 | jquery-nouislider-rails (4.0.1.1) 113 | jquery-rails (>= 2.0) 114 | jquery-rails (3.1.2) 115 | railties (>= 3.0, < 5.0) 116 | thor (>= 0.14, < 2.0) 117 | json (1.8.1) 118 | kgio (2.9.2) 119 | launchy (2.4.3) 120 | addressable (~> 2.3) 121 | mail (2.6.3) 122 | mime-types (>= 1.16, < 3) 123 | mime-types (2.4.3) 124 | mini_portile (0.6.1) 125 | minitest (5.4.3) 126 | money-tree (0.8.8) 127 | ffi 128 | multi_json (1.10.1) 129 | multi_xml (0.5.5) 130 | nokogiri (1.6.4.1) 131 | mini_portile (~> 0.6.0) 132 | onchain (2.1.4) 133 | bitcoin-ruby 134 | chain-ruby (~> 2.0.1) 135 | httparty 136 | money-tree 137 | orm_adapter (0.5.0) 138 | pg (0.17.1) 139 | pusher (0.14.2) 140 | httpclient (~> 2.4) 141 | multi_json (~> 1.0) 142 | signature (~> 0.1.6) 143 | quiet_assets (1.0.3) 144 | railties (>= 3.1, < 5.0) 145 | rack (1.5.2) 146 | rack-test (0.6.2) 147 | rack (>= 1.0) 148 | rails (4.1.6) 149 | actionmailer (= 4.1.6) 150 | actionpack (= 4.1.6) 151 | actionview (= 4.1.6) 152 | activemodel (= 4.1.6) 153 | activerecord (= 4.1.6) 154 | activesupport (= 4.1.6) 155 | bundler (>= 1.3.0, < 2.0) 156 | railties (= 4.1.6) 157 | sprockets-rails (~> 2.0) 158 | rails_12factor (0.0.3) 159 | rails_serve_static_assets 160 | rails_stdout_logging 161 | rails_layout (1.0.24) 162 | rails_serve_static_assets (0.0.2) 163 | rails_stdout_logging (0.0.3) 164 | railties (4.1.6) 165 | actionpack (= 4.1.6) 166 | activesupport (= 4.1.6) 167 | rake (>= 0.8.7) 168 | thor (>= 0.18.1, < 2.0) 169 | raindrops (0.13.0) 170 | rake (10.4.0) 171 | rdoc (4.1.2) 172 | json (~> 1.4) 173 | responders (1.1.2) 174 | railties (>= 3.2, < 4.2) 175 | rqrcode (0.4.2) 176 | rspec-core (3.1.7) 177 | rspec-support (~> 3.1.0) 178 | rspec-expectations (3.1.2) 179 | diff-lcs (>= 1.2.0, < 2.0) 180 | rspec-support (~> 3.1.0) 181 | rspec-mocks (3.1.3) 182 | rspec-support (~> 3.1.0) 183 | rspec-rails (3.1.0) 184 | actionpack (>= 3.0) 185 | activesupport (>= 3.0) 186 | railties (>= 3.0) 187 | rspec-core (~> 3.1.0) 188 | rspec-expectations (~> 3.1.0) 189 | rspec-mocks (~> 3.1.0) 190 | rspec-support (~> 3.1.0) 191 | rspec-support (3.1.2) 192 | ruby_parser (3.1.3) 193 | sexp_processor (~> 4.1) 194 | sass (3.2.19) 195 | sass-rails (4.0.4) 196 | railties (>= 4.0.0, < 5.0) 197 | sass (~> 3.2.2) 198 | sprockets (~> 2.8, < 2.12) 199 | sprockets-rails (~> 2.0) 200 | sdoc (0.4.1) 201 | json (~> 1.7, >= 1.7.7) 202 | rdoc (~> 4.0) 203 | sendgrid (1.2.0) 204 | json 205 | json 206 | sexp_processor (4.4.4) 207 | signature (0.1.7) 208 | simplecov (0.9.1) 209 | docile (~> 1.1.0) 210 | multi_json (~> 1.0) 211 | simplecov-html (~> 0.8.0) 212 | simplecov-html (0.8.0) 213 | spring (1.2.0) 214 | sprockets (2.11.3) 215 | hike (~> 1.2) 216 | multi_json (~> 1.0) 217 | rack (~> 1.0) 218 | tilt (~> 1.1, != 1.3.0) 219 | sprockets-rails (2.2.1) 220 | actionpack (>= 3.0) 221 | activesupport (>= 3.0) 222 | sprockets (>= 2.8, < 4.0) 223 | sqlite3 (1.3.10) 224 | thor (0.19.1) 225 | thread_safe (0.3.4) 226 | tilt (1.4.1) 227 | turbolinks (2.5.2) 228 | coffee-rails 229 | tzinfo (1.2.2) 230 | thread_safe (~> 0.1) 231 | uglifier (2.5.3) 232 | execjs (>= 0.3.0) 233 | json (>= 1.8.0) 234 | unicorn (4.8.3) 235 | kgio (~> 2.6) 236 | rack 237 | raindrops (~> 0.7) 238 | warden (1.2.3) 239 | rack (>= 1.0) 240 | xpath (2.0.0) 241 | nokogiri (~> 1.3) 242 | 243 | PLATFORMS 244 | ruby 245 | 246 | DEPENDENCIES 247 | better_errors 248 | binding_of_caller 249 | bootstrap-material-design 250 | bootstrap-sass 251 | capybara 252 | capybara-webkit 253 | coffee-rails (~> 4.0.0) 254 | database_cleaner 255 | devise 256 | factory_girl_rails 257 | faker 258 | figaro 259 | font-awesome-rails 260 | haml-rails 261 | html2haml 262 | jbuilder (~> 2.0) 263 | jquery-nouislider-rails 264 | jquery-rails 265 | launchy 266 | onchain 267 | pg 268 | pusher 269 | quiet_assets 270 | rails (= 4.1.6) 271 | rails_12factor 272 | rails_layout 273 | rqrcode 274 | rspec-rails 275 | sass-rails (~> 4.0.3) 276 | sdoc (~> 0.4.0) 277 | sendgrid 278 | simplecov 279 | spring 280 | sqlite3 281 | turbolinks 282 | uglifier (>= 1.3.0) 283 | unicorn 284 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/Bitsino/BitsinoDice.svg?branch=master)](https://travis-ci.org/Bitsino/BitsinoDice) 2 | 3 | ## Bitcoin Dice Gambling Site 4 | 5 | 6 | ![](http://i.imgur.com/BY4bmB3.png) 7 | 8 | ## Provably Fair 9 | 10 | Bitcoinary implements a provably fair gaming engine. Provably fair works by publishing the hash of a secret before a game. At the end of the day, the secret is released and can be compared to the result. Publishing the hash of the secret prevents the operator from changing the secret and by extension, the result of the game. 11 | 12 | ## Installation 13 | 14 | Live demonstration https://bitsinodice.com 15 | 16 | Bitcoinary is designed to install easily into the cloud using Heroku. You can also install to your own server. 17 | 18 | Click the link below to install the software directly to Heroku. 19 | 20 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/onchain/bitcoinary) 21 | 22 | ## Security 23 | 24 | ### BitsinoDice does not require you to install bitcoind 25 | 26 | Bitcoinary uses the chain.com API to get balance information and to scan for incoming Bitcoins. As no private keys are kept on the site we remove some major security issues. 27 | 28 | ### Cold storage and multi signature funds. 29 | 30 | The site works off a Bitcoin master public key. Bitcoinary can then generate as many bitcoin public keys as it needs. ONCHAIN.IO which is the cold storage provider sweeps and incoming bitcoins daily into a bitcoin transaction. You can then safely sign this transaction to send the funds into cold storage. 31 | 32 | There are no private keys on ONCHAIN.IO or Bitcoinary. 33 | 34 | Bitcoinary makes a daily payout request to ONCHAIN.IO. Basically for users who are winners they can select to withdraw funds. Bitcoinary sends a payout request to ONCHAIN.IO which is turned into a bitcoin transaction paying the users. 35 | 36 | You get a notification from ONCHAIN.IO and can decide wether or not to sign this transaction. 37 | 38 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Bitcoinary", 3 | "description": "Bitcoin Gambling Site - Using OnChain.io programmable Bitcoin cold storage.", 4 | "logo": "https://camo.githubusercontent.com/2d1608a32c72618dd61b82d62f19d566cf982e1a/687474703a2f2f692e696d6775722e636f6d2f386855314b32652e706e67", 5 | "repository": "https://github.com/onchain/bitcoinary", 6 | "keywords": [ 7 | "Bitcoin", 8 | "Gambling", 9 | "Rails" 10 | ], 11 | "scripts": {"postdeploy": "bundle exec rake db:migrate; bundle exec rake db:seed"}, 12 | "env": { 13 | "SENDGRID_USERNAME": { 14 | "description": "Your SendGrid address for sending mail.", 15 | "value": "user@example.com", 16 | "required": false 17 | }, 18 | "SENDGRID_PASSWORD": { 19 | "description": "Your SendGrid password for sending mail.", 20 | "value": "changeme", 21 | "required": false 22 | }, 23 | "DOMAIN_NAME": { 24 | "description": "Required for sending mail. Give an app name or use a custom domain.", 25 | "value": "myapp.herokuapp.com", 26 | "required": true 27 | }, 28 | "master_public_keys": { 29 | "description": "Master public keys taked from the OnChain fund you want to use.", 30 | "value": "MPK1,MPK2,MPK3", 31 | "required": true 32 | }, 33 | "RAILS_ENV": "production" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. 9 | // 10 | // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require jquery_ujs 15 | //= require turbolinks 16 | //= require bootstrap-sprockets 17 | //= require bootstrap-material-design 18 | //= require chance.min 19 | //= require pusher.min 20 | var initialise = function() { 21 | 22 | $.material.init(); 23 | 24 | $('form.submit-once').submit(function(e){ 25 | if( $(this).hasClass('form-submitted') ){ 26 | e.preventDefault(); 27 | return; 28 | } 29 | $(this).addClass('form-submitted'); 30 | }); 31 | 32 | var pusher = new Pusher('1fdb3cf163217908dd6f'); 33 | var channel = pusher.subscribe('test_channel'); 34 | channel.bind('my_event', function(data) { 35 | 36 | var js = "showVerification(" + data.id + ")"; 37 | row = '' 38 | row += '' + data.username + '' 39 | row += '' + data.created_at + '' 40 | row += '' + data.amount + '' 41 | row += '' + data.multiplier + '' 42 | row += '' + data.rolltype + ' ' + data.game + '' 43 | row += '' + data.roll + '' 44 | 45 | if(data.win_or_lose == 'win') { 46 | row += '' 47 | } else { 48 | row += '' 49 | } 50 | row += data.profit + '' 51 | 52 | $('#bets tr:first').before(row); 53 | 54 | $('#bets tr:last').remove(); 55 | }); 56 | 57 | var client_seed = chance.hash({length: 16}); 58 | $('#client-seed').val(client_seed); 59 | $('#client-seed-form').val(client_seed); 60 | 61 | $("#probability-slider").noUiSlider({ 62 | start: parseFloat($('#start-prob').val()), 63 | connect: "lower", 64 | range: { 65 | min: 0.5, 66 | max: 99.5 67 | } 68 | }); 69 | 70 | $("#probability-slider").on({ 71 | slide: function(){ 72 | update_button_text(); 73 | }, 74 | change: function(){ 75 | update_button_text(); 76 | } 77 | }); 78 | 79 | $("#amount-slider").noUiSlider({ 80 | start: parseInt($('#amount-hidden').val()), 81 | connect: "lower", 82 | range: { 83 | min: parseInt($('#range').val().split(',')[0]), 84 | max: parseInt($('#range').val().split(',')[1]) 85 | } 86 | }); 87 | 88 | $("#amount-slider").on({ 89 | slide: function(){ 90 | update_button_text(); 91 | }, 92 | change: function(){ 93 | update_button_text(); 94 | } 95 | }); 96 | 97 | update_button_text(); 98 | 99 | //$("#amount-slider").bind("slider:changed", function (event, data) { 100 | // update_button_text(); 101 | //}); 102 | 103 | //$("#probability-slider").bind("slider:changed", function (event, data) { 104 | // update_button_text(); 105 | //}); 106 | 107 | function update_button_text() { 108 | 109 | amount = $("#amount-slider").val(); 110 | $('#amount-hidden').val(amount); 111 | prob = parseFloat($("#probability-slider").val()).toFixed(1); 112 | multiplier = (99 / prob).toFixed(2); 113 | profit = (amount * multiplier / 100000000.0).toFixed(4) 114 | 115 | $('#roll-prob').val(prob) 116 | $('#bet_profit').val(profit) 117 | $('#amount-view').val((amount / 100000000.00).toFixed(5)); 118 | $('#bet_chance').val(prob + '%'); 119 | $('#roll-button').val("Click for a " + prob + "% chance of multiplying your bet by " + multiplier); 120 | } 121 | }; 122 | 123 | $(document).ready(initialise); 124 | $(document).on('page:load', initialise); -------------------------------------------------------------------------------- /app/assets/javascripts/chance.min.js: -------------------------------------------------------------------------------- 1 | !function(){function a(b){return this instanceof a?(void 0!==b&&("function"==typeof b?this.random=b:this.seed=b),"undefined"==typeof this.random&&(this.mt=this.mersenne_twister(b),this.random=function(){return this.mt.random(this.seed)}),this):new a(b)}function b(a,b){if(a||(a={}),b)for(var c in b)"undefined"==typeof a[c]&&(a[c]=b[c]);return a}function c(a,b){if(a)throw new RangeError(b)}function d(a){return function(){return this.natural(a)}}function e(a,b){var c;b=b||(Array.isArray(a)?[]:{});for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]||b[c]);return b}var f=9007199254740992,g=-f,h="0123456789",i="abcdefghijklmnopqrstuvwxyz",j=i.toUpperCase(),k=h+"abcdef",l=Array.prototype.slice;a.prototype.VERSION="0.6.1",a.prototype.bool=function(a){return a=b(a,{likelihood:50}),c(a.likelihood<0||a.likelihood>100,"Chance: Likelihood accepts values from 0 to 100."),100*this.random()g,"Chance: Max specified is out of range with fixed. Max should be, at most, "+g),a=b(a,{min:h,max:g}),d=this.integer({min:a.min*e,max:a.max*e});var i=(d/e).toFixed(a.fixed);return parseFloat(i)},a.prototype.integer=function(a){return a=b(a,{min:g,max:f}),c(a.min>a.max,"Chance: Min cannot be greater than Max."),Math.floor(this.random()*(a.max-a.min+1)+a.min)},a.prototype.natural=function(a){return a=b(a,{min:0,max:f}),this.integer(a)},a.prototype.string=function(a){a=b(a);var c=a.length||this.natural({min:5,max:20}),d=a.pool,e=this.n(this.character,c,{pool:d});return e.join("")},a.prototype.capitalize=function(a){return a.charAt(0).toUpperCase()+a.substr(1)},a.prototype.mixin=function(b){for(var c in b)a.prototype[c]=b[c];return this},a.prototype.unique=function(a,c,d){d=b(d,{comparator:function(a,b){return-1!==a.indexOf(b)}});for(var e,f=[],g=0,h=50*c,i=l.call(arguments,2);f.lengthh)throw new RangeError("Chance: num is likely too large for sample set");return f},a.prototype.n=function(a,b){var c=b||1,d=[],e=l.call(arguments,2);for(null;c--;null)d.push(a.apply(this,e));return d},a.prototype.pad=function(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a},a.prototype.pick=function(a,b){return b&&1!==b?this.shuffle(a).slice(0,b):a[this.natural({max:a.length-1})]},a.prototype.shuffle=function(a){for(var b=a.slice(0),c=[],d=0,e=Number(b.length),f=0;e>f;f++)d=this.natural({max:b.length-1}),c[f]=b[d],b.splice(d,1);return c},a.prototype.weighted=function(a,b){if(a.length!==b.length)throw new RangeError("Chance: length of array and weights must match");if(b.some(function(a){return 1>a})){var c=b.reduce(function(a,b){return a>b?b:a},b[0]),d=1/c;b=b.map(function(a){return a*d})}var e,f=b.reduce(function(a,b){return a+b},0),g=this.natural({min:1,max:f}),h=0;return b.some(function(b,c){return h+b>=g?(e=a[c],!0):(h+=b,!1)}),e},a.prototype.paragraph=function(a){a=b(a);var c=a.sentences||this.natural({min:3,max:7}),d=this.n(this.sentence,c);return d.join(" ")},a.prototype.sentence=function(a){a=b(a);var c,d=a.words||this.natural({min:12,max:18}),e=this.n(this.word,d);return c=e.join(" "),c=this.capitalize(c)+"."},a.prototype.syllable=function(a){a=b(a);for(var c,d=a.length||this.natural({min:2,max:3}),e="bcdfghjklmnprstvwz",f="aeiou",g=e+f,h="",i=0;d>i;i++)c=this.character(0===i?{pool:g}:-1===e.indexOf(c)?{pool:e}:{pool:f}),h+=c;return h},a.prototype.word=function(a){a=b(a),c(a.syllables&&a.length,"Chance: Cannot specify both syllables AND length.");var d=a.syllables||this.natural({min:1,max:3}),e="";if(a.length){do e+=this.syllable();while(e.lengthf;f++)e+=this.syllable();return e},a.prototype.age=function(a){a=b(a);var c;switch(a.type){case"child":c={min:1,max:12};break;case"teen":c={min:13,max:19};break;case"adult":c={min:18,max:65};break;case"senior":c={min:65,max:100};break;case"all":c={min:1,max:100};break;default:c={min:18,max:65}}return this.natural(c)},a.prototype.birthday=function(a){return a=b(a,{year:(new Date).getFullYear()-this.age(a)}),this.date(a)},a.prototype.cpf=function(){var a=this.n(this.natural,9,{max:9}),b=2*a[8]+3*a[7]+4*a[6]+5*a[5]+6*a[4]+7*a[3]+8*a[2]+9*a[1]+10*a[0];b=11-b%11,b>=10&&(b=0);var c=2*b+3*a[8]+4*a[7]+5*a[6]+6*a[5]+7*a[4]+8*a[3]+9*a[2]+10*a[1]+11*a[0];return c=11-c%11,c>=10&&(c=0),""+a[0]+a[1]+a[2]+"."+a[3]+a[4]+a[5]+"."+a[6]+a[7]+a[8]+"-"+b+c},a.prototype.first=function(a){return a=b(a,{gender:this.gender()}),this.pick(this.get("firstNames")[a.gender.toLowerCase()])},a.prototype.gender=function(){return this.pick(["Male","Female"])},a.prototype.last=function(){return this.pick(this.get("lastNames"))},a.prototype.name=function(a){a=b(a);var c,d=this.first(a),e=this.last();return c=a.middle?d+" "+this.first(a)+" "+e:a.middle_initial?d+" "+this.character({alpha:!0,casing:"upper"})+". "+e:d+" "+e,a.prefix&&(c=this.prefix(a)+" "+c),c},a.prototype.name_prefixes=function(a){a=a||"all";var b=[{name:"Doctor",abbreviation:"Dr."}];return("male"===a||"all"===a)&&b.push({name:"Mister",abbreviation:"Mr."}),("female"===a||"all"===a)&&(b.push({name:"Miss",abbreviation:"Miss"}),b.push({name:"Misses",abbreviation:"Mrs."})),b},a.prototype.prefix=function(a){return this.name_prefix(a)},a.prototype.name_prefix=function(a){return a=b(a,{gender:"all"}),a.full?this.pick(this.name_prefixes(a.gender)).name:this.pick(this.name_prefixes(a.gender)).abbreviation},a.prototype.ssn=function(a){a=b(a,{ssnFour:!1,dashes:!0});var c,d="1234567890",e=a.dashes?"-":"";return c=a.ssnFour?this.string({pool:d,length:4}):this.string({pool:d,length:3})+e+this.string({pool:d,length:2})+e+this.string({pool:d,length:4})},a.prototype.apple_token=function(){return this.string({pool:"abcdef1234567890",length:64})},a.prototype.color=function(a){function c(a,b){return[a,a,a].join(b||"")}a=b(a,{format:this.pick(["hex","shorthex","rgb"]),grayscale:!1});var d=a.grayscale;if("hex"===a.format)return"#"+(d?c(this.hash({length:2})):this.hash({length:6}));if("shorthex"===a.format)return"#"+(d?c(this.hash({length:1})):this.hash({length:3}));if("rgb"===a.format)return d?"rgb("+c(this.natural({max:255}),",")+")":"rgb("+this.natural({max:255})+","+this.natural({max:255})+","+this.natural({max:255})+")";throw new Error('Invalid format provided. Please provide one of "hex", "shorthex", or "rgb"')},a.prototype.domain=function(a){return a=b(a),this.word()+"."+(a.tld||this.tld())},a.prototype.email=function(a){return a=b(a),this.word({length:a.length})+"@"+(a.domain||this.domain())},a.prototype.fbid=function(){return parseInt("10000"+this.natural({max:1e11}),10)},a.prototype.google_analytics=function(){var a=this.pad(this.natural({max:999999}),6),b=this.pad(this.natural({max:99}),2);return"UA-"+a+"-"+b},a.prototype.hashtag=function(){return"#"+this.word()},a.prototype.ip=function(){return this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})+"."+this.natural({max:255})},a.prototype.ipv6=function(){var a=this.n(this.hash,8,{length:4});return a.join(":")},a.prototype.klout=function(){return this.natural({min:1,max:99})},a.prototype.tlds=function(){return["com","org","edu","gov","co.uk","net","io"]},a.prototype.tld=function(){return this.pick(this.tlds())},a.prototype.twitter=function(){return"@"+this.word()},a.prototype.address=function(a){return a=b(a),this.natural({min:5,max:2e3})+" "+this.street(a)},a.prototype.altitude=function(a){return a=b(a,{fixed:5,max:8848}),this.floating({min:0,max:a.max,fixed:a.fixed})},a.prototype.areacode=function(a){a=b(a,{parens:!0});var c=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:8}).toString()+this.natural({min:0,max:9}).toString();return a.parens?"("+c+")":c},a.prototype.city=function(){return this.capitalize(this.word({syllables:3}))},a.prototype.coordinates=function(a){return a=b(a),this.latitude(a)+", "+this.longitude(a)},a.prototype.depth=function(a){return a=b(a,{fixed:5,min:-2550}),this.floating({min:a.min,max:0,fixed:a.fixed})},a.prototype.geohash=function(a){return a=b(a,{length:7}),this.string({length:a.length,pool:"0123456789bcdefghjkmnpqrstuvwxyz"})},a.prototype.geojson=function(a){return a=b(a),this.latitude(a)+", "+this.longitude(a)+", "+this.altitude(a)},a.prototype.latitude=function(a){return a=b(a,{fixed:5,min:-90,max:90}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.longitude=function(a){return a=b(a,{fixed:5,min:-180,max:180}),this.floating({min:a.min,max:a.max,fixed:a.fixed})},a.prototype.phone=function(a){a=b(a,{formatted:!0}),a.formatted||(a.parens=!1);var c=this.areacode(a).toString(),d=this.natural({min:2,max:9}).toString()+this.natural({min:0,max:9}).toString()+this.natural({min:0,max:9}).toString(),e=this.natural({min:1e3,max:9999}).toString();return a.formatted?c+" "+d+"-"+e:c+d+e},a.prototype.postal=function(){var a=this.character({pool:"XVTSRPNKLMHJGECBA"}),b=a+this.natural({max:9})+this.character({alpha:!0,casing:"upper"}),c=this.natural({max:9})+this.character({alpha:!0,casing:"upper"})+this.natural({max:9});return b+" "+c},a.prototype.provinces=function(){return this.get("provinces")},a.prototype.province=function(a){return a&&a.full?this.pick(this.provinces()).name:this.pick(this.provinces()).abbreviation},a.prototype.state=function(a){return a&&a.full?this.pick(this.states(a)).name:this.pick(this.states(a)).abbreviation},a.prototype.states=function(a){a=b(a);var c,d=this.get("us_states_and_dc"),e=this.get("territories"),f=this.get("armed_forces");return c=d,a.territories&&(c=c.concat(e)),a.armed_forces&&(c=c.concat(f)),c},a.prototype.street=function(a){a=b(a);var c=this.word({syllables:2});return c=this.capitalize(c),c+=" ",c+=a.short_suffix?this.street_suffix().abbreviation:this.street_suffix().name},a.prototype.street_suffix=function(){return this.pick(this.street_suffixes())},a.prototype.street_suffixes=function(){return this.get("street_suffixes")},a.prototype.zip=function(a){var b=this.n(this.natural,5,{max:9});return a&&a.plusfour===!0&&(b.push("-"),b=b.concat(this.n(this.natural,4,{max:9}))),b.join("")},a.prototype.ampm=function(){return this.bool()?"am":"pm"},a.prototype.date=function(a){var c,d=this.month({raw:!0});a=b(a,{year:parseInt(this.year(),10),month:d.numeric-1,day:this.natural({min:1,max:d.days}),hour:this.hour(),minute:this.minute(),second:this.second(),millisecond:this.millisecond(),american:!0,string:!1});var e=new Date(a.year,a.month,a.day,a.hour,a.minute,a.second,a.millisecond);return c=a.american?e.getMonth()+1+"/"+e.getDate()+"/"+e.getFullYear():e.getDate()+"/"+(e.getMonth()+1)+"/"+e.getFullYear(),a.string?c:e},a.prototype.hammertime=function(a){return this.date(a).getTime()},a.prototype.hour=function(a){a=b(a);var c=a.twentyfour?24:12;return this.natural({min:1,max:c})},a.prototype.millisecond=function(){return this.natural({max:999})},a.prototype.minute=a.prototype.second=function(){return this.natural({max:59})},a.prototype.month=function(a){a=b(a);var c=this.pick(this.months());return a.raw?c:c.name},a.prototype.months=function(){return this.get("months")},a.prototype.second=function(){return this.natural({max:59})},a.prototype.timestamp=function(){return this.natural({min:1,max:parseInt((new Date).getTime()/1e3,10)})},a.prototype.year=function(a){return a=b(a,{min:(new Date).getFullYear()}),a.max="undefined"!=typeof a.max?a.max:a.min+100,this.natural(a).toString()},a.prototype.cc=function(a){a=b(a);var c,d,e;return c=this.cc_type(a.type?{name:a.type,raw:!0}:{raw:!0}),d=c.prefix.split(""),e=c.length-c.prefix.length-1,d=d.concat(this.n(this.integer,e,{min:0,max:9})),d.push(this.luhn_calculate(d.join(""))),d.join("")},a.prototype.cc_types=function(){return this.get("cc_types")},a.prototype.cc_type=function(a){a=b(a);var c=this.cc_types(),d=null;if(a.name){for(var e=0;ec?"-$"+c.replace("-",""):"$"+c},a.prototype.exp=function(a){a=b(a);var c={};return c.year=this.exp_year(),c.month=c.year===(new Date).getFullYear()?this.exp_month({future:!0}):this.exp_month(),a.raw?c:c.month+"/"+c.year},a.prototype.exp_month=function(a){a=b(a);var c,d,e=(new Date).getMonth();if(a.future){do c=this.month({raw:!0}).numeric,d=parseInt(c,10);while(e>d)}else c=this.month({raw:!0}).numeric;return c},a.prototype.exp_year=function(){return this.year({max:(new Date).getFullYear()+10})},a.prototype.d4=d({min:1,max:4}),a.prototype.d6=d({min:1,max:6}),a.prototype.d8=d({min:1,max:8}),a.prototype.d10=d({min:1,max:10}),a.prototype.d12=d({min:1,max:12}),a.prototype.d20=d({min:1,max:20}),a.prototype.d30=d({min:1,max:30}),a.prototype.d100=d({min:1,max:100}),a.prototype.rpg=function(a,c){if(c=b(c),null===a)throw new Error("A type of die roll must be included");var d=a.toLowerCase().split("d"),e=[];if(2!==d.length||!parseInt(d[0],10)||!parseInt(d[1],10))throw new Error("Invalid format provided. Please provide #d# where the first # is the number of dice to roll, the second # is the max of each die");for(var f=d[0];f>0;f--)e[f-1]=this.natural({min:1,max:d[1]});return"undefined"!=typeof c.sum&&c.sum?e.reduce(function(a,b){return a+b}):e},a.prototype.guid=function(a){a=b(a,{version:5});var c="abcdef1234567890",d="ab89",e=this.string({pool:c,length:8})+"-"+this.string({pool:c,length:4})+"-"+a.version+this.string({pool:c,length:3})+"-"+this.string({pool:d,length:1})+this.string({pool:c,length:3})+"-"+this.string({pool:c,length:12});return e},a.prototype.hash=function(a){a=b(a,{length:40,casing:"lower"});var c="upper"===a.casing?k.toUpperCase():k;return this.string({pool:c,length:a.length})},a.prototype.luhn_check=function(a){var b=a.toString(),c=+b.substring(b.length-1);return c===this.luhn_calculate(+b.substring(0,b.length-1))},a.prototype.luhn_calculate=function(a){for(var b,c=a.toString().split("").reverse(),d=0,e=0,f=c.length;f>e;++e)b=+c[e],e%2===0&&(b*=2,b>9&&(b-=9)),d+=b;return 9*d%10};var m={firstNames:{male:["James","John","Robert","Michael","William","David","Richard","Joseph","Charles","Thomas","Christopher","Daniel","Matthew","George","Donald","Anthony","Paul","Mark","Edward","Steven","Kenneth","Andrew","Brian","Joshua","Kevin","Ronald","Timothy","Jason","Jeffrey","Frank","Gary","Ryan","Nicholas","Eric","Stephen","Jacob","Larry","Jonathan","Scott","Raymond","Justin","Brandon","Gregory","Samuel","Benjamin","Patrick","Jack","Henry","Walter","Dennis","Jerry","Alexander","Peter","Tyler","Douglas","Harold","Aaron","Jose","Adam","Arthur","Zachary","Carl","Nathan","Albert","Kyle","Lawrence","Joe","Willie","Gerald","Roger","Keith","Jeremy","Terry","Harry","Ralph","Sean","Jesse","Roy","Louis","Billy","Austin","Bruce","Eugene","Christian","Bryan","Wayne","Russell","Howard","Fred","Ethan","Jordan","Philip","Alan","Juan","Randy","Vincent","Bobby","Dylan","Johnny","Phillip","Victor","Clarence","Ernest","Martin","Craig","Stanley","Shawn","Travis","Bradley","Leonard","Earl","Gabriel","Jimmy","Francis","Todd","Noah","Danny","Dale","Cody","Carlos","Allen","Frederick","Logan","Curtis","Alex","Joel","Luis","Norman","Marvin","Glenn","Tony","Nathaniel","Rodney","Melvin","Alfred","Steve","Cameron","Chad","Edwin","Caleb","Evan","Antonio","Lee","Herbert","Jeffery","Isaac","Derek","Ricky","Marcus","Theodore","Elijah","Luke","Jesus","Eddie","Troy","Mike","Dustin","Ray","Adrian","Bernard","Leroy","Angel","Randall","Wesley","Ian","Jared","Mason","Hunter","Calvin","Oscar","Clifford","Jay","Shane","Ronnie","Barry","Lucas","Corey","Manuel","Leo","Tommy","Warren","Jackson","Isaiah","Connor","Don","Dean","Jon","Julian","Miguel","Bill","Lloyd","Charlie","Mitchell","Leon","Jerome","Darrell","Jeremiah","Alvin","Brett","Seth","Floyd","Jim","Blake","Micheal","Gordon","Trevor","Lewis","Erik","Edgar","Vernon","Devin","Gavin","Jayden","Chris","Clyde","Tom","Derrick","Mario","Brent","Marc","Herman","Chase","Dominic","Ricardo","Franklin","Maurice","Max","Aiden","Owen","Lester","Gilbert","Elmer","Gene","Francisco","Glen","Cory","Garrett","Clayton","Sam","Jorge","Chester","Alejandro","Jeff","Harvey","Milton","Cole","Ivan","Andre","Duane","Landon"],female:["Mary","Emma","Elizabeth","Minnie","Margaret","Ida","Alice","Bertha","Sarah","Annie","Clara","Ella","Florence","Cora","Martha","Laura","Nellie","Grace","Carrie","Maude","Mabel","Bessie","Jennie","Gertrude","Julia","Hattie","Edith","Mattie","Rose","Catherine","Lillian","Ada","Lillie","Helen","Jessie","Louise","Ethel","Lula","Myrtle","Eva","Frances","Lena","Lucy","Edna","Maggie","Pearl","Daisy","Fannie","Josephine","Dora","Rosa","Katherine","Agnes","Marie","Nora","May","Mamie","Blanche","Stella","Ellen","Nancy","Effie","Sallie","Nettie","Della","Lizzie","Flora","Susie","Maud","Mae","Etta","Harriet","Sadie","Caroline","Katie","Lydia","Elsie","Kate","Susan","Mollie","Alma","Addie","Georgia","Eliza","Lulu","Nannie","Lottie","Amanda","Belle","Charlotte","Rebecca","Ruth","Viola","Olive","Amelia","Hannah","Jane","Virginia","Emily","Matilda","Irene","Kathryn","Esther","Willie","Henrietta","Ollie","Amy","Rachel","Sara","Estella","Theresa","Augusta","Ora","Pauline","Josie","Lola","Sophia","Leona","Anne","Mildred","Ann","Beulah","Callie","Lou","Delia","Eleanor","Barbara","Iva","Louisa","Maria","Mayme","Evelyn","Estelle","Nina","Betty","Marion","Bettie","Dorothy","Luella","Inez","Lela","Rosie","Allie","Millie","Janie","Cornelia","Victoria","Ruby","Winifred","Alta","Celia","Christine","Beatrice","Birdie","Harriett","Mable","Myra","Sophie","Tillie","Isabel","Sylvia","Carolyn","Isabelle","Leila","Sally","Ina","Essie","Bertie","Nell","Alberta","Katharine","Lora","Rena","Mina","Rhoda","Mathilda","Abbie","Eula","Dollie","Hettie","Eunice","Fanny","Ola","Lenora","Adelaide","Christina","Lelia","Nelle","Sue","Johanna","Lilly","Lucinda","Minerva","Lettie","Roxie","Cynthia","Helena","Hilda","Hulda","Bernice","Genevieve","Jean","Cordelia","Marian","Francis","Jeanette","Adeline","Gussie","Leah","Lois","Lura","Mittie","Hallie","Isabella","Olga","Phoebe","Teresa","Hester","Lida","Lina","Winnie","Claudia","Marguerite","Vera","Cecelia","Bess","Emilie","John","Rosetta","Verna","Myrtie","Cecilia","Elva","Olivia","Ophelia","Georgie","Elnora","Violet","Adele","Lily","Linnie","Loretta","Madge","Polly","Virgie","Eugenia","Lucile","Lucille","Mabelle","Rosalie"]},lastNames:["Smith","Johnson","Williams","Jones","Brown","Davis","Miller","Wilson","Moore","Taylor","Anderson","Thomas","Jackson","White","Harris","Martin","Thompson","Garcia","Martinez","Robinson","Clark","Rodriguez","Lewis","Lee","Walker","Hall","Allen","Young","Hernandez","King","Wright","Lopez","Hill","Scott","Green","Adams","Baker","Gonzalez","Nelson","Carter","Mitchell","Perez","Roberts","Turner","Phillips","Campbell","Parker","Evans","Edwards","Collins","Stewart","Sanchez","Morris","Rogers","Reed","Cook","Morgan","Bell","Murphy","Bailey","Rivera","Cooper","Richardson","Cox","Howard","Ward","Torres","Peterson","Gray","Ramirez","James","Watson","Brooks","Kelly","Sanders","Price","Bennett","Wood","Barnes","Ross","Henderson","Coleman","Jenkins","Perry","Powell","Long","Patterson","Hughes","Flores","Washington","Butler","Simmons","Foster","Gonzales","Bryant","Alexander","Russell","Griffin","Diaz","Hayes","Myers","Ford","Hamilton","Graham","Sullivan","Wallace","Woods","Cole","West","Jordan","Owens","Reynolds","Fisher","Ellis","Harrison","Gibson","McDonald","Cruz","Marshall","Ortiz","Gomez","Murray","Freeman","Wells","Webb","Simpson","Stevens","Tucker","Porter","Hunter","Hicks","Crawford","Henry","Boyd","Mason","Morales","Kennedy","Warren","Dixon","Ramos","Reyes","Burns","Gordon","Shaw","Holmes","Rice","Robertson","Hunt","Black","Daniels","Palmer","Mills","Nichols","Grant","Knight","Ferguson","Rose","Stone","Hawkins","Dunn","Perkins","Hudson","Spencer","Gardner","Stephens","Payne","Pierce","Berry","Matthews","Arnold","Wagner","Willis","Ray","Watkins","Olson","Carroll","Duncan","Snyder","Hart","Cunningham","Bradley","Lane","Andrews","Ruiz","Harper","Fox","Riley","Armstrong","Carpenter","Weaver","Greene","Lawrence","Elliott","Chavez","Sims","Austin","Peters","Kelley","Franklin","Lawson","Fields","Gutierrez","Ryan","Schmidt","Carr","Vasquez","Castillo","Wheeler","Chapman","Oliver","Montgomery","Richards","Williamson","Johnston","Banks","Meyer","Bishop","McCoy","Howell","Alvarez","Morrison","Hansen","Fernandez","Garza","Harvey","Little","Burton","Stanley","Nguyen","George","Jacobs","Reid","Kim","Fuller","Lynch","Dean","Gilbert","Garrett","Romero","Welch","Larson","Frazier","Burke","Hanson","Day","Mendoza","Moreno","Bowman","Medina","Fowler","Brewer","Hoffman","Carlson","Silva","Pearson","Holland","Douglas","Fleming","Jensen","Vargas","Byrd","Davidson","Hopkins","May","Terry","Herrera","Wade","Soto","Walters","Curtis","Neal","Caldwell","Lowe","Jennings","Barnett","Graves","Jimenez","Horton","Shelton","Barrett","Obrien","Castro","Sutton","Gregory","McKinney","Lucas","Miles","Craig","Rodriquez","Chambers","Holt","Lambert","Fletcher","Watts","Bates","Hale","Rhodes","Pena","Beck","Newman","Haynes","McDaniel","Mendez","Bush","Vaughn","Parks","Dawson","Santiago","Norris","Hardy","Love","Steele","Curry","Powers","Schultz","Barker","Guzman","Page","Munoz","Ball","Keller","Chandler","Weber","Leonard","Walsh","Lyons","Ramsey","Wolfe","Schneider","Mullins","Benson","Sharp","Bowen","Daniel","Barber","Cummings","Hines","Baldwin","Griffith","Valdez","Hubbard","Salazar","Reeves","Warner","Stevenson","Burgess","Santos","Tate","Cross","Garner","Mann","Mack","Moss","Thornton","Dennis","McGee","Farmer","Delgado","Aguilar","Vega","Glover","Manning","Cohen","Harmon","Rodgers","Robbins","Newton","Todd","Blair","Higgins","Ingram","Reese","Cannon","Strickland","Townsend","Potter","Goodwin","Walton","Rowe","Hampton","Ortega","Patton","Swanson","Joseph","Francis","Goodman","Maldonado","Yates","Becker","Erickson","Hodges","Rios","Conner","Adkins","Webster","Norman","Malone","Hammond","Flowers","Cobb","Moody","Quinn","Blake","Maxwell","Pope","Floyd","Osborne","Paul","McCarthy","Guerrero","Lindsey","Estrada","Sandoval","Gibbs","Tyler","Gross","Fitzgerald","Stokes","Doyle","Sherman","Saunders","Wise","Colon","Gill","Alvarado","Greer","Padilla","Simon","Waters","Nunez","Ballard","Schwartz","McBride","Houston","Christensen","Klein","Pratt","Briggs","Parsons","McLaughlin","Zimmerman","French","Buchanan","Moran","Copeland","Roy","Pittman","Brady","McCormick","Holloway","Brock","Poole","Frank","Logan","Owen","Bass","Marsh","Drake","Wong","Jefferson","Park","Morton","Abbott","Sparks","Patrick","Norton","Huff","Clayton","Massey","Lloyd","Figueroa","Carson","Bowers","Roberson","Barton","Tran","Lamb","Harrington","Casey","Boone","Cortez","Clarke","Mathis","Singleton","Wilkins","Cain","Bryan","Underwood","Hogan","McKenzie","Collier","Luna","Phelps","McGuire","Allison","Bridges","Wilkerson","Nash","Summers","Atkins"],provinces:[{name:"Alberta",abbreviation:"AB"},{name:"British Columbia",abbreviation:"BC"},{name:"Manitoba",abbreviation:"MB"},{name:"New Brunswick",abbreviation:"NB"},{name:"Newfoundland and Labrador",abbreviation:"NL"},{name:"Nova Scotia",abbreviation:"NS"},{name:"Ontario",abbreviation:"ON"},{name:"Prince Edward Island",abbreviation:"PE"},{name:"Quebec",abbreviation:"QC"},{name:"Saskatchewan",abbreviation:"SK"},{name:"Northwest Territories",abbreviation:"NT"},{name:"Nunavut",abbreviation:"NU"},{name:"Yukon",abbreviation:"YT"}],us_states_and_dc:[{name:"Alabama",abbreviation:"AL"},{name:"Alaska",abbreviation:"AK"},{name:"Arizona",abbreviation:"AZ"},{name:"Arkansas",abbreviation:"AR"},{name:"California",abbreviation:"CA"},{name:"Colorado",abbreviation:"CO"},{name:"Connecticut",abbreviation:"CT"},{name:"Delaware",abbreviation:"DE"},{name:"District of Columbia",abbreviation:"DC"},{name:"Florida",abbreviation:"FL"},{name:"Georgia",abbreviation:"GA"},{name:"Hawaii",abbreviation:"HI"},{name:"Idaho",abbreviation:"ID"},{name:"Illinois",abbreviation:"IL"},{name:"Indiana",abbreviation:"IN"},{name:"Iowa",abbreviation:"IA"},{name:"Kansas",abbreviation:"KS"},{name:"Kentucky",abbreviation:"KY"},{name:"Louisiana",abbreviation:"LA"},{name:"Maine",abbreviation:"ME"},{name:"Maryland",abbreviation:"MD"},{name:"Massachusetts",abbreviation:"MA"},{name:"Michigan",abbreviation:"MI"},{name:"Minnesota",abbreviation:"MN"},{name:"Mississippi",abbreviation:"MS"},{name:"Missouri",abbreviation:"MO"},{name:"Montana",abbreviation:"MT"},{name:"Nebraska",abbreviation:"NE"},{name:"Nevada",abbreviation:"NV"},{name:"New Hampshire",abbreviation:"NH"},{name:"New Jersey",abbreviation:"NJ"},{name:"New Mexico",abbreviation:"NM"},{name:"New York",abbreviation:"NY"},{name:"North Carolina",abbreviation:"NC"},{name:"North Dakota",abbreviation:"ND"},{name:"Ohio",abbreviation:"OH"},{name:"Oklahoma",abbreviation:"OK"},{name:"Oregon",abbreviation:"OR"},{name:"Pennsylvania",abbreviation:"PA"},{name:"Rhode Island",abbreviation:"RI"},{name:"South Carolina",abbreviation:"SC"},{name:"South Dakota",abbreviation:"SD"},{name:"Tennessee",abbreviation:"TN"},{name:"Texas",abbreviation:"TX"},{name:"Utah",abbreviation:"UT"},{name:"Vermont",abbreviation:"VT"},{name:"Virginia",abbreviation:"VA"},{name:"Washington",abbreviation:"WA"},{name:"West Virginia",abbreviation:"WV"},{name:"Wisconsin",abbreviation:"WI"},{name:"Wyoming",abbreviation:"WY"}],territories:[{name:"American Samoa",abbreviation:"AS"},{name:"Federated States of Micronesia",abbreviation:"FM"},{name:"Guam",abbreviation:"GU"},{name:"Marshall Islands",abbreviation:"MH"},{name:"Northern Mariana Islands",abbreviation:"MP"},{name:"Puerto Rico",abbreviation:"PR"},{name:"Virgin Islands, U.S.",abbreviation:"VI"}],armed_forces:[{name:"Armed Forces Europe",abbreviation:"AE"},{name:"Armed Forces Pacific",abbreviation:"AP"},{name:"Armed Forces the Americas",abbreviation:"AA"}],street_suffixes:[{name:"Avenue",abbreviation:"Ave"},{name:"Boulevard",abbreviation:"Blvd"},{name:"Center",abbreviation:"Ctr"},{name:"Circle",abbreviation:"Cir"},{name:"Court",abbreviation:"Ct"},{name:"Drive",abbreviation:"Dr"},{name:"Extension",abbreviation:"Ext"},{name:"Glen",abbreviation:"Gln"},{name:"Grove",abbreviation:"Grv"},{name:"Heights",abbreviation:"Hts"},{name:"Highway",abbreviation:"Hwy"},{name:"Junction",abbreviation:"Jct"},{name:"Key",abbreviation:"Key"},{name:"Lane",abbreviation:"Ln"},{name:"Loop",abbreviation:"Loop"},{name:"Manor",abbreviation:"Mnr"},{name:"Mill",abbreviation:"Mill"},{name:"Park",abbreviation:"Park"},{name:"Parkway",abbreviation:"Pkwy"},{name:"Pass",abbreviation:"Pass"},{name:"Path",abbreviation:"Path"},{name:"Pike",abbreviation:"Pike"},{name:"Place",abbreviation:"Pl"},{name:"Plaza",abbreviation:"Plz"},{name:"Point",abbreviation:"Pt"},{name:"Ridge",abbreviation:"Rdg"},{name:"River",abbreviation:"Riv"},{name:"Road",abbreviation:"Rd"},{name:"Square",abbreviation:"Sq"},{name:"Street",abbreviation:"St"},{name:"Terrace",abbreviation:"Ter"},{name:"Trail",abbreviation:"Trl"},{name:"Turnpike",abbreviation:"Tpke"},{name:"View",abbreviation:"Vw"},{name:"Way",abbreviation:"Way"}],months:[{name:"January",short_name:"Jan",numeric:"01",days:31},{name:"February",short_name:"Feb",numeric:"02",days:28},{name:"March",short_name:"Mar",numeric:"03",days:31},{name:"April",short_name:"Apr",numeric:"04",days:30},{name:"May",short_name:"May",numeric:"05",days:31},{name:"June",short_name:"Jun",numeric:"06",days:30},{name:"July",short_name:"Jul",numeric:"07",days:31},{name:"August",short_name:"Aug",numeric:"08",days:31},{name:"September",short_name:"Sep",numeric:"09",days:30},{name:"October",short_name:"Oct",numeric:"10",days:31},{name:"November",short_name:"Nov",numeric:"11",days:30},{name:"December",short_name:"Dec",numeric:"12",days:31}],cc_types:[{name:"American Express",short_name:"amex",prefix:"34",length:15},{name:"Bankcard",short_name:"bankcard",prefix:"5610",length:16},{name:"China UnionPay",short_name:"chinaunion",prefix:"62",length:16},{name:"Diners Club Carte Blanche",short_name:"dccarte",prefix:"300",length:14},{name:"Diners Club enRoute",short_name:"dcenroute",prefix:"2014",length:15},{name:"Diners Club International",short_name:"dcintl",prefix:"36",length:14},{name:"Diners Club United States & Canada",short_name:"dcusc",prefix:"54",length:16},{name:"Discover Card",short_name:"discover",prefix:"6011",length:16},{name:"InstaPayment",short_name:"instapay",prefix:"637",length:16},{name:"JCB",short_name:"jcb",prefix:"3528",length:16},{name:"Laser",short_name:"laser",prefix:"6304",length:16},{name:"Maestro",short_name:"maestro",prefix:"5018",length:16},{name:"Mastercard",short_name:"mc",prefix:"51",length:16},{name:"Solo",short_name:"solo",prefix:"6334",length:16},{name:"Switch",short_name:"switch",prefix:"4903",length:16},{name:"Visa",short_name:"visa",prefix:"4",length:16},{name:"Visa Electron",short_name:"electron",prefix:"4026",length:16}],currency_types:[{code:"AED",name:"United Arab Emirates Dirham"},{code:"AFN",name:"Afghanistan Afghani"},{code:"ALL",name:"Albania Lek"},{code:"AMD",name:"Armenia Dram"},{code:"ANG",name:"Netherlands Antilles Guilder"},{code:"AOA",name:"Angola Kwanza"},{code:"ARS",name:"Argentina Peso"},{code:"AUD",name:"Australia Dollar"},{code:"AWG",name:"Aruba Guilder"},{code:"AZN",name:"Azerbaijan New Manat"},{code:"BAM",name:"Bosnia and Herzegovina Convertible Marka"},{code:"BBD",name:"Barbados Dollar"},{code:"BDT",name:"Bangladesh Taka"},{code:"BGN",name:"Bulgaria Lev"},{code:"BHD",name:"Bahrain Dinar"},{code:"BIF",name:"Burundi Franc"},{code:"BMD",name:"Bermuda Dollar"},{code:"BND",name:"Brunei Darussalam Dollar"},{code:"BOB",name:"Bolivia Boliviano"},{code:"BRL",name:"Brazil Real"},{code:"BSD",name:"Bahamas Dollar"},{code:"BTN",name:"Bhutan Ngultrum"},{code:"BWP",name:"Botswana Pula"},{code:"BYR",name:"Belarus Ruble"},{code:"BZD",name:"Belize Dollar"},{code:"CAD",name:"Canada Dollar"},{code:"CDF",name:"Congo/Kinshasa Franc"},{code:"CHF",name:"Switzerland Franc"},{code:"CLP",name:"Chile Peso"},{code:"CNY",name:"China Yuan Renminbi"},{code:"COP",name:"Colombia Peso"},{code:"CRC",name:"Costa Rica Colon"},{code:"CUC",name:"Cuba Convertible Peso"},{code:"CUP",name:"Cuba Peso"},{code:"CVE",name:"Cape Verde Escudo"},{code:"CZK",name:"Czech Republic Koruna"},{code:"DJF",name:"Djibouti Franc"},{code:"DKK",name:"Denmark Krone"},{code:"DOP",name:"Dominican Republic Peso"},{code:"DZD",name:"Algeria Dinar"},{code:"EGP",name:"Egypt Pound"},{code:"ERN",name:"Eritrea Nakfa"},{code:"ETB",name:"Ethiopia Birr"},{code:"EUR",name:"Euro Member Countries"},{code:"FJD",name:"Fiji Dollar"},{code:"FKP",name:"Falkland Islands (Malvinas) Pound"},{code:"GBP",name:"United Kingdom Pound"},{code:"GEL",name:"Georgia Lari"},{code:"GGP",name:"Guernsey Pound"},{code:"GHS",name:"Ghana Cedi"},{code:"GIP",name:"Gibraltar Pound"},{code:"GMD",name:"Gambia Dalasi"},{code:"GNF",name:"Guinea Franc"},{code:"GTQ",name:"Guatemala Quetzal"},{code:"GYD",name:"Guyana Dollar"},{code:"HKD",name:"Hong Kong Dollar"},{code:"HNL",name:"Honduras Lempira"},{code:"HRK",name:"Croatia Kuna"},{code:"HTG",name:"Haiti Gourde"},{code:"HUF",name:"Hungary Forint"},{code:"IDR",name:"Indonesia Rupiah"},{code:"ILS",name:"Israel Shekel"},{code:"IMP",name:"Isle of Man Pound"},{code:"INR",name:"India Rupee"},{code:"IQD",name:"Iraq Dinar"},{code:"IRR",name:"Iran Rial"},{code:"ISK",name:"Iceland Krona"},{code:"JEP",name:"Jersey Pound"},{code:"JMD",name:"Jamaica Dollar"},{code:"JOD",name:"Jordan Dinar"},{code:"JPY",name:"Japan Yen"},{code:"KES",name:"Kenya Shilling"},{code:"KGS",name:"Kyrgyzstan Som"},{code:"KHR",name:"Cambodia Riel"},{code:"KMF",name:"Comoros Franc"},{code:"KPW",name:"Korea (North) Won"},{code:"KRW",name:"Korea (South) Won"},{code:"KWD",name:"Kuwait Dinar"},{code:"KYD",name:"Cayman Islands Dollar"},{code:"KZT",name:"Kazakhstan Tenge"},{code:"LAK",name:"Laos Kip"},{code:"LBP",name:"Lebanon Pound"},{code:"LKR",name:"Sri Lanka Rupee"},{code:"LRD",name:"Liberia Dollar"},{code:"LSL",name:"Lesotho Loti"},{code:"LTL",name:"Lithuania Litas"},{code:"LYD",name:"Libya Dinar"},{code:"MAD",name:"Morocco Dirham"},{code:"MDL",name:"Moldova Leu"},{code:"MGA",name:"Madagascar Ariary"},{code:"MKD",name:"Macedonia Denar"},{code:"MMK",name:"Myanmar (Burma) Kyat"},{code:"MNT",name:"Mongolia Tughrik"},{code:"MOP",name:"Macau Pataca"},{code:"MRO",name:"Mauritania Ouguiya"},{code:"MUR",name:"Mauritius Rupee"},{code:"MVR",name:"Maldives (Maldive Islands) Rufiyaa"},{code:"MWK",name:"Malawi Kwacha"},{code:"MXN",name:"Mexico Peso"},{code:"MYR",name:"Malaysia Ringgit"},{code:"MZN",name:"Mozambique Metical"},{code:"NAD",name:"Namibia Dollar"},{code:"NGN",name:"Nigeria Naira"},{code:"NIO",name:"Nicaragua Cordoba"},{code:"NOK",name:"Norway Krone"},{code:"NPR",name:"Nepal Rupee"},{code:"NZD",name:"New Zealand Dollar"},{code:"OMR",name:"Oman Rial"},{code:"PAB",name:"Panama Balboa"},{code:"PEN",name:"Peru Nuevo Sol"},{code:"PGK",name:"Papua New Guinea Kina"},{code:"PHP",name:"Philippines Peso"},{code:"PKR",name:"Pakistan Rupee"},{code:"PLN",name:"Poland Zloty"},{code:"PYG",name:"Paraguay Guarani"},{code:"QAR",name:"Qatar Riyal"},{code:"RON",name:"Romania New Leu"},{code:"RSD",name:"Serbia Dinar"},{code:"RUB",name:"Russia Ruble"},{code:"RWF",name:"Rwanda Franc"},{code:"SAR",name:"Saudi Arabia Riyal"},{code:"SBD",name:"Solomon Islands Dollar"},{code:"SCR",name:"Seychelles Rupee"},{code:"SDG",name:"Sudan Pound"},{code:"SEK",name:"Sweden Krona"},{code:"SGD",name:"Singapore Dollar"},{code:"SHP",name:"Saint Helena Pound"},{code:"SLL",name:"Sierra Leone Leone"},{code:"SOS",name:"Somalia Shilling"},{code:"SPL",name:"Seborga Luigino"},{code:"SRD",name:"Suriname Dollar"},{code:"STD",name:"São Tomé and Príncipe Dobra"},{code:"SVC",name:"El Salvador Colon"},{code:"SYP",name:"Syria Pound"},{code:"SZL",name:"Swaziland Lilangeni"},{code:"THB",name:"Thailand Baht"},{code:"TJS",name:"Tajikistan Somoni"},{code:"TMT",name:"Turkmenistan Manat"},{code:"TND",name:"Tunisia Dinar"},{code:"TOP",name:"Tonga Pa'anga"},{code:"TRY",name:"Turkey Lira"},{code:"TTD",name:"Trinidad and Tobago Dollar"},{code:"TVD",name:"Tuvalu Dollar"},{code:"TWD",name:"Taiwan New Dollar"},{code:"TZS",name:"Tanzania Shilling"},{code:"UAH",name:"Ukraine Hryvnia"},{code:"UGX",name:"Uganda Shilling"},{code:"USD",name:"United States Dollar"},{code:"UYU",name:"Uruguay Peso"},{code:"UZS",name:"Uzbekistan Som"},{code:"VEF",name:"Venezuela Bolivar"},{code:"VND",name:"Viet Nam Dong"},{code:"VUV",name:"Vanuatu Vatu"},{code:"WST",name:"Samoa Tala"},{code:"XAF",name:"Communauté Financière Africaine (BEAC) CFA Franc BEAC"},{code:"XCD",name:"East Caribbean Dollar"},{code:"XDR",name:"International Monetary Fund (IMF) Special Drawing Rights"},{code:"XOF",name:"Communauté Financière Africaine (BCEAO) Franc"},{code:"XPF",name:"Comptoirs Français du Pacifique (CFP) Franc"},{code:"YER",name:"Yemen Rial"},{code:"ZAR",name:"South Africa Rand"},{code:"ZMW",name:"Zambia Kwacha"},{code:"ZWD",name:"Zimbabwe Dollar"}]}; 2 | a.prototype.get=function(a){return e(m[a])},a.prototype.mac_address=function(a){a=b(a),a.separator||(a.separator=a.networkVersion?".":":");var c="ABCDEF1234567890",d="";return d=a.networkVersion?this.n(this.string,3,{pool:c,length:4}).join(a.separator):this.n(this.string,6,{pool:c,length:2}).join(a.separator)},a.prototype.normal=function(a){a=b(a,{mean:0,dev:1});var c,d,e,f,g=a.mean,h=a.dev;do d=2*this.random()-1,e=2*this.random()-1,c=d*d+e*e;while(c>=1);return f=d*Math.sqrt(-2*Math.log(c)/c),h*f+g},a.prototype.radio=function(a){a=b(a,{side:"?"});var c="";switch(a.side.toLowerCase()){case"east":case"e":c="W";break;case"west":case"w":c="K";break;default:c=this.character({pool:"KW"})}return c+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})+this.character({alpha:!0,casing:"upper"})},a.prototype.set=function(a,b){"string"==typeof a?m[a]=b:m=e(a,m)},a.prototype.tv=function(a){return this.radio(a)},a.prototype.mersenne_twister=function(a){return new n(a)};var n=function(a){void 0===a&&(a=(new Date).getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,this.init_genrand(a)};n.prototype.init_genrand=function(a){for(this.mt[0]=a>>>0,this.mti=1;this.mti>>30,this.mt[this.mti]=(1812433253*((4294901760&a)>>>16)<<16)+1812433253*(65535&a)+this.mti,this.mt[this.mti]>>>=0},n.prototype.init_by_array=function(a,b){var c,d,e=1,f=0;for(this.init_genrand(19650218),c=this.N>b?this.N:b;c;c--)d=this.mt[e-1]^this.mt[e-1]>>>30,this.mt[e]=(this.mt[e]^(1664525*((4294901760&d)>>>16)<<16)+1664525*(65535&d))+a[f]+f,this.mt[e]>>>=0,e++,f++,e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1),f>=b&&(f=0);for(c=this.N-1;c;c--)d=this.mt[e-1]^this.mt[e-1]>>>30,this.mt[e]=(this.mt[e]^(1566083941*((4294901760&d)>>>16)<<16)+1566083941*(65535&d))-e,this.mt[e]>>>=0,e++,e>=this.N&&(this.mt[0]=this.mt[this.N-1],e=1);this.mt[0]=2147483648},n.prototype.genrand_int32=function(){var a,b=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var c;for(this.mti===this.N+1&&this.init_genrand(5489),c=0;c>>1^b[1&a];for(;c>>1^b[1&a];a=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^a>>>1^b[1&a],this.mti=0}return a=this.mt[this.mti++],a^=a>>>11,a^=a<<7&2636928640,a^=a<<15&4022730752,a^=a>>>18,a>>>0},n.prototype.genrand_int31=function(){return this.genrand_int32()>>>1},n.prototype.genrand_real1=function(){return this.genrand_int32()*(1/4294967295)},n.prototype.random=function(){return this.genrand_int32()*(1/4294967296)},n.prototype.genrand_real3=function(){return(this.genrand_int32()+.5)*(1/4294967296)},n.prototype.genrand_res53=function(){var a=this.genrand_int32()>>>5,b=this.genrand_int32()>>>6;return(67108864*a+b)*(1/9007199254740992)},"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=a),exports.Chance=a),"function"==typeof define&&define.amd&&define([],function(){return a}),"object"==typeof window&&"object"==typeof window.document&&(window.Chance=a,window.chance=new a)}(); -------------------------------------------------------------------------------- /app/assets/javascripts/pusher.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Pusher JavaScript Library v2.2.3 3 | * http://pusher.com/ 4 | * 5 | * Copyright 2014, Pusher 6 | * Released under the MIT licence. 7 | */ 8 | 9 | (function(){function b(a,d){(null===a||void 0===a)&&b.warn("Warning","You must pass your app key when you instantiate Pusher.");d=d||{};var c=this;this.key=a;this.config=b.Util.extend(b.getGlobalConfig(),d.cluster?b.getClusterConfig(d.cluster):{},d);this.channels=new b.Channels;this.global_emitter=new b.EventsDispatcher;this.sessionID=Math.floor(1E9*Math.random());this.timeline=new b.Timeline(this.key,this.sessionID,{cluster:this.config.cluster,features:b.Util.getClientFeatures(),params:this.config.timelineParams|| 10 | {},limit:50,level:b.Timeline.INFO,version:b.VERSION});this.config.disableStats||(this.timelineSender=new b.TimelineSender(this.timeline,{host:this.config.statsHost,path:"/timeline/v2/jsonp"}));this.connection=new b.ConnectionManager(this.key,b.Util.extend({getStrategy:function(a){a=b.Util.extend({},c.config,a);return b.StrategyBuilder.build(b.getDefaultStrategy(a),a)},timeline:this.timeline,activityTimeout:this.config.activity_timeout,pongTimeout:this.config.pong_timeout,unavailableTimeout:this.config.unavailable_timeout}, 11 | this.config,{encrypted:this.isEncrypted()}));this.connection.bind("connected",function(){c.subscribeAll();c.timelineSender&&c.timelineSender.send(c.connection.isEncrypted())});this.connection.bind("message",function(a){var d=0===a.event.indexOf("pusher_internal:");if(a.channel){var b=c.channel(a.channel);b&&b.handleEvent(a.event,a.data)}d||c.global_emitter.emit(a.event,a.data)});this.connection.bind("disconnected",function(){c.channels.disconnect()});this.connection.bind("error",function(a){b.warn("Error", 12 | a)});b.instances.push(this);this.timeline.info({instances:b.instances.length});b.isReady&&c.connect()}var c=b.prototype;b.instances=[];b.isReady=!1;b.debug=function(){b.log&&b.log(b.Util.stringify.apply(this,arguments))};b.warn=function(){var a=b.Util.stringify.apply(this,arguments);window.console&&(window.console.warn?window.console.warn(a):window.console.log&&window.console.log(a));b.log&&b.log(a)};b.ready=function(){b.isReady=!0;for(var a=0,d=b.instances.length;ac;c++)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c);var a=function(a){var d=a.charCodeAt(0);return 128>d?a:2048>d?b(192|d>>>6)+b(128|d&63):b(224|d>>>12&15)+b(128|d>>>6&63)+b(128|d&63)},d=function(a){var d=[0,2,1][a.length%3];a=a.charCodeAt(0)<<16|(1>>18),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>> 43 | 12&63),2<=d?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6&63),1<=d?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a&63)].join("")},h=window.btoa||function(a){return a.replace(/[\s\S]{1,3}/g,d)};Pusher.Base64={encode:function(d){return h(d.replace(/[^\x00-\x7F]/g,a))}}}).call(this); 44 | (function(){function b(a,b){this.url=a;this.data=b}function c(a){return Pusher.Util.mapObject(a,function(a){"object"===typeof a&&(a=JSON.stringify(a));return encodeURIComponent(Pusher.Base64.encode(a.toString()))})}var a=b.prototype;a.send=function(a){if(!this.request){var b=Pusher.Util.filterObject(this.data,function(a){return void 0!==a}),b=Pusher.Util.map(Pusher.Util.flatten(c(b)),Pusher.Util.method("join","=")).join("&");this.request=new Pusher.ScriptRequest(this.url+"/"+a.number+"?"+b);this.request.send(a)}}; 45 | a.cleanup=function(){this.request&&this.request.cleanup()};Pusher.JSONPRequest=b}).call(this); 46 | (function(){function b(a,b,c){this.key=a;this.session=b;this.events=[];this.options=c||{};this.uniqueID=this.sent=0}var c=b.prototype;b.ERROR=3;b.INFO=6;b.DEBUG=7;c.log=function(a,b){a<=this.options.level&&(this.events.push(Pusher.Util.extend({},b,{timestamp:Pusher.Util.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())};c.error=function(a){this.log(b.ERROR,a)};c.info=function(a){this.log(b.INFO,a)};c.debug=function(a){this.log(b.DEBUG,a)};c.isEmpty=function(){return 0=== 47 | this.events.length};c.send=function(a,b){var c=this,f=Pusher.Util.extend({session:c.session,bundle:c.sent+1,key:c.key,lib:"js",version:c.options.version,cluster:c.options.cluster,features:c.options.features,timeline:c.events},c.options.params);c.events=[];a(f,function(a,g){a||c.sent++;b&&b(a,g)});return!0};c.generateUniqueID=function(){this.uniqueID++;return this.uniqueID};Pusher.Timeline=b}).call(this); 48 | (function(){function b(b,a){this.timeline=b;this.options=a||{}}b.prototype.send=function(b,a){var d=this;d.timeline.isEmpty()||d.timeline.send(function(a,f){var e=new Pusher.JSONPRequest("http"+(b?"s":"")+"://"+(d.host||d.options.host)+d.options.path,a),g=Pusher.ScriptReceivers.create(function(a,b){Pusher.ScriptReceivers.remove(g);e.cleanup();b&&b.host&&(d.host=b.host);f&&f(a,b)});e.send(g)},a)};Pusher.TimelineSender=b}).call(this); 49 | (function(){function b(a){this.strategies=a}function c(a,b,c){var h=Pusher.Util.map(a,function(a,d,h,f){return a.connect(b,c(d,f))});return{abort:function(){Pusher.Util.apply(h,d)},forceMinPriority:function(a){Pusher.Util.apply(h,function(b){b.forceMinPriority(a)})}}}function a(a){return Pusher.Util.all(a,function(a){return Boolean(a.error)})}function d(a){!a.error&&!a.aborted&&(a.abort(),a.aborted=!0)}var h=b.prototype;h.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))}; 50 | h.connect=function(b,d){return c(this.strategies,b,function(b,c){return function(h,f){(c[b].error=h)?a(c)&&d(!0):(Pusher.Util.apply(c,function(a){a.forceMinPriority(f.transport.priority)}),d(null,f))}})};Pusher.BestConnectedEverStrategy=b}).call(this); 51 | (function(){function b(a,b,d){this.strategy=a;this.transports=b;this.ttl=d.ttl||18E5;this.encrypted=d.encrypted;this.timeline=d.timeline}function c(a){return"pusherTransport"+(a?"Encrypted":"Unencrypted")}function a(a){var b=Pusher.Util.getLocalStorage();if(b)try{var h=b[c(a)];if(h)return JSON.parse(h)}catch(k){d(a)}return null}function d(a){var b=Pusher.Util.getLocalStorage();if(b)try{delete b[c(a)]}catch(d){}}var h=b.prototype;h.isSupported=function(){return this.strategy.isSupported()};h.connect= 52 | function(b,h){var g=this.encrypted,k=a(g),l=[this.strategy];if(k&&k.timestamp+this.ttl>=Pusher.Util.now()){var m=this.transports[k.transport];m&&(this.timeline.info({cached:!0,transport:k.transport,latency:k.latency}),l.push(new Pusher.SequentialStrategy([m],{timeout:2*k.latency+1E3,failFast:!0})))}var p=Pusher.Util.now(),n=l.pop().connect(b,function s(a,k){if(a)d(g),0b.code?1002<=b.code&&1004>=b.code?"backoff":null:4E3===b.code?"ssl_only":4100>b.code?"refused":4200>b.code?"backoff":4300>b.code?"retry":"refused"},getCloseError:function(b){return 1E3!==b.code&&1001!==b.code?{type:"PusherError",data:{code:b.code,message:b.reason||b.message}}: 88 | null}}}).call(this); 89 | (function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.id=a;this.transport=b;this.activityTimeout=b.activityTimeout;this.bindListeners()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.handlesActivityChecks=function(){return this.transport.handlesActivityChecks()};c.send=function(a){return this.transport.send(a)};c.send_event=function(a,b,c){a={event:a,data:b};c&&(a.channel=c);Pusher.debug("Event sent",a);return this.send(Pusher.Protocol.encodeMessage(a))};c.ping= 90 | function(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})};c.close=function(){this.transport.close()};c.bindListeners=function(){var a=this,b={message:function(b){var c;try{c=Pusher.Protocol.decodeMessage(b)}catch(d){a.emit("error",{type:"MessageParseError",error:d,data:b.data})}if(void 0!==c){Pusher.debug("Event recd",c);switch(c.event){case "pusher:error":a.emit("error",{type:"PusherError",data:c.data});break;case "pusher:ping":a.emit("ping");break;case "pusher:pong":a.emit("pong")}a.emit("message", 91 | c)}},activity:function(){a.emit("activity")},error:function(b){a.emit("error",{type:"WebSocketError",error:b})},closed:function(b){c();b&&b.code&&a.handleCloseEvent(b);a.transport=null;a.emit("closed")}},c=function(){Pusher.Util.objectApply(b,function(b,c){a.transport.unbind(c,b)})};Pusher.Util.objectApply(b,function(b,c){a.transport.bind(c,b)})};c.handleCloseEvent=function(a){var b=Pusher.Protocol.getCloseAction(a);(a=Pusher.Protocol.getCloseError(a))&&this.emit("error",a);b&&this.emit(b)};Pusher.Connection= 92 | b}).call(this); 93 | (function(){function b(a,b){this.transport=a;this.callback=b;this.bindListeners()}var c=b.prototype;c.close=function(){this.unbindListeners();this.transport.close()};c.bindListeners=function(){var a=this;a.onMessage=function(b){a.unbindListeners();try{var c=Pusher.Protocol.processHandshake(b);"connected"===c.action?a.finish("connected",{connection:new Pusher.Connection(c.id,a.transport),activityTimeout:c.activityTimeout}):(a.finish(c.action,{error:c.error}),a.transport.close())}catch(f){a.finish("error",{error:f}), 94 | a.transport.close()}};a.onClosed=function(b){a.unbindListeners();var c=Pusher.Protocol.getCloseAction(b)||"backoff";b=Pusher.Protocol.getCloseError(b);a.finish(c,{error:b})};a.transport.bind("message",a.onMessage);a.transport.bind("closed",a.onClosed)};c.unbindListeners=function(){this.transport.unbind("message",this.onMessage);this.transport.unbind("closed",this.onClosed)};c.finish=function(a,b){this.callback(Pusher.Util.extend({transport:this.transport,action:a},b))};Pusher.Handshake=b}).call(this); 95 | (function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.key=a;this.options=b||{};this.state="initialized";this.connection=null;this.encrypted=!!b.encrypted;this.timeline=this.options.timeline;this.connectionCallbacks=this.buildConnectionCallbacks();this.errorCallbacks=this.buildErrorCallbacks();this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var c=this;Pusher.Network.bind("online",function(){c.timeline.info({netinfo:"online"});("connecting"===c.state||"unavailable"=== 96 | c.state)&&c.retryIn(0)});Pusher.Network.bind("offline",function(){c.timeline.info({netinfo:"offline"});c.connection&&c.sendActivityCheck()});this.updateStrategy()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.connect=function(){!this.connection&&!this.runner&&(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))};c.send=function(a){return this.connection?this.connection.send(a):!1}; 97 | c.send_event=function(a,b,c){return this.connection?this.connection.send_event(a,b,c):!1};c.disconnect=function(){this.disconnectInternally();this.updateState("disconnected")};c.isEncrypted=function(){return this.encrypted};c.startConnecting=function(){var a=this,b=function(c,f){c?a.runner=a.strategy.connect(0,b):"error"===f.action?(a.emit("error",{type:"HandshakeError",error:f.error}),a.timeline.error({handshakeError:f.error})):(a.abortConnecting(),a.handshakeCallbacks[f.action](f))};a.runner=a.strategy.connect(0, 98 | b)};c.abortConnecting=function(){this.runner&&(this.runner.abort(),this.runner=null)};c.disconnectInternally=function(){this.abortConnecting();this.clearRetryTimer();this.clearUnavailableTimer();this.connection&&this.abandonConnection().close()};c.updateStrategy=function(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,encrypted:this.encrypted})};c.retryIn=function(a){var b=this;b.timeline.info({action:"retry",delay:a});0 "+a),this.timeline.info({state:a,params:b}),this.emit("state_change",{previous:c,current:a}),this.emit(a,b))};c.shouldRetry=function(){return"connecting"=== 104 | this.state||"connected"===this.state};Pusher.ConnectionManager=b}).call(this); 105 | (function(){function b(){Pusher.EventsDispatcher.call(this);var b=this;void 0!==window.addEventListener&&(window.addEventListener("online",function(){b.emit("online")},!1),window.addEventListener("offline",function(){b.emit("offline")},!1))}Pusher.Util.extend(b.prototype,Pusher.EventsDispatcher.prototype);b.prototype.isOnline=function(){return void 0===window.navigator.onLine?!0:window.navigator.onLine};Pusher.NetInfo=b;Pusher.Network=new b}).call(this); 106 | (function(){function b(){this.reset()}var c=b.prototype;c.get=function(a){return Object.prototype.hasOwnProperty.call(this.members,a)?{id:a,info:this.members[a]}:null};c.each=function(a){var b=this;Pusher.Util.objectApply(b.members,function(c,f){a(b.get(f))})};c.setMyID=function(a){this.myID=a};c.onSubscription=function(a){this.members=a.presence.hash;this.count=a.presence.count;this.me=this.get(this.myID)};c.addMember=function(a){null===this.get(a.user_id)&&this.count++;this.members[a.user_id]=a.user_info; 107 | return this.get(a.user_id)};c.removeMember=function(a){var b=this.get(a.user_id);b&&(delete this.members[a.user_id],this.count--);return b};c.reset=function(){this.members={};this.count=0;this.me=this.myID=null};Pusher.Members=b}).call(this); 108 | (function(){function b(a,b){Pusher.EventsDispatcher.call(this,function(b,c){Pusher.debug("No callbacks on "+a+" for "+b)});this.name=a;this.pusher=b;this.subscribed=!1}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.authorize=function(a,b){return b(!1,{})};c.trigger=function(a,b){if(0!==a.indexOf("client-"))throw new Pusher.Errors.BadEventName("Event '"+a+"' does not start with 'client-'");return this.pusher.send_event(a,b,this.name)};c.disconnect=function(){this.subscribed= 109 | !1};c.handleEvent=function(a,b){0===a.indexOf("pusher_internal:")?"pusher_internal:subscription_succeeded"===a&&(this.subscribed=!0,this.emit("pusher:subscription_succeeded",b)):this.emit(a,b)};c.subscribe=function(){var a=this;a.authorize(a.pusher.connection.socket_id,function(b,c){b?a.handleEvent("pusher:subscription_error",c):a.pusher.send_event("pusher:subscribe",{auth:c.auth,channel_data:c.channel_data,channel:a.name})})};c.unsubscribe=function(){this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}; 110 | Pusher.Channel=b}).call(this);(function(){function b(a,b){Pusher.Channel.call(this,a,b)}var c=b.prototype;Pusher.Util.extend(c,Pusher.Channel.prototype);c.authorize=function(a,b){return(new Pusher.Channel.Authorizer(this,this.pusher.config)).authorize(a,b)};Pusher.PrivateChannel=b}).call(this); 111 | (function(){function b(a,b){Pusher.PrivateChannel.call(this,a,b);this.members=new Pusher.Members}var c=b.prototype;Pusher.Util.extend(c,Pusher.PrivateChannel.prototype);c.authorize=function(a,b){var c=this;Pusher.PrivateChannel.prototype.authorize.call(c,a,function(a,e){if(!a){if(void 0===e.channel_data){Pusher.warn("Invalid auth response for channel '"+c.name+"', expected 'channel_data' field");b("Invalid auth response");return}var g=JSON.parse(e.channel_data);c.members.setMyID(g.user_id)}b(a,e)})}; 112 | c.handleEvent=function(a,b){switch(a){case "pusher_internal:subscription_succeeded":this.members.onSubscription(b);this.subscribed=!0;this.emit("pusher:subscription_succeeded",this.members);break;case "pusher_internal:member_added":var c=this.members.addMember(b);this.emit("pusher:member_added",c);break;case "pusher_internal:member_removed":(c=this.members.removeMember(b))&&this.emit("pusher:member_removed",c);break;default:Pusher.PrivateChannel.prototype.handleEvent.call(this,a,b)}};c.disconnect= 113 | function(){this.members.reset();Pusher.PrivateChannel.prototype.disconnect.call(this)};Pusher.PresenceChannel=b}).call(this); 114 | (function(){function b(){this.channels={}}var c=b.prototype;c.add=function(a,b){if(!this.channels[a]){var c=this.channels,f;f=0===a.indexOf("private-")?new Pusher.PrivateChannel(a,b):0===a.indexOf("presence-")?new Pusher.PresenceChannel(a,b):new Pusher.Channel(a,b);c[a]=f}return this.channels[a]};c.all=function(a){return Pusher.Util.values(this.channels)};c.find=function(a){return this.channels[a]};c.remove=function(a){var b=this.channels[a];delete this.channels[a];return b};c.disconnect=function(){Pusher.Util.objectApply(this.channels, 115 | function(a){a.disconnect()})};Pusher.Channels=b}).call(this); 116 | (function(){Pusher.Channel.Authorizer=function(b,a){this.channel=b;this.type=a.authTransport;this.options=a;this.authOptions=(a||{}).auth||{}};Pusher.Channel.Authorizer.prototype={composeQuery:function(b){b="socket_id="+encodeURIComponent(b)+"&channel_name="+encodeURIComponent(this.channel.name);for(var a in this.authOptions.params)b+="&"+encodeURIComponent(a)+"="+encodeURIComponent(this.authOptions.params[a]);return b},authorize:function(b,a){return Pusher.authorizers[this.type].call(this,b,a)}}; 117 | var b=1;Pusher.auth_callbacks={};Pusher.authorizers={ajax:function(b,a){var d;d=Pusher.XHR?new Pusher.XHR:window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");d.open("POST",this.options.authEndpoint,!0);d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var h in this.authOptions.headers)d.setRequestHeader(h,this.authOptions.headers[h]);d.onreadystatechange=function(){if(4===d.readyState)if(200===d.status){var b,c=!1;try{b=JSON.parse(d.responseText), 118 | c=!0}catch(g){a(!0,"JSON returned from webapp was invalid, yet status code was 200. Data was: "+d.responseText)}c&&a(!1,b)}else Pusher.warn("Couldn't get auth info from your webapp",d.status),a(!0,d.status)};d.send(this.composeQuery(b));return d},jsonp:function(c,a){void 0!==this.authOptions.headers&&Pusher.warn("Warn","To send headers with the auth request, you must use AJAX, rather than JSONP.");var d=b.toString();b++;var h=Pusher.Util.getDocument(),f=h.createElement("script");Pusher.auth_callbacks[d]= 119 | function(b){a(!1,b)};f.src=this.options.authEndpoint+"?callback="+encodeURIComponent("Pusher.auth_callbacks['"+d+"']")+"&"+this.composeQuery(c);d=h.getElementsByTagName("head")[0]||h.documentElement;d.insertBefore(f,d.firstChild)}}}).call(this); -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | *= require ./framework_and_overrides.css.scss 14 | *= require bootstrap-material-design 15 | *= require_self 16 | */ 17 | 18 | a.qr-code { 19 | 20 | font-size: 11px; 21 | } 22 | 23 | table.qr-code { 24 | border-width: 0; 25 | border-style: none; 26 | border-color: #0000ff; 27 | border-collapse: collapse; 28 | margin: 20px; 29 | width: auto; 30 | border: none; 31 | border-radius: none; 32 | -webkit-border-radius: none; 33 | } 34 | 35 | table.qr-code td { 36 | border-width: 0; 37 | border-style: none; 38 | border-color: #0000ff; 39 | border-collapse: collapse; 40 | padding: 0; 41 | margin: 0; 42 | width: 10px; 43 | height: 10px; 44 | border-radius: none; 45 | -webkit-border-radius: none; 46 | } 47 | 48 | table.qr-code td.black { 49 | background-color: #000; 50 | } 51 | 52 | table.qr-code td.white { 53 | background-color: #fff; 54 | } 55 | -------------------------------------------------------------------------------- /app/assets/stylesheets/framework_and_overrides.css.scss: -------------------------------------------------------------------------------- 1 | // import the CSS framework 2 | @import "bootstrap-sprockets"; 3 | @import "bootstrap"; 4 | 5 | // apply styles to HTML elements 6 | // to make views framework-neutral 7 | main { 8 | @extend .container; 9 | padding-bottom: 80px; 10 | width: 100%; 11 | margin-top: 75px; // accommodate the navbar 12 | } 13 | section { 14 | @extend .row; 15 | margin-top: 20px; 16 | } 17 | 18 | // Styles for form views 19 | // using Bootstrap 20 | // generated by the rails_layout gem 21 | .authform { 22 | padding-top: 30px; 23 | max-width: 320px; 24 | margin: 0 auto; 25 | } 26 | .authform form { 27 | padding-bottom: 40px; 28 | } 29 | .authform .right { 30 | float: right !important; 31 | } 32 | .authform .button { 33 | @extend .btn; 34 | @extend .btn-primary; 35 | } 36 | #error_explanation h2 { 37 | font-size: 16px; 38 | } 39 | .button-xs { 40 | @extend .btn; 41 | @extend .btn-primary; 42 | @extend .btn-xs; 43 | } 44 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | before_action :are_we_configured, :except => [:configure] 6 | 7 | protected 8 | 9 | def are_we_configured 10 | if Figaro.env.master_public_keys == nil 11 | redirect_to configuration_path 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/controllers/bets_controller.rb: -------------------------------------------------------------------------------- 1 | class BetsController < ApplicationController 2 | 3 | skip_before_action :authenticate_user_from_token!, only: :show 4 | 5 | def show 6 | @bet = Bet.find(params[:id]) 7 | 8 | render layout: false 9 | end 10 | 11 | def create 12 | bet = current_user.bets.build(bet_attributes) 13 | bet.secret = Secret.last || Secret.create 14 | bet.server_seed = session[:server_seed] 15 | 16 | if bet.amount < 0 17 | bet.amount = 0 18 | end 19 | 20 | # Set limit to 1 BTC (100,000,000 satoshis). 21 | # Set limit to 0.2 BTC 22 | limit = 20000000 23 | if ENV['limit'] != nil 24 | limit = ENV['limit'].to_i 25 | end 26 | 27 | # We need to put a thread lock around this to stop timing attacks. 28 | if bet.amount <= current_user.balance and bet.amount < limit 29 | 30 | bet.save 31 | 32 | if ENV['PUSHER_URL'] != nil or ENV['pusher_url'] != nil 33 | Pusher['test_channel'].trigger('my_event', bet.as_json) 34 | end 35 | end 36 | 37 | respond_to do |format| 38 | format.html { redirect_to root_url } 39 | format.json { render json: bet.to_json } 40 | end 41 | end 42 | 43 | protected 44 | 45 | def bet_attributes 46 | params.require(:bet).permit(:client_seed, :amount, :game, :rolltype) 47 | end 48 | 49 | end -------------------------------------------------------------------------------- /app/controllers/cashouts_controller.rb: -------------------------------------------------------------------------------- 1 | class CashoutsController < ApplicationController 2 | 3 | before_action :authenticate_user_from_token!, only: :show 4 | 5 | def create 6 | 7 | 8 | cashout = current_user.cashouts.build(cashout_attributes) 9 | 10 | # We deal in statoshis. 11 | cashout.amount = current_user.balance - ((cashout.amount * 100000000).to_i) 12 | # Take off miners fee. 13 | cashout.amount = cashout.amount - 10000 14 | 15 | if cashout.amount > 0 and Bitcoin::valid_address?(cashout.address) 16 | 17 | cashout.save 18 | 19 | bal = Balance.new 20 | bal.user_id = current_user.id 21 | bal.transaction_hash = "Cashout to " + cashout.address 22 | bal.amount = 0 - cashout.amount 23 | bal.save 24 | 25 | end 26 | 27 | respond_to do |format| 28 | format.html { redirect_to root_url } 29 | format.json { render json: co.to_json } 30 | end 31 | end 32 | 33 | protected 34 | 35 | def cashout_attributes 36 | params.require(:cashout).permit(:address, :amount) 37 | end 38 | end -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/visitors_controller.rb: -------------------------------------------------------------------------------- 1 | class VisitorsController < ApplicationController 2 | 3 | def index 4 | session[:server_seed] = SecureRandom.hex(12) 5 | 6 | respond_to do |format| 7 | format.html do 8 | @bet = Bet.new.tap do |b| 9 | b.server_seed = session[:server_seed] 10 | b.amount = 0 11 | b.game = 49.5 12 | end 13 | 14 | @cashout = Cashout.new 15 | 16 | @transactions = [] 17 | 18 | @bets = Bet.latest_bets 19 | @data_slider_range = "0,0" 20 | 21 | if current_user 22 | 23 | setup_transactions 24 | 25 | make_sure_user_address_is_set 26 | 27 | last_bet = current_user.bets.last 28 | if last_bet != nil and last_bet.amount < current_user.balance 29 | @bet.amount = last_bet.amount 30 | @bet.game = last_bet.game 31 | end 32 | 33 | @data_slider_range = "0," + current_user.balance.to_s 34 | 35 | @qr = RQRCode::QRCode.new(current_user.bitcoin_address) 36 | end 37 | end 38 | format.json do 39 | attrs = { server_seed: session[:server_seed] } 40 | attrs.merge!(auth_token: current_user.auth_token) if current_user 41 | 42 | render json: attrs 43 | end 44 | end 45 | end 46 | 47 | def bet_table 48 | 49 | respond_to do |format| 50 | format.html do 51 | @bets = Bet.latest_bets 52 | render :layout => false 53 | end 54 | end 55 | end 56 | 57 | def make_sure_user_address_is_set 58 | if current_user.bitcoin_address == nil 59 | keys = ColdStorage.get_extended_keys 60 | current_user.bitcoin_address = OnChain::Sweeper.multi_sig_address_from_mpks( 61 | keys.length, keys, "m/#{current_user.id}") 62 | current_user.save 63 | end 64 | end 65 | 66 | def setup_transactions 67 | 68 | balances = current_user.balances.all 69 | 70 | @transactions = [] 71 | 72 | balances.each do |balance| 73 | if ! balance.transaction_hash.start_with? "Bet" 74 | if ! balance.transaction_hash.start_with? "Cashout" 75 | tx = {} 76 | tx[:amount] = balance.amount / 100000000.0 77 | tx[:address] = "Deposit" 78 | tx[:status] = "Processed" 79 | tx[:date] = balance.created_at 80 | @transactions << tx 81 | else 82 | tx = {} 83 | tx[:amount] = balance.amount / 100000000.0 84 | tx[:address] = balance.transaction_hash 85 | tx[:status] = "Awaiting Signoff" 86 | tx[:date] = balance.created_at 87 | @transactions << tx 88 | end 89 | end 90 | end 91 | end 92 | 93 | # We get here if our ENV vars are not set. 94 | def configure 95 | end 96 | 97 | end 98 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/app/models/.keep -------------------------------------------------------------------------------- /app/models/balance.rb: -------------------------------------------------------------------------------- 1 | class Balance < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/models/bet.rb: -------------------------------------------------------------------------------- 1 | class Bet < ActiveRecord::Base 2 | include ActionView::Helpers::DateHelper 3 | 4 | belongs_to :user 5 | belongs_to :secret 6 | 7 | before_create :calculate_roll 8 | after_create :update_balance 9 | 10 | def as_json(options = {}) 11 | { 12 | id: id, 13 | username: user.try(:name) || 'Guest', 14 | amount: amount_formatted, 15 | multiplier: multiplier.round(2), 16 | game: game, 17 | rolltype: rolltype == 'under' ? '<' : '>', 18 | roll: roll.round(2), 19 | profit: profit_formatted, 20 | win_or_lose: win? ? 'win' : 'lose', 21 | created_at: time_ago_in_words(created_at) + ' ago', 22 | } 23 | end 24 | 25 | def multiplier 26 | return (99 / game) 27 | end 28 | 29 | def profit 30 | if win? 31 | return ((amount.to_d * (multiplier).to_d) - amount.to_d).to_i 32 | else 33 | return -amount 34 | end 35 | end 36 | 37 | def win? 38 | if rolltype == 'under' 39 | roll < game 40 | else 41 | roll > game 42 | end 43 | end 44 | 45 | def self.latest_bets 46 | bets = Bet.order('created_at DESC').limit(25) 47 | end 48 | 49 | def profit_formatted 50 | return format_btc(profit) 51 | end 52 | 53 | def amount_formatted 54 | return format_btc(amount) 55 | end 56 | 57 | def format_btc(amount) 58 | if amount < 10000 59 | return "%.8f" % (amount / 100000000.0) 60 | end 61 | return amount / 100000000.0 62 | end 63 | 64 | protected 65 | 66 | def calculate_roll 67 | 68 | # Combine all the secrets. 69 | str = [secret.secret, server_seed, client_seed].join 70 | 71 | # Generate a hexadecimal hash. 72 | hash = Digest::SHA512.hexdigest(str) 73 | 74 | # Generate a number between 0 and 9999 inclusive. 75 | one_and_ten_thousand = hash.hex % 10000 76 | 77 | # Conver it to a 2 decimal point number between 0 and 99.99 78 | self.roll = one_and_ten_thousand / 100.0 79 | end 80 | 81 | def update_balance 82 | return if user.nil? 83 | 84 | b = user.balances.new 85 | b.transaction_hash = "Bet #{id}" 86 | 87 | if win? 88 | b.amount = profit 89 | else 90 | b.amount = (- amount) 91 | end 92 | 93 | if b.amount != 0 94 | b.save 95 | end 96 | end 97 | 98 | def make_payment 99 | return if user.nil? 100 | 101 | if win? 102 | Cashout.perform(ENV['PKEY'], user.address, profit.in_satoshi) 103 | else 104 | Cashout.perform(user.pkey ENV['FEE_ADDRESS'], amount.in_satoshi) 105 | end 106 | end 107 | 108 | end 109 | -------------------------------------------------------------------------------- /app/models/cashout.rb: -------------------------------------------------------------------------------- 1 | class Cashout < ActiveRecord::Base 2 | 3 | def self.create_onchain_payment_request 4 | 5 | # Collect all the payouts inyo an array of address,amount 6 | cashouts = Cashout.where('status is null') 7 | payees = cashouts.map { |c| [c.address, c.amount] } 8 | 9 | 10 | # No one to pay out to ? 11 | if payees.count == 0 12 | return 13 | end 14 | 15 | total = Cashout.all.inject(0){|sum,c| sum += c.amount } 16 | 17 | puts "Paying out " + total.to_s 18 | 19 | # Get the redmption script for our fund 20 | rs = ColdStorage.redemption_script 21 | 22 | # Create a transaction for the lucky winners :) 23 | # or unlucky for us. :( 24 | tx = OnChain::Payments.create_payment_tx(rs, payees) 25 | 26 | # Did we get an error back ? 27 | if tx.is_a? String 28 | puts tx 29 | else 30 | # Update the cashout status 31 | cashouts.each do |cashout| 32 | cashout.status = true 33 | cashout.save 34 | end 35 | 36 | # Forward the TX to onchain for signing. 37 | tx_hex = OnChain.bin_to_hex(tx.to_payload) 38 | OnChain::Sweeper.post_tx_for_signing(tx_hex, [], ColdStorage.get_fund_address) 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /app/models/cold_storage.rb: -------------------------------------------------------------------------------- 1 | class ColdStorage < ActiveRecord::Base 2 | 3 | self.table_name = 'cold_storage' 4 | def self.get_addresses 5 | mpks = Figaro.env.master_public_keys.split(",") 6 | 7 | addresses = [] 8 | mpks.each do |mpk| 9 | master = MoneyTree::Node.from_serialized_address(mpk) 10 | addresses << master.public_key.to_hex 11 | end 12 | return addresses 13 | end 14 | 15 | def self.get_fund_address 16 | return OnChain::Sweeper.generate_address_of_redemption_script(redemption_script) 17 | end 18 | 19 | def self.get_extended_keys 20 | return Figaro.env.master_public_keys.split(",") 21 | end 22 | 23 | def self.redemption_script 24 | addresses = get_addresses 25 | return OnChain::Sweeper.generate_redemption_script(addresses.length, addresses) 26 | end 27 | end -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/secret.rb: -------------------------------------------------------------------------------- 1 | class Secret < ActiveRecord::Base 2 | 3 | belongs_to :bet 4 | 5 | before_create :generate_secret 6 | 7 | def to_s 8 | created_at < 24.hours.ago ? secret : '************************************' 9 | end 10 | 11 | protected 12 | 13 | def generate_secret 14 | self.secret = SecureRandom.hex(64) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/models/transaction.rb: -------------------------------------------------------------------------------- 1 | class Transaction < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | 3 | # Include default devise modules. Others available are: 4 | # :confirmable, :lockable, :timeoutable and :omniauthable 5 | devise :database_authenticatable, :registerable, 6 | :recoverable, :rememberable, :trackable, :validatable 7 | 8 | has_many :bets 9 | has_many :transactions 10 | has_many :cashouts 11 | has_many :balances 12 | 13 | def balance 14 | bal = 0 15 | balances.each{ |balance| bal = bal + balance.amount } 16 | return bal 17 | end 18 | 19 | def balance_as_btc 20 | (balance / 100000000.0) 21 | end 22 | 23 | def self.get_cold_storage 24 | cs = ColdStorage.first 25 | if cs == nil 26 | cs = ColdStorage.create 27 | cs.save 28 | end 29 | return cs 30 | end 31 | 32 | def self.sweep_for_incoming_coins 33 | 34 | block = get_cold_storage.block 35 | if block == nil 36 | block = 0 37 | end 38 | count = User.count 39 | keys = ColdStorage.get_extended_keys 40 | 41 | puts "Sweeping #{count} users starting from block #{block}" 42 | incoming, block_end = OnChain::Sweeper.sweep(keys.count, keys, 'm/#{index}', count, block) 43 | 44 | ActiveRecord::Base.transaction do 45 | incoming.each do |coins| 46 | u = User.find_by_bitcoin_address(coins[0]) 47 | 48 | bal = u.balances.new 49 | bal.transaction_hash = coins[3] 50 | bal.amount = coins[2].to_i 51 | bal.save 52 | end 53 | cs = ColdStorage.first 54 | cs.block = block_end 55 | cs.save 56 | end 57 | end 58 | 59 | def self.sweep_bitcoins_to_onchain_fund 60 | 61 | block = get_cold_storage.sweep_block 62 | if block == nil 63 | block = 0 64 | end 65 | count = User.count 66 | keys = ColdStorage.get_extended_keys 67 | 68 | puts "Sweeping #{count} users starting from block #{block}" 69 | incoming, block_end = OnChain::Sweeper.sweep(keys.length, keys, 'm/#{index}', count, block) 70 | 71 | cs = ColdStorage.first 72 | cs.sweep_block = block_end 73 | cs.save 74 | 75 | tx, paths = OnChain::Sweeper.create_payment_tx_from_sweep(keys.length, incoming, ColdStorage.get_fund_address, keys) 76 | 77 | puts ENV['ONCHAIN_EMAIL'] 78 | 79 | if tx != 'Not enough coins to create a transaction.' 80 | 81 | OnChain::Sweeper.post_tx_for_signing(tx, paths, ColdStorage.get_fund_address) 82 | 83 | return true 84 | end 85 | return false 86 | end 87 | end 88 | -------------------------------------------------------------------------------- /app/services/create_admin_service.rb: -------------------------------------------------------------------------------- 1 | class CreateAdminService 2 | def call 3 | user = User.find_or_create_by!(email: Rails.application.secrets.admin_email) do |user| 4 | user.password = Rails.application.secrets.admin_password 5 | user.password_confirmation = Rails.application.secrets.admin_password 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /app/views/bets/show.html.haml: -------------------------------------------------------------------------------- 1 | 2 | %dl 3 | %dt Bet Id 4 | %dd 5 | %input.form-control{:type => "text", :value => @bet.id.to_s, :readonly => "true"} 6 | %dt Server Seed 7 | %dd 8 | %input.form-control{:type => "text", :value => @bet.server_seed, :readonly => "true"} 9 | %dt Client Seed 10 | %dd 11 | %input.form-control{:type => "text", :value => @bet.client_seed, :readonly => "true"} 12 | %dt Secret Seed (Revealed after 24 hours.) 13 | %dd 14 | %textarea.form-control{:type => "text", :readonly => "true"} 15 | = @bet.secret.to_s 16 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> 3 |

Change your password

4 | <%= devise_error_messages! %> 5 | <%= f.hidden_field :reset_password_token %> 6 |
7 | <%= f.label :password, 'New password' %> 8 | <%= f.password_field :password, autofocus: true, autocomplete: 'off', class: 'form-control' %> 9 | <%= f.label :password_confirmation, 'Confirm new password' %> 10 | <%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %> 11 |
12 | <%= f.submit 'Change my Password', :class => 'button right' %> 13 | <% end %> 14 |
15 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :role => 'form'}) do |f| %> 3 |

Forgot your password?

4 |

We'll send password reset instructions.

5 | <%= devise_error_messages! %> 6 |
7 | <%= f.label :email %> 8 | <%= f.email_field :email, :autofocus => true, class: 'form-control' %> 9 |
10 | <%= f.submit 'Reset Password', :class => 'button right' %> 11 | <% end %> 12 |
13 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Edit <%= resource_name.to_s.humanize %>

3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :role => 'form'}) do |f| %> 4 | <%= devise_error_messages! %> 5 |
6 | <%= f.label :name %> 7 | <%= f.text_field :name, :autofocus => true, class: 'form-control' %> 8 |
9 |
10 | <%= f.label :email %> 11 | <%= f.email_field :email, class: 'form-control' %> 12 | <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> 13 |
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
14 | <% end %> 15 |
16 |
17 |

Leave these fields blank if you don't want to change your password.

18 |
19 | <%= f.label :password %> 20 | <%= f.password_field :password, :autocomplete => 'off', class: 'form-control' %> 21 |
22 |
23 | <%= f.label :password_confirmation %> 24 | <%= f.password_field :password_confirmation, class: 'form-control' %> 25 |
26 |
27 |
28 |

You must enter your current password to make changes.

29 |
30 | <%= f.label :current_password %> 31 | <%= f.password_field :current_password, class: 'form-control' %> 32 |
33 |
34 | <%= f.submit 'Update', :class => 'button right' %> 35 | <% end %> 36 |
37 |
38 |

Cancel Account

39 |

Unhappy? We'll be sad to see you go.

40 | <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'button right' %> 41 |
42 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :role => 'form'}) do |f| %> 3 |

Sign up

4 | <%= devise_error_messages! %> 5 |
6 | <%= f.label :name %> 7 | <%= f.text_field :name, :autofocus => true, class: 'form-control' %> 8 |
9 |
10 | <%= f.label :email %> 11 | <%= f.email_field :email, class: 'form-control' %> 12 |
13 |
14 | <%= f.label :password %> 15 | <%= f.password_field :password, class: 'form-control' %> 16 |
17 |
18 | <%= f.label :password_confirmation %> 19 | <%= f.password_field :password_confirmation, class: 'form-control' %> 20 |
21 | <%= f.submit 'Sign up', :class => 'button right' %> 22 | <% end %> 23 |
24 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :role => 'form'}) do |f| %> 3 |

Sign in

4 | <%= devise_error_messages! %> 5 |
6 | <%- if devise_mapping.registerable? %> 7 | <%= link_to 'Sign up', new_registration_path(resource_name), class: 'right' %> 8 | <% end -%> 9 | <%= f.label :email %> 10 | <%= f.email_field :email, :autofocus => true, class: 'form-control' %> 11 |
12 |
13 | <%- if devise_mapping.recoverable? %> 14 | <%= link_to "Forgot password?", new_password_path(resource_name), class: 'right' %> 15 | <% end -%> 16 | <%= f.label :password %> 17 | <%= f.password_field :password, class: 'form-control' %> 18 |
19 | <%= f.submit 'Sign in', :class => 'button right' %> 20 | <% if devise_mapping.rememberable? -%> 21 |
22 | 25 |
26 | <% end -%> 27 | <% end %> 28 |
29 | -------------------------------------------------------------------------------- /app/views/layouts/_messages.html.haml: -------------------------------------------------------------------------------- 1 | -# Rails flash messages styled for Bootstrap 3.0 2 | - flash.each do |name, msg| 3 | - if msg.is_a?(String) 4 | %input.snackbar{ type: 'hidden', value: msg } 5 | 6 | :javascript 7 | $( document ).ready(function() { 8 | $('.snackbar').each(function(i, obj) { 9 | $.snackbar({content: $(this).val(), timeout: 3000}); 10 | }); 11 | }); -------------------------------------------------------------------------------- /app/views/layouts/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | -# navigation styled for Bootstrap 3.0 2 | %nav.navbar.navbar-default.navbar-fixed-top 3 | .container 4 | .navbar-header 5 | %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"} 6 | %span.sr-only Toggle navigation 7 | %span.icon-bar 8 | %span.icon-bar 9 | %span.icon-bar 10 | %a{ href: root_path, class: 'navbar-brand' } 11 | %i.mdi-action-swap-vert-circle 12 | Bitsino Dice 13 | .collapse.navbar-collapse 14 | %ul.nav.navbar-nav 15 | = render 'layouts/navigation_links' 16 | -------------------------------------------------------------------------------- /app/views/layouts/_navigation_links.html.erb: -------------------------------------------------------------------------------- 1 | <%# add navigation links to this file %> 2 | <% if user_signed_in? %> 3 |
  • <%= link_to 'Edit account', edit_user_registration_path %>
  • 4 |
  • <%= link_to 'Sign out', destroy_user_session_path, :method=>'delete' %>
  • 5 | <% else %> 6 |
  • <%= link_to 'Sign in', new_user_session_path %>
  • 7 |
  • <%= link_to 'Sign up', new_user_registration_path %>
  • 8 | <% end %> 9 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"} 5 | %title= content_for?(:title) ? yield(:title) : 'Bitsino Dice - Provably fair Bitcoin dice game.' 6 | %meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Bitcoinary'}"} 7 | = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 8 | = javascript_include_tag 'application', 'data-turbolinks-track' => true 9 | = csrf_meta_tags 10 | = favicon_link_tag 'favicon.ico' 11 | %body 12 | %header 13 | = render 'layouts/navigation' 14 | %main{:role => "main"} 15 | = render 'layouts/messages' 16 | = yield 17 | 18 | -if Figaro.env.ga != nil 19 | %script 20 | = raw 'var GA = "' + Figaro.env.ga + '"' 21 | :javascript 22 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 23 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 24 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 25 | })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 26 | 27 | ga('create', GA, 'auto'); 28 | ga('send', 'pageview'); 29 | -------------------------------------------------------------------------------- /app/views/visitors/_bets_table_rows.html.haml: -------------------------------------------------------------------------------- 1 | - @bets.each do |bet| 2 | - begin 3 | %tr 4 | %td.text-primary 5 | = link_to bet.id.to_s, bet_url(bet), { onclick: 'showVerification("' + bet.id.to_s + '"); return false' } 6 | %td 7 | = bet.user.name 8 | %td 9 | = time_ago_in_words(bet.created_at) 10 | ago. 11 | %td 12 | = bet.amount_formatted 13 | %td 14 | = bet.multiplier.round(2) 15 | %td 16 | - if bet.rolltype == 'under' 17 | < 18 | - else 19 | > 20 | = bet.game 21 | %td 22 | = bet.roll 23 | %td 24 | - if bet.win? or bet.amount == 0 25 | %span.label.label-success 26 | = bet.profit_formatted 27 | - else 28 | %span.label.label-default 29 | = bet.profit_formatted 30 | - rescue => e 31 | - puts e -------------------------------------------------------------------------------- /app/views/visitors/_cashout_modal.html.haml: -------------------------------------------------------------------------------- 1 | #cashoutModal.modal.fade 2 | .modal-dialog 3 | .modal-content 4 | .modal-header 5 | %button.close{"data-dismiss" => "modal", :type => "button"} 6 | %span.aria-hidden 7 | × 8 | %span.sr-only 9 | Close 10 | %h4.modal-title Cashout 11 | %p Please note a fee of 0.0005 BTC will be taken from your balance. 12 | .modal-body 13 | = form_for(@cashout, html: { role: 'form', class: 'inline-form', id: 'cashoutForm' }) do |f| 14 | .row 15 | .col-md-12 16 | %label Address 17 | 18 | = f.text_field :address, class: 'form-control', id: 'address' 19 | .col-md-12 20 | %label Amount 21 | = f.text_field :amount, class: 'form-control', id: 'amount' 22 | .col-md-12 23 | %input.btn.btn-primary#cashout-button{:style => "margin-top: 10px", :type => "submit", :value => "Cashout"}/ -------------------------------------------------------------------------------- /app/views/visitors/_deposit_modal.html.haml: -------------------------------------------------------------------------------- 1 | #depositModal.modal.fade 2 | .modal-dialog 3 | .modal-content 4 | .modal-header 5 | %button.close{"data-dismiss" => "modal", :type => "button"} 6 | %span.aria-hidden 7 | × 8 | %span.sr-only 9 | Close 10 | %h4.modal-title Deposit 11 | .modal-body 12 | %p.center-block Please send funds to: 13 | %h3.center-block 14 | - if current_user != nil 15 | = current_user.bitcoin_address 16 | %table.qr-code 17 | - @qr.modules.each_index do |x| 18 | %tr 19 | - @qr.modules.each_index do |y| 20 | %td{:class => (@qr.dark?(x,y) ? 'black' : 'white')} -------------------------------------------------------------------------------- /app/views/visitors/_transaction_history_modal.html.haml: -------------------------------------------------------------------------------- 1 | #transactionModal.modal.fade 2 | .modal-dialog 3 | .modal-content 4 | .modal-header 5 | %button.close{"data-dismiss" => "modal", :type => "button"} 6 | %span.aria-hidden 7 | × 8 | %span.sr-only 9 | Close 10 | %h4.modal-title Transaction History 11 | .modal-body 12 | %table.table.table-striped 13 | %thead 14 | %tr 15 | %th Amount 16 | %th Type 17 | %th Status 18 | %th Date 19 | %tbody#transaction-history 20 | - @transactions.each do |tx| 21 | %tr 22 | %td 23 | = tx[:amount] 24 | %td 25 | = tx[:address] 26 | %td 27 | = tx[:status] 28 | %td 29 | = time_ago_in_words(tx[:date]) + ' ago.' -------------------------------------------------------------------------------- /app/views/visitors/_verification_modal.html.haml: -------------------------------------------------------------------------------- 1 | #verificationModal.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "myModalLabel", :role => "dialog", :tabindex => "-1"} 2 | .modal-dialog 3 | .modal-content 4 | .modal-header 5 | %button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} × 6 | %h4.modal-title Provably Fair 7 | .modal-body 8 | #verCont 9 | .modal-footer 10 | %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close 11 | 12 | :javascript 13 | function showVerification(id) { 14 | var url = '/bets/' + id; 15 | 16 | $( "#verCont" ).load( url ); 17 | $('#verificationModal').modal(); 18 | } -------------------------------------------------------------------------------- /app/views/visitors/bet_table.html.haml: -------------------------------------------------------------------------------- 1 | = render :partial => "bets_table_rows" -------------------------------------------------------------------------------- /app/views/visitors/configure.html.haml: -------------------------------------------------------------------------------- 1 | .container 2 | .row 3 | %h3 4 | Secure Cold Storage Installation 5 | %p 6 | To configure 7 | we need to connect to the ONCHAIN.IO cold storage service. ONCHAIN.IO provides multi signature 8 | funds to secure yours and your users money. 9 | %p 10 | Create or log into your account on ONCHAIN.IO and complete the following steps. 11 | %ol 12 | %li 13 | Go to the funds menu and create a new fund. 14 | %li 15 | Add up to 10 people to the fund. People in the fund will have the ability to sign transactions. 16 | %li 17 | Click the send invites button. 18 | %li 19 | Wait until all your invitees have accepted the invitations and added their public keys to the 20 | fund. 21 | %li 22 | You need to create an environment variable called 'master_public_keys' and set this to the value of each public key. Comma separated. 23 | 24 | %textarea.form-control 25 | master_public_keys=xpub69GZWTQPtwQRriHyYuYJpDgAUrHHRD8ksBbQ61QpY1CbSUrcW7udYcZ1YLuLVtSQx9xW5QApiGidDfmFVLEz4Lep3AoCGD2HQmfvXwH1GMt,xpub69GZWTQPtwQRriHyYuYJpDgAUrHHRD8ksBbQ61QpY1CbSUrcW7udYcZ1YLuLVtSQx9xW5QApiGidDfmFVLEz4Lep3AoCGD2HQmfvXwH1GMt 26 | 27 | -------------------------------------------------------------------------------- /app/views/visitors/index.html.haml: -------------------------------------------------------------------------------- 1 | .container 2 | .row{ :style => 'margin-bottom: 40px' } 3 | .col-md-12.text-center 4 | - if current_user == nil 5 | %h1 6 | Provably Fair Bitcoin Gambling 7 | %h2 8 | Register to try BitsinoDice out for free 9 | .row 10 | .col-md-3 11 | #userDetails 12 | %dl 13 | %dt Name 14 | %dd 15 | %input#username.form-control{:type => "text", :value => current_user.try(:name), :readonly => "true"} 16 | %dt User Id 17 | %dd 18 | %input#userid.form-control{:type => "text", :value => current_user.try(:id), :readonly => "true" } 19 | 20 | #seeds 21 | %dl 22 | %dt Server Seed 23 | %dd 24 | %input#server-seed.form-control{:readonly => "true", :type => "text", :value => session[:server_seed]} 25 | %dt Client Seed 26 | %dd 27 | %input#client-seed.form-control{:type => "text"}/ 28 | .col-md-6.well 29 | = form_for(@bet, html: { role: 'form', class: 'inline-form submit-once', id: 'betForm' }) do |f| 30 | .row 31 | .col-md-12 32 | %label Probability of winning 33 | %div#probability-slider.slider{ style: 'width: 100%' } 34 | %input#start-prob{ type: 'hidden', value: @bet.game } 35 | .row{ style: 'margin-top:20px' } 36 | .col-md-12 37 | %label Amount of Bet. 38 | %div#amount-slider.slider{ style: 'width: 100%' } 39 | %input#range{ type: 'hidden', value: @data_slider_range} 40 | = f.hidden_field :amount, id: 'amount-hidden' 41 | .row{ style: 'margin-top:20px' } 42 | .col-md-3 43 | .form-group 44 | %label Roll Under 45 | = f.text_field :game, class: 'form-control', readonly: true, value: '49.50', id: 'roll-prob' 46 | = f.hidden_field :rolltype 47 | = f.hidden_field :client_seed, id: 'client-seed-form' 48 | .col-md-3 49 | %label For a profit of 50 | %input#bet_profit.form-control{:readonly => "true", :type => "text", :value => "0"}/ 51 | .col-md-3 52 | %label With probability 53 | %input#bet_chance.form-control{:readonly => "true", :type => "text", :value => "49.50%"}/ 54 | .col-md-3 55 | %label Amount of Bet 56 | %input{ type: 'text', class: 'form-control input-small', readonly: "true", id: 'amount-view', placeholder: 'Amount', value: '0' } 57 | .form-group{:style => "margin-top: 10px"} 58 | - if current_user == nil 59 | = f.submit 'Roll Dice', class: 'btn btn-block btn-info disabled', id: 'roll-button' 60 | - else 61 | = f.submit 'Roll Dice', class: 'btn btn-block btn-info btn-raised', id: 'roll-button' 62 | .col-md-3.btc-options 63 | .row 64 | .col-md-12 65 | %label BTC Balance 66 | - if current_user != nil 67 | %input#balance.form-control{:type => "text", 68 | :value => number_to_human(current_user.balance_as_btc, precision: 8, strip_insignificant_zeros: true), 69 | :readonly => "true", "data-address" => "#{current_user.try(:address)}"} 70 | - else 71 | %input#balance.form-control{:type => "text", :value => '0', :readonly => "true"} 72 | .row{ style: 'margin-top:10px' } 73 | .col-md-12 74 | - if current_user == nil 75 | %button.btn.btn-primary.disabled.btn-block 76 | %i.mdi-action-account-balance-wallet 77 | Deposit 78 | - else 79 | %button.btn.btn-primary.btn-block{"data-target" => "#depositModal", "data-toggle" => "modal"} 80 | %i.mdi-action-account-balance-wallet 81 | Deposit 82 | .row{ style: 'margin-top:10px' } 83 | .col-md-12 84 | - if current_user == nil 85 | %button.btn.btn-primary.disabled.btn-block 86 | %i.mdi-action-account-balance 87 | Cashout 88 | - else 89 | %button.btn.btn-primary.btn-block{"data-target" => "#cashoutModal", "data-toggle" => "modal"} 90 | %i.mdi-action-account-balance 91 | Cashout 92 | 93 | .row{ style: 'margin-top:10px' } 94 | .col-md-12 95 | - if current_user == nil 96 | %button.btn.btn-primary.disabled.btn-block 97 | %i.mdi-action-receipt 98 | Transaction History 99 | - else 100 | %button.btn.btn-primary.btn-block#transButton{"data-target" => "#transactionModal", "data-toggle" => "modal"} 101 | %i.mdi-action-receipt 102 | Transaction History 103 | .container 104 | .row 105 | .col-md-12 106 | %table.table.table-striped 107 | %thead 108 | %tr 109 | %th Bet ID 110 | %th User 111 | %th Time 112 | %th Bet 113 | %th Payout 114 | %th Game 115 | %th Roll 116 | %th Profit 117 | %tbody#bets 118 | = render :partial => "bets_table_rows" 119 | 120 | = render :partial => "deposit_modal" 121 | 122 | = render :partial => "cashout_modal" 123 | 124 | = render :partial => "transaction_history_modal" 125 | 126 | = render :partial => "verification_modal" -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast 4 | # It gets overwritten when you run the `spring binstub` command 5 | 6 | unless defined?(Spring) 7 | require "rubygems" 8 | require "bundler" 9 | 10 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) 11 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module Bitcoinary 10 | class Application < Rails::Application 11 | 12 | config.generators do |g| 13 | g.test_framework :rspec, 14 | fixtures: true, 15 | view_specs: false, 16 | helper_specs: false, 17 | routing_specs: false, 18 | controller_specs: false, 19 | request_specs: false 20 | g.fixture_replacement :factory_girl, dir: "spec/factories" 21 | end 22 | 23 | # Settings in config/environments/* take precedence over those specified here. 24 | # Application configuration should go into files in config/initializers 25 | # -- all .rb files in that directory are automatically loaded. 26 | 27 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 28 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 29 | # config.time_zone = 'Central Time (US & Canada)' 30 | 31 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 32 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 33 | # config.i18n.default_locale = :de 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | config.action_mailer.smtp_settings = { 31 | address: "smtp.sendgrid.net", 32 | port: 587, 33 | domain: Rails.application.secrets.domain_name, 34 | authentication: "plain", 35 | enable_starttls_auto: true, 36 | user_name: Rails.application.secrets.email_provider_username, 37 | password: Rails.application.secrets.email_provider_password 38 | } 39 | # ActionMailer Config 40 | config.action_mailer.default_url_options = { :host => 'localhost:3000' } 41 | config.action_mailer.delivery_method = :smtp 42 | config.action_mailer.raise_delivery_errors = true 43 | # Send email in development mode? 44 | config.action_mailer.perform_deliveries = true 45 | 46 | 47 | # Adds additional error checking when serving assets at runtime. 48 | # Checks for improperly declared sprockets dependencies. 49 | # Raises helpful error messages. 50 | config.assets.raise_runtime_errors = true 51 | 52 | # Raises error for missing translations 53 | # config.action_view.raise_on_missing_translations = true 54 | end 55 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | 3 | # Settings specified here will take precedence over those in config/application.rb. 4 | 5 | # Code is not reloaded between requests. 6 | config.cache_classes = true 7 | 8 | # Eager load code on boot. This eager loads most of Rails and 9 | # your application in memory, allowing both threaded web servers 10 | # and those relying on copy on write to perform better. 11 | # Rake tasks automatically ignore this option for performance. 12 | config.eager_load = true 13 | 14 | # Full error reports are disabled and caching is turned on. 15 | config.consider_all_requests_local = false 16 | config.action_controller.perform_caching = true 17 | 18 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 19 | # Add `rack-cache` to your Gemfile before enabling this. 20 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable Rails's static asset server (Apache or nginx will already do this). 24 | config.serve_static_assets = false 25 | 26 | # Compress JavaScripts and CSS. 27 | config.assets.js_compressor = :uglifier 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # Generate digests for assets URLs. 34 | config.assets.digest = true 35 | 36 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Set to :debug to see everything in the log. 46 | config.log_level = :info 47 | 48 | # Prepend all log lines with the following tags. 49 | # config.log_tags = [ :subdomain, :uuid ] 50 | 51 | # Use a different logger for distributed setups. 52 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 53 | 54 | # Use a different cache store in production. 55 | # config.cache_store = :mem_cache_store 56 | 57 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 58 | # config.action_controller.asset_host = "http://assets.example.com" 59 | 60 | # Ignore bad email addresses and do not raise email delivery errors. 61 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 62 | # config.action_mailer.raise_delivery_errors = false 63 | 64 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 65 | # the I18n.default_locale when a translation cannot be found). 66 | config.i18n.fallbacks = true 67 | 68 | # Send deprecation notices to registered listeners. 69 | config.active_support.deprecation = :notify 70 | 71 | config.action_mailer.smtp_settings = { 72 | address: "smtp.sendgrid.net", 73 | port: 587, 74 | domain: Rails.application.secrets.domain_name, 75 | authentication: "plain", 76 | enable_starttls_auto: true, 77 | user_name: Rails.application.secrets.email_provider_username, 78 | password: Rails.application.secrets.email_provider_password 79 | } 80 | # ActionMailer Config 81 | config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name } 82 | config.action_mailer.delivery_method = :smtp 83 | config.action_mailer.perform_deliveries = true 84 | config.action_mailer.raise_delivery_errors = false 85 | 86 | 87 | # Disable automatic flushing of the log to improve performance. 88 | # config.autoflush_log = false 89 | 90 | # Use default logging formatter so that PID and timestamp are not suppressed. 91 | config.log_formatter = ::Logger::Formatter.new 92 | 93 | # Do not dump schema after migrations. 94 | config.active_record.dump_schema_after_migration = false 95 | end 96 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure static asset server for tests with Cache-Control for performance. 16 | config.serve_static_assets = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | end 40 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Precompile additional assets. 7 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 8 | # Rails.application.config.assets.precompile += %w( search.js ) 9 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # Use this hook to configure devise mailer, warden hooks and so forth. 2 | # Many of these configuration options can be set straight in your model. 3 | Devise.setup do |config| 4 | # The secret key used by Devise. Devise uses this key to generate 5 | # random tokens. Changing this key will render invalid all existing 6 | # confirmation, reset password and unlock tokens in the database. 7 | # config.secret_key = '2d43db95793eec39ee116b33dd9f6e0931046ca56dbb9a32554e7ef7783f65d2732b05ccd442afdaf40e3b6aad89dfaae26d3ebbb557ba4fcdb49e4a7a5eb10b' 8 | 9 | # ==> Mailer Configuration 10 | # Configure the e-mail address which will be shown in Devise::Mailer, 11 | # note that it will be overwritten if you use your own mailer class 12 | # with default "from" parameter. 13 | config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name 14 | 15 | # Configure the class responsible to send e-mails. 16 | # config.mailer = 'Devise::Mailer' 17 | 18 | # ==> ORM configuration 19 | # Load and configure the ORM. Supports :active_record (default) and 20 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 21 | # available as additional gems. 22 | require 'devise/orm/active_record' 23 | 24 | # ==> Configuration for any authentication mechanism 25 | # Configure which keys are used when authenticating a user. The default is 26 | # just :email. You can configure it to use [:username, :subdomain], so for 27 | # authenticating a user, both parameters are required. Remember that those 28 | # parameters are used only when authenticating and not when retrieving from 29 | # session. If you need permissions, you should implement that in a before filter. 30 | # You can also supply a hash where the value is a boolean determining whether 31 | # or not authentication should be aborted when the value is not present. 32 | # config.authentication_keys = [ :email ] 33 | 34 | # Configure parameters from the request object used for authentication. Each entry 35 | # given should be a request method and it will automatically be passed to the 36 | # find_for_authentication method and considered in your model lookup. For instance, 37 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 38 | # The same considerations mentioned for authentication_keys also apply to request_keys. 39 | # config.request_keys = [] 40 | 41 | # Configure which authentication keys should be case-insensitive. 42 | # These keys will be downcased upon creating or modifying a user and when used 43 | # to authenticate or find a user. Default is :email. 44 | config.case_insensitive_keys = [ :email ] 45 | 46 | # Configure which authentication keys should have whitespace stripped. 47 | # These keys will have whitespace before and after removed upon creating or 48 | # modifying a user and when used to authenticate or find a user. Default is :email. 49 | config.strip_whitespace_keys = [ :email ] 50 | 51 | # Tell if authentication through request.params is enabled. True by default. 52 | # It can be set to an array that will enable params authentication only for the 53 | # given strategies, for example, `config.params_authenticatable = [:database]` will 54 | # enable it only for database (email + password) authentication. 55 | # config.params_authenticatable = true 56 | 57 | # Tell if authentication through HTTP Auth is enabled. False by default. 58 | # It can be set to an array that will enable http authentication only for the 59 | # given strategies, for example, `config.http_authenticatable = [:database]` will 60 | # enable it only for database authentication. The supported strategies are: 61 | # :database = Support basic authentication with authentication key + password 62 | # config.http_authenticatable = false 63 | 64 | # If 401 status code should be returned for AJAX requests. True by default. 65 | # config.http_authenticatable_on_xhr = true 66 | 67 | # The realm used in Http Basic Authentication. 'Application' by default. 68 | # config.http_authentication_realm = 'Application' 69 | 70 | # It will change confirmation, password recovery and other workflows 71 | # to behave the same regardless if the e-mail provided was right or wrong. 72 | # Does not affect registerable. 73 | # config.paranoid = true 74 | 75 | # By default Devise will store the user in session. You can skip storage for 76 | # particular strategies by setting this option. 77 | # Notice that if you are skipping storage for all authentication paths, you 78 | # may want to disable generating routes to Devise's sessions controller by 79 | # passing skip: :sessions to `devise_for` in your config/routes.rb 80 | config.skip_session_storage = [:http_auth] 81 | 82 | # By default, Devise cleans up the CSRF token on authentication to 83 | # avoid CSRF token fixation attacks. This means that, when using AJAX 84 | # requests for sign in and sign up, you need to get a new CSRF token 85 | # from the server. You can disable this option at your own risk. 86 | # config.clean_up_csrf_token_on_authentication = true 87 | 88 | # ==> Configuration for :database_authenticatable 89 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If 90 | # using other encryptors, it sets how many times you want the password re-encrypted. 91 | # 92 | # Limiting the stretches to just one in testing will increase the performance of 93 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 94 | # a value less than 10 in other environments. Note that, for bcrypt (the default 95 | # encryptor), the cost increases exponentially with the number of stretches (e.g. 96 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 97 | config.stretches = Rails.env.test? ? 1 : 10 98 | 99 | # Setup a pepper to generate the encrypted password. 100 | # config.pepper = 'be3a23290004d909d2ec1b51af20c90182f4a1754a88e6bbeb567287e1e2aaf564662857fc8ef6aeaa5c27da85af9851b3c14a92f3b398cae50aa91d55dc0f68' 101 | 102 | # ==> Configuration for :confirmable 103 | # A period that the user is allowed to access the website even without 104 | # confirming their account. For instance, if set to 2.days, the user will be 105 | # able to access the website for two days without confirming their account, 106 | # access will be blocked just in the third day. Default is 0.days, meaning 107 | # the user cannot access the website without confirming their account. 108 | # config.allow_unconfirmed_access_for = 2.days 109 | 110 | # A period that the user is allowed to confirm their account before their 111 | # token becomes invalid. For example, if set to 3.days, the user can confirm 112 | # their account within 3 days after the mail was sent, but on the fourth day 113 | # their account can't be confirmed with the token any more. 114 | # Default is nil, meaning there is no restriction on how long a user can take 115 | # before confirming their account. 116 | # config.confirm_within = 3.days 117 | 118 | # If true, requires any email changes to be confirmed (exactly the same way as 119 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 120 | # db field (see migrations). Until confirmed, new email is stored in 121 | # unconfirmed_email column, and copied to email column on successful confirmation. 122 | config.reconfirmable = true 123 | 124 | # Defines which key will be used when confirming an account 125 | # config.confirmation_keys = [ :email ] 126 | 127 | # ==> Configuration for :rememberable 128 | # The time the user will be remembered without asking for credentials again. 129 | # config.remember_for = 2.weeks 130 | 131 | # Invalidates all the remember me tokens when the user signs out. 132 | config.expire_all_remember_me_on_sign_out = true 133 | 134 | # If true, extends the user's remember period when remembered via cookie. 135 | # config.extend_remember_period = false 136 | 137 | # Options to be passed to the created cookie. For instance, you can set 138 | # secure: true in order to force SSL only cookies. 139 | # config.rememberable_options = {} 140 | 141 | # ==> Configuration for :validatable 142 | # Range for password length. 143 | config.password_length = 8..128 144 | 145 | # Email regex used to validate email formats. It simply asserts that 146 | # one (and only one) @ exists in the given string. This is mainly 147 | # to give user feedback and not to assert the e-mail validity. 148 | # config.email_regexp = /\A[^@]+@[^@]+\z/ 149 | 150 | # ==> Configuration for :timeoutable 151 | # The time you want to timeout the user session without activity. After this 152 | # time the user will be asked for credentials again. Default is 30 minutes. 153 | # config.timeout_in = 30.minutes 154 | 155 | # If true, expires auth token on session timeout. 156 | # config.expire_auth_token_on_timeout = false 157 | 158 | # ==> Configuration for :lockable 159 | # Defines which strategy will be used to lock an account. 160 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 161 | # :none = No lock strategy. You should handle locking by yourself. 162 | # config.lock_strategy = :failed_attempts 163 | 164 | # Defines which key will be used when locking and unlocking an account 165 | # config.unlock_keys = [ :email ] 166 | 167 | # Defines which strategy will be used to unlock an account. 168 | # :email = Sends an unlock link to the user email 169 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 170 | # :both = Enables both strategies 171 | # :none = No unlock strategy. You should handle unlocking by yourself. 172 | # config.unlock_strategy = :both 173 | 174 | # Number of authentication tries before locking an account if lock_strategy 175 | # is failed attempts. 176 | # config.maximum_attempts = 20 177 | 178 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 179 | # config.unlock_in = 1.hour 180 | 181 | # Warn on the last attempt before the account is locked. 182 | # config.last_attempt_warning = true 183 | 184 | # ==> Configuration for :recoverable 185 | # 186 | # Defines which key will be used when recovering the password for an account 187 | # config.reset_password_keys = [ :email ] 188 | 189 | # Time interval you can reset your password with a reset password key. 190 | # Don't put a too small interval or your users won't have the time to 191 | # change their passwords. 192 | config.reset_password_within = 6.hours 193 | 194 | # ==> Configuration for :encryptable 195 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use 196 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 197 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 198 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 199 | # REST_AUTH_SITE_KEY to pepper). 200 | # 201 | # Require the `devise-encryptable` gem when using anything other than bcrypt 202 | # config.encryptor = :sha512 203 | 204 | # ==> Scopes configuration 205 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 206 | # "users/sessions/new". It's turned off by default because it's slower if you 207 | # are using only default views. 208 | # config.scoped_views = false 209 | 210 | # Configure the default scope given to Warden. By default it's the first 211 | # devise role declared in your routes (usually :user). 212 | # config.default_scope = :user 213 | 214 | # Set this configuration to false if you want /users/sign_out to sign out 215 | # only the current scope. By default, Devise signs out all scopes. 216 | # config.sign_out_all_scopes = true 217 | 218 | # ==> Navigation configuration 219 | # Lists the formats that should be treated as navigational. Formats like 220 | # :html, should redirect to the sign in page when the user does not have 221 | # access, but formats like :xml or :json, should return 401. 222 | # 223 | # If you have any extra navigational formats, like :iphone or :mobile, you 224 | # should add them to the navigational formats lists. 225 | # 226 | # The "*/*" below is required to match Internet Explorer requests. 227 | # config.navigational_formats = ['*/*', :html] 228 | 229 | # The default HTTP method used to sign out a resource. Default is :delete. 230 | config.sign_out_via = :delete 231 | 232 | # ==> OmniAuth 233 | # Add a new OmniAuth provider. Check the wiki for more information on setting 234 | # up on your models and hooks. 235 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 236 | 237 | # ==> Warden configuration 238 | # If you want to use other strategies, that are not supported by Devise, or 239 | # change the failure app, you can configure them inside the config.warden block. 240 | # 241 | # config.warden do |manager| 242 | # manager.intercept_401 = false 243 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 244 | # end 245 | 246 | # ==> Mountable engine configurations 247 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 248 | # is mountable, there are some extra configurations to be taken into account. 249 | # The following options are available, assuming the engine is mounted as: 250 | # 251 | # mount MyEngine, at: '/my_engine' 252 | # 253 | # The router that invoked `devise_for`, in the example above, would be: 254 | # config.router_name = :my_engine 255 | # 256 | # When using omniauth, Devise cannot automatically set Omniauth path, 257 | # so you need to do it manually. For the users scope, it would be: 258 | # config.omniauth_path_prefix = '/my_engine/users/auth' 259 | end 260 | -------------------------------------------------------------------------------- /config/initializers/devise_permitted_parameters.rb: -------------------------------------------------------------------------------- 1 | module DevisePermittedParameters 2 | extend ActiveSupport::Concern 3 | 4 | included do 5 | before_filter :configure_permitted_parameters 6 | end 7 | 8 | protected 9 | 10 | def configure_permitted_parameters 11 | devise_parameter_sanitizer.for(:sign_up) << :name 12 | devise_parameter_sanitizer.for(:account_update) << :name 13 | end 14 | 15 | end 16 | 17 | DeviseController.send :include, DevisePermittedParameters 18 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password, :password_confirmation] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/pusher.rb: -------------------------------------------------------------------------------- 1 | require 'pusher' 2 | 3 | if ENV['PUSHER_URL'] != nil 4 | Pusher.url = ENV['PUSHER_URL'] 5 | elsif ENV['pusher_url'] != nil 6 | Pusher.url = ENV['pusher_url'] 7 | end -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_bitcoinary_session' 4 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters) 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your email address has been successfully confirmed." 7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid %{authentication_keys} or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account is locked." 15 | not_found_in_database: "Invalid %{authentication_keys} or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your email address before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock instructions" 26 | omniauth_callbacks: 27 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 28 | success: "Successfully authenticated from %{kind} account." 29 | passwords: 30 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 31 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 32 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 33 | updated: "Your password has been changed successfully. You are now signed in." 34 | updated_not_active: "Your password has been changed successfully." 35 | registrations: 36 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 37 | signed_up: "Welcome! You have signed up successfully." 38 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 39 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 40 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 41 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address." 42 | updated: "Your account has been updated successfully." 43 | sessions: 44 | signed_in: "Signed in successfully." 45 | signed_out: "Signed out successfully." 46 | already_signed_out: "Signed out successfully." 47 | unlocks: 48 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 49 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 50 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 51 | errors: 52 | messages: 53 | already_confirmed: "was already confirmed, please try signing in" 54 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 55 | expired: "has expired, please request a new one" 56 | not_found: "not found" 57 | not_locked: "was not locked" 58 | not_saved: 59 | one: "1 error prohibited this %{resource} from being saved:" 60 | other: "%{count} errors prohibited this %{resource} from being saved:" 61 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | 3 | root to: 'visitors#index' 4 | devise_for :users 5 | resources :users 6 | 7 | 8 | resources :bets, only: [ :show, :create ] 9 | resources :cashouts, only: [ :create ] 10 | resources :transactions, only: [ :index ] 11 | 12 | get 'configuration' => 'visitors#configure' 13 | 14 | get "/bet_table" => "visitors#bet_table" 15 | end 16 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rake secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | development: 14 | admin_name: First User 15 | admin_email: user@example.com 16 | admin_password: changeme 17 | email_provider_username: <%= ENV["SENDGRID_USERNAME"] %> 18 | email_provider_password: <%= ENV["SENDGRID_PASSWORD"] %> 19 | domain_name: example.com 20 | secret_key_base: f29b840a8fbe99988d88dcb998949d2367446adba8e1a16009641e245aaf294533c3117ba752fe2428296ffed1a46d69e63b6aba7a44a5d71ceb45c96a4ebd2a 21 | 22 | test: 23 | domain_name: example.com 24 | secret_key_base: c14065c2e1bbdf17b507ba8f9ba4e83e96f7c9710a19e5e4813683aa4c8eb6284b078f798eed05508492671ccf0d93b29c46bfc99f2c60545ead185b2efe3ad8 25 | 26 | # Do not keep production secrets in the repository, 27 | # instead read values from the environment. 28 | production: 29 | admin_name: <%= ENV["ADMIN_NAME"] %> 30 | admin_email: <%= ENV["ADMIN_EMAIL"] %> 31 | admin_password: <%= ENV["ADMIN_PASSWORD"] %> 32 | email_provider_username: <%= ENV["SENDGRID_USERNAME"] %> 33 | email_provider_password: <%= ENV["SENDGRID_PASSWORD"] %> 34 | domain_name: <%= ENV["DOMAIN_NAME"] %> 35 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 36 | -------------------------------------------------------------------------------- /db/migrate/20140115101221_create_bets.rb: -------------------------------------------------------------------------------- 1 | class CreateBets < ActiveRecord::Migration 2 | def change 3 | create_table :bets do |t| 4 | t.references :user 5 | t.references :secret 6 | t.decimal :amount, scale: 8, precision: 15 7 | t.decimal :multiplier, scale: 4, precision: 8 8 | t.decimal :game, scale: 2, precision: 4 9 | t.decimal :roll, scale: 2, precision: 4 10 | t.string :rolltype, default: 'under' 11 | t.string :client_seed 12 | t.string :server_seed 13 | t.timestamps 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /db/migrate/20140116001104_create_secrets.rb: -------------------------------------------------------------------------------- 1 | class CreateSecrets < ActiveRecord::Migration 2 | def change 3 | create_table :secrets do |t| 4 | t.string :secret 5 | t.timestamps 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /db/migrate/20140930085512_cold_storage.rb: -------------------------------------------------------------------------------- 1 | class ColdStorage < ActiveRecord::Migration 2 | def change 3 | create_table(:cold_storage) do |t| 4 | ## Database authenticatable 5 | t.string :mpk 6 | t.string :fund_address 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /db/migrate/20141002112057_create_cashouts.rb: -------------------------------------------------------------------------------- 1 | class CreateCashouts < ActiveRecord::Migration 2 | def change 3 | create_table :cashouts do |t| 4 | t.string :address 5 | t.integer :amount 6 | t.boolean :status 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20141009160404_create_transactions.rb: -------------------------------------------------------------------------------- 1 | class CreateTransactions < ActiveRecord::Migration 2 | def change 3 | create_table :transactions do |t| 4 | t.integer :user_id 5 | t.integer :amount 6 | t.string :type 7 | t.string :status 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20141014133052_add_user_id_to_cashouts.rb: -------------------------------------------------------------------------------- 1 | class AddUserIdToCashouts < ActiveRecord::Migration 2 | def change 3 | add_column :cashouts, :user_id, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141017133717_add_block_to_coldstore.rb: -------------------------------------------------------------------------------- 1 | class AddBlockToColdstore < ActiveRecord::Migration 2 | def change 3 | add_column :cold_storage, :block, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141021062306_create_balances.rb: -------------------------------------------------------------------------------- 1 | class CreateBalances < ActiveRecord::Migration 2 | def change 3 | create_table :balances do |t| 4 | t.string :transaction_hash 5 | t.integer :amount 6 | t.integer :user_id 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20141022064014_add_sweep_block_to_cold_storage.rb: -------------------------------------------------------------------------------- 1 | class AddSweepBlockToColdStorage < ActiveRecord::Migration 2 | def change 3 | add_column :cold_storage, :sweep_block, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141029123750_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | class DeviseCreateUsers < ActiveRecord::Migration 2 | def change 3 | create_table(:users) do |t| 4 | ## Database authenticatable 5 | t.string :email, null: false, default: "" 6 | t.string :encrypted_password, null: false, default: "" 7 | 8 | ## Recoverable 9 | t.string :reset_password_token 10 | t.datetime :reset_password_sent_at 11 | 12 | ## Rememberable 13 | t.datetime :remember_created_at 14 | 15 | ## Trackable 16 | t.integer :sign_in_count, default: 0, null: false 17 | t.datetime :current_sign_in_at 18 | t.datetime :last_sign_in_at 19 | t.string :current_sign_in_ip 20 | t.string :last_sign_in_ip 21 | 22 | ## Confirmable 23 | # t.string :confirmation_token 24 | # t.datetime :confirmed_at 25 | # t.datetime :confirmation_sent_at 26 | # t.string :unconfirmed_email # Only if using reconfirmable 27 | 28 | ## Lockable 29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 30 | # t.string :unlock_token # Only if unlock strategy is :email or :both 31 | # t.datetime :locked_at 32 | 33 | 34 | t.timestamps 35 | end 36 | 37 | add_index :users, :email, unique: true 38 | add_index :users, :reset_password_token, unique: true 39 | # add_index :users, :confirmation_token, unique: true 40 | # add_index :users, :unlock_token, unique: true 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /db/migrate/20141029123753_add_name_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddNameToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :name, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141029154512_add_bitcoin_address_to_user.rb: -------------------------------------------------------------------------------- 1 | class AddBitcoinAddressToUser < ActiveRecord::Migration 2 | def change 3 | add_column :users, :bitcoin_address, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141029160455_remove_mpk_from_cold_storage.rb: -------------------------------------------------------------------------------- 1 | class RemoveMpkFromColdStorage < ActiveRecord::Migration 2 | def change 3 | remove_column :cold_storage, :mpk, :string 4 | remove_column :cold_storage, :fund_address, :string 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /db/migrate/20141030135705_remove_multiplier_from_bets.rb: -------------------------------------------------------------------------------- 1 | class RemoveMultiplierFromBets < ActiveRecord::Migration 2 | def change 3 | remove_column :bets, :multiplier, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/migrate/20141119122639_change_amount_to_integer.rb: -------------------------------------------------------------------------------- 1 | class ChangeAmountToInteger < ActiveRecord::Migration 2 | def change 3 | change_table :bets do |t| 4 | t.change :amount, :integer 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /db/migrate/20141217121140_add_unique_constraint_to_server_seed.rb: -------------------------------------------------------------------------------- 1 | class AddUniqueConstraintToServerSeed < ActiveRecord::Migration 2 | def change 3 | add_index(:bets, :server_seed, :unique => true) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20141217121140) do 15 | 16 | create_table "balances", force: true do |t| 17 | t.string "transaction_hash" 18 | t.integer "amount" 19 | t.integer "user_id" 20 | t.datetime "created_at" 21 | t.datetime "updated_at" 22 | end 23 | 24 | create_table "bets", force: true do |t| 25 | t.integer "user_id" 26 | t.integer "secret_id" 27 | t.integer "amount", limit: 15 28 | t.decimal "game", precision: 4, scale: 2 29 | t.decimal "roll", precision: 4, scale: 2 30 | t.string "rolltype", default: "under" 31 | t.string "client_seed" 32 | t.string "server_seed" 33 | t.datetime "created_at" 34 | t.datetime "updated_at" 35 | end 36 | 37 | add_index "bets", ["server_seed"], name: "index_bets_on_server_seed", unique: true 38 | 39 | create_table "cashouts", force: true do |t| 40 | t.string "address" 41 | t.integer "amount" 42 | t.boolean "status" 43 | t.datetime "created_at" 44 | t.datetime "updated_at" 45 | t.integer "user_id" 46 | end 47 | 48 | create_table "cold_storage", force: true do |t| 49 | t.integer "block" 50 | t.integer "sweep_block" 51 | end 52 | 53 | create_table "secrets", force: true do |t| 54 | t.string "secret" 55 | t.datetime "created_at" 56 | t.datetime "updated_at" 57 | end 58 | 59 | create_table "transactions", force: true do |t| 60 | t.integer "user_id" 61 | t.integer "amount" 62 | t.string "type" 63 | t.string "status" 64 | t.datetime "created_at" 65 | t.datetime "updated_at" 66 | end 67 | 68 | create_table "users", force: true do |t| 69 | t.string "email", default: "", null: false 70 | t.string "encrypted_password", default: "", null: false 71 | t.string "reset_password_token" 72 | t.datetime "reset_password_sent_at" 73 | t.datetime "remember_created_at" 74 | t.integer "sign_in_count", default: 0, null: false 75 | t.datetime "current_sign_in_at" 76 | t.datetime "last_sign_in_at" 77 | t.string "current_sign_in_ip" 78 | t.string "last_sign_in_ip" 79 | t.datetime "created_at" 80 | t.datetime "updated_at" 81 | t.string "name" 82 | t.string "bitcoin_address" 83 | end 84 | 85 | add_index "users", ["email"], name: "index_users_on_email", unique: true 86 | add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 87 | 88 | end 89 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | user = CreateAdminService.new.call 9 | puts 'CREATED ADMIN USER: ' << user.email 10 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/lib/tasks/.keep -------------------------------------------------------------------------------- /lib/tasks/pirate_metrics.rake: -------------------------------------------------------------------------------- 1 | task :pirate_metrics => :environment do 2 | 3 | count = User.where("created_at >= ?", 1.day.ago).count 4 | bets = Bet.where("created_at >= ?", 1.day.ago).count 5 | btc = Balance.where('created_at < ? and length(transaction_hash) > ?', 24.hours.ago, 20).sum(:amount) 6 | 7 | if btc < 10000 8 | btc = "%.8f" % (btc / 100000000.0) 9 | end 10 | btc = btc / 100000000.0 11 | 12 | message = "User Registrations (last 24 hours) : #{count} " 13 | message += "
    " 14 | message += "Bets made (last 24 hours) : #{bets} " 15 | message += "
    " 16 | message += "BTC Deposited (last 24 hours) : #{btc} " 17 | 18 | uri = URI.parse("https://hall.com") 19 | http = Net::HTTP.new(uri.host, uri.port) 20 | http.use_ssl = true 21 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE 22 | request = Net::HTTP::Post.new("/api/1/services/generic/550e2fabd234eda198cd0936e8799e63") 23 | request.add_field('Content-Type', 'application/json') 24 | request.body = {'title' => 'How are we doing ?', 'message' => message}.to_json 25 | response = http.request(request) 26 | end -------------------------------------------------------------------------------- /lib/tasks/scheduler.rake: -------------------------------------------------------------------------------- 1 | desc "Generate new secret each day" 2 | task :generate_secret => :environment do 3 | Secret.create 4 | end 5 | 6 | desc "Sweep addresses on block chain" 7 | task :sweep_blockchain => :environment do 8 | User.sweep_for_incoming_coins 9 | end 10 | 11 | desc "Create payouts" 12 | task :create_payouts => :environment do 13 | Cashout.create_onchain_payment_request 14 | end 15 | 16 | desc "Sweep incoming coins to fund" 17 | task :sweep_tx => :environment do 18 | User.sweep_bitcoins_to_onchain_fund 19 | end -------------------------------------------------------------------------------- /lib/tasks/simulator.rake: -------------------------------------------------------------------------------- 1 | task :simulate_heavy_user => :environment do 2 | 3 | u = User.find_by_email('ian.purton@gmail.com') 4 | 5 | while u.balance > 0 do 6 | 7 | r = rand * 100.0 8 | b = u.bets.new 9 | b.secret = Secret.last 10 | b.server_seed = SecureRandom.hex(12) 11 | b.amount = 10000 12 | b.game = 49.5 13 | b.client_seed = 'baebbde11f8bb328' 14 | b.save 15 | 16 | sleep 4 17 | end 18 | end 19 | 20 | task :simulate_gamblers_ruin, [:email] => :environment do |t, args| 21 | 22 | user_email = args[:email] 23 | 24 | u = User.find_by_email(user_email) 25 | 26 | LIMIT = 20000000 27 | GAMBLE = 10000 28 | 29 | profit = 0 30 | 31 | while u.balance > GAMBLE do 32 | 33 | win = false 34 | amount = GAMBLE 35 | 36 | while win == false and amount < u.balance and amount < LIMIT 37 | b = u.bets.new 38 | b.secret = Secret.last 39 | b.server_seed = SecureRandom.hex(12) 40 | b.amount = amount 41 | b.game = 49.5 42 | b.client_seed = 'baebbde11f8bb328' 43 | b.save 44 | 45 | Pusher['test_channel'].trigger('my_event', b.as_json) 46 | 47 | win = b.win? 48 | 49 | if !win 50 | amount = amount * 2 51 | else 52 | # We won, start again. 53 | puts "A win resetting amount, total we had to bet " + amount.to_s + " profit " + profit.to_s 54 | profit = profit + GAMBLE 55 | amount = GAMBLE 56 | Bet.where("client_seed = ? and created_at < ?", "baebbde11f8bb328", 3.minutes.ago).delete_all 57 | end 58 | sleep (rand 120) 59 | end 60 | 61 | end 62 | 63 | Bet.where("client_seed = ?", "baebbde11f8bb328").delete_all 64 | u.balances.where("amount < 100000000").delete_all 65 | end -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/log/.keep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    The page you were looking for doesn't exist.

    62 |

    You may have mistyped the address or the page may have moved.

    63 |
    64 |

    If you are the application owner check the logs for more information.

    65 |
    66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    The change you wanted was rejected.

    62 |

    Maybe you tried to change something you didn't have access to.

    63 |
    64 |

    If you are the application owner check the logs for more information.

    65 |
    66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
    60 |
    61 |

    We're sorry, but something went wrong.

    62 |
    63 |

    If you are the application owner check the logs for more information.

    64 |
    65 | 66 | 67 | -------------------------------------------------------------------------------- /public/humans.txt: -------------------------------------------------------------------------------- 1 | /* the humans responsible & colophon */ 2 | /* humanstxt.org */ 3 | 4 | 5 | /* TEAM */ 6 | : 7 | Site: 8 | Twitter: 9 | Location: 10 | 11 | /* THANKS */ 12 | Daniel Kehoe (@rails_apps) for the RailsApps project 13 | 14 | /* SITE */ 15 | Standards: HTML5, CSS3 16 | Components: jQuery 17 | Software: Ruby on Rails 18 | 19 | /* GENERATED BY */ 20 | Rails Composer: http://railscomposer.com/ 21 | -------------------------------------------------------------------------------- /public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/public/images/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /spec/factories/balances.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :balance do 3 | user_id 1 4 | amount 500000 5 | transaction_hash "dbb4fa1da1d6d53911c45b52d94d38507c3f27fa245a7e58bb2d7e6e7056ed72" 6 | end 7 | 8 | trait :big_spender do 9 | amount 500000000 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/factories/users.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :user do 3 | name "Test User" 4 | email "test@example.com" 5 | password "please123" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/features/gambling/cashout_spec.rb: -------------------------------------------------------------------------------- 1 | include Warden::Test::Helpers 2 | Warden.test_mode! 3 | 4 | feature 'When cashing out.', :js => true do 5 | 6 | after(:each) do 7 | Warden.test_reset! 8 | end 9 | 10 | scenario 'does the data get saved' do 11 | user = FactoryGirl.create(:user) 12 | user = FactoryGirl.create(:balance) 13 | signin('test@example.com', 'please123') 14 | 15 | click_on 'Cashout' 16 | 17 | fill_in 'address', with: '38BqfF4LUgpbvoYbGpyYAw44qrpS841GA1' 18 | fill_in 'amount', with: '0.001' 19 | 20 | page.save_screenshot('tmp/screenshot.jpg') 21 | 22 | page.find('#cashout-button').click 23 | 24 | click_on 'Transaction History' 25 | 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /spec/features/gambling/limits_spec.rb: -------------------------------------------------------------------------------- 1 | include Warden::Test::Helpers 2 | Warden.test_mode! 3 | 4 | feature 'When hacking' do 5 | 6 | after(:each) do 7 | Warden.test_reset! 8 | end 9 | 10 | scenario 'can a user bet more than their balance.' do 11 | user = FactoryGirl.create(:user) 12 | user = FactoryGirl.create(:balance) 13 | 14 | signin('test@example.com', 'please123') 15 | 16 | find("#amount-hidden").set "1000000" 17 | 18 | page.find("#roll-button").click 19 | 20 | b = Bet.all 21 | 22 | expect(b.count).to eq(0) 23 | end 24 | 25 | scenario 'can a bet more than our limit.' do 26 | user = FactoryGirl.create(:user) 27 | user = FactoryGirl.create(:balance, :big_spender) 28 | 29 | signin('test@example.com', 'please123') 30 | 31 | # Bet above the limit 32 | find("#amount-hidden").set "200000000" 33 | 34 | page.find("#roll-button").click 35 | 36 | b = Bet.all 37 | 38 | expect(b.count).to eq(0) 39 | 40 | # Bet just below the limit 41 | find("#amount-hidden").set "9999999" 42 | 43 | page.find("#roll-button").click 44 | 45 | b = Bet.all 46 | 47 | expect(b.count).to eq(1) 48 | end 49 | 50 | end 51 | -------------------------------------------------------------------------------- /spec/features/gambling/simple_gamble_spec.rb: -------------------------------------------------------------------------------- 1 | include Warden::Test::Helpers 2 | Warden.test_mode! 3 | 4 | feature 'When gambling', :js => true do 5 | 6 | after(:each) do 7 | Warden.test_reset! 8 | end 9 | 10 | scenario 'can the user sign in and roll the dice' do 11 | user = FactoryGirl.create(:user) 12 | signin('test@example.com', 'please123') 13 | 14 | expect(page.all('tbody#bets tr').count).to eq(0) 15 | 16 | page.find("#roll-button").click 17 | 18 | page.save_screenshot('tmp/screenshot.png') 19 | 20 | expect(page.all('tbody#bets tr').count).to eq(1) 21 | 22 | tr = page.find('tbody#bets tr') 23 | 24 | expect(tr.all('td')[0].text).to eq("1") 25 | expect(tr.all('td')[1].text).to eq("Test User") 26 | expect(tr.all('td')[2].text).to eq("less than a minute ago.") 27 | expect(tr.all('td')[3].text).to eq("0.00000000") 28 | expect(tr.all('td')[4].text).to eq("2.0") 29 | expect(tr.all('td')[5].text).to eq("< 49.5") 30 | expect(tr.all('td')[7].text).to eq("0.00000000") 31 | end 32 | 33 | scenario 'is the balance displaying correctly.' do 34 | user = FactoryGirl.create(:user) 35 | user = FactoryGirl.create(:balance) 36 | signin('test@example.com', 'please123') 37 | 38 | bal = page.find('#balance').value 39 | 40 | expect(bal).to eq('0.005') 41 | end 42 | 43 | scenario 'does the users balance increase or decrease with each bet' do 44 | user = FactoryGirl.create(:user) 45 | user = FactoryGirl.create(:balance) 46 | signin('test@example.com', 'please123') 47 | 48 | bal_before = page.find('#balance').value 49 | 50 | page.find("#roll-button").click 51 | 52 | bal_after = page.find('#balance').value 53 | 54 | expect(bal_before).to eq(bal_after) 55 | 56 | # OK let's slide the amount slider and see what happens 57 | page.execute_script("$('#amount-slider').val(20000);$('#amount-slider').change()") 58 | 59 | page.find("#roll-button").click 60 | 61 | bal_after = page.find('#balance').value 62 | 63 | expect(bal_before).to_not eq(bal_after) 64 | end 65 | 66 | scenario 'does the amount slider work.' do 67 | 68 | user = FactoryGirl.create(:user) 69 | user = FactoryGirl.create(:balance) 70 | signin('test@example.com', 'please123') 71 | 72 | page.execute_script("$('#amount-slider').val(10000);$('#amount-slider').change()") 73 | 74 | amount = page.find('#amount-view').value 75 | 76 | expect(amount).to eq("0.00010") 77 | 78 | button = page.find('#roll-button').value 79 | 80 | expect(button).to eq("Click for a 49.5% chance of multiplying your bet by 2.00") 81 | 82 | # OK, Make the bet. 83 | page.find("#roll-button").click 84 | 85 | expect(page.all('tbody#bets tr').count).to eq(1) 86 | 87 | tr = page.find('tbody#bets tr') 88 | 89 | expect(tr.all('td')[0].text).to eq("1") 90 | expect(tr.all('td')[1].text).to eq("Test User") 91 | expect(tr.all('td')[2].text).to eq("less than a minute ago.") 92 | expect(tr.all('td')[3].text).to eq("0.0001") 93 | expect(tr.all('td')[4].text).to eq("2.0") 94 | expect(tr.all('td')[5].text).to eq("< 49.5") 95 | 96 | end 97 | 98 | scenario 'does the probability slider work.' do 99 | user = FactoryGirl.create(:user) 100 | signin('test@example.com', 'please123') 101 | 102 | page.execute_script("$('#probability-slider').val(80);$('#probability-slider').change()") 103 | 104 | prob = page.find('#bet_chance').value 105 | 106 | expect(prob).to eq("80.0%") 107 | 108 | button = page.find('#roll-button').value 109 | 110 | expect(button).to eq("Click for a 80.0% chance of multiplying your bet by 1.24") 111 | 112 | # OK, Make the bet. 113 | page.find("#roll-button").click 114 | 115 | expect(page.all('tbody#bets tr').count).to eq(1) 116 | 117 | tr = page.find('tbody#bets tr') 118 | 119 | expect(tr.all('td')[0].text).to eq("1") 120 | expect(tr.all('td')[1].text).to eq("Test User") 121 | expect(tr.all('td')[2].text).to eq("less than a minute ago.") 122 | expect(tr.all('td')[3].text).to eq("0.00000000") 123 | expect(tr.all('td')[4].text).to eq("1.24") 124 | expect(tr.all('td')[5].text).to eq("< 80.0") 125 | expect(tr.all('td')[7].text).to eq("0.00000000") 126 | 127 | end 128 | 129 | end 130 | -------------------------------------------------------------------------------- /spec/features/users/sign_in_spec.rb: -------------------------------------------------------------------------------- 1 | # Feature: Sign in 2 | # As a user 3 | # I want to sign in 4 | # So I can visit protected areas of the site 5 | feature 'Sign in', :devise do 6 | 7 | # Scenario: User cannot sign in if not registered 8 | # Given I do not exist as a user 9 | # When I sign in with valid credentials 10 | # Then I see an invalid credentials message 11 | scenario 'user cannot sign in if not registered' do 12 | signin('test@example.com', 'please123') 13 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email' 14 | end 15 | 16 | # Scenario: User can sign in with valid credentials 17 | # Given I exist as a user 18 | # And I am not signed in 19 | # When I sign in with valid credentials 20 | # Then I see a success message 21 | scenario 'user can sign in with valid credentials' do 22 | user = FactoryGirl.create(:user) 23 | signin(user.email, user.password) 24 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.sessions.signed_in' 25 | end 26 | 27 | # Scenario: User cannot sign in with wrong email 28 | # Given I exist as a user 29 | # And I am not signed in 30 | # When I sign in with a wrong email 31 | # Then I see an invalid email message 32 | scenario 'user cannot sign in with wrong email' do 33 | user = FactoryGirl.create(:user) 34 | signin('invalid@email.com', user.password) 35 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email' 36 | end 37 | 38 | # Scenario: User cannot sign in with wrong password 39 | # Given I exist as a user 40 | # And I am not signed in 41 | # When I sign in with a wrong password 42 | # Then I see an invalid password message 43 | scenario 'user cannot sign in with wrong password' do 44 | user = FactoryGirl.create(:user) 45 | signin(user.email, 'invalidpass') 46 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.failure.invalid', authentication_keys: 'email' 47 | end 48 | 49 | end 50 | -------------------------------------------------------------------------------- /spec/features/users/sign_out_spec.rb: -------------------------------------------------------------------------------- 1 | # Feature: Sign out 2 | # As a user 3 | # I want to sign out 4 | # So I can protect my account from unauthorized access 5 | feature 'Sign out', :devise do 6 | 7 | # Scenario: User signs out successfully 8 | # Given I am signed in 9 | # When I sign out 10 | # Then I see a signed out message 11 | scenario 'user signs out successfully' do 12 | user = FactoryGirl.create(:user) 13 | signin(user.email, user.password) 14 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.sessions.signed_in' 15 | click_link 'Sign out' 16 | expect(find('.snackbar', :visible => false).value).to eq I18n.t 'devise.sessions.signed_out' 17 | end 18 | 19 | end 20 | 21 | 22 | -------------------------------------------------------------------------------- /spec/features/users/user_delete_spec.rb: -------------------------------------------------------------------------------- 1 | include Warden::Test::Helpers 2 | Warden.test_mode! 3 | 4 | # Feature: User delete 5 | # As a user 6 | # I want to delete my user profile 7 | # So I can close my account 8 | feature 'User delete', :devise, :js do 9 | 10 | after(:each) do 11 | Warden.test_reset! 12 | end 13 | 14 | # Scenario: User can delete own account 15 | # Given I am signed in 16 | # When I delete my account 17 | # Then I should see an account deleted message 18 | scenario 'user can delete own account' do 19 | #skip 'skip a slow test' 20 | user = FactoryGirl.create(:user) 21 | login_as(user, :scope => :user) 22 | visit edit_user_registration_path(user) 23 | click_button 'Cancel my account' 24 | 25 | expect(first('.snackbar', :visible => false).value).to eq I18n.t 'devise.registrations.destroyed' 26 | end 27 | 28 | end 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /spec/features/users/user_edit_spec.rb: -------------------------------------------------------------------------------- 1 | include Warden::Test::Helpers 2 | Warden.test_mode! 3 | 4 | # Feature: User edit 5 | # As a user 6 | # I want to edit my user profile 7 | # So I can change my email address 8 | feature 'User edit', :devise do 9 | 10 | after(:each) do 11 | Warden.test_reset! 12 | end 13 | 14 | # Scenario: User changes email address 15 | # Given I am signed in 16 | # When I change my email address 17 | # Then I see an account updated message 18 | scenario 'user changes email address' do 19 | user = FactoryGirl.create(:user) 20 | login_as(user, :scope => :user) 21 | visit edit_user_registration_path(user) 22 | fill_in 'Email', :with => 'newemail@example.com' 23 | fill_in 'Current password', :with => user.password 24 | click_button 'Update' 25 | expect(find('.snackbar', :visible => false).value).to eq I18n.t( 'devise.registrations.updated') 26 | end 27 | 28 | # Scenario: User cannot edit another user's profile 29 | # Given I am signed in 30 | # When I try to edit another user's profile 31 | # Then I see my own 'edit profile' page 32 | scenario "user cannot cannot edit another user's profile", :me do 33 | me = FactoryGirl.create(:user) 34 | other = FactoryGirl.create(:user, email: 'other@example.com') 35 | login_as(me, :scope => :user) 36 | visit edit_user_registration_path(other) 37 | expect(page).to have_content 'Edit User' 38 | expect(page).to have_field('Email', with: me.email) 39 | end 40 | 41 | end 42 | -------------------------------------------------------------------------------- /spec/features/visitors/home_page_spec.rb: -------------------------------------------------------------------------------- 1 | # Feature: Home page 2 | # As a visitor 3 | # I want to visit a home page 4 | # So I can learn more about the website 5 | feature 'Home page' do 6 | 7 | # Scenario: Visit the home page 8 | # Given I am a visitor 9 | # When I visit the home page 10 | # Then I see "Welcome" 11 | scenario 'visit the home page' do 12 | visit root_path 13 | expect(page).to have_content 'Server Seed' 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /spec/features/visitors/navigation_spec.rb: -------------------------------------------------------------------------------- 1 | # Feature: Navigation links 2 | # As a visitor 3 | # I want to see navigation links 4 | # So I can find home, sign in, or sign up 5 | feature 'Navigation links', :devise do 6 | 7 | # Scenario: View navigation links 8 | # Given I am a visitor 9 | # When I visit the home page 10 | # Then I see "home," "sign in," and "sign up" 11 | scenario 'view navigation links' do 12 | visit root_path 13 | expect(page).to have_content 'Bitsino' 14 | expect(page).to have_content 'Sign in' 15 | expect(page).to have_content 'Sign up' 16 | end 17 | 18 | end 19 | -------------------------------------------------------------------------------- /spec/features/visitors/sign_up_spec.rb: -------------------------------------------------------------------------------- 1 | # Feature: Sign up 2 | # As a visitor 3 | # I want to sign up 4 | # So I can visit protected areas of the site 5 | feature 'Sign Up', :devise do 6 | 7 | # Scenario: Visitor can sign up with valid email address and password 8 | # Given I am not signed in 9 | # When I sign up with a valid email address and password 10 | # Then I see a successful sign up message 11 | scenario 'visitor can sign up with valid email address and password' do 12 | sign_up_with('test@example.com', 'please123', 'please123') 13 | expect(find('.snackbar', :visible => false).value).to eq I18n.t( 'devise.registrations.signed_up') 14 | end 15 | 16 | # Scenario: Visitor cannot sign up with invalid email address 17 | # Given I am not signed in 18 | # When I sign up with an invalid email address 19 | # Then I see an invalid email message 20 | scenario 'visitor cannot sign up with invalid email address' do 21 | sign_up_with('bogus', 'please123', 'please123') 22 | expect(page).to have_content 'Email is invalid' 23 | end 24 | 25 | # Scenario: Visitor cannot sign up without password 26 | # Given I am not signed in 27 | # When I sign up without a password 28 | # Then I see a missing password message 29 | scenario 'visitor cannot sign up without password' do 30 | sign_up_with('test@example.com', '', '') 31 | expect(page).to have_content "Password can't be blank" 32 | end 33 | 34 | # Scenario: Visitor cannot sign up with a short password 35 | # Given I am not signed in 36 | # When I sign up with a short password 37 | # Then I see a 'too short password' message 38 | scenario 'visitor cannot sign up with a short password' do 39 | sign_up_with('test@example.com', 'please', 'please') 40 | expect(page).to have_content "Password is too short" 41 | end 42 | 43 | # Scenario: Visitor cannot sign up without password confirmation 44 | # Given I am not signed in 45 | # When I sign up without a password confirmation 46 | # Then I see a missing password confirmation message 47 | scenario 'visitor cannot sign up without password confirmation' do 48 | sign_up_with('test@example.com', 'please123', '') 49 | expect(page).to have_content "Password confirmation doesn't match" 50 | end 51 | 52 | # Scenario: Visitor cannot sign up with mismatched password and confirmation 53 | # Given I am not signed in 54 | # When I sign up with a mismatched password confirmation 55 | # Then I should see a mismatched password message 56 | scenario 'visitor cannot sign up with mismatched password and confirmation' do 57 | sign_up_with('test@example.com', 'please123', 'mismatch') 58 | expect(page).to have_content "Password confirmation doesn't match" 59 | end 60 | 61 | end 62 | -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | describe User do 2 | 3 | before(:each) { @user = User.new(email: 'user@example.com') } 4 | 5 | subject { @user } 6 | 7 | it { should respond_to(:email) } 8 | 9 | it "#email returns a string" do 10 | expect(@user.email).to match 'user@example.com' 11 | end 12 | 13 | it "#sweep_bitcoins_to_onchain_fund should create a valid tx" do 14 | 15 | tx = User.sweep_bitcoins_to_onchain_fund 16 | 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV["RAILS_ENV"] ||= 'test' 3 | require 'spec_helper' 4 | require File.expand_path("../../config/environment", __FILE__) 5 | require 'rspec/rails' 6 | require 'capybara' 7 | require "capybara-webkit" 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } 24 | 25 | Capybara.javascript_driver = :webkit 26 | # Checks for pending migrations before tests are run. 27 | # If you are not using ActiveRecord, you can remove this line. 28 | ActiveRecord::Migration.maintain_test_schema! 29 | 30 | RSpec.configure do |config| 31 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 32 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 33 | 34 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 35 | # examples within a transaction, remove the following line or assign false 36 | # instead of true. 37 | config.use_transactional_fixtures = false 38 | 39 | # RSpec Rails can automatically mix in different behaviours to your tests 40 | # based on their file location, for example enabling you to call `get` and 41 | # `post` in specs under `spec/controllers`. 42 | # 43 | # You can disable this behaviour by removing the line below, and instead 44 | # explicitly tag your specs with their type, e.g.: 45 | # 46 | # RSpec.describe UsersController, :type => :controller do 47 | # # ... 48 | # end 49 | # 50 | # The different available types are documented in the features, such as in 51 | # https://relishapp.com/rspec/rspec-rails/docs 52 | config.infer_spec_type_from_file_location! 53 | end 54 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | SimpleCov.start 3 | 4 | RSpec.configure do |config| 5 | # rspec-expectations config goes here. You can use an alternate 6 | # assertion/expectation library such as wrong or the stdlib/minitest 7 | # assertions if you prefer. 8 | 9 | config.expect_with :rspec do |expectations| 10 | # This option will default to `true` in RSpec 4. It makes the `description` 11 | # and `failure_message` of custom matchers include text for helper methods 12 | # defined using `chain`, e.g.: 13 | # be_bigger_than(2).and_smaller_than(4).description 14 | # # => "be bigger than 2 and smaller than 4" 15 | # ...rather than: 16 | # # => "be bigger than 2" 17 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 18 | end 19 | 20 | # rspec-mocks config goes here. You can use an alternate test double 21 | # library (such as bogus or mocha) by changing the `mock_with` option here. 22 | config.mock_with :rspec do |mocks| 23 | # Prevents you from mocking or stubbing a method that does not exist on 24 | # a real object. This is generally recommended, and will default to 25 | # `true` in RSpec 4. 26 | mocks.verify_partial_doubles = true 27 | end 28 | 29 | end 30 | -------------------------------------------------------------------------------- /spec/support/capybara.rb: -------------------------------------------------------------------------------- 1 | Capybara.asset_host = 'http://localhost:3000' 2 | -------------------------------------------------------------------------------- /spec/support/database_cleaner.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.before(:suite) do 3 | DatabaseCleaner.clean_with(:truncation) 4 | end 5 | 6 | config.before(:each) do 7 | DatabaseCleaner.strategy = :transaction 8 | end 9 | 10 | config.before(:each, :js => true) do 11 | DatabaseCleaner.strategy = :truncation 12 | end 13 | 14 | config.before(:each) do 15 | DatabaseCleaner.start 16 | end 17 | 18 | config.append_after(:each) do 19 | DatabaseCleaner.clean 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /spec/support/devise.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include Devise::TestHelpers, :type => :controller 3 | end 4 | -------------------------------------------------------------------------------- /spec/support/factory_girl.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include FactoryGirl::Syntax::Methods 3 | end 4 | -------------------------------------------------------------------------------- /spec/support/helpers.rb: -------------------------------------------------------------------------------- 1 | require 'support/helpers/session_helpers' 2 | RSpec.configure do |config| 3 | config.include Features::SessionHelpers, type: :feature 4 | end 5 | -------------------------------------------------------------------------------- /spec/support/helpers/session_helpers.rb: -------------------------------------------------------------------------------- 1 | module Features 2 | module SessionHelpers 3 | def sign_up_with(email, password, confirmation) 4 | visit new_user_registration_path 5 | fill_in 'Email', with: email 6 | fill_in 'Password', with: password 7 | fill_in 'Password confirmation', :with => confirmation 8 | click_button 'Sign up' 9 | end 10 | 11 | def signin(email, password) 12 | visit new_user_session_path 13 | fill_in 'Email', with: email 14 | fill_in 'Password', with: password 15 | click_button 'Sign in' 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bitsino/BitsinoDice/ab7040438fac437b6b146e208f0813dd97c09690/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------