blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 4 137 | path stringlengths 2 355 | src_encoding stringclasses 31
values | length_bytes int64 11 3.9M | score float64 2.52 5.47 | int_score int64 3 5 | detected_licenses listlengths 0 49 | license_type stringclasses 2
values | text stringlengths 11 3.93M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
5db8f83abd9419a1b98bc594e46fcbddd49ae09a | Ruby | Odaeus/amee-ruby | /lib/amee/user.rb | UTF-8 | 3,824 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright (C) 2008-2013 AMEE UK Ltd. - http://www.amee.com
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
module AMEE
module Admin
class User < AMEE::Object
attr_reader :username
attr_reader :name
attr_reader :email
attr_reader :api_ver... | true |
2ee43b74101c55462234729652bc6882e0a62b76 | Ruby | gcapizzi/mutant | /lib/mutant/strategy.rb | UTF-8 | 1,774 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
module Mutant
# Abstract base class for killing strategies
class Strategy
include AbstractType, Adamantium::Flat, Equalizer.new
REGISTRY = {}
# Lookup strategy for name
#
# @param [String] name
#
# @return [Strategy]
# if found
#
# @api private
#
... | true |
a7ff56c21e42cad62a54beb6db02f0c249a05614 | Ruby | michaelhuisman/knife-ovmcli | /lib/chef/knife/ovmcli_vm_clone.rb | UTF-8 | 1,410 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #
# Code copied from Author:: Geoff O'Callaghan (<geoffocallaghan@gmail.com>)
# Author:: Michael Huisman michhuis@gmail.com
# License:: Apache License, Version 2.0
#
require 'chef/knife'
require 'chef/knife/BaseOraclevmCommand'
require 'netaddr'
require 'net/ssh'
# Clone a virtual machine
class Chef::Knif... | true |
34df4fb9ebbd78e31d8a530f59f1d3ba2a55ff7b | Ruby | tabbies-k/records | /app/models/entry.rb | UTF-8 | 680 | 2.546875 | 3 | [] | no_license | class Entry < ApplicationRecord
belongs_to :record, optional: true
default_scope -> { order(record_id: :asc) }
def record
return Record.find_by(id: self.record_id)
end
def user
return User.find_by(id: self.record.user_id)
end
def caliculation
if expected_... | true |
68eb3fb2a16ed32ff985047f4138bf7c57d8b593 | Ruby | sarsena/RubyClass | /orders.rb | UTF-8 | 2,483 | 2.765625 | 3 | [] | no_license | require 'json'
require 'mysql2'
require 'yaml'
order_object = [
{
"orderid" => 123,
"customer_id" => 1,
"order_products" => [
{
"product_id" => 1,
"product_description" => "Cocaine",
"product_price" => 30,
"quantity" => 1
},
{
"product_id" => 2,
... | true |
53b344fe57aa5b298b2356b56db46f32a5f460d4 | Ruby | jogi91/worms-on-a-plane | /lib/strategie_le_prof.rb | UTF-8 | 9,924 | 2.890625 | 3 | [] | no_license |
require "strategie"
class Fixnum
def sign
return 1 if self>0
return 0 if self == 0
return -1 if self<0
end
end
# Strategie du Prof
class Strategie_leProf < Strategie
def initialize
@force = 0
@boese = Array.new(4,false)
end
#
def wohin?(spiel)
@spiel = spiel
# Position und... | true |
c625e786f845ea7cfc024a28f7909ad15d4277e6 | Ruby | OregonDigital/oregondigital | /lib/oregon_digital/rdf/list.rb | UTF-8 | 1,386 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | module OregonDigital::RDF
##
# Override default List implementation to fix some bugs with appending to a list.
# TODO: Move this up and analyze the resulting n-triples.
class List < ActiveFedora::Rdf::List
class << self
def from_uri(uri, vals)
list = ListResource.from_uri(uri, vals)
se... | true |
6dd36716547b196ee5477b413ef2df5c9b272a7c | Ruby | eregon/path | /lib/path/file.rb | UTF-8 | 3,410 | 3.203125 | 3 | [
"MIT"
] | permissive | class Path
# @!group File
# Returns the last access time. See +File.atime+.
def atime
File.atime(@path)
end
# Returns the last change time (of the directory entry, not the file itself).
# See +File.ctime+.
def ctime
File.ctime(@path)
end
# Returns last modification time. See +File.mtime+.
... | true |
b298968455d7eebe65959e5abb404da7db08d864 | Ruby | WOLAS-Revolution/wolas-content-cli | /thumbnails.rb | UTF-8 | 3,167 | 2.796875 | 3 | [] | no_license | class Thumbnail
# require gems & libraries.
require 'securerandom'
require 'aws-sdk'
require 'yaml'
require 'active_record'
require 'mysql2'
# require active record models.
require './models/content.rb'
# require any classes that are needed.
require './check_existence.rb'
require './image_compress.rb... | true |
a2dd5b4fd8f18a82d5d83af34cd2ace1df0b8ce1 | Ruby | Dalf32/Sheetwise | /app/lib/utilities/extensions/hash_extensions.rb | UTF-8 | 859 | 3.125 | 3 | [] | no_license | # hash_extensions.rb
#
# Author:: Kyle Mullins
require_relative 'proc_extensions'
module HashExtensions
def transform_keys(&block)
inject({}){ |result, (key, value)|
new_key = block.call(key)
new_value = case value
when Hash then value.transform_keys(block)
else value
... | true |
67ee87aa0bd3844f8d01fe79515639f6df85b694 | Ruby | DrDhoom/RMVXA-Script-Repository | /Himeworks/Dominant_Class.rb | UTF-8 | 4,288 | 2.90625 | 3 | [
"MIT"
] | permissive | =begin
#===============================================================================
Title: Dominant Class
Author: Hime
Date: Apr 4, 2013
--------------------------------------------------------------------------------
** Change log
Apr 4, 2013
- Initial release
----------------------------------------------... | true |
cb46ec5a3802fe91f676be49b7b9e94fc2179547 | Ruby | Yamoos/parser | /parser.rb | UTF-8 | 1,001 | 2.515625 | 3 | [] | no_license | #!/usr/bin/ruby1.9.3
require 'mechanize'
require 'green_shoes'
def connect
url ="http://www.lostfilm.tv/"
agent = Mechanize.new
agent.user_agent_alias = 'Linux Mozilla'
agent.get(url)
end
def get
b = connect.search('#new_sd_list').inner_text
h = Array.new
b.delete!("\r, \t").each_line {|s|
if s.lstrip.empt... | true |
d1dc41d779d1f07ced5e9c0c4ac33d9554a09f54 | Ruby | shinji62/buildpacks-ci | /lib/cve-history.rb | UTF-8 | 683 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # encoding: utf-8
require 'yaml'
class CVEHistory
attr_accessor :cves_dir
def initialize(cve_dir)
@cves_dir = cve_dir
end
def read_yaml_cves(yaml_filename)
file_path = "#{cves_dir}/#{yaml_filename}"
if File.exist? file_path
YAML.load_file("#{cves_dir}/#{yaml_filename}").to_a
else
... | true |
60606a889dccec1426595e864cdf9324bcbc03d7 | Ruby | johnchapin/frids-backend | /lib/frids_geocoder.rb | UTF-8 | 2,183 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'ym4r/google_maps/geocoding'
require 'active_record'
require 'yaml'
require 'frids-backend-webapp/app/models/location.rb'
require 'frids-backend-webapp/app/models/tax_map.rb'
require 'frids-backend-webapp/app/helpers/locations_helper.rb'
require 'pp'
include Ym4r::Google... | true |
700b24b95e5f0a1f2f1db2d7b41caabb7c18784a | Ruby | assunta09/phase-0-tracks | /ruby/santa.rb | UTF-8 | 2,493 | 3.875 | 4 | [] | no_license | class Santa
attr_reader :ethnicity, :gender
attr_accessor :ranking, :celebrate_birthday
def initialize(gender, ethnicity)
#puts "Initializing Santa instance"
@gender = gender
@ethnicity = ethnicity
end
# setter method for gender - allows the gender to be reassigned from outside the class
#def gender=(gende... | true |
475428242318c0dca9ef1fa14474c59af99e88f8 | Ruby | matreya88/nlp_100 | /takasugi/Ruby/NLP-100-04.rb | UTF-8 | 193 | 3.109375 | 3 | [
"MIT"
] | permissive | #
check_str = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
c = check_str.split(/[,. ]/).map{|x| x.size}.delete_if{|x| x == 0}
puts c.to_s
| true |
9d638f701a6e22ce90c1c57ba396f44d4d776007 | Ruby | Henry1776/desafio_ciclos | /metodo_gen.rb | UTF-8 | 690 | 4.0625 | 4 | [] | no_license | n = ARGV[0].to_i #este valor recibe el dato que introduce el usuario
def gen(number) # aqui definimos el metodo y el parametro es number
letter = "a" # aca inicia a contar el programa para efectos de el ejercicio que es una variable
string = "" # este es el acumulador, que funciona como variable
number.tim... | true |
1036047a7398d348047135f65d80ee58a3a0ff22 | Ruby | kevin892/the-bachelor-todo-denver-web-career-031119 | /lib/bachelor.rb | UTF-8 | 1,063 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def get_first_name_of_season_winner(data, season)
data.each do |seasons, array|
if season == seasons
array.each do |x|
return x["name"].split(' ').first if x["status"]= "Winner"
end
end
end
end
def get_contestant_name(data, occupation)
data.each do |seasons, array|
arra... | true |
7cce8e10f0ccdc92dd0a6d014be70bc443df89a2 | Ruby | neslom/robodoku | /lib/puzzle.rb | UTF-8 | 532 | 3.3125 | 3 | [] | no_license | require 'pry'
class Puzzle
attr_accessor :board, :row, :column, :file
def initialize(file="./test/support/puzzle_missing_each_row.txt")
@file = file
@row = []
@column = []
board
row_maker
column_maker
end
def board
File.open(@file).readlines.map do |line|
line.delete("\n")
... | true |
970a434957388fe049c6ac99b66d3fe35d8c1d99 | Ruby | ensconced/101-programming-foundations | /small_problems/medium 1/rotate_part_2.rb | UTF-8 | 580 | 4.09375 | 4 | [] | no_license | def rotate_array(arr)
arr[1..-1] + [arr[0]]
end
def rotate_string(str)
rotate_array(str.chars).join
end
def rotate_int(int)
rotate_string(int.to_s).to_i
end
def rotate_rightmost_digits(int, n)
a = int.to_s
(a[0, (a.length - n)] + rotate_string(a[-n..-1])).to_i
end
puts rotate_rightmost_digits(735291, 1)... | true |
743c96fba54da617dee0ca5cbb3da811316cc6b0 | Ruby | drbig/ckb | /lib/devinput.rb | UTF-8 | 1,549 | 3.015625 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
# vim: ts=2 et sw=2 sts=2
#
# ckb/devinput.rb - Parse /dev/input/event blobs.
#
# © Copyright Piotr S. Staszewski 2013
# Visit http://www.drbig.one.pl for contact information.
#
# DevInput parses keyboard-like events.
#
# Developed on linux x64 and may not be portable.
#
class DevI... | true |
083e20d31306a58da5c55d22f9fa891831a411d2 | Ruby | eddiepr/MySecondRepository | /ex1.rb | UTF-8 | 223 | 2.546875 | 3 | [] | no_license | file_contents = IO.read("my_file.txt")
IO.write()
puts "What is the source file?"
first_file = gets.chomp
puts "What is the destination file?"
destination_file = gets.chomp
IO.write('first_file.txt', destination_file) | true |
023648ba93c8c6ae19944ed49dd691a6301d9173 | Ruby | heyvito/giter8.rb | /lib/giter8/renderer/executor.rb | UTF-8 | 4,168 | 3.046875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Giter8
# Module Renderer implements all mechanisms related to template rendering
module Renderer
# Executor implements methods for rendering remplates
class Executor
# Initializes the executor with a given Pairs set
def initialize(props)
@props = pro... | true |
3b30ebbce5bd5136e5c04fe31d03f990fd9b90fb | Ruby | alitaso345-sandbox/forwardable-exercises | /implement_stack/my_stack.rb | UTF-8 | 196 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'forwardable'
class MyStack
extend Forwardable
def initialize
@stack = []
end
def_delegators(:@stack, :push, :size, :clear, :pop)
def_delegator(:@stack, :last, :peek)
end
| true |
753bc514956ddefc15d128ab73a0a2804f9b1b10 | Ruby | SteveVallay/ruby-practice | /c4/queue.rb | UTF-8 | 84 | 2.984375 | 3 | [] | no_license | queue = []
queue.push "red"
queue.push "green"
puts queue.shift
puts queue.shift
| true |
06d5041645eb9ae917fe3eb2f9a97f24abfdd650 | Ruby | 709213219/iOSCodeSign.rb | /iOSCodeSign.rb | UTF-8 | 3,142 | 2.5625 | 3 | [] | no_license | =begin
需要的文件:
appName.ipa: 要重签名的ipa
embedded.mobileprovision: 用来签名的provision文件
entitlements.plist: 授权机制
distributionName: 指该签名对应的证书的名字,在keychain中可以找到对应证书的名称
步骤:
步骤一:将ipa包、mobileprovision文件、plist文件、iOSCodeSign.rb放在同一目录下。
步骤二:更改entitlements.plist文件,其中application-identifier中的BundleID必须是用来签名的证书下的BundleID,不然会出现安装ipa包不成功。
步... | true |
ff0b6eb513ea766a38a363a7305e522368474eb0 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/5ecfed60047c46a9a61f622ee411caca.rb | UTF-8 | 515 | 3.703125 | 4 | [] | no_license | NUMERALS = [
[1000, 'M'],
[900, 'CM'],
[500, 'D'],
[400, 'CD'],
[100, 'C'],
[90, 'XC'],
[50, 'L'],
[40, 'XL'],
[10, 'X'],
[9, 'IX'],
[5, 'V'],
[4, 'IV'],
[1, 'I'],
]
class Integer < Numeric
def to_roman
arabic = self.to_i
roman = ''
... | true |
33134d073ea80f44524e2f69484570fdf5ee2384 | Ruby | Toegram/oo-meowing-cat-nyc-web-062518 | /lib/meowing_cat.rb | UTF-8 | 141 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cat
attr_accessor :name
def inititalize(name)
@name = name
end
def meow
puts "meow!"
end
end
bagheera = Cat.new
| true |
b97889443da27edc7c83fbec034527d868da9ec5 | Ruby | cha63506/mob | /app/helpers/account_helper.rb | UTF-8 | 815 | 2.765625 | 3 | [] | no_license | module AccountHelper
MIN_USERNAME_LENGTH = 6
#TODO: filter chars that are not allowed
FORBIDDEN_USERNAME_CHARS = /\?|\<|\>|\'|\.|\,|\?|\[|\]|\}|\{|\=|\)|\(|\*|\&|\|^|\%|\$|\#|\`|\~|/
def form_username(email)
formed_username = email.split("@")[0]
formed_username = formed_username.gsub(FORBIDDEN... | true |
681dbd1c69be64e0904b6890cf3f808d1b8b3682 | Ruby | Codaisseur/Narnia-Return-to-Deathwater | /db/stories/390_405.rb | UTF-8 | 13,982 | 2.796875 | 3 | [] | no_license | quest = Quest.create(
ref_number: 390,
description: <<-STORY
"Oh, no!" you gasp, grabbing the Mouse by the shoulder.
"Those are the pirates who kidnapped me. They must have
been washed onto the island too!"
"Well, then," says the Mouse drawing his rapier silently.
"They'll have a piece of my mind, and a bit of my sword... | true |
243637103a88c2b9d8b6a21c3a0648f2d229c695 | Ruby | harhogefoo/AtCoder_Ruby | /ABC035/C.rb | UTF-8 | 279 | 3.203125 | 3 | [] | no_license | # This answer is TLE: 60 point
n, q = gets.split(" ").map(&:to_i)
board = '0' * n
q.times do
l, r = gets.split(" ").map(&:to_i)
mask = '0' * n
l -= 1; r -=1
mask[l..r] = '1' * mask[l..r].length
board = sprintf("%0#{n}b", (board.to_i(2) ^ mask.to_i(2)))
end
puts board
| true |
d00a829ed6f2d6ca2aa2538b5630371810b47138 | Ruby | malteschmitz/celltrack | /lib/bit_vector.rb | UTF-8 | 618 | 3.578125 | 4 | [] | no_license | # BitVector can be used to create a binary string from single bits. You can
# create a new instance and append new bits (0 or 1) using << operator.
# BitVector has no support to edit the created binary data and is optimized
# only for performance.
class BitVector
def initialize
@data = []
@base = 12... | true |
ebd8ddcfe9f0e8596b05ad1cd3958d25fbb0beef | Ruby | RamseyMahgoub/battleship | /spec/models/grid_spec.rb | UTF-8 | 2,329 | 2.8125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Grid, type: :model do
let(:game) { Game.create }
let(:game_player) { game.get_player(game.human_game_player_id) }
it 'create will make a grid for the game player' do
grid = Grid.create(game_player)
expect(grid.game_player).to be(game_player)
end
it 'create make... | true |
44abc9dbbcc4acdb08b1cab10e47989cd7a3c720 | Ruby | nekokat/codewars | /8 kyu_1/duck-duck-goose.rb | UTF-8 | 171 | 3.03125 | 3 | [
"Unlicense"
] | permissive | #Kata: Duck Duck Goose
#URL: https://www.codewars.com/kata/582e0e592029ea10530009ce
def duck_duck_goose(players, goose)
players[(goose%players.size).pred].name
end | true |
f0d98b0e466b54be1e1d3bdc3625e2f143f3e35a | Ruby | brandonlilly/adventofcode-challenges | /day5/day5.rb | UTF-8 | 1,065 | 3.40625 | 3 | [] | no_license | lines = File.readlines('input.txt').map(&:chomp)
def nice?(str)
vowels = "aeiou"
offenders = ["ab", "cd", "pq", "xy"]
num_vowels = 0
contains_double = false
(0...str.length - 1).each do |i|
char, next_char = str[i], str[i + 1]
char_group = str[i, 2]
if vowels.include?(char)
num_vowels += ... | true |
e2d8ad9a49e8960a0cb0509bca8f6f610b32d895 | Ruby | SampsonCrowley/Board | /spec/board_spec/empty_spec.rb | UTF-8 | 736 | 2.609375 | 3 | [] | no_license | #empty?_spec
require 'rspec'
require 'gameboard/board'
require 'gameboard/cell'
describe Gameboard::Board do
before do
@gameboard = Gameboard::Board
end
include_context "board_spec"
describe "#empty?" do
it "returns true if the board is empty" do
expect(valid_board.empty?).to be true
end
... | true |
c5851f7a6939eadaca46f87c3593de304568be24 | Ruby | lynnchin/robot-simulator-ruby | /spec/robot_spec.rb | UTF-8 | 3,308 | 2.921875 | 3 | [] | no_license | require 'rspec'
require_relative '../lib/robot'
describe 'Robot' do
subject { Robot.new }
describe '#new' do
it 'creates an instance of Robot' do
expect(subject).to be_a Robot
end
end
describe '#set_orientation' do
it 'returns no direction' do
expect(subject.orientation).to eq nil
... | true |
1e5fb88bced806621c8caa3af57dccdf59e15924 | Ruby | mk7upurz87/linkchecker | /html generator/AllTheLinks.rb | UTF-8 | 1,303 | 2.84375 | 3 | [] | no_license |
#This is the maximum number of pages that will get populated with links
max_populated = 10
#Number of lijnks to put on each page
links_per_page = 10
domain = 'file:///home/sdevos/shelob/mock/pages'
#Return the head of the file
def head
%{
<head>
<title>Shelob</title>
</head>
}
end
#Generate and return t... | true |
a995c48fd65a41258dd1dba861307ccd63f0e5c5 | Ruby | xea/toolbox | /lib/service/heartbeat.rb | UTF-8 | 2,512 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../core/service'
require_relative '../console/mode'
require 'monitor'
class HeartBeatService < Service
provided_features :heartbeat
attr_reader :counter
def init
@counter = 0
@observers = []
@observers_monitor = Monitor.new
end
def start(beat_count = -... | true |
62c5d5d4db0d7c84deb2887d20b2d01d52133080 | Ruby | bapemos/gilded-rose | /ruby/gilded_rose.rb | UTF-8 | 1,658 | 3.359375 | 3 | [] | no_license | class GildedRose
def initialize(items)
@items = items.collect{|i| ItemOp.new(i)}
end
def update_quality()
@items.each { |item| item.update_quality! }
end
end
class ItemOp
LEGENDARY_ARRAY = ['Sulfuras, Hand of Ragnaros']
WELL_AGED_ARRAY = ['Aged Brie']
BACKSTAGE_ARRAY = ['Backstage... | true |
d9f87bd148b2e55f60f3987f2a059912285c4921 | Ruby | katebeavis/new-zealand-scraper | /lib/page.rb | UTF-8 | 408 | 3.015625 | 3 | [] | no_license | class Page
attr_accessor :address, :title, :words
def initialize(address=nil, title=nil, words=nil)
@address = address
@title = title
@words = words
end
def parse_page
@doc ||= Nokogiri::HTML(open(address))
end
def title
@title = @doc.css("h1#firstHeading").text
end
def word_cou... | true |
7114d9481096ece17271bde94bfed786bbe57def | Ruby | puppetlabs/support-tasks | /tasks/st0317b_purge_node.rb | UTF-8 | 1,484 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | #!/opt/puppetlabs/puppet/bin/ruby
# Puppet Task to purge nodes
# This can only be run against the Puppet Primary Server.
# Parameters:
# * agent_certnames - A comma-separated list of agent certificate names.
# Original code by Nate McCurdy
# https://github.com/natemccurdy/puppet-purge_node
require 'puppet'
requir... | true |
0a950311be12b38ea0ca3fddcc0af38930ab9f2f | Ruby | kmelt/tealeaf_academy | /intro_to_programming/var_scope.rb | UTF-8 | 2,250 | 4 | 4 | [] | no_license | # VARIABLES: used to store info to be referenced and manipulated in program
# scope is determined by where var is init
# defined by block (piece of code following method invocation)
# blocks usually delimited by { } or do/end pairs
# INNER SCOPE CAN ACCESS VARS INIT IN OUTER SCOPE, BUT NOT VICE VERSA
# Variable Scop... | true |
8e1eb1d8718fb2e610a7361b6dfd9df88e7dea19 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/leap/cfab1afc559a432c8f3d21dc89e33578.rb | UTF-8 | 334 | 3.4375 | 3 | [] | no_license | class Year
attr_reader :year
def initialize(year)
@year = year
end
def leap?
return true if exceptional_century?
multiple_of_four? && !century?
end
private
def multiple_of_four?
year % 4 == 0
end
def century?
year % 100 == 0
end
def exceptional_century?
year % 400 ==... | true |
d557383bf4dd7ff8a414f32f091288b61623e0f3 | Ruby | dstrants/redd | /lib/redd/auth_strategies/web.rb | UTF-8 | 1,277 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require_relative 'auth_strategy'
module Redd
module AuthStrategies
# A typical code-based authentication, for 'web' and 'installed' types.
class Web < AuthStrategy
def initialize(client_id:, redirect_uri:, secret: '', **kwargs)
super(client_id: client_id, secret: ... | true |
f116a7844d5f5e32e5155cbc2354017644c98108 | Ruby | garybernhardt/rubies | /spec/rubies/configuration_spec.rb | UTF-8 | 2,918 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative "../../lib/rubies"
module Rubies
describe Configuration do
def capture_stderr(&block)
old_stderr = $stderr
$stderr = @stderr_string_io = StringIO.new
block.call
ensure
$stderr = old_stderr
end
def stderr
@stderr_string_io.string
end
around(:eac... | true |
55ec0de52a7ea275fddcd304ad1c5b059cdb964a | Ruby | CassBaltz/chess | /piece.rb | UTF-8 | 4,262 | 3.578125 | 4 | [] | no_license | require 'singleton'
require 'byebug'
class Piece
attr_reader :symbol, :color, :board
attr_accessor :position
def initialize(symbol, color, position, board)
@symbol = symbol
@color = color
@position = position
@board = board
end
def moves
end
def valid_move?(pos, color)
x, y = pos
... | true |
22f9dd8b8938462680ca36b258fd03936b687668 | Ruby | MagnusTiberius/code | /ruby/db/basic/dog.rb | UTF-8 | 441 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby1.9
require "active_record"
require "pp"
conn = { adapter: 'sqlite3', database: 'db/dogs.db' }
ActiveRecord::Base.establish_connection(conn)
ActiveRecord::Schema.define do
create_table :dogs do |t|
t.integer :id, :null => false
t.string :name
t.date :dob
end
end
class Dog <... | true |
4117a219e26a856a48ee60cb21ca5c628616f278 | Ruby | JoshCheek/hylite | /spec/hylite_spec.rb | UTF-8 | 1,307 | 2.953125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"WTFPL"
] | permissive | require 'stringio'
require 'spec_helpers'
require 'hylite'
RSpec.describe 'hylite' do
it 'invokes whichever hyliter "ChooseHyliter" returns' do
expect(Hylite::ChooseHyliter).to receive(:call).with("to hylite", 'some lang').and_return(-> { "hylited" })
hylited = Hylite.new("to hylite", l: "some lang").call
... | true |
57a4da7f6b88d6519a0029703993a421af947986 | Ruby | tuanlv1206/algorithm-code | /active_and_inactive/active_and_inactive.rb | UTF-8 | 544 | 3.3125 | 3 | [] | no_license | def active_and_inactive(arr,k)
temp = arr.map { |e| e }
n = arr.length
while k > 0
temp[0] = 0^arr[1]
temp[n-1] = 0^arr[n-2]
for j in (1..n-2)
temp[j]= arr[j-1]^arr[j+1]
end
for j in (0..n-1)
arr[j]= temp[j]
end
k -= 1
end
active, inactive = 0, 0
for i in (0..n-1)
... | true |
39d36580cccfd5a528f4c64738d0c653297c9fd9 | Ruby | deathowl/nagios-herald | /lib/nagios-herald/helpers/logstash_query.rb | UTF-8 | 4,356 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'uri'
require 'json'
require 'elasticsearch'
# Query Logstash with arbitrary search criteria
module NagiosHerald
module Helpers
class LogstashQuery
attr_reader :query
# Public: Initialize a new LogstashQuery object.
#
# query - A string representing the query... | true |
a5f4fb4ee95fcbf0919687d9c7d2a256d573271a | Ruby | sunghyukpark/algorithm_practice | /binary_tree.rb | UTF-8 | 1,603 | 4.125 | 4 | [] | no_license | require_relative "queue"
class Node
attr_accessor :value, :right, :left
def initialize(value)
@value = value
@right = nil
@left = nil
end
end
module BinaryTree
def BinaryTree.level_order(root)
return if root.nil?
# initialize queue of size 20 / push root value to start with
queu... | true |
4bd3c08e29b2a832d9a5a9bdb9f2234a259a656b | Ruby | metakirby5/.dots | /base/.weechat/ruby/url_hinter.rb | UTF-8 | 9,100 | 2.734375 | 3 | [
"MIT"
] | permissive | # coding: utf-8
#
# Copyright (c) 2014 Kengo Tateishi <embrace.ddd.flake.peace@gmail.com>
# https://github.com/tkengo/weechat-url-hinter
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either ... | true |
121fd42ed4e966b2b586ae22e3a6b09a427c0f18 | Ruby | himz/MobileMine | /vendor/app/models/order.rb | UTF-8 | 943 | 2.65625 | 3 | [] | no_license | class Order < ActiveRecord::Base
##
# The Order model has details of an item including:
#
# buyer_id: The user buying the product, Mandatory parameter
# seller_id: The item seller, Mandatory parameter
# item_id: Item_id for the product, Mandatory parameter
# state: Order state =>{processing, transit, ship... | true |
6976c2a540547fb67ac698cc8a04ee9c1f3a54c0 | Ruby | ReinaldoAguilar/AT03_API_test | /DanielCabero/practice4/exercise1.rb | UTF-8 | 622 | 3.390625 | 3 | [] | no_license |
def listNumber
number = Array.new 20 do | e | e*2
end
puts "#{number}"
end
def firstList
number = Array.new 20 do |e|e*3
end
puts "#{number.first}"
end
def lastList
number = Array.new 20 do |e|e*3
end
puts "#{number.last}"
end
def listCommons numbers
number = Array.new 20 do |e|... | true |
dd0d8b538129c09c210267764dd7013aaab3a380 | Ruby | yuraksisa/ysd_md_payment | /lib/payments/ysd_md_charge.rb | UTF-8 | 3,881 | 2.703125 | 3 | [] | no_license | require 'data_mapper' unless defined?DataMapper
require 'dm-types'
require 'ysd_md_yito' unless defined?Yito::Model::Finder
module Payments
#
# It represents a charge.
#
# A charge usually has a source that origins the charge. For example an
# order, a donation, a booking, ...
#
# To define the charge ... | true |
854f9c17615e994c772a6bcad274f8f8c1a65476 | Ruby | gAddun/csci305-ruby-lab | /ruby_lab.rb | UTF-8 | 5,120 | 3.9375 | 4 | [
"MIT"
] | permissive |
#!/usr/bin/ruby
###############################################################
#
# CSCI 305 - Ruby Programming Lab
#
# <Giovany> <Addun>
# <giovany.m.addun@gmail.com>
#
###############################################################
# The $bigram global variable stores the frequency of every consecutive word-pair
# ... | true |
71073575ca74e886782f79b088084758f70b6b80 | Ruby | jjlippman/ttt-with-ai-project-v-000 | /bin/tictactoe | UTF-8 | 788 | 3.84375 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
def greeting
puts "Welcome to Tic Tac Toe!"
puts "How many players? 0 - 1 - 2 "
num_player = gets.strip
end
def make_game(num)
if num=="2"
game=Game.new()
game.play
end
if num=="1"
game=Game.new(Computer.new("X"))
game.play
... | true |
7935377b928c17fc7b588f6e1cc5b23af354536b | Ruby | RSUN/clsi_breakpoints | /console_helper.rb | UTF-8 | 760 | 2.546875 | 3 | [] | no_license | def find_breakpoint(isolate, drug)
test_mic = Mic.where(isolate_id: isolate, drug_id: drug).first
mic_drug = Drug.where(drugid: test_mic['drug_id']).first
mic_isolate = Isolate.where(isolate_id: test_mic['isolate_id']).first
mic_organism = Organism.where(code: mic_isolate['organism_code']).first
puts "-- Mic to test --... | true |
2e5520abaf067bdfefbfb03ba53a0e5a7cc1346b | Ruby | DerekMaffett/data_structures_algorithms | /spec/merge_sort_spec.rb | UTF-8 | 1,128 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
require 'sort'
describe Array do
it 'merge sort should return a sorted array with insertion sort' do
[1, 32, 4, 7, 42, 16].merge_sort.must_equal [1, 4, 7, 16, 32, 42]
end
it 'merge sort should sort an inverse array' do
(1..10).to_a.reverse.merge_sort.must_equal((1..10).to_a)
end
... | true |
c3fc36dc6dd6051c0d10c1223314934ea1da0193 | Ruby | becpr/coworking-dashboard | /cowo_list.rb | UTF-8 | 983 | 2.6875 | 3 | [] | no_license | require 'twitter'
require 'csv'
require 'dotenv'
Dotenv.load
@client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret ... | true |
5f983a150f872f72f8aa2b4cfeb8250fdb1ef302 | Ruby | lewcastles/LS100 | /Hashes/no2.rb | UTF-8 | 86 | 2.515625 | 3 | [] | no_license | hasha = {name: "lewis"}
hashb = {name: "john"}
p hasha.merge!(hashb)
p hasha
p hashb | true |
5ea863b3df492443c1284aa1a8bbbe4f294f7247 | Ruby | kotovalexarian/yard-cov | /lib/yard/cov/document.rb | UTF-8 | 4,090 | 2.890625 | 3 | [
"MIT"
] | permissive | module YARD::Cov
# Wraps a yard docstring to make a nicer interface
class Document
@registered_rules = Set.new
class << self
# Shows currently registered rules
#
# @return [Array<Class>]
#
# @api private
attr_reader :registered_rules
end
# Register rule with doc... | true |
39a9e81b0654a90b4ef1ee61e5d76c7a81ab244e | Ruby | anggiimaisa/my-library | /app/model/shelf.rb | UTF-8 | 1,315 | 3.171875 | 3 | [] | no_license | class Shelf
attr_reader :shelf_id, :row_id, :column_id
def initialize(shelf_id, row_id, column_id)
@shelf_id = shelf_id
@row_id = row_id
@column_id = column_id
end
def valid?
return false unless shelf_id_valid?
return false unless row_id_valid?
return false unless column_id_valid?
... | true |
991f72eda9d4833b097ad669f136702df9021a9b | Ruby | cquiro/class_exercises | /stock_picker.rb | UTF-8 | 1,314 | 4.28125 | 4 | [] | no_license | #Array of stock prices. Each element represents a price for that day (index represents day number).
stock_prices = [17, 3, 6, 9, 15, 8, 6, 30, 10]
#Initializes the array that keeps track of the days when profit is higher
#with the first two days in the aray.
days_prof = [0, 1]
#Initilizes the buy and sell days with t... | true |
104aef66ea2762ed34bc6d0dd9bdbb38b66a04ca | Ruby | YujohnNattrass/ruby_small_problems | /easy9/welcome_strange.rb | UTF-8 | 849 | 4.15625 | 4 | [] | no_license | =begin
input: array (a persons full name 2 or more arguements)
hash (two keys :title and :occupation)
output: a string greeting using the full name and mention the person's title
rules: name can be 2 or more arguements
what if the person has no title or occupation?
data structure / algorithm
save vari... | true |
6032038bfee75b84f06985c9338452f4da3768bf | Ruby | DrAmaze/Algorithms | /dynamic_programming/lib/dynamic_programming.rb | UTF-8 | 2,982 | 3.671875 | 4 | [] | no_license | class DynamicProgramming
def initialize
@blair_cache = {1 => 1, 2 => 2}
@frog_cache = {
0 => [],
1 => [[1]],
2 => [[1, 1], [2]],
3 => [[1, 1, 1], [1, 2], [2, 1], [3]]
}
end
def blair_nums(n)
return @blair_cache[n] if @blair_cache[n]
result = blair_nums(n - 1) + blair... | true |
52755a1937298682fcc62cc4bedd5207e920e1f2 | Ruby | Slmnk/EXOS-RUBY | /exo_12.rb | UTF-8 | 321 | 3.90625 | 4 | [] | no_license | puts "Salut toi! Choisis un chiffre"
print "> "
number = gets.to_i
number.times do |i|
puts "#{i}"
end
#je ne sais pas si l'exercice est bien fait ou non, si je tape 9 ça va compter jusqu'à 8, pas jusqu'à 9, pourtant il me semble bien que c'est le plus approprié, je comprends pas pourquoi ça va pas jusque 9.
| true |
b00576ba43bcdab691cfcb79b86cc27cfcbf6a54 | Ruby | wsierradev/Launch-Academy-2017 | /challenges/cohort-stats/lib/system_check_submission.rb | UTF-8 | 470 | 3.15625 | 3 | [] | no_license | class SystemCheckSubmission
attr_reader :solution, :student
def initialize(solution, student)
@solution = solution
@student = student
end
def assign_grade(grade)
if grade >= 0
@grade = grade
else
raise InvalidGradeError, "What kinda grade is that? Try again teach.... | true |
78863d54089542eb121adeb274085b6d4f3c8383 | Ruby | apalmer0/MagicMirrorApi | /spec/services/fetch_trivia_service_spec.rb | UTF-8 | 1,552 | 2.5625 | 3 | [] | no_license | require "rails_helper"
describe FetchTriviaService do
describe ".run" do
let(:response) do
{
"response_code" => 0,
"results" => [
{
"category" => "Entertainment: Video Games",
"type" => "boolean",
"difficulty" => "hard",
"question" =... | true |
d2504d50b9f5188b33bdbb88761c8f0ffa7e60e9 | Ruby | akioh1980/nspec | /1.2/dso_5054a/ruby/transpose_waveform.rb | UTF-8 | 1,345 | 3.5 | 4 | [] | no_license | #!/usr/bin/ruby -w
require "matrix"
def read_csv_matrix_as_array_of_arrays(filename)
data=Array.new
## process each file line by line
f_in=File.new(filename,"r")
f_in.each do |line|
x=line.chomp.split(",")
## delete any elements whose size==0
x.delete_if { |element_i| (element_i.si... | true |
10dbb3696ca44ffd933a8e5c366c48b3952d239c | Ruby | mrknip/odin-ruby-exercises | /9-knights_travails/lib/pathfinder.rb | UTF-8 | 977 | 3.328125 | 3 | [] | no_license | require_relative 'board'
require_relative 'knight'
class Pathfinder
PathNode = Struct.new(:position, :parent)
class << self
def knight_moves(position, target)
raise ArgumentError, "Invalid coordinates" unless Board.valid? target
queue = [PathNode.new(position, nil)]
until queue.empty... | true |
824729239b57093bbf8602071616c7c2b494bc0e | Ruby | arvind02/HotelAutomation | /automation_main | UTF-8 | 789 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative './lib/automation_controller.rb'
controller = AutomationController.new(2, 1, 2)
puts " "
puts "Status - Current"
puts controller.status
puts " "
#Optional to check power consumption of Hotel
#puts controller.power_consumption
puts "\n\n\n"
puts controller.movement(1, 2, true) #(... | true |
f231a0221166896e23e30331cfcca875c05b3d98 | Ruby | kirinrastogi/Blood-Donors | /db/seeds.rb | UTF-8 | 871 | 3.015625 | 3 | [] | no_license | def getBloodType
case rand(8)
when 0
"o+"
when 1
"o-"
when 2
"a+"
when 3
"a-"
when 4
"b+"
when 5
"b-"
when 6
"ab+"
else
"ab-"
end
end
SIZE = 100
DONATION_SIZE = SIZE * 3
NURSE_SIZE = SIZE / 20
puts 'Creating donors and recipients and nurses'
SIZE.times do |id|
Don... | true |
9cfa94ddbe2df339557a19ffd090a565a81d2b08 | Ruby | tomorrow-lauren/phase-0 | /week-6/credit-card/my_solution.rb | UTF-8 | 3,442 | 4.21875 | 4 | [
"MIT"
] | permissive | # Class Warfare, Validate a Credit Card Number
# I worked on this challenge [with: Devin Mandelbaum ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: Take a 16 digit number.
# Output: If it's valid, it will return true, otherwise false.
# Steps: First, verify that it's 16 digits long by converting it i... | true |
41a744fec770d89523ed1b668c0ddfcde4a06c9c | Ruby | xiuzhong/groupdate2 | /lib/groupdate/sql_server_group_clause.rb | UTF-8 | 3,835 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'json'
module Groupdate
module SqlServerGroupClause
def sql_server_group_clause(tzid)
time_zone = to_windows_tz(tzid)
raise Groupdate::Error, "unknown timezone: #{tzid}" if time_zone.nil?
datetime_column = "(CAST(#{column} AS DATETIME2(3)) AT TIME ZONE 'UTC')"
if day_start.to_i >... | true |
324134df1968e2dbd21c7fb9f69d70b2f748a248 | Ruby | grzegorz-jakubiak/checkers-game | /lib/checkers/ai/tree.rb | UTF-8 | 492 | 2.890625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Checkers
module AI
class Tree
attr_reader :root
def self.build(board, depth)
Tree.new(Node.new(board, :ai, depth))
end
def initialize(node)
@root = node
end
def depth
current_depth = 0
children = @root.chi... | true |
4150d41c165ab96baac8d0bec5065535266211a0 | Ruby | watr-li/blog | /_plugins/kramdown_codeblock_syntax.rb | UTF-8 | 1,193 | 2.828125 | 3 | [] | no_license | require 'kramdown'
require 'pygments'
module Kramdown
module Converter
class Html < Base
def convert_codeblock(el, indent)
attr = el.attr.dup
attr["class"] ||= ""
attr["class"] += " highlight"
lang = detect_code_language!(el)
lang ||= 'text'
highlighted_co... | true |
80e5f49f8c10628ab3c61d21a87ba7f3194081fd | Ruby | MarcelRaschke/brew | /Library/Homebrew/cmd/desc.rb | UTF-8 | 2,587 | 2.765625 | 3 | [
"CC-BY-4.0",
"BSD-2-Clause"
] | permissive | #: * `desc` <formula>:
#: Display <formula>'s name and one-line description.
#:
#: * `desc` [`--search`|`--name`|`--description`] (<text>|`/`<text>`/`):
#: Search both name and description (`--search` or `-s`), just the names
#: (`--name` or `-n`), or just the descriptions (`--description` or `-d`) for
#: ... | true |
9cf9e3087e7a55d7b928f65c1301998595033dbf | Ruby | rammazzoti2000/Repl.IT.Ruby | /depth_first_search.rb | UTF-8 | 350 | 3.296875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
def depth_first_search(graph, node = 0, visited = [])
return if visited.include?(node)
visited << node
graph[node].each { |n| depth_first_search(graph, n, visited) }
visited
end
p depth_first_search(
0 => [2],
1 => [4],
2 => [5, 0, 3],
3 => [2],
4 => [1, 5],
5 => [4,... | true |
b79a4ecdd9bb077bbdd31bd3bf5765f842b14198 | Ruby | melatran/turing_lessons | /mod1/individual_challenges/museo/lib/curator.rb | UTF-8 | 1,018 | 3.328125 | 3 | [] | no_license | class Curator
attr_reader :photographs, :artists
def initialize
@photographs = []
@artists = []
end
def add_photograph(photo)
@photographs << photo
end
def add_artist(artist)
@artists << artist
end
def find_artist_by_id(id)
@artists.find do |artist|
artist.id == id
end
... | true |
4f08e34c8d4234e973d12bdeca6534c728769ce2 | Ruby | Jtpiland/craft_time_2105 | /lib/person.rb | UTF-8 | 517 | 3.09375 | 3 | [] | no_license | require './lib/craft'
class Person
attr_reader :name,
:interests,
:supplies
def initialize(info)
@name = info[:name]
@interests = info[:interests]
@supplies = Hash.new { |hash, key| hash[key] = 0 }
end
def add_supply(supply, quantity)
@supplies[supply] += quantity
... | true |
87c9cd7a81133de205904b57b59ef75448239bfd | Ruby | parhaml/stock_trader | /stock.rb | UTF-8 | 318 | 3.578125 | 4 | [] | no_license | def stock_picker(rates)
total = 0
answer = []
rates.each do |buy|
rates.each do |sell|
if ((buy < sell && rates.index(buy) < rates.index(sell))) && sell - buy > total
total = sell - buy
answer = [rates.index(buy), rates.index(sell)]
end
end
end
puts answer.inspect
end
| true |
3763d97649c44c8cba771b3a0ba0f24442e8812b | Ruby | djanowski/snippets | /spec/snippet_spec.rb | UTF-8 | 2,147 | 2.96875 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/spec_helper'
describe Snippet do
it "is identified by slug" do
create(:slug => 'homepage')
Snippet.get('homepage').should == 'Lorem ipsum'
Snippet.get('Homepage').should == 'Lorem ipsum'
lambda { create(:slug => '') }.should raise_error
end
it "does nothing a... | true |
aad49e9a842cc3153a542f12ab61f8f4e1ca7cd0 | Ruby | undeadlabs/wukong | /lib/wukong/runner/boot_sequence.rb | UTF-8 | 3,539 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | require_relative('help_message')
module Wukong
class Runner
# The boot sequence of a runner consists of the following phases,
# each corresponding to a method provided by this module.
#
# * #load -- loads all application code
# * #configure -- configures settings from core Wukong, any loaded plug... | true |
065724a350a72bd3bbb83e5d61e06d7d4b4cf2c2 | Ruby | gilesbowkett/reek | /bin/reek | UTF-8 | 429 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# Created on 2008-2-17.
# Copyright (c) 2008 Kevin Rutherford, Rutherford Software Ltd. All rights reserved.
require File.join(File.dirname(__FILE__), '../lib/', 'reek')
require File.join(File.dirname(__FILE__), '../lib/', 'reek/options')
files = Reek::Options.parse(ARGV)
files.each do |file|
... | true |
fdb5380c449b6ab55c185911178d27bf5a836228 | Ruby | cyberarm/against_the_clock | /against_the_clock.rb | UTF-8 | 4,630 | 2.953125 | 3 | [] | no_license | require "gosu"
# require_relative "lib/menu"
require_relative "lib/text"
Modifier = Struct.new(:name, :value, :dangerous_amount, :fatal_amount, :decrease_per_second, :time_at_last_change, :bar_color, :death_messages)
class Window < Gosu::Window
def initialize
$window = self
super(800, 600, false)
@dead =... | true |
0907714151bd03dd0603464a7f0a5b72eb2c68a3 | Ruby | gglin/project-euler | /ruby_all/296.rb | UTF-8 | 494 | 3.28125 | 3 | [] | no_license | # Problem 296: Angular Bisector and Tangent
# http://projecteuler.net/problem=296
#
# Given is an integer sided triangle ABC with BC ≤AC ≤AB.k is the angular bisector of angle ACB.m is the tangent at C to the circumscribed circle of ABC.n is a line parallel to m through B.
# The intersection of n and k is called E.
#... | true |
5276fac435b0bbd449b3b0ba15ff9e7e6b2b2647 | Ruby | tanordheim/unify-crm | /app/models/account.rb | UTF-8 | 2,505 | 3.140625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
#
# Accounts defines an account used to track income and expenses within a
# financial budget.
class Account
TYPES = {
'0' => :balance,
'10' => :income,
'20' => :expense,
'30' => :activa,
'40' => :passiva
}
# Accounts are Mongoid documents.
include Mongoid::Document
#... | true |
c7fa883646e91e36cf5dfa36b05b2feda38ec2eb | Ruby | kvokka/alphavantage_ruby | /lib/alphavantage/forex.rb | UTF-8 | 1,319 | 2.75 | 3 | [
"MIT"
] | permissive | module Alphavantage
class Forex
include Validations
FUNCTIONS = {
exchange_rates: 'CURRENCY_EXCHANGE_RATE',
intraday: 'FX_INTRADAY',
daily: 'FX_DAILY',
weekly: 'FX_WEEKLY',
monthly: 'FX_MONTHLY'
}
def initialize(from_symbol:,to_symbol:)
@from_symbol = from_symbol
... | true |
bd396489ededb1a7a9a5ed8428bfb343891dfed5 | Ruby | mukesh-kumar1905/ruby | /rack/response/config.ru | UTF-8 | 548 | 2.875 | 3 | [] | no_license | class Hello
def self.call(env)
res = Rack::Response.new
# This will automatically set the Content-Length header for you
res.write "Hello from Rack!"
# returns the standard [status, headers, body] array
res.finish
#same as returning [200, {"Content-type"=>"text/html"},["Hello from Rack!"]]
# You ... | true |
c66f7650abdd460b461c9f6aa8e8cf10a912c3ba | Ruby | yhunglee/agriculture_webapp | /app/controllers/fruits_controller.rb | UTF-8 | 6,060 | 2.5625 | 3 | [] | no_license | class DateformatError < StandardError ; end
class FruitsController < VegetablesController
layout "fruit"
def bulletin_board
@specifiedFruits = specified_fruits_search(params["name"], params["code"], params["market"], params["kind"], params["date"])
respond_to do |format|
format.html
format.js {}
end
e... | true |
7481d8685e8cdc68483d3ac23b438578e205dfed | Ruby | JuanFdS/case-classes-for-ruby | /src/case_class.rb | UTF-8 | 2,763 | 3.203125 | 3 | [] | no_license | class Class
def case_class(with: {})
extend CaseClass::ClassBehaviour
include CaseClass::InstanceBehaviour
self.class_parameters = with
self
end
end
module CaseClass
module ClassBehaviour
attr_reader :class_parameters
def class_parameters=(class_parameters)
@class_parameters = clas... | true |
996f0ab71e68d1910455a5a0dd5735a1a9622284 | Ruby | danarchy85/danarchy_sys | /lib/danarchy_sys/ssh.rb | UTF-8 | 1,196 | 2.640625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | require 'open3'
require 'shellwords'
class SSH
def self.new(connector, opts = {})
# connector: { ipv4: "str", ssh_user: "str", ssh_key: "str" }
# options: { command: "str", timeout: int, quiet: true|false }
opts[:timeout] ||= 30
opts[:quiet] ||= false
pid, stdout, stderr = nil
ssh = "ssh -... | true |
a0890407332fefeb64014dd5b594199b1f29bdec | Ruby | secretariat/citrusgraph | /app/helpers/diagrams_helper.rb | UTF-8 | 1,319 | 2.59375 | 3 | [] | no_license | module DiagramsHelper
def get_total(diagrams)
n = 0
diagrams.each do |d|
n += d.val
end
return n
end
def get_diagram_url(diagrams,name)
arr = Array.new
diagrams.each do |d|
arr << d.val
end
Gchart.pie(
title: name,
bg: 'efefef',
legend: ['yes', 'no', 'i do not know'],
... | true |
b89f159844528101c509db1dec4ca39cf166902c | Ruby | miguelgraz/searcher | /searcher.rb | UTF-8 | 836 | 2.609375 | 3 | [] | no_license | require 'sinatra'
require 'yaml'
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'oauth'
require 'googleajax'
get '/' do
"hello"
end
get '/q/:word' do
@tweets = []
@googles = []
tw_search("http://search.twitter.com/search.json?rpp=4&q=#{params[:word]}")
goo_search(params[:word])
... | true |
5a341b0468189e8ed9cafeb0dfd081db751d3209 | Ruby | vishnu403/cricket_problem | /main/probabilities.rb | UTF-8 | 450 | 3.203125 | 3 | [] | no_license | require "pickup"
class Probability
attr_accessor :probability
def initialize(dot, single, double, triple, four, five, six, out)
@probability = {
"dot" => dot,
"single" => single,
"double" => double,
"triple" => triple,
"four" => four,
"five" => five,
"six... | true |
ef0c2c41f3768855f8aa32fd88f5955905ea1f8b | Ruby | fw-jjohnson-test/s-99-ruby | /problem10.rb | UTF-8 | 1,097 | 3.5625 | 4 | [] | no_license | ###############################################################################
# Run-length encoding of a list.
# Use the result of problem P09 to implement the so-called run-length encoding data
# compression method. Consecutive duplicates of elements are encoded as tuples (N, E)
# where N is the number of duplicat... | true |
37379b8586a611b669c752f2d03639b1274238cc | Ruby | MITLibraries/thing | /app/models/archivematica_course.rb | UTF-8 | 641 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | class ArchivematicaCourse
# If `code_dw` is a numeric code, pad to two digits.
# If `code_dw` starts with a number, preface it with `Course_`
# If `code_dw` is not numeric, use it without modification.
def self.format_course(code_dw)
return code_dw unless starts_with_number?(code_dw)
# if entirely numer... | true |
f92574577dd58ce46fd63589b093065314fc7d78 | Ruby | mtcmorris/antwars-bot | /ruby_starter_package/lib/bot.rb | UTF-8 | 558 | 3.265625 | 3 | [] | no_license | require 'ant_engine'
require 'util/logger'
class Bot
def self.run(ai = AntEngine::AI.new)
bot = new
ai.setup do |ai|
bot.setup ai
end
ai.run do |ai|
bot.run ai
end
end
def setup(ai)
@logger = Logger.new
end
def run(ai)
# your turn code here
@logger.log "Ran turn"
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.