Skip to content

Instantly share code, notes, and snippets.

View tabishiqbal's full-sized avatar

Tabish Iqbal tabishiqbal

  • Toronto, Ontario
View GitHub Profile
@inopinatus
inopinatus / organisation.rb
Created December 14, 2020 22:57
Value object that replaced an enum
# app/models/organisation.rb
# schema like:
#
# create_table "organisations", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
# t.string "transponder", default: "my_laps", null: false
#
class Organisation < ApplicationRecord
attribute :transponder, TransponderType.new
@tabishiqbal
tabishiqbal / bare_transitions.js
Created September 12, 2020 03:55 — forked from bnjamin/bare_transitions.js
Transitions stolen from alpine.js
export function transitionIn (el, show = () => {}) {
const attrs = getXAttrs(el, 'transition')
// If any transition attrs.
if (attrs.filter(attr => ['enter', 'enter-start', 'enter-end'].includes(attr.value)).length > 0) {
transitionClassesIn(el, attrs, show)
} else {
// If not, just show that damn thing.
show()
}
@eminkel
eminkel / form.html.erb
Last active September 10, 2020 02:17
StimulusJS Tag Component
<div class="mt-6">
<%= f.label :tags, class: 'form-label' %>
<div class="border border-gray-300 rounded-md flex-1 block w-full transition duration-150 ease-in-out pt-1.5 px-2 mt-1" data-controller="tags" data-tags-tag-collection data-tags-autocomplete="true" data-tags-show-dropdown="" data-target="tags.container">
<div class="flex flex-wrap cursor-text" data-action="click->tags#active">
<div class="flex flex-wrap" data-target="tags.tags">
<div class="text-sm p-2 bg-gray-100 rounded-md flex items-center space-x-1.5 mb-1.5 mr-2">
<p>tag</p>
<div class="inline-flex bg-gray-500 text-gray-100 rounded-full p-1 hover:bg-gray-700 cursor-pointer">
<svg class="h-3 w-3" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M6 18L18 6M6 6l12 12"></path></
@joshuap
joshuap / jumpstart_heya.md
Last active December 9, 2021 15:50
Configuring Jumpstart to send a welcome sequence w/ Heya
@leastbad
leastbad / README.md
Created April 16, 2020 08:08
Choices.js Stimulus wrapper preview

Choices.js Stimulus wrapper

https://joshuajohnson.co.uk/Choices/

Soon, this will be published as an NPM package, but there's an absence of documentation right now. It supports almost all functions from the original library; soon it will support 100% of them.

This wrapper adds Ajax pre-fetch search. Happens if controller has a data-search-path attribute.

Stimulus controller targets use new v2 syntax. Controller attaches a reference to itself on the element so that you can access the internal state from external scripts.

@pooot
pooot / uppy-vue-example
Created January 2, 2018 15:54
Very basic vuejs usage of uppy
<template>
<div :id="uppyId">
<div class="ThumbnailContainer" v-if="collection === 'thumbnail'">
<button id="open-thumbnail-modal" class="button">Select file</button>
</div>
<div class="DashboardContainer" v-else></div>
</div>
</template>
@cole007
cole007 / digitalocean.md
Last active November 22, 2023 16:54
Digital Ocean internal migration - moving files between droplets over SSH/SCP

If you need to move a lot of files between DO server you can move these through SCP over the internal private Digital Ocean network.

NB both droplets need to be within the same region

To do this you need:

  1. enable private network for each droplet (if not done at creation, note the droplet needs to be off for this to be enabled once live)
  2. ensure that eth1 is enabled for both droplets if not already - see https://www.digitalocean.com/community/tutorials/how-to-enable-digitalocean-private-networking-on-existing-droplets
  3. scp files from the source server to the destination server are sent like:
@RTLer
RTLer / app.js
Last active March 25, 2019 01:59
vueJs flash message component (alert)
Vue.component('child', {
ready(){
// send flash message
this.$root.$broadcast('flashMessage',{
text: 'Better check yourself, you\'re not looking too good.',
type: 'warning',//optional
important: false,//optional
timeout: 5000//optional
});
@maxivak
maxivak / __readme.md
Last active April 8, 2024 01:03
Tree with ancestry. Rails

Contents:

  • show full path for the item
  • show tree in ol li
  • show tree in dropdown select

Show full path for item

  • one item
@apneadiving
apneadiving / migration.rb
Last active May 1, 2020 09:50
incremental invoice numbers without gap in rails + postgresql
class CreateInvoiceNumbers < ActiveRecord::Migration
def up
create_table :invoice_numbers do |t|
t.integer :year, null: false, unique: true
t.integer :next_number_within_year, null: false, default: 1
end
add_index :invoice_numbers, :year, unique: true
(2016..2045).each do |year|