Skip to content

Instantly share code, notes, and snippets.

View Krutie's full-sized avatar
🌻

Krutie Patel Krutie

🌻
View GitHub Profile
@Krutie
Krutie / vue-awesome.js
Created May 15, 2020 13:36
Vue Awesome as a Nuxt Plugin
import Vue from "vue";
// only import the icons you use to reduce bundle size
import "vue-awesome/icons/regular/play-circle";
import "vue-awesome/icons/map-marker";
import "vue-awesome/icons/phone";
import "vue-awesome/icons/bars";
import "vue-awesome/icons/times";
import "vue-awesome/icons/chevron-up";
import "vue-awesome/icons/chevron-down";
@Krutie
Krutie / machine.js
Last active April 21, 2021 05:41
Generated by XState Viz: https://xstate.js.org/viz
// MATTER MACHINE
// ===================
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
@Krutie
Krutie / machine.js
Last active April 21, 2021 05:41
Generated by XState Viz: https://xstate.js.org/viz
// TRAFFIC-LIGHT MACHINE
// ===================
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
@Krutie
Krutie / machine.js
Created May 5, 2021 12:54
Generated by XState Viz: https://xstate.js.org/viz
// v1 - probably incorrect machine
const lastQuestion = (context, event) => {
return context.ques > 0
}
const quizMachine = Machine({
id: 'quiz',
initial: 'idle',
context: {
@Krutie
Krutie / machine.js
Last active January 21, 2022 19:56
Generated by XState Viz: https://xstate.js.org/viz
/**
* Validate answer
* @param ctx
* @param evt
*/
const validateAnswer = (ctx, evt) =>
new Promise((resolve, reject) => {
if (evt.type === "ANSWER" && evt.answer?.selectedOption !== undefined) {
resolve(evt.answer);
} else {
@Krutie
Krutie / custom_page_layout.rb
Last active September 30, 2024 13:01
This script will modify how the title page, part-title, and chapter-title are rendered.
require 'asciidoctor-pdf'
class CustomPdfConverter < Asciidoctor::PDF::Converter
register_for 'pdf'
# Customize the title page layout
def layout_title_page(doc)
start_new_page
font 'Helvetica', size: 48, style: :bold
text doc.doctitle, align: :center, valign: :center
@Krutie
Krutie / two-col-layout.gist.rb
Created October 10, 2024 07:23
Ruby extension to create two-column TOC layout for Asciidoctor PDF
module TOCHelpers
# Method to convert integers to Roman numerals
def to_roman(num)
romans = {
1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD',
100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL',
10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I'
}
result = ''