Skip to content

Instantly share code, notes, and snippets.

View webinista's full-sized avatar

Tiffany Brown webinista

View GitHub Profile
@webinista
webinista / _transparent-placeholder-mixin.scss
Last active August 29, 2015 13:57
Clear placeholder input on focus using transparent keyword
@mixin placeholder{
&:focus::-webkit-input-placeholder{
color: transparent;
}
&:focus::-moz-placeholder {
color: transparent;
}
&:focus:-ms-input-placeholder {
color: transparent;
@webinista
webinista / zeropad.js
Last active August 29, 2015 13:57
Add zeroes to the left of a digit. Useful for date and time applications.
/*
input = number or numeric string.
length = pad with zeroes until it hits this length.
*/
function zeroPadLeft(input, length){
var zero = '0', pad = '', len, padded, inp, extract;
/* Convert to string */
inp = input+'';
@webinista
webinista / median.js
Created April 1, 2014 19:43
A simple function for finding the median value in an array of numbers.
var median = function(array){
var med, a, len;
len = array.length;
/* Sort by numeric value */
a = array.sort(function(a,b){return a - b});
med = Math.floor(len / 2);
@webinista
webinista / mean.js
Created April 1, 2014 19:46
A method to finding the mean (average) value from an array of numbers.
var mean = function(array){
var len, sum;
sum = array.reduce( function(a,b){
return a + b;
});
len = array.length;
return sum / len;
}
mean([2,4]); // 3
@webinista
webinista / formattime.js
Created April 1, 2014 23:32
Formatting time from timestamps. Takes seconds and returns a time string.
function formattime(timeinseconds){
var zeroes = '0', hours, minutes, seconds, time;
/*
Create a new date object and pass our time in seconds as the seconds parameter
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
*/
time = new Date(0, 0, 0, 0, 0, timeinseconds, 0);
hours = time.getHours();
@webinista
webinista / Fancy-checkboxes.markdown
Created June 21, 2014 00:42
A Pen by Tiffany Brown.

Fancy checkboxes

One of many ways in which to achieve fancy checkboxes. Can do the same for radio buttons by changing the input type as needed and updating styles.

A Pen by Tiffany Brown on CodePen.

License.

@webinista
webinista / removeHash.scss
Last active August 29, 2015 14:02
removeHash.scss: Removes the # from hexRGB colors
// Removes the # from hexRGB colors for use in SVG data URIs
@function removeHash($hexColor){
$hexColor: $hexColor + ''; // Convert to a string
$colorNum: str-slice($hexColor,2);
@return $colorNum;
}
// Sample usage
@mixin check($fillColor) {
$noHashColor: removeHash($fillColor);
@webinista
webinista / factorial.php
Created August 19, 2014 21:11
Factorial in PHP
<?php
function factorial($num){
$rng = range(1,$num);
return array_product($rng); // array_product function requires PHP5.1.0+
}
print factorial(10); // 3628800
@webinista
webinista / flex_gallery_shortcode
Last active August 29, 2015 14:06
Rewrite WordPress' gallery shortcode output to use markup that's FlexSlider friendly.
@webinista
webinista / radio-buttons.css
Created December 16, 2014 05:44
Custom radio buttons
input[type=radio].fancy-rb {
color: #c09 !important;
border: 1px solid #0c0 !important;
}
input[type=radio].fancy-rb {
opacity: 0;
}
input[type=radio].fancy-rb + label::before,
input[type=radio].fancy-rb + label::after {