Skip to content

Instantly share code, notes, and snippets.

@ajaxray
ajaxray / slatedocs_middle_clumn_code.md
Created February 7, 2023 20:03
How to show multiline code or JSON in the middle column in slatedocs/slate API Documentation

Showing multiline code or JSON in the middle column of slatedocs/slate API Documentation

Slate comes with 3 built in aside class (i.e. notice, warning and success) for showing blocked notes.

Let's a new aside class pre, that will show preformatted code in the middle column.

At the end of source/stylesheets/screen.css.scss, add the following lines:

// Style an aside like  to show code in middle column
@ajaxray
ajaxray / mysqldump_to_mega.sh
Last active May 2, 2024 05:47
Backup MySQL database to MEGA.nz cloud storage
#!/bin/bash
# ----------------------------------------------------
# A Shell script to take MySql database backup
# and upload to MEGA cloud storage using megatools
# ----------------------------------------------------
# REQUIREMENTS : You should have -
# 1. Registered and verified MEGA account - https://mega.nz/
# 2. Installed megatools - https://github.com/megous/megatools
# ----------------------------------------------------
@zdennis
zdennis / browser_logging.rb
Created June 26, 2018 19:11
Chromedriver browser logging for Capybara
# browser_logging.rb will print out the browser log from Chrome
# when running specs with "js: true". This is so we can easily debug
# issues where there are JS errors or other console warnings/error(s), etc.
#
# Output file is: Rails.root/log/browser.log
#
# Note: Nothing will be printed out for non-JS examples.
RSpec.configure do |config|
browser_log = File.new(Rails.root.join("log/browser.log").to_s, "w")
browser_log.sync = true
@caseywatts
caseywatts / 0 README.md
Last active May 2, 2024 05:47
Generate Graphviz Files for Project

short url: caseywatts.com/graphviz

Graphviz is like markdown, for diagrams.

It's a tool that can transform text input into a "directed graph" output, which is nodes pointing to other nodes. You can use it for architecture diagrams, DB diagrams, documentation for users, etc.

graphviz-it

You'll want to use a tool with a two-pane layout - the left side is the source text, the right side is the image output.

  • For just you working on it, use (shown above; it has more features)
@sukima
sukima / maybe.js
Last active May 2, 2024 05:47
Simple Maybe monad utility for dealing with lookup on objects, etc. (1.8kb minified)
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
@jonkwheeler
jonkwheeler / RevealText.js
Last active May 2, 2024 05:46
React: Animation component using GSAP's SplitText plugin to reveal text on a page
// @flow
import { PureComponent, type Node, Fragment } from 'react';
import { TimelineLite } from 'gsap';
import SplitText from 'Lib/gsap-bonus/umd/SplitText';
import Waypoint from 'react-waypoint';
type RevealTextProps = {
children: Node,
waypointTopOffset: string,
waypointBottomOffset: string,
@jonkwheeler
jonkwheeler / wasm-links.txt
Last active May 2, 2024 05:46
WebAssembly Links to check out
@jonkwheeler
jonkwheeler / NextJsDynamicImportNoSsr.js
Created August 29, 2018 11:08
Next.js - Window is not defined - Dynamic Import
import React from 'react'
import dynamic from 'next/dynamic'
const ReactJsonNoSSR = dynamic(import('react-json-view'), {
ssr: false
})
const starWarsJson = {
"name": "Luke Skywalker",
"height": "172",
@jonkwheeler
jonkwheeler / Hubspot Number Comma Separator.liquid
Last active May 2, 2024 05:46
Hubspot Number Comma Separator
{% macro number_comma_separator(number) %}
{# Check if a number first #}
{% if number|int != 0 %}
{# split all numbers to an array #}
{% set numbers = number|string|regex_replace("(\\d)", "$1,")|split(",") %}
{% set new_numbers = [] %}
{# loop over array in reverse #}
{% for digit in numbers|reverse %}
{% if loop.index is divisibleby 3 %}{% set new_digit = digit + "," %}{% else %}{% set new_digit = digit %}{% endif %}
{% set new_numbers = new_numbers + new_digit %}
@jonkwheeler
jonkwheeler / useState-vs-useSignal.jsx
Last active May 2, 2024 05:46
useState vs useSignal
import { render } from "preact";
import { useRef, useState } from "preact/hooks";
import { signal, useSignal, useComputed } from "@preact/signals";
// Create a signal that can be subscribed to:
const globalCount = signal(0);
function Counter({ number }) {
const [stateCount, setStateCount] = useState(0);