| Inequality | Interval | Ruby range | Active Record¹ | Arel² | Description |
|---|---|---|---|---|---|
| x >= a | [a, ∞) | a.. | where(x: a..) | x.gteq(a) | Right unbounded closed |
| x > a | (a, ∞) | n/a | where.not(x: ..a) | x.gt(a) | Right unbounded open |
| x <= a | (-∞, a] | ..a | where(x: ..a) | x.lteq(a) | Left unbounded closed |
| x < a | (-∞, a) | ...a | where(x: ...a) | x.lt(a) | Left unbounded open |
| a <= x <= b | [a, b] | a..b | where(x: a..b) | x.between(a..b) | Closed |
| a < x < b | (a, b) | n/a | where.not(x: ..a).where(x: ...b) | x.gt(a).and(x.lt(b)) | Open |
| a <= x < b | [a, b) | a...b | where(x: a... |
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
| module Uu58 | |
| ALPHABET58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".chars.freeze | |
| ALPHAMAP58 = ALPHABET58.each_with_index.to_h.freeze | |
| # Convert a string UUID to a base58 string representation. | |
| # | |
| # Output will be padded up to 22 digits if necessary. | |
| # | |
| # Behaviour is undefined if passing something other than a 128-bit | |
| # hex string in network order with optional interstitial hyphens. |
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
| <template lang='pug'> | |
| div.drop-zone(:class='{dragging: isDragging }' | |
| @dragover.prevent='dragover' | |
| @dragenter.prevent='dragover' | |
| @drop.prevent.stop='onDrop' | |
| @dragleave.prevent='dragleave') | |
| div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser') | |
| slot | |
| i {{label}} | |
| input(type='file' :multiple='multiple' ref='input' style='display: none') |
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
| let fnGetFileNameFromContentDispostionHeader = function (header) { | |
| let contentDispostion = header.split(';'); | |
| const fileNameToken = `filename*=UTF-8''`; | |
| let fileName = 'downloaded.pdf'; | |
| for (let thisValue of contentDispostion) { | |
| if (thisValue.trim().indexOf(fileNameToken) === 0) { | |
| fileName = decodeURIComponent(thisValue.trim().replace(fileNameToken, '')); | |
| break; | |
| } |
This gist will collects all issues we solved with Rails 5.2 and Webpacker
# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
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
| # base58_to_int and int_to_base58 loosely based on base58 gem by Douglas F. Shearer | |
| # https://github.com/dougal/base58 | |
| ALPHABET = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".chars | |
| BASE = ALPHABET.size | |
| def base58_to_int(base58_val) | |
| base58_val.chars | |
| .reverse_each.with_index | |
| .reduce(0) do |int_val, (char, index)| |
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
| console.log('Loading function'); | |
| const https = require('https'); | |
| const url = require('url'); | |
| // to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration | |
| const slack_url = 'https://hooks.slack.com/services/...'; | |
| const slack_req_opts = url.parse(slack_url); | |
| slack_req_opts.method = 'POST'; | |
| slack_req_opts.headers = {'Content-Type': 'application/json'}; |
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 BigDecimal | |
| def inspect | |
| "#<BigDecimal: #{to_s}>" | |
| end | |
| 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
| # include from an initializer | |
| module HstoreAccessor | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| def hstore_accessor(hstore_attribute, *keys) | |
| Array(keys).flatten.each do |key| |
NewerOlder