This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css"> | |
| <link rel="stylesheet" href="main.css"> | |
| <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800"> | |
| <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900"> | |
| <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css"> | |
| </head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //--- INSTRUCTIONS ------------------ | |
| /* | |
| 1. `Array.total()`, which returns the total of all the values in the array | |
| 2. `Array.mean()`, which returns the mean of the array | |
| 3. `Array.median()`, which returns the median of the array | |
| 4. `Array.mode()`, which returns an object representing the mode(s) of the array with the property being the mode and the value being the frequency | |
| //--- CODE -------------------------- | |
| Array.prototype.total = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script src="js.js"></script> | |
| <title>JS Play</title> | |
| <style> | |
| body { font-size: 30px; font-family: sans-serif; } | |
| div { text-align: center;} | |
| input { | |
| width: 500px; | |
| background-color: #2ecc71; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var MenuItems = { | |
| init: function(){ | |
| $(".menus").on("ajax:success", '.closed a', this.openMenuItems) | |
| $(".menus").on("ajax:success", '.open a', this.closeMenuItems) | |
| $(".menus").on("ajax:success", 'form', this.addMenuItems) | |
| }, | |
| openMenuItems: function(e, data){ | |
| var itemDiv = MenuItems.getItemDiv(e) | |
| $(itemDiv).html(data).hide() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <h1 id='quiz_name'></h1> | |
| <a href='#' id='next_question'>Start Quiz</a> | |
| <div id='question'> | |
| <h3 id='question_text'></h3> | |
| <div id='answers'></div> | |
| <div id='correct'></div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bubble_sort(list) | |
| sorted = false | |
| until sorted | |
| sorted = true | |
| (0...list.length).each do |i| | |
| if !list[i + 1].nil? && list[i] > list[i + 1] | |
| list[i], list[i + 1] = list[i + 1], list[i] | |
| sorted = false | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Creating a linked list in Ruby, based on this tutorial | |
| # http://www.commandercoriander.net/blog/2012/12/23/reversing-a-linked-list-in-ruby/ | |
| require 'benchmark' | |
| class Entry | |
| attr_accessor :next, :data | |
| def initialize(data) | |
| @next = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A filter method using meta-programming to send multiple methods to the class. | |
| # This allows multiple ActiveRecord scopes to be stacked easily. | |
| def self.filter(params) | |
| max = params[:limit] || 10 | |
| methods = [:new_prices] | |
| methods << :free if params[:free] | |
| methods << :games if params[:games] | |
| methods << [:limit, max] | |
| Application.send_chain(methods) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo '********************************************' | |
| date -u | |
| echo ' Beginning Incremental Import' | |
| echo ' Setting PATH, GEM and RUBYLIB variables' | |
| export PATH=/home/ckoziak/webapps/rails/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ckoziak/bin; | |
| export GEM_HOME=/home/ckoziak/webapps/rails/gems; | |
| export RUBYLIB=/home/ckoziak/webapps/rails/lib; | |
| echo ' Changing Directory to /home/ckoziak/webapps/rails/fas/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For a project I needed to find the nearest denominator from a set number and divisor. | |
| // I started off hacking it together to see if it would work in my project. | |
| // Then I refactored. Refactored code is shown first. | |
| // Refactored Code | |
| function findNearestInt(num, div){ | |
| for(var i = 0; i < div / 2; i++){ | |
| if(num % (div - i) == 0){return div - i} | |
| if(num % (div + i) == 0){return div + i} |