Skip to content

Instantly share code, notes, and snippets.

<script>
/**
* Example 1
*/
anchors.options = {
placement: 'right',
visible: 'hover',
};
@tomeara
tomeara / inline_svg_helper.rb
Last active October 25, 2019 13:01
Inline SVG for Rails
# Put this method in your helper file to render inline SVG
def inline_svg(path)
file = File.open("app/assets/images/#{path}", "rb")
raw file.read
end
@IanLunn
IanLunn / gist:4666512
Created January 29, 2013 18:41
Reverse a two-point cubic bezier
/* sample cubic beziers */
linear = [0.250, 0.250, 0.750, 0.750];
ease = [0.250, 0.100, 0.250, 1.000];
easeIn = [0.420, 0.000, 1.000, 1.000];
easeOut = [0.000, 0.000, 0.580, 1.000];
easeInOut = [0.420, 0.000, 0.580, 1.000];
function reverseCubicBezier(cubicBezier) {
return [
1 - cubicBezier[2],
@hotzenklotz
hotzenklotz / spritemaker
Created March 5, 2013 21:17
use imagemagick to merge all images in a folder to produce a spritesheet
#!/bin/bash
# use imagemagick to merge all images in a folder to produce a spritesheet
# use conver -append for vertical stacking and
# convert +append for horizontal
if [ $# -gt 0 ]
then
if [ $2 ]
@jordanmoore
jordanmoore / Better Emmet Media Queries
Created November 18, 2013 10:08
Go to Preferences > Browse Packages > Emmet > Emmet.sublime-settings and add this between the curly brackets under snippets for writing better media queries quickly in Emmet. mqm => min-width media query mqx => max-width media query
"css": {
"abbreviations": {
"mqm": "@media screen and (min-width:${1}) {\n\t|\n}",
"mqx": "@media screen and (max-width:${1}) {\n\t|\n}"
}
}
@MariaJackson1
MariaJackson1 / Poor Man's Style Guide
Last active August 8, 2022 21:03
Poorman's Styleguide
bryanbraun/poor-mans-styleguide
https://www.poormansstyleguide.com/
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
@wiledal
wiledal / template-literals-3-for-loops.js
Last active March 13, 2023 22:47
Template Literals example: For loops
/*
Template literals for-loop example
Using `Array(5).join(0).split(0)`, we create an empty array
with 5 items which we can iterate through using `.map()`
*/
var element = document.createElement('div')
element.innerHTML = `
<h1>This element is looping</h1>
${Array(5).join(0).split(0).map((item, i) => `
@bessfernandez
bessfernandez / setting-up-html-storybook-app.md
Last active March 28, 2023 16:37
How to setup a simple Storybook HTML demo app

icon-storybook-default

Storybook for HTML

Storybook is all about writing stories. A story usually contains a single state of one component, almost like a visual test case.

Typically you see Storybook used for React or other frameworks, but the library has recently introduced the option to use HTML for your Storybook projects. As a prototyping tool or playground this is great! No larger scale knowledge of other frameworks needed.

Install Storybook HTML

@treyhoover
treyhoover / useStatus.ts
Last active July 26, 2023 19:19
Hook for automatically creating helpers to
import { useState, useMemo } from "react";
// Usage example (booleans)
const userActivity = useStatus([true, false]);
userActivity.status; // true
userActivity.toggle();
userActivity.setTrue();
userActivity.setFalse();
userActivity.reset();
const express = require('express');
const { html, Component } = require('htm/preact');
const renderToString = require('preact-render-to-string');
class App extends Component {
render(props) {
return html`
<div class="app">
<h1>This is an app</h1>
<p>Current server time: ${new Date + ''}</p>