Skip to content

Instantly share code, notes, and snippets.

@dmill
dmill / shufflin.rb
Last active December 29, 2015 20:59
#I thought I would try something shuffling the array in-place destructively:
def destructive_perfect_shuffle(array, cut_size)
cut_size.times do |i|
array.insert(-cut_size + i, array.shift)
end
array
end
#and then implementing a similar counting method:
<head>
</head>
<body>
<div id="heading">HaslgfinwergeinroGIENROGIWENRGOWIENGOWEIRGNQOWEIRGNOWIERGNWOEIRGNOQEWRIGNOEQIRNGOQEIRGN</div>
<h2 id="bye">Bye</h2>
<textarea id="usertext">insert text</textarea>
<script src="test.js"></script>
</body>
function numbersInWords(number){
printArray = [];
ones = ["zero","one", "two", "three", "four", "five","six", "seven", "eight", "nine"];
teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
tens = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];
if(number < 10)
{
return ones[number];
}
table, .cell{
border: 4px solid green;
width: 800px;
height: 300px;
text-align: center;
background-color: gray;
}
img {
width:200px;
var shuffle = function(originalArray){
shuffledArray = []
while(originalArray.length > 0){
var randomIndex = Math.floor(Math.random()*originalArray.length)
shuffledArray.push(originalArray[randomIndex])
originalArray.splice(randomIndex, 1)
}
return shuffledArray
}
https://github.com/dmill/ar-student-schema
require 'sqlite3'
$db = SQLite3::Database.new 'address_book.db'
module AddressBookDB
def self.setup
$db.execute(
<<-SQL
CREATE TABLE IF NOT EXISTS contacts (
class Car
@@WHEELS = 4
def initialize(args)
@color = args[:color]
@wheels = @@WHEELS
end
def drive
@status = :driving
end
def brake
require 'open-uri'
require 'nokogiri'
class Player
attr_reader :name, :position, :pts
def initialize(player_hash)
@name = player_hash[:name]
@position = player_hash[:position]
@pts = player_hash[:pts].to_f
@reb = player_hash[:reb].to_f