Skip to content

Instantly share code, notes, and snippets.

@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 {
@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,
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' }
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')

Keybase proof

I hereby claim:

  • I am alex-min on github.
  • I am alexmin (https://keybase.io/alexmin) on keybase.
  • I have a public key whose fingerprint is 2072 083A 46DF 68F9 0D45 0848 924D 281F FD45 AA4D

To claim this, I am signing this object:

local M = {}
-----
math.randomseed( os.time() )
math.random()
-----
local function num2bs(num)
local _mod = math.fmod or math.mod
local _floor = math.floor
--
local result = ""