Skip to content

Instantly share code, notes, and snippets.

View phlegx's full-sized avatar
💪
never stop coding

Phlegx Systems phlegx

💪
never stop coding
View GitHub Profile
@rdnewman
rdnewman / after_rspec_example.rb
Created August 29, 2020 21:18
Rswag support for multiple examples (could eventually be a complementary gem to rswag)
# /spec/support/documentation/after_rspec_example.rb
# Normally, we'd want to break into multiple files, but then it becomes more to install (unless gemified)
module SomeApp
module Documentation
class AfterRspecExample
def self.apply!(context, example, response)
SwaggerExample::Request.apply!(context, example, response)
SwaggerExample::Response.apply!(context, example, response)
end
@lonesometraveler
lonesometraveler / main.cpp
Created March 31, 2020 11:20
Mbed EventQueue example 2: Serial Interrupt Callback and deferred printf()
// Execution of certain function in an ISR context is not safe.
// For example, printf() in an interrupt context causes a Mutex error.
// Using Mbed's EventQueue, you can defer execution of code from an interrupt context to a user context.
// More about EventQueue: https://os.mbed.com/docs/mbed-os/v5.15/tutorials/the-eventqueue-api.html
#include "mbed.h"
EventQueue *queue = mbed_event_queue(); // event queue
RawSerial pc(USBTX, USBRX);
@justalever
justalever / validate_array_datatype.rb
Created January 3, 2020 03:08
Validate an array data type in Ruby on Rails using a custom validator - PostGresQL allows arrays as a DB type.
# Define the validator
# app/validators/array_validator.rb
class ArrayValidator < ActiveModel::EachValidator
def validate_each(record, attribute, values)
Array(values).each do |value|
options.each do |key, args|
validator_options = { attributes: attribute }
validator_options.merge!(args) if args.is_a?(Hash)
@FGRibreau
FGRibreau / 1_stripe-schema.md
Last active February 5, 2025 04:18
Stripe database schema (extracted from their sigma product) as of 2019-10-09
jqn -r markdown-table 'map(x => "## " + x.name + "\n\n" + markdownTable(x.columns.map(y => [y.name, y.type]))  ) | join("\n\n")' < /tmp/stripe.json

accounts

id varchar
business_name varchar
business_url varchar
@lazaronixon
lazaronixon / _form.html.erb
Last active March 28, 2025 10:19
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
@labbots
labbots / Ubuntu 18.04 setup.md
Created June 10, 2019 11:12
Ubuntu 18.04 Manual partitioning setup with LUKS encryption and LVM - https://labbots.com/ubuntu-18-04-installation-with-luks-and-lvm

Ubuntu 18.04 installation with LUKS and LVM

Installation Process

Pre-installation from live OS

This setup of Ubuntu with LUKS and LVM is tested on Ubuntu 18.04.

Boot Ubuntu from a Live OS and select the option to try Ubuntu without installing. Follow the steps I've outlined below. Let's assume you're installing to /dev/nvme0n1.

  1. Partition the drive with your tool of choice: I used gparted to set mine up.
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
@dragover.prevent='dragover'
@dragenter.prevent='dragover'
@drop.prevent.stop='onDrop'
@dragleave.prevent='dragleave')
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
slot
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')
@JasonTrue
JasonTrue / searchkick_and_elasticsearch_guidance.md
Last active March 11, 2025 03:37
Searchkick and Elastic Search guidance

Resources:

https://github.com/ankane/searchkick

Indexing

By default, simply adding the call 'searchkick' to a model will do an unclever indexing of all fields (but not has_many or belongs_to attributes).

In practice, you'll need to customize what gets indexed. This is done by defining a method on your model called search_data

def search_data

@loilo
loilo / pass-slots.md
Last active February 20, 2025 09:47
Vue: Pass Slots through from Parent to Child Components

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

Serial Keys:
YV54A-2ZW5P-M887Y-UWXNE-QPUXD
VY3R2-0NW0L-H845Q-TDMXT-XQAT0
VC7JR-A0Z97-08EGZ-M4YNV-XVHD0
FC1TU-4RGEQ-084EP-2XQQX-ZGHWA
CU1WA-8HGEN-M815Z-HQP5E-QKADF
AY7D0-FTG44-H846Y-2XPGV-P32T8
If i request you to be my mentor, what will you teach? comment below.