Skip to content

Instantly share code, notes, and snippets.

@stoikerty
stoikerty / dabblet.css
Last active July 6, 2022 15:37
SVG alternative to fittext.js, see http://dabblet.com/gist/5231222
/* SVG alternative to fittext.js */
div {
width: 300px;
height: 150px;
float: left;
margin-right : 10px;
background: #f06;
font: bold 150% sans-serif;
text-shadow: 0 1px 2px rgba(0,0,0,.5);
@stoikerty
stoikerty / javascript.js
Last active May 31, 2020 14:02
Gulp + Browserify - multi-file recipe (JSX, coffeescript, uglify & sourcemaps)
// Config that can be loaded externally, similar
// to [gulp-starter](https://github.com/greypants/gulp-starter)
var src = './app/assets';
var dest = './public';
var config = {
javascript: {
src: src + '/javascript_app/**/*.{js,coffee}',
rootFiles: [
{
@stoikerty
stoikerty / what-forces-layout.md
Last active May 14, 2020 13:40 — forked from paulirish/what-forces-layout.md
What forces layout/reflow in Chrome. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@stoikerty
stoikerty / gist:40ee7d3ee6016a485092
Last active April 9, 2020 18:59
Mixin for creating Google’s “Material Design” in SCSS
// Creating Google’s “Material Design” in SCSS
// (specifically Material Shadow, uses compass)
// see: http://www.google.com/design/spec/layout/layout-principles.html#layout-principles-paper-craft
// Demo: http://codepen.io/stoikerty/full/Glwxi/
// Animating Box-Shadow is EXPENSIVE:
// http://www.html5rocks.com/en/tutorials/speed/high-performance-animations/#toc-
// Moving between z-index-depths is done via opacity & multiple
@stoikerty
stoikerty / moebius-strip.html
Last active February 9, 2019 20:24 — forked from topologicallytony/index.html
Mobius Strip
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mobius Strip</title>
@stoikerty
stoikerty / products-server.js
Last active April 16, 2018 11:37
Products Server
const express = require('express')
const cors = require('cors')
const server = express()
server.use(cors({ origin: true, credentials: true }))
server.use((req, res, next) => {
const productsResponse = {
products: [
{
@stoikerty
stoikerty / with-babel-register.js
Created August 28, 2017 14:23
Modern javascript at all times
const path = require('path');
// Teach Node how to use babel compilation, using closest babelrc config
require('babel-register');
// Run specified file from second argument when first argument `--run` or `-r` is given
const options = process.argv.slice(2);
const runCommandGiven = (options[0] === '--run' || options[0] === '-r');
const fileToRun = runCommandGiven && path.resolve(process.cwd(), options[1]);
@stoikerty
stoikerty / filesHook.js
Created June 27, 2017 12:27
Example of how dev-toolit v5 handles server-rendering of images
// filesHook.js - adapted from dev-toolkit@5.5.4
import filesHook from 'files-require-hook';
const rootForRequire = process.cwd();
// Set up server-side rendering of image files
// ---
// Implement a hook that uses a file-path for node
export default () => {
@stoikerty
stoikerty / cssHook.js
Last active June 27, 2017 09:42
Example of how dev-toolit v5 handles server-rendering of .sass files
// cssHook.js - adapted from dev-toolkit@5.5.4
import path from 'path';
import cssHook from 'css-modules-require-hook';
import sass from 'node-sass';
const rootForProject = './';
const scssIncludePaths = path.resolve(rootForProject, 'src/client');
const cssChunkNaming = '[name]__[local]___[hash:base64:5]';
@stoikerty
stoikerty / Shell.jsx
Last active March 10, 2017 19:39
Setting up the `dynamic-pages`-package with `dev-toolkit` [ https://github.com/stoikerty/dev-toolkit ]
// ----- src/client/views/Shell.jsx -----
// Dynamic components & pages are handled differently. `react-router` doesn't use the `children` object for rendered content.
// Instead it uses the keys specified in each route defined by dynamic-pages in `routes.jsx`, such as `header` and `content`.
import React, { Component, PropTypes } from 'react';
import s from './Shell/_style.scss';
export default class Shell extends Component {