Skip to content

Instantly share code, notes, and snippets.

View webinista's full-sized avatar

Tiffany Brown webinista

View GitHub Profile
@webinista
webinista / selectmenu.css
Created December 7, 2014 21:34
CSS for fancy select / dropdown menu arrows in modern browsers
/**
* See it in action http://demos.tiffanybbrown.com/2014/select-menu/
**/
/**
* For later versions of Firefox, Safari, Chrome, and Opera
**/
select {
-webkit-appearance: none; /* Safari, Chrome, Opera, etc */
-moz-appearance: none; /* Firefox */
@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 / 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 / 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 / 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 / numberFormat.js
Last active June 14, 2018 01:18
Format a number with a separator.
const numberFormat = (number, separator = ',') => {
const num = Number.isNaN(+number) ? 0 : +number;
let x = 0;
let fnum = [];
const digits = (num + '').split('');
const seg = digits.length / 3;
while(x < seg){
fnum[x] = digits.splice(-3).join('');
@webinista
webinista / array.chunk.js
Last active March 29, 2023 23:02
Array.prototype.chunk: Splits an array into an array of smaller arrays containing `groupsize` members
/*
Split an array into chunks and return an array
of these chunks.
With kudos to github.com/JudeQuintana
This is an update example for code I originally wrote 5+ years ago before
JavaScript took over the world.
Extending native objects like this is now considered a bad practice, so use
@webinista
webinista / formatUSPhoneNumber.js
Created April 7, 2014 02:43
Format a numeric string as xxx-xxx-xxxx
function formatUSPhoneNumber(number) {
var x = 0, groups = [], len, num;
/* Force string conversion */
num = number+'';
/* Remove non numeric characters */
@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 / 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