Skip to content

Instantly share code, notes, and snippets.

Avatar
👶
On paternity leave

Paul Smith paulcsmith

👶
On paternity leave
View GitHub Profile
@ParamagicDev
ParamagicDev / port_in_use.rb
Last active Aug 17, 2020
Check if a port is being used.
View port_in_use.rb
require "socket"
def detect_port!
hostname = Snowpacker.config.hostname || "localhost"
port = Snowpacker.config.port || 4035
server = TCPServer.new(hostname, port)
server.close
rescue Errno::EADDRINUSE
puts "#{port} is currently being used"
exit!
@stephendolan
stephendolan / lucky_spec_action.yml
Last active Apr 27, 2020
GitHub Action - Lucky Setup and Spec
View lucky_spec_action.yml
name: Lucky Build and Spec CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
View Mount with block and m.cr
def mount(component, *args, **named)
component.new(*args, **named).render do |*yield_args|
yield *yield_args
end
end
class Component
def initialize(@name : String)
end
@gilesvangruisen
gilesvangruisen / ci.yml
Created Apr 5, 2020
Ruby/Rails GitHub Actions CI
View ci.yml
name: rspec
on:
pull_request:
branches:
- "master"
push:
branches:
- "master"
@manveru
manveru / bytea.cr
Last active Dec 2, 2019
Additional types for Avram
View bytea.cr
record Bytea, bytes : Bytes
struct Bytea
def self.adapter
Lucky
end
def blank?
@bytes.size == 0
end
@reinink
reinink / DateInput.vue
Created Aug 27, 2019
Pikaday Vue Component
View DateInput.vue
<template>
<div>
<label v-if="label" class="form-label" :for="`date-input-${_uid}`">{{ label }}:</label>
<input v-bind="$attrs" class="form-input" :id="`date-input-${_uid}`" :class="{ error: error }" type="text" ref="input" :value="value" @change="change" @keyup="change">
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>
<script>
import pikaday from 'pikaday'
@watzon
watzon / not_pwned_validation.cr
Created Jun 14, 2019
Lucky valdator to make sure a password isn't in the Have I Been Pwned database
View not_pwned_validation.cr
require "http/client"
require "openssl"
module NotPwnedValidation
def validate_not_in_hibp
password.value.try do |value|
hash = get_sha1_hash(value).upcase
first_five = hash[0...5]
response = HTTP::Client.get("https://api.pwnedpasswords.com/range/" + first_five)
hashes = response.body.split("\r\n")
@watzon
watzon / app.js
Last active Jun 14, 2019
Toggle password field with Lucky and stimulus
View app.js
import { Application } from 'stimulus'
import PasswordController from './controllers/password_controller'
const application = Application.start()
application.register("password", PasswordController)
@calebporzio
calebporzio / pure_html_css_modal.css
Last active Feb 28, 2021
The CSS for the pure HTML/CSS modal I tweeted about.
View pure_html_css_modal.css
details summary {
cursor: pointer;
outline: none !important;
display: inline-block;
padding: 8px 12px;
padding-top: 10px;
border-radius: 4px;
overflow: hidden;
background: #F09825;
color: white;
@paulcsmith
paulcsmith / lucky.cr
Last active Apr 19, 2019
Lucky search form
View lucky.cr
class Candidates::Searches::Show < BrowserAction
get "/candidates/search" do
CandidateSearchForm.new(params).submit do |form, candidates|
render Candidates::IndexPage, search_form: form, candidates: candidates
end
end
end
class CandidateSearchForm < Avram::VirtualForm
virtual query : String