Skip to content

Instantly share code, notes, and snippets.

Avatar

Dillon de Voor CrocoDillon

View GitHub Profile
View polyfills.js
if (typeof Promise === 'undefined') {
require.ensure([], (require) => {
require('imports?this=>window!es6-promise')
})
}
if (typeof fetch === 'undefined') {
require.ensure([], (require) => {
require('imports?self=>window!whatwg-fetch')
})
@cahnory
cahnory / middleware.js
Created Dec 21, 2015
koa-webpack-middleware
View middleware.js
import connect from 'koa-connect';
import compose from 'koa-compose';
import webpack from 'webpack';
import webpackDev from 'webpack-dev-middleware';
import webpackHot from 'webpack-hot-middleware';
export default function (config = {}) {
let compiler = webpack(config);
return compose([
@paulirish
paulirish / what-forces-layout.md
Last active Sep 28, 2022
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@kopiro
kopiro / sudoku-solver-with-bt.js
Created May 11, 2015
Sudoku solver with backtracking
View sudoku-solver-with-bt.js
function getp(puzzle, x, y) {
var hash = {};
for (var u = 0; u < 9; u++) hash[ puzzle[y][u] ] = 1;
for (var u = 0; u < 9; u++) hash[ puzzle[u][x] ] = 1;
for (var u = 0; u < 9; u++) hash[ puzzle[ 3*((y/3)|0) + ((u/3)|0) ][ 3*((x/3)|0) + (u%3) ] ] = 1;
var poss = [];
for (var i = 1; i <= 9; i++) if (!(i in hash)) poss.push(i);
return poss;
}
@p3t3r67x0
p3t3r67x0 / pseudo_elements.md
Last active Aug 1, 2022
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.
View pseudo_elements.md

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@razwan
razwan / _baseline.scss
Created Apr 14, 2014
Aligning type to baseline the right way with SASS
View _baseline.scss
$base-font-size: 16px;
$base-line-height: 1.5;
// this value may vary for each font
// unitless value relative to 1em
$cap-height: 0.68;
@mixin baseline($font-size, $scale: 2) {
View css-tricks_chrisburton_readability_DB.php
<?php
// you can't just get this as JSON in the first place, can you ...?
$xml = simplexml_load_file( "http://readability.com/christopherburton/latest/feed" );
$json = json_encode( $xml );
$array = json_decode( $json,TRUE );
$items = $array['channel']['item'];
// we're doing this now so we can sanitize the data without requiring a second loop
// (substitute your actual DB credentials)
$DB = new mysqli( DB_HOST,DB_USER,DB_PASS,DB_NAME );
@cheeaun
cheeaun / js-error-logging-services.md
Last active Nov 4, 2021
JavaScript error logging services
View js-error-logging-services.md
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active Sep 26, 2022
A badass list of frontend development resources I collected over time.
View frontendDevlopmentBookmarks.md
@bubbleheadinc
bubbleheadinc / gist:5725438
Created Jun 6, 2013
Mixin loop to spit out span classes based on # of grid columns for JustifyGrid.com SCSS
View gist:5725438
@mixin grid-spans($col-span){
@while $col-span > 0{
.grid-span-#{$col-span}{
width: grid-span($col-span);
}
$col-span: $col-span - 1;
}
}