This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Binary_heap | |
def initialize(num = 10) | |
@ary = Array.new | |
num.times do @ary << rand(100) end | |
end | |
attr_reader :items, :ary | |
def binary_heap() | |
@ary.unshift(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = Time.now | |
dayth = t.yday | |
last_digit = dayth.to_s.slice(-1, 1).to_i | |
def ordinal(last_digit) | |
case last_digit | |
when 1 | |
"st" | |
when 2 | |
"nd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rock Paper Scissors is a usual game | |
class Opponent | |
def initialize | |
@rps = ['rock', 'paper', 'scissors'] | |
end | |
def play | |
@rps[rand 3] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Client < ActiveRecord::Base | |
attr_accessible :first_name, :last_name, :middle_initial, :suffix, | |
:email, :email_2, :phone, :using, :phone_2, :using_2, | |
:age_group, :communication_types, :funder, | |
:street_address, :street_address_2, :city, :county, :zip_code, :state, | |
:permission_to_photograph, :mailing_list, :email_or_letter, | |
:notes | |
validates :first_name, presence: true, length: { maximum: 15 } | |
validates :last_name, presence: true, length: { maximum: 15 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
survey "Grid question test", default_mandatory: false do | |
section 'Communication Skills' do | |
grid 'Identify communication and interviewing skills' do | |
a 'Yes' | |
a 'No' | |
q 'Able to articulate job duties and skills', pick: :one | |
q 'Easily understood, clear', pick: :one | |
q 'Demonstrates good listening skills', pick: :one | |
q 'Professional via phone/email and in person', pick: :one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object FizzBuzz { | |
def convertToFizzBuzz(listOfNumber: List[Int]): List[String] = { | |
listOfNumber.map((i: Int) => fizzbuzz(i)) | |
} | |
def fizzbuzz(n: Int): String = { | |
if (n % 3 == 0 && n % 5 == 0) { "FizzBuzz" } | |
else if (n % 3 == 0) { "Fizz" } | |
else if (n % 5 == 0) { "Buzz" } | |
else { n.toString } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.SortedMap | |
object FizzBuzz { | |
def generator(mapping: SortedMap[Int, String], lst: List[Int]): List[String] = { | |
// sort Map descending - Unimplemented | |
// Something very simple | |
// (n: Int) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkTime = function(){ | |
currTime = myPlayer.currentTime(); | |
if (currTime >= 3 && currTime <= 4 && hsh['calendar'] === false) { | |
hsh['calendar'] = true; | |
$('.fc-highlight-this').effect("highlight", 3000); | |
} | |
if (currTime >= 13 && currTime <= 14 && hsh['always'] === false) { | |
hsh['always'] = true; | |
$('.always span').effect("highlight", {color: '#83c0ff', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- default desktop configuration for Fedora | |
import System.Posix.Env (getEnv) | |
import Data.Maybe (maybe) | |
import XMonad | |
import XMonad.Config.Desktop | |
import XMonad.Config.Gnome | |
import XMonad.Config.Kde | |
import XMonad.Config.Xfce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::old_io::net::tcp::TcpStream; | |
fn main() { | |
// use std::old_io::net::ip::{Ipv4Addr, SocketAddr}; | |
// let SocketAddress = SocketAddr { ip: "irc.freenode.net", port: "6667" }; | |
let mut g = 1; | |
{ | |
let mut stream = TcpStream::connect("irc.freenode.net:6667").unwrap(); | |
let _ = stream.write_all(b"NICK simplerustbot\r\n"); |
OlderNewer