Skip to content

Instantly share code, notes, and snippets.

View lvl99's full-sized avatar

Matt Scheurich lvl99

View GitHub Profile
@lvl99
lvl99 / scss-dynamic-breakpoint-media-queries.scss
Last active March 2, 2016 10:20
This is just a few ramshackle mixins I put together based on a theory. Don't know if they're suitable for production yet, but check it out. Please note that it's all only supported by `min/max-width`, no pixel density or orientation conditions, or even anything other than the `screen` media type.
/*
* SCSS Dynamic Breakpoint Media Queries
* Author: Matt Scheurich <[email protected]>
*
* This is just a few ramshackle mixins I put together based on a theory.
* Don't know if they're suitable for production yet, but check it out.
* Please note that it's all only supported by `min/max-width`, no pixel
* density or orientation, or even anything other than the `screen` media type.
*/
@lvl99
lvl99 / inline-svg-code.less
Created March 20, 2016 09:34
This mixin allows you to embed SVG code within CSS files using LESS. The techniques within this mixin relate to the insights found at CSS Tricks' article "Probably Don't Base64 SVG"
// Inline SVG code images in LESS CSS
// @author Matt Scheurich <[email protected]> (http://lvl99.com)
// Github: https://github.com/lvl99/less-inline-svg-code
.inline-svg-code( @code ) {
@-svg-code: escape(~'<?xml version="1.0" ?>@{code}');
@-inline-svg-code: ~'data:image/svg+xml,@{-svg-code}';
@-inline-svg-url: ~"url('@{-inline-svg-code}')";
}
// Basic Example
@lvl99
lvl99 / emoji.json
Last active August 27, 2016 11:27
A JSON array containing unicode/byte character info and description extracted from Tim Whitlock's "Emoji Unicode Tables" (http://apps.timwhitlock.info/emoji/tables/unicode), which is probably the best reference out there. From last count there are 842 characters listed.
[
{
"unicode": "U+1F601",
"bytes": "\\xF0\\x9F\\x98\\x81",
"description": "grinning face with smiling eyes",
"htmlchar": "&#x1F601;"
},
{
"unicode": "U+1F602",
"bytes": "\\xF0\\x9F\\x98\\x82",
# Incorporate this function into your .bash_profile (.bashrc, .zshrc, or whatever you use...)
# Run `mov2frames name-of-mov.mov` to extract frames from the movie file
# Run `mov2frames name-of-mov.mov 300` to extract frames from the movie file at a maximum width of 300 pixels
# Frames will be exported into a `frames/` folder
# NOTE: if the frames folder exists and contains files that match the filename `frame_%03d.png`, no frames will be generated
mov2frames() {
if [ ! -z "$2" ]
then
size=$2
else
@lvl99
lvl99 / components.create-item.js
Last active February 23, 2017 07:01
Filtering and sorting via computed properties
import Ember from 'ember'
export default Ember.Component.extend({
store: Ember.inject.service(),
title: undefined,
location: undefined,
rating: undefined,
inputRatings: [{
label: 'Not rated',
@lvl99
lvl99 / components.filter-items.js
Last active February 15, 2017 14:44
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
filteredItems: Ember.computed('items', function () {
// Imagine more than just one filter here
return this.get('items').filterBy('showMe', true)
}),
sortDirection: ['lastUpdated:desc', 'createdAt:desc'],
sortedItems: Ember.computed.sort('filteredItems', 'sortDirection'),
@lvl99
lvl99 / 01-Example-of-ES6-class-extending.js
Created April 7, 2017 13:54
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
class Modal extends Toggleable {
  // … magic goes here …
}
@lvl99
lvl99 / 02-Example-of-HTML-when-declaring-CSS-classes-on-elements.html
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
<!-- Modal component HTML structure with modal and toggleable classes applied -->
<!-- This is usually the most basic way to combine multiple classes on an element -->
<div id=”example-a” class=”modal toggleable”>
<!-- … oh la la, magic~~~ … -->
</div>
@lvl99
lvl99 / 03-Example-Toggleable-composable-mixin-class.less
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Toggleable Mixin Class
// @param @ns Namespaces the custom state classes
// @param @-toggleable-display Sets the display property for showing the toggleable
.ui-lvl99-toggleable(@ns: ~"lvl99-toggleable"; @-toggleable-display: ~"block") {
// Uses the namespace to build custom state classes
@-toggleable-ns-class-show: ~".ui-@{ns}-show";
@-toggleable-ns-class-hide: ~".ui-@{ns}-hide";
// Class mixin which contain style definitions for `show` state
.-toggleable-class-show(@rules: {}) {
@lvl99
lvl99 / 04-Example-of-instantiating-Toggleable-mixin.less
Created April 7, 2017 13:55
Object-oriented inspired composable LESS mixins. View the article on the blog: http://blog.lvl99.com
// Import and apply the Toggleable Mixin Class to a specific class
.toggleable {
// Imports the mixin and its related mixins and variables
.ui-lvl99-toggleable(@ns: ~"toggleable");
// Initialise the default since we have no other modifications from the normal
.-toggleable-init-default();
}
// Let's do a parametric modification since spans should be displayed using `inline` or `inline-block`
span.toggleable {