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
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/structs.rb
Ruby
bsd-3-clause
93
master
1,738
# miscelaneous structs needed for other calls/structures module Ragweed; end module Ragweed::Wraposx class FpControl < FFI::Struct layout :value, :ushort def invalid self.value >> 15 end def denorm (self.value >> 14) & 1 end def zdiv (self.value >> 13) & 1 end d...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/constants.rb
Ruby
bsd-3-clause
93
master
4,278
module Ragweed; end module Ragweed::Wraposx;end # PTRACE request constants module Ragweed::Wraposx::Ptrace TRACE_ME = 0 # child declares it's being traced #(READ|WRITE)_[IDU] are not valid in OSX but defined in ptrace.h READ_I = 1 # read word in child's I space READ_D = 2 # read word in child's D space READ_...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/thread_context.rb
Ruby
bsd-3-clause
93
master
40,038
# 127 ((x == x86_THREAD_STATE32) || \ # 128 (x == x86_FLOAT_STATE32) || \ # 129 (x == x86_EXCEPTION_STATE32) || \ # 130 (x == x86_DEBUG_STATE32) || \ # 131 (x == x86_THREAD_STATE64) || \ # 132 (x == x86_FLOAT_STATE64) || \ # 133 ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/kernelerrorx.rb
Ruby
bsd-3-clause
93
master
9,819
module Ragweed; end module Ragweed::Wraposx; end # Exception objects for kernel errors likely in Wraposx module Ragweed::Wraposx::KernelReturn SUCCESS = { :value => 0, :message => 'Not an error'} INVALID_ADDRESS = { :value => 1, :message => 'Specified address is not currently valid.'} PROTECT...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/event.rb
Ruby
bsd-3-clause
93
master
1,372
class Ragweed::Event # Quick wrapper around Win32 events. Events are simple thread sync # objects that are cross-process. They are like semaphores that you # can select() on. # You can just do WinEvent.new to get a new anonymous handle, and # then call .handle on it to find out what the handle was. Communic...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/hooks.rb
Ruby
bsd-3-clause
93
master
1,193
class Ragweed::Debugger32 # Hook function calls # nargs is the number of arguments taken by function at ip # callable/block is called with ev, ctx, dir (:enter or :leave), and args Array (see examples/hook_notepad.rb) # default handler prints arguments def hook(ip, nargs, callable=nil, &block) callable |...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/wrap32.rb
Ruby
bsd-3-clause
93
master
20,470
require 'ffi' require 'ostruct' require 'Win32API' require 'pp' module Ragweed;end module Ragweed::Wrap32 NULL = 0x0 module PagePerms EXECUTE = 0x10 EXECUTE_READ = 0x20 EXECUTE_READWRITE = 0x40 EXECUTE_WRITECOPY = 0x80 NOACCESS = 0x1 READONLY = 0x2 READWRITE = 0x4 WRITECOPY = 0x8 ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/process.rb
Ruby
bsd-3-clause
93
master
17,692
class Ragweed::Process def handle; @h; end attr_reader :pid include Ragweed def self.find_by_regex(name) Ragweed::Wrap32::all_processes do |p| if p.szExeFile =~ name return self.new(p.th32ProcessID) end end end # Get a pointer into the remote process; pointers are just fixnums ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/process_token.rb
Ruby
bsd-3-clause
93
master
2,517
module Ragweed::Wrap32 module TokenAccess ADJUST_DEFAULT = 128 ADJUST_GROUPS = 64 ADJUST_PRIVILEGES = 32 ALL_ACCESS = 0xf00ff ASSIGN_PRIMARY = 1 DUPLICATE = 2 EXECUTE = 0x20000 IMPERSONATE = 4 QUERY = 8 QUERY_SOURCE = 16 READ = 0x20008 WRITE = 0x200e0 end module Pr...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/winx.rb
Ruby
bsd-3-clause
93
master
433
%w[ostruct Win32API pp].each {|x| require x} module Ragweed;end module Ragweed::Wrap32 class WinX < StandardError attr_reader :code attr_reader :msg attr_reader :call def initialize(sym=nil) @call = sym @code = Ragweed::Wrap32::get_last_error() @msg = "#{(@call ? @call.to_s + ": " ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/overlapped.rb
Ruby
bsd-3-clause
93
master
990
class Ragweed::Wrap32::Overlapped attr_accessor :internal attr_accessor :internal_high attr_accessor :offset attr_accessor :offset_high attr_accessor :event attr_accessor :target def self.get h = Ragweed::Wrap32::create_event(nil, false, true) r = self.new r.event = h return r end de...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/thread_context.rb
Ruby
bsd-3-clause
93
master
3,793
require 'ffi' module Ragweed::Wrap32 module EFlags CARRY = (1 << 0) X0 = (1 << 1) PARITY = (1 << 2) X1 = (1 << 3) ADJUST = (1 << 4) X2 = (1 << 5) ZERO = (1 << 6) SIGN = (1 << 7) TRAP = (1 << 8) INTERRUPT = (1 << 9) DIRECTION = (1 << 10) OVERFLOW = (1 << 11) IOPL1 =...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/device.rb
Ruby
bsd-3-clause
93
master
1,132
module Ragweed class Device def initialize(path, options={}) @path = path @options = options @h = Ragweed::Wrap32::create_file(@path, :flags => Ragweed::Wrap32::FileAttributes::OVERLAPPED|Ragweed::Wrap32::FileAttributes::NORMAL) end def ioctl(code, inbuf, outbuf) overlap(lambda do...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32/debugging.rb
Ruby
bsd-3-clause
93
master
14,521
require 'ffi' module Ragweed::Wrap32 module DebugCodes CREATE_PROCESS = 3 CREATE_THREAD = 2 EXCEPTION = 1 EXIT_PROCESS = 5 EXIT_THREAD = 4 LOAD_DLL = 6 OUTPUT_DEBUG_STRING = 8 RIP = 9 UNLOAD_DLL = 7 end module PagePermissions PAGE_NOACCESS = 0x1 PAGE_READONLY = 0x2 ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
examples/hittracerx.rb
Ruby
bsd-3-clause
93
master
1,670
#!/usr/bin/env ruby # A simple hittracer to debug and test Debuggerosx. # FILE is CSV file,address # PID is the proces id to attach to. require 'rubygems' require 'ragweed' require 'pp' require 'irb' include Ragweed filename = ARGV[0] pid = ARGV[1].to_i raise "hittracerx.rb FILE PID" if (ARGV.size < 2 or pid <= 0) ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
examples/hook_notepad.rb
Ruby
bsd-3-clause
93
master
263
require "ragweed" include Ragweed dbg = Debugger32.find_by_regex /notepad/i raise "notepad not running" if dbg.nil? dbg.hook('kernel32!CreateFileW', 7) {|e,c,d,a| puts "#{d} CreateFileW for #{dbg.process.read(a[0],512).from_utf16_buffer}"} dbg.loop dbg.release
github
tduehr/ragweed
https://github.com/tduehr/ragweed
examples/tux-example.rb
Ruby
bsd-3-clause
93
master
572
#!/usr/bin/env ruby ## Simple example of attaching to a process and letting it run require 'ragweed' pid = Ragweed::Debuggertux.find_by_regex(/gcalctool/) begin t = Ragweed::Debuggertux.threads(pid) puts "Available pid/tdpids\n" t.each do |h| puts h end puts "Which thread do you want to attach to?" pid = STDIN...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
examples/snicker.rb
Ruby
bsd-3-clause
93
master
4,634
#!/usr/bin/env ruby # This is a slightly more complex hit tracer implementation of # Debuggerosx. It does fork/exec and attempts, in a manner resembling # rocket surgery with a steamroller, to skip any call to ptrace. # This was last setup to debug the race condition in Debuggerosx#on_breakpoint # using ftp as the ch...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
examples/hittracertux.rb
Ruby
bsd-3-clause
93
master
908
#!/usr/bin/env ruby require 'ragweed' filename = ARGV[0] pid = ARGV[1].to_i raise "hittracertux.rb FILE PID" if (ARGV.size < 2 or pid <= 0) opts = {} d = Ragweed::Debuggertux.new(pid, opts) d.attach File.open(filename, "r") do |fd| lines = fd.readlines lines.map {|x| x.chomp} lines.each do |tl| fn, addr ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
Guardfile
Ruby
mit
93
master
280
require 'guard/guard' guard :rspec, all_on_start: false, all_after_pass: false, cli: '--fail-fast --format doc' do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end
github
welldan97/protocolist
https://github.com/welldan97/protocolist
protocolist.gemspec
Ruby
mit
93
master
1,189
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "protocolist/version" Gem::Specification.new do |s| s.name = "protocolist" s.version = Protocolist::VERSION s.authors = ["Dmitry Yakimov"] s.email = ["welldan97@gmail.com"] s.homepage = "" s.summary =...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
spec/spec_helper.rb
Ruby
mit
93
master
327
require 'protocolist' require 'supermodel' Bundler.require(:default) User = Class.new(SuperModel::Base) Activity = Class.new(SuperModel::Base) RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.filter_run(focus: true) config.run_all_when_everything_filtered = tr...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
spec/protocolist_spec.rb
Ruby
mit
93
master
1,551
require "spec_helper" class User < SuperModel::Base end class Activity < SuperModel::Base end describe Protocolist do let(:actor) { User.new(name: 'Bill') } let(:another_actor) { User.new(name: 'Bob') } let(:target) { User.new(name: 'Mary') } before do Activity.destroy_all Protocolist.actor = act...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
spec/protocolist/model_additions_spec.rb
Ruby
mit
93
master
3,840
require "spec_helper" class Firestarter < SuperModel::Base include Protocolist::ModelAdditions def delete fire :delete, target: false end def myself fire :myself end def love_letter_for_mary(target, data) fire :love_letter, target: target, data: data end end class SimpleFirestarter < Supe...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
spec/protocolist/controller_additions_spec.rb
Ruby
mit
93
master
2,905
require "spec_helper" class FirestartersController #stub before filter def self.before_filter *args end include Protocolist::ControllerAdditions def explicit_use(target, data) fire :gogogo, target: target, data: data end def implicit_use(target) @firestarter = target fire end end descri...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist.rb
Ruby
mit
93
master
469
require 'active_support' require 'protocolist/version' require 'protocolist/model_additions' require 'protocolist/controller_additions' require 'protocolist/railtie' if defined? Rails module Protocolist def self.fire(activity_type, options = {}) options = options.reverse_merge(actor:@actor, activity_type: ac...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/generators/protocolist/install/install_generator.rb
Ruby
mit
93
master
2,464
require 'rails/generators/active_record' module Protocolist module Generators class InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path("../templates", __FILE__) class_option 'model-orm', type: :string, default: 'active_record', ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/generators/protocolist/install/templates/migration.rb
Ruby
mit
93
master
384
class CreateActivities < ActiveRecord::Migration def change create_table :activities do |t| t.references :actor, polymorphic: true t.references :target, polymorphic: true t.string :activity_type t.text :data t.timestamps end add_index :activities, [:actor_id, :actor_type] ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist/model_additions.rb
Ruby
mit
93
master
1,111
require 'protocolist/util/data_proc' module Protocolist module ModelAdditions extend ActiveSupport::Concern include Util::DataProc def fire(activity_type, options = {}) target = case options[:target] when nil self when false nil ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist/railtie.rb
Ruby
mit
93
master
527
module Protocolist class Railtie < Rails::Railtie initializer 'protocolist.model_additions' do ActiveSupport.on_load(:active_record) do include ModelAdditions end if defined?(Mongoid) Mongoid::Document.module_eval do included do include ModelAdditions ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist/controller_additions.rb
Ruby
mit
93
master
1,334
require 'protocolist/controller_additions/initializer' require 'protocolist/util/data_proc' module Protocolist module ControllerAdditions extend ActiveSupport::Concern include Initializer include Util::DataProc def fire(activity_type = nil, options = {}) target = case options[:target] ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist/controller_additions/initializer.rb
Ruby
mit
93
master
344
module Protocolist module ControllerAdditions module Initializer extend ActiveSupport::Concern included do before_filter :initialize_protocolist end def initialize_protocolist Protocolist.actor = current_user Protocolist.activity_class = Activity ...
github
welldan97/protocolist
https://github.com/welldan97/protocolist
lib/protocolist/util/data_proc.rb
Ruby
mit
93
master
492
module Protocolist module Util module DataProc extend ActiveSupport::Concern module ClassMethods private def extract_data_proc(data) if data.respond_to?(:call) ->(o) { data.call(o) } elsif data.is_a?(Symbol) ->(o) { o.send(data) } ...
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
Gemfile
Ruby
mit
93
master
1,963
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '3.1.2' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.1' # Use sqlite3 as the database for Active Record gem 'sqlite3', '~> 1.4' # Use Puma as the app server gem 'puma', '~> 4.1' # B...
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
config/routes.rb
Ruby
mit
93
master
226
Rails.application.routes.draw do get 'hello_world', to: 'hello_world#index' get '/', to: redirect('/hello_world') # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
config/application.rb
Ruby
mit
93
master
1,080
require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" require "action_mailbox/engine" require "action_text/en...
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
config/environments/development.rb
Ruby
mit
93
master
1,964
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
spec/rails_helper.rb
Ruby
mit
93
master
4,704
# This file is copied to spec/ when you run 'rails generate rspec:install' require_relative 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.product...
github
shakacode/react-on-rails-demo-ssr-hmr
https://github.com/shakacode/react-on-rails-demo-ssr-hmr
spec/system/hello_world_spec.rb
Ruby
mit
93
master
527
# frozen_string_literal: true require 'rails_helper' RSpec.describe "hello_world", **{ type: :system, js: true } do it 'loads correct view' do visit '/hello_world' expect(page).to have_content 'Hello, World!' expect(page).to have_content 'Hello, Stranger from MDX!' end context 'react component' do ...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
Rakefile
Ruby
mit
93
master
1,451
require 'rake' require "rake/rdoctask" require 'rake/gempackagetask' require File.join(File.dirname(__FILE__), 'spec', 'spec_helper') require 'spec/rake/spectask' require 'spec/rake/verify_rcov' rdoc_files = FileList["{bin,lib,example_configs}/**/*"].to_a extra_rdoc_files = %w(README COPYRIGHT RELEASES CHANGELOG) Rak...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
init.rb
Ruby
mit
93
master
1,335
class << ActiveRecord::Base # Allows you create common named_scopes and chain them together with #search and # #search_for. # # class Topic # belongs_to :forum # # can_search do # scoped_by :forums # scoped_by :created, :scope => :date_range # end # # # creates ...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
lib/can_search.rb
Ruby
mit
93
master
555
module CanSearch def self.extended(base) class << base attr_accessor :search_scopes end end # Calls either #paginate or #all on the returned scoped from #search_for. def search(options = {}) options = options.dup.symbolize_keys search_for(options).send(options.key?(:page) ? :paginate : :a...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
lib/can_search/like_query_scope.rb
Ruby
mit
93
master
890
module CanSearch # Generates a named scope for searching with a "LIKE ?" query. A format option can be specified # to change the string used for matching. The default matching string is "%?%". # # class Topic # can_search do # scoped_by :name, :scope => :like # end # end # # Top...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
lib/can_search/date_range_scope.rb
Ruby
mit
93
master
3,172
module CanSearch # Generates a named scope for searching by time ranges. You can either specify # your own time range, or specify a single time and use one of the periods to determine # the range. # # class Topic # can_search do # scoped_by :created, :scope => :date_range # end # en...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
lib/can_search/search_scopes.rb
Ruby
mit
93
master
4,332
module CanSearch # Tracks the search scopes for a given model. class SearchScopes # Registered scope_types using their symbolized names as keys. def self.scope_types() @scope_types ||= {} end attr_reader :model, :scopes def initialize(model, &block) @scopes = {} @model = model @...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
spec/spec_helper.rb
Ruby
mit
93
master
3,160
require 'rubygems' dir = File.dirname(__FILE__) rails_app_spec = "#{dir}/../../../../config/environment.rb" vendor_rspec = "#{dir}/../../rspec/lib" $:.unshift "#{dir}/../lib" if File.exist?(vendor_rspec) $:.unshift vendor_rspec else gem 'rspec' end if File.exist?(rails_app_spec) require rails_app_spec else ...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
spec/date_range_scope_spec.rb
Ruby
mit
93
master
5,468
require File.dirname(__FILE__) + '/spec_helper' module CanSearch DateRangeScope.periods[:spec] = lambda do |now| (now..now + 300) end describe "all DateRange Scopes", :shared => true do include CanSearchSpecHelper it "instantiates date range scope" do Record.search_scopes[@scope.name].should ...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
spec/search_scopes_spec.rb
Ruby
mit
93
master
3,549
require File.dirname(__FILE__) + '/spec_helper' module CanSearch describe "all Reference Scopes", :shared => true do include CanSearchSpecHelper it "instantiates reference scope" do Record.search_scopes[@scope.name].should == @scope end it "creates named_scope" do Record.scopes[@scope.n...
github
technoweenie/can_search
https://github.com/technoweenie/can_search
spec/like_query_scope_spec.rb
Ruby
mit
93
master
2,018
require File.dirname(__FILE__) + '/spec_helper' module CanSearch describe "all LikeQuery Scopes", :shared => true do include CanSearchSpecHelper it "instantiates like query scope" do Record.search_scopes[@scope.name].should == @scope end it "creates named_scope" do Record.scopes[@scope....
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
magic-link.gemspec
Ruby
mit
93
master
732
$:.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "magic/link/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "magic-link" s.version = Magic::Link::VERSION s.authors = ["David Van Der Beek"] s.email = ["earlyn...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
Rakefile
Ruby
mit
93
master
680
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'Magic::Link' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.md') r...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
Gemfile
Ruby
mit
93
master
629
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Declare your gem's dependencies in magic-link.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare ...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
app/helpers/magic/link/application_helper.rb
Ruby
mit
93
master
661
module Magic module Link module ApplicationHelper def method_missing method, *args, &block if method.to_s.end_with?('_path') or method.to_s.end_with?('_url') if main_app.respond_to?(method) main_app.send(method, *args) else super end else...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
app/controllers/magic/link/magic_links_controller.rb
Ruby
mit
93
master
2,078
module Magic module Link class MagicLinksController < ::ApplicationController skip_before_action :authenticate_user!, :raise => false before_action :check_user, only: :new def new @magic_link = MagicLink.new end def create @magic_link = MagicLink.new(permitted_param...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
app/mailers/magic/link/magic_link_mailer.rb
Ruby
mit
93
master
213
module Magic::Link class MagicLinkMailer < ApplicationMailer def send_magic_link(email, token) @email = email @token = token mail(to: email, subject: "Your sign in link") end end end
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
app/models/magic/link/magic_link.rb
Ruby
mit
93
master
956
module Magic module Link class MagicLink include ActiveModel::Model attr_accessor :email def send_login_instructions token = set_sign_in_token send_magic_link_email(token) if token token end private def user @user ||= Magic::Link.user_clas...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
test/test_helper.rb
Ruby
mit
93
master
863
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] ActiveRecord::Migrator.migrations_paths << File.expand_path('../db/migrate', __dir__) require "rails/test_help" ...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
test/dummy/config/application.rb
Ruby
mit
93
master
564
require_relative 'boot' require 'rails/all' Bundler.require(*Rails.groups) require "magic/link" module Dummy class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 # Settings in config/environments/* take precedence o...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
test/dummy/config/environments/development.rb
Ruby
mit
93
master
2,177
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
dvanderbeek/magic-link
https://github.com/dvanderbeek/magic-link
lib/magic/link.rb
Ruby
mit
93
master
534
require "magic/link/engine" require "magic/link/railtie" module Magic module Link mattr_accessor :user_class @@user_class = "User" mattr_accessor :email_from @@email_from = "please-change-me@magic-link.com" mattr_accessor :token_expiration_hours @@token_expiration_hours = 6 mattr_acces...
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
Rakefile
Ruby
mit
93
master
222
require 'bundler' require 'rake/testtask' Bundler::GemHelper.install_tasks Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/*.rb' test.verbose = true end task :default => :test
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
Appraisals
Ruby
mit
93
master
273
appraise "rails-30" do gem "rails", "~> 3.0.20" end appraise "rails-31" do gem "rails", "~> 3.1.12" end appraise "rails-32" do gem "rails", "~> 3.2.19" end appraise "rails-40" do gem "rails", "~> 4.0.10" end appraise "rails-41" do gem "rails", "~> 4.1.6" end
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
serialize_with_options.gemspec
Ruby
mit
93
master
1,033
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "serialize_with_options/version" Gem::Specification.new do |s| s.name = "serialize_with_options" s.version = SerializeWithOptions::VERSION s.platform = Gem::Platform::RUBY s.authors = ["David Eisinger"] s.email ...
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
lib/serialize_with_options.rb
Ruby
mit
93
master
2,293
require 'serialize_with_options/railtie' if defined?(Rails) module SerializeWithOptions def self.extended(base) base.class_attribute :serialization_conf base.class_attribute :serialization_opts end def serialize_with_options(set = :default, &block) conf = self.serialization_conf || {} opts = sel...
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
lib/serialize_with_options/railtie.rb
Ruby
mit
93
master
295
module SerializeWithOptions class Railtie < Rails::Railtie initializer 'serialize_with_options.extend_active_record', :after => 'active_record.initialize_database' do |app| ActiveSupport.on_load(:active_record) do self.extend SerializeWithOptions end end end end
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
test/serialize_with_options_test.rb
Ruby
mit
93
master
6,644
require 'test_helper' class User < ActiveRecord::Base has_many :posts has_many :blog_posts has_many :check_ins has_many :reviews, :as => :reviewable serialize_with_options do methods :post_count includes :posts except :email end serialize_with_options(:with_email) do methods :po...
github
vigetlabs/serialize_with_options
https://github.com/vigetlabs/serialize_with_options
test/test_helper.rb
Ruby
mit
93
master
1,545
$:.unshift(File.dirname(__FILE__) + '/..') $:.unshift(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'bundler' begin Bundler.setup(:default, :development) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end ...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/Q3_02_Stack_Min.rb
Ruby
mit
93
master
303
def higest_num_stack(stack) return stack[0] if stack.length == 1 temp_queue = [] smallest = stack.min until stack.length == 0 temp_queue << stack.pop end until smallest == temp_queue.last temp_queue.push(temp_queue.shift) end stack = temp_queue stack.pop higest_num_stack(stack) end
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/Q3_01_Three_In_One.rb
Ruby
mit
93
master
344
def three_in_one(array) three_stacks = [ num_stack = [], string_stack = [], other_stack = [], ] until array.length == 0 if array[0].class == String string_stack << array.shift elsif array[0].class == Fixnum || array[0].class == Float num_stack << array.shift else other_stack << array.shift end...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/Q3_03_Stack_of_Plates.rb
Ruby
mit
93
master
820
def fill_plates(plates, set_of_stacks=[]) plates.each_with_index do |plate, index| if index % 5 == 0 set_of_stacks << stack = [] set_of_stacks[-1] << plate else set_of_stacks[-1] << plate end end set_of_stacks end def add_plates(plates, set_of_stacks=[]) index = set_of_stacks[-1].length plates.each...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/stacks_and_queue_spec/Q3_01_Three_In_One_Spec.rb
Ruby
mit
93
master
1,214
require_relative('../Q3_01_Three_In_One') describe 'it can handle mix inputs and size' do let(:mix_array) {['jason',2,nil,nil,nil,nil,88,7,'pizza','hello',7.98,nil]} let(:small_array) {[4,'jason',nil]} let(:nil_array) {[nil, nil,nil,nil]} it 'should return 3 for the number of stacks' do expect(three_in_one(mix_...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/stacks_and_queue_spec/Q3_03_Stack_of_Plates_Spec.rb
Ruby
mit
93
master
816
require_relative('../Q3_03_Stack_of_Plates') describe 'it can handle mix sizes' do let(:plates) {('a'..'z')} let(:small_plates) {('a'..'e')} it 'can fill a stack or many' do expect(fill_plates(plates).length).to_not eq(0) end it 'should return 6 for the number of stacks' do expect(fill_plates(plates).length...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_3_Stacks_and_Queues/stacks_and_queue_spec/Q3_02_Stack_Min_Spec.rb
Ruby
mit
93
master
224
require_relative('../Q3_02_Stack_Min') describe 'Find the highest number' do let(:test_array) {[23,34,45,5,5,5,5,5,324,7,8,9,89,0]} it 'it should return 324' do expect(higest_num_stack(test_array)).to eq(324) end end
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_2_Listed_Lists/Q2_03_Delete_Middle_Node.rb
Ruby
mit
93
master
672
class Node attr_accessor :value, :next_node def initialize(value, next_node) @value = value @next_node = next_node end end class LinkedList def self.delete_node(head_node, node_num) count = 0 node = head_node until count == node_num previous = node node = head_node.next_node next_node = node.nex...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/Q1_05_One_Away.rb
Ruby
mit
93
master
556
def one_away(s1, s2) if s1 == s2 return true elsif (s1.length - s2.length).abs > 1 return false end string_1 = s1.length >= s2.length ? s1 : s2 string_2 = s1.length < s2.length ? s1 : s2 chars_1 = string_1.split('') chars_2 = string_2.split('') index_1 = 0 index_2 = 0 edit_count = 0 while (index_1 < ...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/Q1_02_Solution2_Check_Permutation.rb
Ruby
mit
93
master
233
def check_permutation_solution2(s1="", s2="") return false if s1.length != s2.length letters = Array.new(128, 0) s1.chars{ |char| letters[char.ord] += 1 } s2.chars{|char| return false if (letters[char.ord] -= 1) < 0 } true end
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/Q1_09_String_Rotation.rb
Ruby
mit
93
master
278
def string_rotation(s1, s2) matching = false if s1.length == s2.length count = 0 until count == s1.length splitted = s1.split('') s1 = splitted.push(splitted.shift).join if s1 == s2 matching = true end count += 1 end else false end matching end
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/Q1_06_String_Compression.rb
Ruby
mit
93
master
326
def string_compression(string) compressed_string = '' current = nil count = 1 string.split('').each_with_index do |char, index| if char == string[index + 1] count += 1 else compressed_string << "#{char}#{count}" count = 1 end end string.length <= compressed_string.length ? string : compressed_strin...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/Q1_08_Zero_Matrix.rb
Ruby
mit
93
master
432
def zero_matrix(matrix) zero = nil matrix.length.times do |row| if matrix[row].include?(0) matrix[row].each_with_index do |zeros, idx| if zeros == 0 zero = idx else matrix[row][idx] = 0 end end end end matrix = matrix.transpose matrix.length.times do |row| if zero == row matrix...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_08_Zero_Matrix_Spec.rb
Ruby
mit
93
master
317
require_relative('../Q1_08_Zero_Matrix') describe 'it will zero out rows and col' do let(:matrix){[[1, 0, 3], [4, 5, 6], [7, 8, 9]]} let(:zeros){[[0, 0, 0], [4, 0, 6], [7, 0, 9]]} it 'return a new matrix with 0s replacing the row and col that the 0 was in' do expect(zero_matrix(matrix)).to eq(zeros) end end
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_05_One_Away_Spec.rb
Ruby
mit
93
master
745
require_relative('../Q1_05_One_Away') describe 'Checks if two words are one edit away' do let(:pale) {'pale'} let(:ple) {'ple'} let(:cake) {'cake'} let(:bake) {'bake'} let(:cat) {'cat'} let(:dog) {'dog'} let(:cakess) {'cakess'} let(:elp) {'elp'} it 'it will return true if 1 edit away' do expect(one_away(pa...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_09_String_Rotation_Spec.rb
Ruby
mit
93
master
650
require_relative('../Q1_09_String_Rotation') describe 'checks 2 strings if they are rotations of each other' do let(:waterbottle){'waterbottle'} let(:erbottlewat){'erbottlewat'} let(:jason){'jason'} let(:not_jason){'pizza&tacos'} let(:trees){'trees'} let(:fishs){'fishs'} it 'it will return true if s1 is a rota...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_01_Is_Unique_Spec.rb
Ruby
mit
93
master
625
require_relative('../Q1_01_Is_Unique') describe 'detects if characters are unique in a word' do let(:word1) {"jason"} let(:word2) {"banana"} let(:word3) {"cool"} let(:word4) {"cat"} it 'Should return true, since nothing repeats' do expect(is_unique?(word1)).to eq(true) end it 'Should return true, s...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_02_Check_Permutation_Spec.rb
Ruby
mit
93
master
608
require_relative('../Q1_02_Check_Permutation') describe 'check if two words are permutations of each other' do let(:lemon) {'lemon'} let(:melon) {'melon'} let(:jason) {'jason'} let(:horse) {'horse'} it 'should true for being a permutation' do expect(check_permutation(lemon, melon)).to eq(true) end it 'shou...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_03_URLify_Spec.rb
Ruby
mit
93
master
363
require_relative('../Q1_03_URLify') describe '' do let(:string){"Jason Loves TDD"} let(:url) {"Jason%20Loves%20TDD"} let(:name){"jason"} it 'it should convert convert the string if it contains spaces' do expect(urlify(string)).to eq(url) end it 'it should output the word if it does not contain spaces' do ...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_07_Rotate_Matrix_Spec.rb
Ruby
mit
93
master
398
require_relative('../Q1_07_Rotate_Matrix') describe 'turn an array 90 degrees to the right' do let(:portrait){[["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"]]} let(:portrait_90cc){[["g", "d", "a"], ["h", "e", "b"], ["i", "f", "c"]]} it 'it will return a new array that has bee...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_06_String_Compression_Spec.rb
Ruby
mit
93
master
411
require_relative('../Q1_06_String_Compression') describe 'string compression' do let(:aabcccccaaa){'aabcccccaaa'} let(:a2b1c5a3){'a2b1c5a3'} let(:abcc){'abcc'} it 'it should compress the word down ' do expect(string_compression(aabcccccaaa)).to eq(a2b1c5a3) end it 'it does not compress the word down that are...
github
careercup/CtCI-6th-Edition-Ruby
https://github.com/careercup/CtCI-6th-Edition-Ruby
Chap_1_Arrays_and_Strings/array_and_string_spec/Q1_02_Check_Permutation2_Spec.rb
Ruby
mit
93
master
658
require_relative('../Q1_02_Solution2_Check_Permutation') describe 'check if two words are permutations of each other' do let(:lemon) {'lemon'} let(:melon) {'melon'} let(:jason) {'jason'} let(:horse) {'horse'} it 'should true for being a permutation' do expect(check_permutation_solution2(lemon, melon)).to eq(tr...
github
ngauthier/domino
https://github.com/ngauthier/domino
Rakefile
Ruby
mit
93
master
248
require 'bundler/gem_tasks' desc "Run the tests" task :test do require File.join(File.dirname(__FILE__), 'test', 'test_helper.rb') Dir[File.join(File.dirname(__FILE__), "test", "**", "*.rb")].each { |f| require f } end task :default => :test
github
ngauthier/domino
https://github.com/ngauthier/domino
domino.gemspec
Ruby
mit
93
master
930
# -*- encoding: utf-8 -*- Gem::Specification.new do |gem| gem.name = "domino" gem.version = "0.11.0" gem.platform = Gem::Platform::RUBY gem.authors = ["Nick Gauthier"] gem.email = ["ngauthier@gmail.com"] gem.homepage = "http://github.com/ngauthier/domino" gem.summary = "View abstraction for integration te...
github
ngauthier/domino
https://github.com/ngauthier/domino
test/domino_test.rb
Ruby
mit
93
master
6,373
class DominoTest < Minitest::Test include Capybara::DSL module Dom class Person < Domino selector '#people .person' attribute :name attribute :last_name attribute :biography, '.bio' attribute :favorite_color, '.fav-color' attribute :age, &:to_i attribute :rank, '&[dat...
github
ngauthier/domino
https://github.com/ngauthier/domino
test/domino_form_test.rb
Ruby
mit
93
master
7,488
class DominoFormTest < Minitest::Test include Capybara::DSL module Dom class CheckBoxesField < Domino::Form::Field def read(node) node.find(locator).all('input[type=checkbox]').select(&:checked?).map(&:value) end def write(node, value) value = Array(value) node.find(l...
github
ngauthier/domino
https://github.com/ngauthier/domino
test/test_application.rb
Ruby
mit
93
master
5,666
class TestApplication def call(env) [200, { 'Content-Type' => 'text/plain' }, [response(env)]] end def response(env) case env.fetch('PATH_INFO') when '/' root when '/people/23/edit' params = { 'person' => { 'id' => 23, 'name' => 'Alice', 'last_nam...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino.rb
Ruby
mit
93
master
5,315
require 'capybara/dsl' # To create a basic Domino class, inherit from Domino and # define a selector and attributes: # # module Dom # class Post < Domino # selector '#posts .post' # attribute :title # selector defaults to .title # attribute :body, '.post-body' # example of selector ove...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino/attribute.rb
Ruby
mit
93
master
1,361
class Domino::Attribute attr_reader :name, :selector, :callback def initialize(name, selector = nil, &callback) @callback = callback @name = name @selector = selector || %(.#{name.to_s.tr('_', '-')}) end def value(node) val = value_before_typecast(node) convert(val) end def convert(va...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino/form.rb
Ruby
mit
93
master
1,858
class Domino::Form < Domino require 'domino/form/field' require 'domino/form/select_field' require 'domino/form/boolean_field' FIELD_TYPES = { select: SelectField, boolean: BooleanField }.freeze def self.key(k) @key = k end def self.fields field_definitions.keys end def self.fiel...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino/form/select_field.rb
Ruby
mit
93
master
894
class Domino::Form::SelectField < Domino::Form::Field # Returns the set of selected options that can be processed in the callback. def read(node) s = field(node) selected = s.all('option[selected]') s.multiple? ? selected : selected.first end def write(node, value) s = field(node) values = ...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino/form/field.rb
Ruby
mit
93
master
999
class Domino::Form::Field attr_reader :name, :locator, :options, :callback def initialize(name, locator, options = {}, &callback) @name = name @locator = locator @options = options @callback = callback extract_field_options end # Delete any options for your field type that shouldn't be pas...
github
ngauthier/domino
https://github.com/ngauthier/domino
lib/domino/form/boolean_field.rb
Ruby
mit
93
master
263
class Domino::Form::BooleanField < Domino::Form::Field def read(node) node.find_field(locator, options).checked? end def write(node, value) if value node.check(locator, options) else node.uncheck(locator, options) end end end
github
rspec/rspec
https://github.com/rspec/rspec
Rakefile
Ruby
mit
93
main
727
# frozen_string_literal: true require "bundler" Bundler.setup GEMS = %i[rspec rspec-core rspec-mocks rspec-expectations rspec-support] desc "Release all rspec gems" task :release_all do helpers = {} GEMS.each do |name| helpers[name] = Bundler::GemHelper.new(name.to_s) end helpers[:rspec].send(:guard_cle...