Skip to content

Instantly share code, notes, and snippets.

@crystalw
crystalw / SCSS.md
Created March 26, 2017 00:07 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@crystalw
crystalw / pseudo-elements.md
Created April 15, 2016 21:41 — forked from p3t3r67x0/pseudo_elements.md
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.

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] {
@crystalw
crystalw / SassMeister-input.scss
Created April 14, 2016 07:52 — forked from davidkpiano/SassMeister-input.scss
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
$scotch-color-key: 'base' !default;
$scotch-colors: (
'primary': (
'base': #8e3329,
@crystalw
crystalw / .bash_profile
Created April 6, 2016 20:38
bash aliases
#opens chrome with CORS disabled
alias chromex='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security'
#removes merged local branches (except for master)
alias gitprune='git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d'
#switches to ui project
alias backend="cd ${PWD/ui/backend}"
#switches to backend project
// iframes
var $iframes = $( document.querySelectorAll( '.widget iframe' ) );
function iframeSizing() {
var $this = $( this ),
width = $this.width(),
height = $this.height(),
containerWidth = $this.parent().width(),
heightRatio = height / width,
newHeight = heightRatio * containerWidth;
@crystalw
crystalw / Regex Phone Validation
Created February 5, 2014 15:06
A few regex examples for validating common phone number formats
<?php
//regex for 7 or 10 digit number, delimiters are spaces, dashes, or periods:
^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]‌​)\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-‌​9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
//same regex as above, but for 10 digit number only
^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]‌​)\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)([2-9]1[02-9]‌​|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
//this regex will not allow the preceeding 1 at the beginning of the phone number
^(?:(?:(\s*\(?([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2‌​-9][02-8]1|[2-9][02-8][02-9]))\)?\s*(?:[.-]\s*)?)([2-9]1[02-9]|[2-9][02-9]1|[2-9]‌​[02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
@crystalw
crystalw / outcome.html
Last active December 19, 2015 03:19
Check an element's class to determine the outcome of an event and push the occurrence to Google Analytics. Useful for tracking successful form submits on Ajax or other form types with static urls. Google Event Tracking Guide: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
<div class="outcome" class="successful">
<p>Thanks, your message has been sent!</p>
</div>
<script>
$(document).ready(function() {
if ($( '#outcome' ).hasClass( "successful" )) {
_gaq.push(['_trackEvent', 'Category', 'Action', 'opt_label']);
}
});
@crystalw
crystalw / html5_doctype.html.haml
Last active December 19, 2015 01:28
HTML5 HAML Doc Type Declaration
!!! 5
%html
%head
%title= "My Website"
%meta{ :charset => "utf-8" }
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
%body