Skip to content

Instantly share code, notes, and snippets.

View ryanve's full-sized avatar
📶
stay free

deepskyblue ryanve

📶
stay free
View GitHub Profile
@ryanve
ryanve / solo.js
Last active August 29, 2015 13:55
Play only one track at a time. When one track plays, pause the rest.
// gist.github.com/ryanve/8703402
// Play only one track at a time.
(function(doc, tags) {
var listen = 'addEventListener', some = tags.some, pause = function(e) {
this !== e && !this.ended && !this.paused && !e.ended && !e.paused && e.pause();
};
some && listen in doc && tags.some(function(tag) {
var live = doc.getElementsByTagName(tag), solo = function() {
some.call(live, pause, this);
};
@ryanve
ryanve / .bash_profile
Created May 19, 2015 17:38
.bash_profile mac aliases
alias gitr='git'
alias gti='git'
alias got='git'
alias gut='git'
alias gi='git'
alias g='git'
alias gurnt='grunt'
alias gr='grunt'
<!DOCTYPE html>
<title>.slideshow demo</title>
<style>
html { font: normal 1em/1.6 sans-serif; background: pink; }
body { margin: 0; }
</style>
<style>
.slideshow {
text-align: center;
margin: 0;
@ryanve
ryanve / browse.scss
Last active October 28, 2015 00:32
CSS module for semantic inline [type=file] inputs
.browse {
display: inline;
font-size: inherit;
}
.browse__input {
display: inline-block;
position: absolute;
@include px-rem(padding, .1);
@include px-rem(margin, 0, -.5);
@ryanve
ryanve / self-source.php
Created March 18, 2013 20:42
Show source of a PHP file its .txt extension if it exists.
<?php
# Show source of this file in .txt extension if it exists
call_user_func(function() {
$txt = __FILE__ . '.txt';
if ( ! file_exists($txt))
return;
# update (cache at least 5-min)
if (300 < time() - filemtime($txt))
file_put_contents($txt, file_get_contents(__FILE__));
@ryanve
ryanve / untabulate.css
Created April 25, 2013 05:41
Use .untabulate as a state helper for converting tables to a mobile-friendlier view.
table.untabulate,
.untabulate table,
.untabulate thead,
.untabulate tbody,
.untabulate tfoot,
.untabulate th,
.untabulate td,
.untabulate tr { display:block; }
.untabulate tr + tr { margin-top:1em; }
@ryanve
ryanve / data.php
Created May 24, 2013 19:29
PHP data function to get/set data stored in private static hash.
<?php
namespace demo;
/**
* Get or set data.
* @param mixed $key
* @param mixed $val
* @return mixed
*/
function data($key = null, $val = null) {
@ryanve
ryanve / show-jumps.css
Created August 12, 2013 15:24
Use this CSS to display the target of jumps in figures. It is designed for use with images wrapped in jump anchors.
figure[id] > a[href^="#"]:after {
content:attr(href); display:table;
position:relative; top:-1.4em; bottom:-1.4em;
font-weight:bold; text-decoration:none;
line-height:1; padding:.2em; margin-bottom:-1.4em;
background:#fff; color:#222;
}
@ryanve
ryanve / is_page.php
Created December 27, 2015 23:40
wordpress check if is page or subpage of that page
<?php
$is_page = function($pages) {
global $post;
if (!is_page()) return false;
if (is_page($pages)) return true;
if (empty($post->post_parent)) return false;
$parent = get_post($post->post_parent);
if (!$parent || empty($parent->post_name)) return false;
$slug = $parent->post_name;
@ryanve
ryanve / placeholder.css
Created November 21, 2013 13:08
CSS rules to style [placeholder] text
::-webkit-input-placeholder { color:inherit; }
:-moz-placeholder { color:inherit; } /* FF 4-18 */
::-moz-placeholder { color:inherit; } /* FF 19+ */
:-ms-input-placeholder { color:inherit; } /* IE 10+ */