source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/radios/collection.rb
Ruby
mit
92
main
2,603
module GOVUKDesignSystemFormBuilder module Elements module Radios class Collection < Base include Traits::Error include Traits::Hint include Traits::Supplemental def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/radios/collection_radio_button.rb
Ruby
mit
92
main
2,210
module GOVUKDesignSystemFormBuilder module Elements module Radios class CollectionRadioButton < Base include Traits::Hint include Traits::CollectionItem # @param link_errors [Boolean] used to control the id generated for radio buttons. The # error summary requires that the...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/check_boxes/label.rb
Ruby
mit
92
main
854
module GOVUKDesignSystemFormBuilder module Elements module CheckBoxes class Label < Base using PrefixableArray include Traits::Localisation def initialize(builder, object_name, attribute_name, checkbox, value:, link_errors: true) super(builder, object_name, attribute_name...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/check_boxes/collection_check_box.rb
Ruby
mit
92
main
1,410
module GOVUKDesignSystemFormBuilder module Elements module CheckBoxes class CollectionCheckBox < Base include Traits::CollectionItem include Traits::Hint def initialize(builder, object_name, attribute_name, checkbox, hint_method = nil, link_errors: false) super(builder, ob...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/check_boxes/fieldset_check_box.rb
Ruby
mit
92
main
1,292
module GOVUKDesignSystemFormBuilder module Elements module CheckBoxes class FieldsetCheckBox < Base include Traits::Label include Traits::Hint include Traits::HTMLAttributes include Traits::FieldsetItem def initialize(builder, object_name, attribute_name, value, unch...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/check_boxes/collection.rb
Ruby
mit
92
main
2,664
module GOVUKDesignSystemFormBuilder module Elements module CheckBoxes class Collection < Base include Traits::Error include Traits::Hint include Traits::Supplemental def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint:, legend:,...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb
Ruby
mit
92
main
1,608
module GOVUKDesignSystemFormBuilder module Containers class CheckBoxesFieldset < Base include Traits::Error include Traits::Hint def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, small:, form_group:, multiple:, **kwargs, &block) fail LocalJumpError, 'no bloc...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/check_boxes.rb
Ruby
mit
92
main
699
module GOVUKDesignSystemFormBuilder module Containers class CheckBoxes < Base include Traits::HTMLClasses include Traits::HTMLAttributes def initialize(builder, small:, **kwargs) super(builder, nil, nil) @small = small @html_attributes = kwargs end def html...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/fieldset.rb
Ruby
mit
92
main
1,430
module GOVUKDesignSystemFormBuilder module Containers class Fieldset < Base include Traits::HTMLAttributes def initialize(builder, object_name = nil, attribute_name = nil, legend: {}, caption: {}, described_by: nil, **kwargs, &block) super(builder, object_name, attribute_name, &block) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/form_group.rb
Ruby
mit
92
main
628
module GOVUKDesignSystemFormBuilder module Containers class FormGroup < Base include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, object_name, attribute_name, **kwargs) super(builder, object_name, attribute_name) @html_attributes = kwargs end...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/radios.rb
Ruby
mit
92
main
812
module GOVUKDesignSystemFormBuilder module Containers class Radios < Base include Traits::Hint include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, inline:, small:, **kwargs) super(builder, nil, nil) @inline = inline @small ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/supplemental.rb
Ruby
mit
92
main
352
module GOVUKDesignSystemFormBuilder module Containers class Supplemental < Base def initialize(builder, object_name, attribute_name, content) super(builder, object_name, attribute_name) @content = content end def html return if @content.blank? tag.div { @conten...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb
Ruby
mit
92
main
1,292
module GOVUKDesignSystemFormBuilder module Containers class RadioButtonsFieldset < Base include Traits::Hint include Traits::Error def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, inline:, small:, form_group:, **kwargs, &block) fail LocalJumpError, 'no bloc...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/containers/button_group.rb
Ruby
mit
92
main
298
module GOVUKDesignSystemFormBuilder module Containers class ButtonGroup < Base def initialize(builder, buttons) super(builder, nil, nil) @buttons = buttons end def html tag.div(@buttons, class: %(#{brand}-button-group)) end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/select.rb
Ruby
mit
92
main
271
module GOVUKDesignSystemFormBuilder module Traits module Select private def classes combine_references(%(#{brand}-select), error_class) end def error_class %(#{brand}-select--error) if has_errors? end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/caption.rb
Ruby
mit
92
main
374
module GOVUKDesignSystemFormBuilder module Traits module Caption private def caption_element @caption_element ||= if @caption.nil? Elements::Null.new else Elements::Caption.new(*bound, **@caption) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/label.rb
Ruby
mit
92
main
606
module GOVUKDesignSystemFormBuilder module Traits module Label private def label_element @label_element ||= if @label.nil? Elements::Null.new else Elements::Label.new(*bound, caption: @caption, **label_content)...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/hint.rb
Ruby
mit
92
main
670
module GOVUKDesignSystemFormBuilder module Traits module Hint def hint_id return unless hint_element.active? build_id('hint') end private def hint_element @hint_element ||= if @hint.nil? Elements::Null.new else ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/html_attributes.rb
Ruby
mit
92
main
290
module GOVUKDesignSystemFormBuilder module Traits module HTMLAttributes using HTMLAttributesUtils def attributes(html_attributes = {}) options .deep_merge_html_attributes(html_attributes) .deep_tidy_html_attributes end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/date_input.rb
Ruby
mit
92
main
3,585
module GOVUKDesignSystemFormBuilder module Traits module DateInput using PrefixableArray MULTIPARAMETER_KEY = { year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6 }.freeze SEGMENT_METHOD = { year: :year, month: :month, day: :day, hour: :hour, minute: :min, second: :sec }.freeze def...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/input.rb
Ruby
mit
92
main
3,416
module GOVUKDesignSystemFormBuilder module Traits module Input def initialize(builder, object_name, attribute_name, hint:, label:, caption:, prefix_text:, suffix_text:, width:, extra_letter_spacing:, form_group:, before_input:, after_input:, **kwargs, &block) super(builder, object_name, attribute_na...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/localisation.rb
Ruby
mit
92
main
1,957
module GOVUKDesignSystemFormBuilder module Traits module Localisation # starts with an letter that is followed by other word characters or # spaces, zero or more times BASE_NAME_REGEXP = %r{[[:alpha:]](?:[\w\s]*)} def localised_text(context, segment = nil) return unless @object_na...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/supplemental.rb
Ruby
mit
92
main
346
module GOVUKDesignSystemFormBuilder module Traits module Supplemental def supplemental_id return if @block_content.blank? build_id('supplemental') end private def supplemental_content @supplemental_content ||= Containers::Supplemental.new(*bound, @block_content) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/html_classes.rb
Ruby
mit
92
main
440
module GOVUKDesignSystemFormBuilder module Traits module HTMLClasses # combine all the classes in *args with any keys from **kwargs # where the value is true. Roughly based on the behaviour from # Rails' class_names, but recreated here as that returns a string # where we want an array. ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/collection_item.rb
Ruby
mit
92
main
303
module GOVUKDesignSystemFormBuilder module Traits module CollectionItem private def retrieve(item, method) case method when Symbol, String item.send(method) when Proc capture { method.call(item).to_s } end end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/content_before_and_after.rb
Ruby
mit
92
main
427
module GOVUKDesignSystemFormBuilder module Traits module ContentBeforeAndAfter def before_input_content build_content(@before_input) end def after_input_content build_content(@after_input) end private def build_content(content) case content when...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/fieldset_item.rb
Ruby
mit
92
main
2,054
module GOVUKDesignSystemFormBuilder module Traits module FieldsetItem using PrefixableArray def html safe_join([item, @conditional_content]) end private def class_prefix %(#{brand}-#{input_type}) end def item tag.div(class: %(#{class_prefix}__ite...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/traits/error.rb
Ruby
mit
92
main
402
module GOVUKDesignSystemFormBuilder module Traits module Error def error_id return unless has_errors? build_id('error') end private def error_element @error_element ||= Elements::ErrorMessage.new(*bound) end def set_message_safety(message) conf...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
util/version_formatter.rb
Ruby
mit
92
main
760
class VersionFormatter attr_accessor :lib, :version, :exact def initialize(lib, version, exact) self.lib = lib self.version = version self.exact = exact end def to_a [lib, full_version, sub_version].compact end private # the 'exact' Rails version as set in the gemspec or # RAILS_...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
htmltoword.gemspec
Ruby
mit
91
master
1,303
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'htmltoword/version' Gem::Specification.new do |spec| spec.name = "htmltoword" spec.version = Htmltoword::VERSION spec.authors = ["Nicholas Frandsen, Cristina Matonte"] ...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
lib/htmltoword.rb
Ruby
mit
91
master
480
# encoding: UTF-8 require 'action_controller' require 'action_view' require 'nokogiri' require 'zip' require 'htmltoword/configuration' module Htmltoword class << self def configure yield configuration end def configuration @configuration ||= Configuration.new end alias :config :con...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
lib/htmltoword/htmltoword_helper.rb
Ruby
mit
91
master
1,343
module Htmltoword module HtmltowordHelper def template_file template_file_name=nil default_path = File.join(::Htmltoword.config.default_templates_path, 'default.docx') template_path = template_file_name.present? ? File.join(::Htmltoword.config.custom_templates_path, template_file_name) : '' Fil...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
lib/htmltoword/configuration.rb
Ruby
mit
91
master
521
module Htmltoword class Configuration attr_accessor :default_templates_path, :custom_templates_path, :default_xslt_path, :custom_xslt_path def initialize @default_templates_path = File.join(File.expand_path('../', __FILE__), 'templates') @custom_templates_path = File.join(File.expand_path('../', ...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
lib/htmltoword/document.rb
Ruby
mit
91
master
2,484
module Htmltoword class Document class << self include HtmltowordHelper def create content, file_name, template_name=nil file_name += extension unless file_name =~ /\.docx$/ template_name += extension if template_name && !(template_name =~ /\.docx$/) word_file = new(template_f...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
lib/htmltoword/action_controller.rb
Ruby
mit
91
master
1,548
require 'action_controller' unless defined? Mime::DOCX Mime::Type.register "application/vnd.openxmlformats-officedocument.wordprocessingml.document", :docx end ActionController::Renderers.add :docx do |filename, options| unless formats.include?(:docx) || Rails.version < '3.2' formats[0] = :docx end if opt...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/xslt_simple_text_style_spec.rb
Ruby
mit
91
master
21,655
require 'spec_helper' describe "XSLT to make text bold or italic" do it "transforms simple b, strong, em and italic tags" do html = <<-EOL <!DOCTYPE html> <html> <head></head> <body> <div> Testing <b>bold</b>, <i>italic</i>, <strong>strong</strong>, <em>em</em> text within a div.</div> <p> Testi...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/xslt_spec.rb
Ruby
mit
91
master
3,225
require 'spec_helper' describe "XSLT" do it "transforms an empty html doc into an empty docx doc" do html = '<html><head></head><body></body></html>' compare_resulting_wordml_with_expected(html, "<?xml version=\"1.0\" encoding=\"utf-8\"?> <w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/xslt_heading_spec.rb
Ruby
mit
91
master
18,549
require 'spec_helper' describe "XSLT for Headings" do it "transforms heading tags in the body" do html = <<-EOL <!DOCTYPE html> <html> <head></head> <body> <h1>Heading 1</h1> <h2>Heading 2</h2> <h3>Heading 3</h3> <h4>Heading 4</h4> <h5>Heading 5</h5> <h6>Heading 6</h6> </body> ...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/xslt_alignment_spec.rb
Ruby
mit
91
master
14,589
require 'spec_helper' describe "XSLT to align div, p and td tags" do it "transforms a p element with the correct alignment." do html = <<-EOL <!DOCTYPE html> <html> <head></head> <body> <p style="text-align:center;width:100%"> p using text-aligned center</p> <p style="text-align:right;width:100%...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/spec_helper.rb
Ruby
mit
91
master
678
require 'rubygems' require 'bundler/setup' require 'htmltoword' def compare_resulting_wordml_with_expected(html, resulting_wordml) source = Nokogiri::HTML(html.gsub(/>\s+</, "><")) xslt = Nokogiri::XSLT( File.read(Htmltoword::Document.default_xslt_template)) result = xslt.transform(source) if compare_content_o...
github
nickfrandsen/htmltoword
https://github.com/nickfrandsen/htmltoword
spec/xslt_tables_spec.rb
Ruby
mit
91
master
18,180
require 'spec_helper' describe "XSLT for tables" do it "transforms a table into a tbl element" do html = <<-EOL <!DOCTYPE html> <html> <head></head> <body> <table> <tbody> <tr> <td>Hello</td> </tr> </tbody> </table> </body> </html> EOL ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
Gemfile
Ruby
mit
91
master
689
# frozen_string_literal: true source 'https://rubygems.org' gemspec group :runtime, :cli do gem 'docopt', '~> 0.6' # for argument parsing end group :runtime, :all do gem 'base64', '~> 0.3.0' # for base64 encoding gem 'cgi', '~> 0.4' # url decode / html escape gem 'uri', '~> 1.1' # for url parsing end group...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
ctf_party.gemspec
Ruby
mit
91
master
2,188
# frozen_string_literal: true require_relative 'lib/ctf_party/version' Gem::Specification.new do |s| s.name = 'ctf-party' s.version = CTFParty::VERSION s.platform = Gem::Platform::RUBY s.summary = 'A CLI tool & library to enhance and speed up script/exploit ' \ 'w...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_base64.rb
Ruby
mit
91
master
600
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_base64_to_b64 assert_equal('U3VwZXIgbGliIQ==', 'Super lib!'.to_b64) end def test_base64_to_b64! my_str = 'Ruby' my_str.to_b64! assert_equal('UnVieQ==', my_str) end def test_base64_fro...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_rot.rb
Ruby
mit
91
master
713
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_rot_rot assert_equal('Uryyb jbeyq!', 'Hello world!'.rot) assert_equal('Spwwz hzcwo!', 'Hello world!'.rot(shift: 11)) assert_equal('Hello world!', 'Uryyb jbeyq!'.rot) assert_equal('Hello world!'...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_case.rb
Ruby
mit
91
master
496
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_case_randomcase my_str = 'SELECT * FROM' refute_equal(my_str, my_str.randomcase) end skip def test_case_randomcase! # skip end def test_case_alternatecase my_str = 'SELECT * FROM' ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_digest.rb
Ruby
mit
91
master
1,522
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_digest_md5 assert_equal('556cc23863fef20fab5c456db166bc6e', 'noraj'.md5) end def test_digest_md5! a = '\o/' a.md5! assert_equal('881419964e480e66162da521ccc25ebf', a) end def test_dig...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_dec.rb
Ruby
mit
91
master
682
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_dec_to_dec assert_equal('474316169578', 'noraj'.to_dec) end skip def test_dec_to_dec! # skip end def test_dec_from_dec assert_equal('ctf-party', '1834615104613964215417'.from_dec) end ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_misc.rb
Ruby
mit
91
master
325
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_misc_istrip assert_equal('HelloWorld!', "\t\n\v\f\r Hello \t\n\v\f\r World !\t\n\v\f\r ".istrip) assert_equal('7374726970', '73 74 72 69 70'.istrip) end skip def test_misc_istrip! # skip end...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_defang.rb
Ruby
mit
91
master
9,316
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_defang_defang_ip assert_equal('1[.]1[.]1[.]1', '1.1.1.1'.defang_ip) assert_equal('invalid', 'invalid'.defang_ip) assert_equal('127.0.0', '127.0.0'.defang_ip) assert_equal('x1.1.1.1', 'x1.1.1.1'...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_cgi.rb
Ruby
mit
91
master
3,943
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_cgi_urlencode my_url = 'http://vulnerable.site/search.aspx?txt="><script>alert(/Rubyfu/.source)</script>' my_url_component = "'Stop!' said Fred" assert_equal('http://vulnerable.site/search.aspx?txt...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_leet.rb
Ruby
mit
91
master
400
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_leet_leet assert_equal('7h3 qu1ck 8r0wn f0x jump5 0v3r 7h3 14zy d06', 'The quick brown fox jumps over the lazy dog'.leet) assert_equal('P4ck my 80x w17h f1v3 d0z3n 11qu0r ju65', 'Pack my box with five ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_flag.rb
Ruby
mit
91
master
617
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_flag_flag hash = { prefix: 'sigsegv', suffix: '', enclosing: ['{', '}'], digest: 'md5' } String.flag = hash assert_equal(hash, String.flag) assert_equal('sigsegv{a5bec9e2a86b6b70d288451eb38dfec...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_xor.rb
Ruby
mit
91
master
788
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_xor_ulxor assert_equal("he\a\t\u0016", 'hello'.ulxor('key')) assert_equal("he\a\t\u0016", 'key'.ulxor('hello')) end skip def test_xor_ulxor! # skip end def test_xor_alxor assert_equal...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_bin.rb
Ruby
mit
91
master
1,775
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_bin_to_bin my_str = 'binary' assert_equal('011000100110100101101110011000010111001001111001', my_str.to_bin) assert_equal('010001101001011001110110100001100100111010011110', my_str.to_bin(bitnumber...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_network.rb
Ruby
mit
91
master
5,128
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_network_ipv4? assert_equal(true, '1.1.1.1'.ipv4?) assert_equal(true, '127.0.0.1'.ipv4?) assert_equal(true, '0.0.0.0'.ipv4?) assert_equal(true, '255.255.255.255'.ipv4?) assert_equal(false, '...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
test/test_string_hex.rb
Ruby
mit
91
master
4,518
# frozen_string_literal: false require_relative 'test_helper' class CTFPartyTest < Minitest::Test def test_hex_hex2dec assert_equal('255', 'ff'.hex2dec) assert_equal('243', '\xf3'.hex2dec(prefix: '\x')) assert_equal('474316169578', '6e6f72616a'.hex2dec) assert_equal('474316169578', '\\x6e\\x6f\\x72\...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party.rb
Ruby
mit
91
master
434
# frozen_string_literal: true require 'ctf_party/version' # Project internal require 'ctf_party/base64' require 'ctf_party/binary' require 'ctf_party/case' require 'ctf_party/cgi' require 'ctf_party/dec' require 'ctf_party/defang' require 'ctf_party/digest' require 'ctf_party/flag' require 'ctf_party/hex' require 'ctf...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/dec.rb
Ruby
mit
91
master
1,353
# frozen_string_literal: true class String # Encode a string into decimal (string to hexadecimal then hexadecimal to decimal) # @param opts [Hash] optional parameters (see {String#to_hex} and {String#hex2dec}) # @return [String] the decimal encoded string # @example # 'noraj'.to_dec # => "474316169578" d...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/binary.rb
Ruby
mit
91
master
3,384
# frozen_string_literal: true class String # Encode a string into binary # @param opts [Hash] optional parameters # @option opts [Symbol] :bitnumbering Display output with most significant bit # first (`:MSB` default) or least significant bit first (`:LSB`). # @return [String] the binary encoded string #...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/defang.rb
Ruby
mit
91
master
7,385
# frozen_string_literal: true require 'ipaddr' require 'uri' class String # Defang the string if it is an IP address # @param opts [Hash] optional parameters # @option opts [Symbol] :unvalid Default value: `false`. # If `unvalid: false`, only valid IP address will be defanged. # If `unvalid: true`, ever...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/flag.rb
Ruby
mit
91
master
2,695
# frozen_string_literal: true require 'ctf_party/digest' class String # The flag configuration hash. See {.flag=}. @@flag = { prefix: '', suffix: '', enclosing: ['{', '}'], digest: nil } # Show the actual flag configuration. See {.flag=}. def self.flag @@flag end # Update the flag ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/leet.rb
Ruby
mit
91
master
655
# frozen_string_literal: true class String # Transform into leet speak (l337 5p34k) # @example # 'The quick brown fox jumps over the lazy dog'.leet # => "7h3 qu1ck 8r0wn f0x jump5 0v3r 7h3 14zy d06" # 'leet speak'.leet # => "1337 5p34k" def leet tr = { 'T' => '7', 'E' => '3', 'I' =>...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/rot.rb
Ruby
mit
91
master
1,901
# frozen_string_literal: true class String # "Encrypt / Decrypt" the string with Caesar cipher. This will shift the # alphabet letters by `n`, where `n` is the integer key. The same function # is used for encryption / decryption. # @param opts [Hash] optional parameters # @option opts [Integer] :shift The sh...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/case.rb
Ruby
mit
91
master
1,143
# frozen_string_literal: true class String # Change the case of characters randomly # @return [String] the case modified string # @example # 'SELECT * FROM'.randomcase # => "SElECt * frOm" # 'SELECT * FROM'.randomcase # => "selECT * FROm" def randomcase chars.map { |c| rand(0..1).zero? ? c.downcase...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/digest.rb
Ruby
mit
91
master
3,524
# frozen_string_literal: true # Ruby standard library require 'digest' class String # Calculate the md5 hash of the string. # @see https://ruby-doc.org/stdlib-2.6.1/libdoc/digest/rdoc/Digest/MD5.html # @return [String] md5 hash # @example # 'noraj'.md5 # => "556cc23863fef20fab5c456db166bc6e" def md5 ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/network.rb
Ruby
mit
91
master
5,616
# frozen_string_literal: true require 'ipaddr' require 'uri' class String # Is the string an IPv4? # @return [Boolean] `true` if the string is a valid IPv4, `false` else. # @example # '1.1.1.1'.ipv4? # => true # '127.0.0.300'.ipv4? # => false def ipv4? IPAddr.new(self).ipv4? rescue IPAddr::Inval...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/hex.rb
Ruby
mit
91
master
12,589
# frozen_string_literal: true class String # Encode an hexadecimal string to a decimal string # @param opts [Hash] optional parameters # @option opts [String] :prefix Prefix of the input. Default value is a void # string. Example of values: `0x`, `\x`, `\\x`. # @option opts [Symbol] :padding Minimum size o...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/misc.rb
Ruby
mit
91
master
496
# frozen_string_literal: true class String # Remove leading and trailing whitespace (like {String#strip}) but also all # inner whitespace. # @return [String] the whitespace-free string # @example # "\t\n\v\f\r Hello \t\n\v\f\r World !\t\n\v\f\r ".istrip # => "HelloWorld!" # '73 74 72 69 70'.istrip # =>...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/cgi.rb
Ruby
mit
91
master
4,985
# frozen_string_literal: true # Ruby standard library require 'cgi' require 'uri' class String # URL-encode the URL string (RFC 2396) # @return [String] the URL-encoded string # @example # 'http://vulnerable.site/search.aspx?txt="><script>alert(/Rubyfu/.source)</script>'.urlencode # => "http://vulnerable.si...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/xor.rb
Ruby
mit
91
master
3,019
# frozen_string_literal: true class String # UTF-8 XOR with key, padding left the shortest element # @param key [String] the element to xor the string with # @return [String] the xored string (UTF-8) # @example # 'hello'.ulxor('key') # => "he\a\t\u0016" # 'key'.ulxor('hello') # => "he\a\t\u0016" def ...
github
noraj/ctf-party
https://github.com/noraj/ctf-party
lib/ctf_party/base64.rb
Ruby
mit
91
master
3,055
# frozen_string_literal: true # Ruby standard library require 'base64' class String # Encode the string into base64 # @param opts [Hash] optional parameters # @option opts [Symbol] :mode Default value: `:strict` (`:rfc4648`). # Other values are `:rfc2045` or `:urlsafe`. # @see https://ruby-doc.org/3.2.2/s...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
rack-streaming-proxy.gemspec
Ruby
mit
91
master
1,415
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rack/streaming_proxy/version' Gem::Specification.new do |spec| spec.name = 'rack-streaming-proxy' spec.version = Rack::StreamingProxy::VERSION spec.authors = ['Fred Ngo...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
lib/rack/streaming_proxy/railtie.rb
Ruby
mit
91
master
634
require 'rails/railtie' class Rack::StreamingProxy::Railtie < Rails::Railtie config.streaming_proxy = ActiveSupport::OrderedOptions.new config.after_initialize do options = config.streaming_proxy Rack::StreamingProxy::Proxy.logger = options.logger if options.logger Rack::Strea...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
lib/rack/streaming_proxy/request.rb
Ruby
mit
91
master
2,121
require 'uri' require 'net/https' class Rack::StreamingProxy::Request attr_reader :http_request def initialize(destination_uri, current_request) @destination_uri = URI.parse(destination_uri) @http_request = translate_request(current_request, @destination_uri) end def host @destination_uri.hos...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
lib/rack/streaming_proxy/session.rb
Ruby
mit
91
master
4,739
require 'uri' require 'net/https' require 'servolux' require 'rack/streaming_proxy/errors' class Rack::StreamingProxy::Session def initialize(request) @request = request end # Returns a Rack::StreamingProxy::Response def start @piper = Servolux::Piper.new 'r', timeout: 30 @piper.child { child } ...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
lib/rack/streaming_proxy/response.rb
Ruby
mit
91
master
2,359
require 'rack/streaming_proxy/errors' class Rack::StreamingProxy::Response include Rack::Utils # For HeaderHash attr_reader :status, :headers attr_accessor :client_http_version def initialize(piper) @piper = piper @client_http_version = '1.1' receive end # This method is called by Rack itsel...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
lib/rack/streaming_proxy/proxy.rb
Ruby
mit
91
master
4,288
require 'rack' require 'logger' require 'rack/streaming_proxy/session' require 'rack/streaming_proxy/request' require 'rack/streaming_proxy/response' class Rack::StreamingProxy::Proxy class << self attr_accessor :logger, :log_verbosity, :num_retries_on_5xx, :raise_on_5xx def set_default_configuration ...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
spec/streaming_proxy_spec.rb
Ruby
mit
91
master
7,718
require 'yaml' require File.join(File.dirname(__FILE__), %w[spec_helper]) APP_PORT = 4321 # hardcoded in proxy.ru as well! PROXY_PORT = 4322 shared_examples "rack-streaming-proxy" do it "passes through to the rest of the stack if block returns false" do get "/not_proxied" last_response.should be_ok last...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
spec/app.ru
Ruby
mit
91
master
1,196
require "yaml" class Streamer include Rack::Utils def initialize(sleep=0.05) @sleep = sleep @strings = 5.times.collect {|n| "~~~~~ #{n} ~~~~~\n" } end def call(env) req = Rack::Request.new(env) headers = {"Content-Type" => "text/plain"} headers["Transfer-Encoding"] = "chunked" [200, h...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
spec/spec_helper.rb
Ruby
mit
91
master
288
require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib rack streaming_proxy])) require "rack/test" RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus end
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
spec/proxy.ru
Ruby
mit
91
master
369
require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib rack streaming_proxy])) ENV['RACK_ENV'] = 'none' # 'development' automatically use Rack::Lint and results in errors with unicorn # use Rack::CommonLogger use Rack::StreamingProxy::Proxy do |req| "http://localhost:4321#{req.path}" end run lambda ...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
dev/streamer.ru
Ruby
mit
91
master
1,041
class Streamer include Rack::Utils def call(env) req = Rack::Request.new(env) headers = {"Content-Type" => "text/plain"} @chunked = req.path.start_with?("/chunked") if count = req.path.match(/(\d+)$/) count = count[0].to_i else count = 100 end @strings = count.times.collec...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
dev/client.rb
Ruby
mit
91
master
581
#!/usr/bin/env ruby # coding: utf-8 # cf. https://gist.github.com/sonots/7751554 require 'net/http' require 'uri' # unicorn spec/app.ru -p 4321 # unicorn spec/proxy.ru -p 4322 PORT = ARGV[0] || 8080 http = Net::HTTP.new "localhost", PORT request = Net::HTTP::Get.new "/slow_stream" #request['Transfer-Encoding'] = 'ch...
github
zerowidth/rack-streaming-proxy
https://github.com/zerowidth/rack-streaming-proxy
dev/proxy.ru
Ruby
mit
91
master
418
require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib rack streaming_proxy])) use Rack::Reloader, 1 # use Rack::CommonLogger # rackup already has commonlogger loaded use Rack::Lint use Rack::StreamingProxy do |req| url = "http://localhost:4000#{req.path}" url << "?#{req.query_string}" unless re...
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
Gemfile
Ruby
mit
91
main
217
# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in action_controller-stashed_redirects.gemspec gemspec gem "rake", "~> 13.0" gem "debug" gem "minitest" gem "railties"
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
action_controller-stashed_redirects.gemspec
Ruby
mit
91
main
1,524
# frozen_string_literal: true require_relative "lib/action_controller/stashed_redirects/version" Gem::Specification.new do |spec| spec.name = "action_controller-stashed_redirects" spec.version = ActionController::StashedRedirects::VERSION spec.authors = ["Kasper Timm Hansen"] spec.email = ["hey@kaspth.co...
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
test/test_helper.rb
Ruby
mit
91
main
840
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "debug" require "rails" require "rails/test_help" require "action_controller/stashed_redirects" require "minitest/autorun" require "action_controller/railtie" ENV["RAILS_ENV"] = "test" class ActionController::StashedRedire...
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
test/boot/action_controller.rb
Ruby
mit
91
main
592
class ApplicationController < ActionController::Base skip_forgery_protection end class SessionsController < ApplicationController stash_redirect_for :sign_in, on: :new stash_redirect_for :sign_out, on: :destroy, url: :users_url def new head :no_content end def create redirect_from_stashed :sign_...
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
test/action_controller/stashed_redirects_test.rb
Ruby
mit
91
main
2,438
# frozen_string_literal: true require "test_helper" class ActionController::StashedRedirectsTest < ActionDispatch::IntegrationTest test "version" do assert ActionController::StashedRedirects::VERSION end test "stash and recall redirect from a param" do get new_session_url, params: { redirect_url: users...
github
kaspth/action_controller-stashed_redirects
https://github.com/kaspth/action_controller-stashed_redirects
lib/action_controller/stashed_redirects.rb
Ruby
mit
91
main
4,003
# frozen_string_literal: true require "active_support" # Pass between different controller flows via stashed redirects # # Stash a redirect to execute a controller flow within another and return to the original flow later. module ActionController::StashedRedirects extend ActiveSupport::Concern autoload :VERSION,...
github
tomorrowkey/adb-peco
https://github.com/tomorrowkey/adb-peco
adb-peco.gemspec
Ruby
apache-2.0
91
main
1,110
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'adb/peco/version' Gem::Specification.new do |spec| spec.name = 'adb-peco' spec.version = Adb::Peco::VERSION spec.authors = ['Tomoki Yamashita'] spec.email = [...
github
tomorrowkey/adb-peco
https://github.com/tomorrowkey/adb-peco
spec/adb/command_spec.rb
Ruby
apache-2.0
91
main
2,560
require 'spec_helper' describe Adb::Peco::Command do let(:argv) { [] } let(:command) { Adb::Peco::Command.new(argv) } describe '#serial_option' do subject { command.serial_option } context 'when missing args' do let(:argv) { [] } it { is_expected.to be_nil } end context "when args...
github
tomorrowkey/adb-peco
https://github.com/tomorrowkey/adb-peco
lib/adb/peco/command.rb
Ruby
apache-2.0
91
main
1,012
require 'peco_selector' require 'device_api/android' class Adb::Peco::Command attr_reader :argv def initialize(argv) @argv = argv end def serial_option return nil unless adb_action return nil unless need_serial_option? devices = DeviceAPI::Android.devices return nil if devices.size <= 1 ...
github
tomorrowkey/adb-peco
https://github.com/tomorrowkey/adb-peco
lib/adb/peco/executor.rb
Ruby
apache-2.0
91
main
601
require 'adb/peco/command' class Adb::Peco::Executor AdbUnavailableError = Class.new(StandardError) def adb_available? system('which', 'adb', out: File::NULL) end def ensure_adb_available unless adb_available? raise AdbUnavailableError, 'adb command is not available.' end end def execu...
github
mezis/blurrily
https://github.com/mezis/blurrily
Guardfile
Ruby
mit
91
master
260
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'rspec', cmd: 'bundle exec rspec' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end
github
mezis/blurrily
https://github.com/mezis/blurrily
Rakefile
Ruby
mit
91
master
960
require "bundler/gem_tasks" require 'rake/extensiontask' require 'rspec/core/rake_task' Rake::ExtensionTask.new('blurrily') do |ext| ext.name = 'map_ext' # indicate the name of the extension. # ext.ext_dir = 'ext/weird_world' # search for 'hello_world' inside it. ext.lib_dir = 'lib/...
github
mezis/blurrily
https://github.com/mezis/blurrily
blurrily.gemspec
Ruby
mit
91
master
1,650
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'blurrily/version' Gem::Specification.new do |gem| gem.name = "blurrily" gem.version = Blurrily::VERSION gem.authors = ["Julien Letessier", "Dawid Sklodowski",...
github
mezis/blurrily
https://github.com/mezis/blurrily
ext/blurrily/extconf.rb
Ruby
mit
91
master
485
require 'mkmf' PLATFORM = `uname`.strip.upcase SHARED_FLAGS = "-DPLATFORM_#{PLATFORM} --std=c99 -Wall -Wextra -Werror" case PLATFORM when 'LINUX' # make sure ftruncate is available SHARED_FLAGS << ' -D_XOPEN_SOURCE=700' SHARED_FLAGS << ' -D_GNU_SOURCE=1' # make sure off_t is 64 bit long SHARED_FLAGS << ' -D...
github
mezis/blurrily
https://github.com/mezis/blurrily
spec/integration_spec.rb
Ruby
mit
91
master
2,098
# encoding: utf-8 require 'spec_helper' require 'pathname' require 'fileutils' require 'blurrily/client' require 'blurrily/map' describe 'client/server integration' do let(:data_dir) { Pathname.new 'tmp/data' } let(:data_file) { data_dir.join('foobar.trigrams') } before { data_dir.rmtree if data_dir.exist? } ...