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 fix_encoding(str) | |
# The "b" method returns a copied string with encoding ASCII-8BIT | |
str = str.b | |
# Strip UTF-8 BOM if it's at start of file | |
if str.byteslice(0..2) == "\xEF\xBB\xBF".b | |
str = str.byteslice(3..-1) | |
end | |
if str.ascii_only? |
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
#!/usr/bin/env ruby | |
require 'ferrum' | |
require 'optparse' | |
require 'uri' | |
class WebScreenshotter | |
def initialize(options = {}) | |
@options = { | |
width: 1920, |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Five Squares Puzzle Demo</title> | |
<style> | |
body { | |
margin: 0; | |
font-family: Arial, sans-serif; |
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
gonna : going to | |
wanna : want to | |
gotta : got to | |
ain't : am not : are not : is not : has not : have not | |
lemme : let me | |
gimme : give me | |
dunno : do not know | |
kinda : kind of | |
lotta : lot of | |
outta : out of |
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
const ACCENT_MAP = { | |
" ":" ","¨":" ","ª":"a","¯":" ","²":"2","³":"3","´":" ","¸":" ","¹":"1", | |
"º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C", | |
"È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ñ":"N", | |
"Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U", | |
"Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae", | |
"ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i", | |
"ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u", | |
"û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A", | |
"ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"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
module HashFieldsHelper | |
def flatten_hash(hash, ancestor_names = []) | |
hash.map do |k, v| | |
case v | |
when Hash | |
flatten_hash(v, ancestor_names + [k]) | |
when Array | |
v.map { |item| flatten_hash(item, ancestor_names + [k, '']) }.inject(:merge) | |
else | |
{flat_hash_key(ancestor_names + [k]) => v.to_s} |
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 { Controller } from "@hotwired/stimulus" | |
// Connects to data-controller="table-sortable-headers" | |
export default class extends Controller { | |
static targets = [ "sortingHeader", "sortableRow", "sortableTbody" ]; | |
static values = { | |
sortColumn: { type: String, default: "" }, | |
sortDirection: { type: String, default: "" } | |
}; |
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
<%%= form_for([<%= model_resource_name %>]) do |form| %> | |
<%%= show_errors_for form.object %> | |
<% attributes.each do |attribute| -%> | |
<div class="mb-3"> | |
<% if attribute.password_digest? -%> | |
<%%= form.label :password, class: "form-label" %> | |
<%%= form.password_field :password, class: "form-control", required: form.object.new_record? %> | |
</div> |
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 FixEncoding | |
def FixEncoding.remove_bom(str) | |
if str.byteslice(0..2) == "\xEF\xBB\xBF".b | |
return str.byteslice(3..-1) | |
else | |
return str | |
end | |
end | |
def FixEncoding.has_utf8?(str) |
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 FixEncoding | |
def FixEncoding.fix_encoding(str) | |
# The "b" method returns a copied string with encoding ASCII-8BIT | |
str = str.b | |
# Strip UTF-8 BOM if it's at start of file | |
if str =~ /\A\xEF\xBB\xBF/n | |
str = str.gsub(/\A\xEF\xBB\xBF/n, '') | |
end | |
if str =~ /([\xc0-\xff][\x80-\xbf]{1,3})+/n | |
# String has actual UTF-8 characters |
NewerOlder