Skip to content

Instantly share code, notes, and snippets.

@alex-min
alex-min / generate_routes.cr
Created March 21, 2020 03:54
generate_routes.cr
require "json"
class RouteJSON
JSON.mapping({
verb: String,
controller: String,
action: String,
pipeline: String,
scope: String,
uri_pattern: String,
@alex-min
alex-min / InfiniteScroll.js
Created January 1, 2021 14:24
Infinite Scrool hook for phoenix Live View and fattable.js
require('fattable/fattable.js');
/*
* This variable is used to keep the scroll position when the live view navigation changes.
* This is useful for modals.
*/
let keepScroll = {};
export default {
Error in crecto_test.rb:28: instantiating 'Repo:Module#all(Post.class)'
Repo.all Post
^~~
in lib/crecto/src/crecto/repo.cr:76: instantiating 'add_preloads(Array(Post), Post.class, Array(NamedTuple(symbol: Symbol, query: Crecto::Repo::Query | Nil)))'
add_preloads(results, queryable, preloads)
^~~~~~~~~~~~
class RenderComponentsController < ActionController::Base
def create
render component: params[:component], props: params[:props]
end
end
<div data-react-class="Post" data-react-props="{&quot;title&quot;:&quot;Hello World&quot;}"></div>
<%= react_component(“Post”, {title: “Hello World”}, {camelize_props: true}) %>
RSpec.feature 'Post react component test' do
before(:each) do
post_json(render_component_path, {
component: 'Post',
props: { title: title }
}.to_json)
end
context 'with a title' do
let(:title) { 'Hello World' }

APPCache Api

You can now put headers inside the manifest :

CACHE MANIFEST
#////////////////////////
# Max-Validity: 2 Weeks and 5 Hours
# Check-Update-Every: 60 Minutes
# Update-Style: Immediate
# On-Update: reload
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_session_cache shared:SSL:10m;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_session_timeout 1d;
ssl_session_tickets off;
require 'html_validation'
include PageValidations
HaveValidHTML.show_html_in_failures = true
HTMLValidation.ignored_attribute_errors = ['moznomarginboxes', 'mozdisallowselectionprint']
module HTMLValidationSession
def visit(url)
result = super(url)
if driver.response_headers['Content-Type'].include?('text/html')