This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # frozen_string_literal: true | |
| class CreateFunction < GraphQL::Function | |
| attr_reader :type | |
| def initialize(model) | |
| @model = model | |
| @type = ModelType.new(model) # creates a graphql type from a model | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def decimalize(string) | |
| return 0.0 if string.nil? || string.empty? | |
| string.gsub!(/[^\d\s\/]/, "") | |
| fraction, numeral = string.split.reverse | |
| fraction ||= '0/1' | |
| numeral.to_i + Rational(fraction).to_f | |
| end | |
| # decimalize('1 1/2') => 1.5 | |
| # decimalize('2 3/4 inches') => 2.75 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Original text here: https://whydavewhy.com/2013/08/16/loyalty-and-layoffs/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def rotator_factory(*values) | |
| Enumerator.new do |y| | |
| loop do | |
| y.yield values.first | |
| values = values.rotate | |
| end | |
| end | |
| end | |
| r = rotator_factory('a','b','c') | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'nokogiri' | |
| require 'open-uri' | |
| require 'sqlite3' | |
| db = SQLite3::Database.new("results.db") | |
| db.execute <<-SQL | |
| CREATE TABLE results ( | |
| id int, | |
| score int | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | errors = [ | |
| SystemStackError, LocalJumpError, IOError, RegexpError, ZeroDivisionError, | |
| ThreadError, SystemCallError, SecurityError, RuntimeError, NameError, | |
| RangeError, IndexError, ArgumentError, TypeError | |
| ] | |
| module Kernel | |
| def suppress_warnings | |
| original_verbosity = $VERBOSE | |
| $VERBOSE = nil | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'nokogiri' | |
| require 'open-uri' | |
| words = Hash.new {|h,k| h[k] = 0} | |
| (1971..2013).each do |year| | |
| ["04","10"].each do |month| | |
| talk_list = Nokogiri::HTML(open("http://www.lds.org/general-conference/sessions/#{year}/#{month}?lang=eng")) | |
| talk_list.css("a.print").each do |link| | |
| talk = Nokogiri::HTML(open(link.attributes["href"].value)) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @import "foundation"; | |
| #page { | |
| @include grid-row; | |
| } | |
| #content { | |
| @include grid-column(9, $float:left); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <body> | |
| <div id="page"> | |
| <section id="content"> | |
| <p>Content</p> | |
| </section> | |
| <section id="navigation"> | |
| <ul class="menu"> | |
| <li><a href="#foo">Foo</a></li> | |
| <li><a href="#bar">Bar</a></li> | |
| <li><a href="#baz">Baz</a></li> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class User < ActiveRecord::Base | |
| has_many :items | |
| ... | |
| def self.ranked(year) | |
| select("rank() OVER(ORDER BY SUM(items.amount) DESC), users.*, SUM(items.amount) AS grand_total") | |
| .joins(:items) | |
| .where("EXTRACT(YEAR FROM items.sold_at)=:year", year: year) | |
| .group("users.id") | |
| end | |
| end | 
NewerOlder