Skip to content

Instantly share code, notes, and snippets.

View webinista's full-sized avatar

Tiffany Brown webinista

View GitHub Profile
@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 / 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 / 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 / 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 / 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 {
@webinista
webinista / genpass.php
Created December 18, 2014 19:30
Command-line PHP script for generating random-ish passwords.
<?php
/*
* Designed to be used on the command line.
* php genpass.php [arg1] [arg2] ...
* Accepts up to three parameters:
* --length or -l = length of the password
* --specialchars or -s = whether to include punctuation in generating the password
* --unique or -u = whether to prevent repeated characters in a string
*
*/
@webinista
webinista / gist:3adbd4ce1b95566d5d13
Created March 10, 2015 16:21
Rewrite base dir and all URLs to subdir
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/$ /content/ [L]
RewriteRule ^(.*)$ /content/$1 [L]
</IfModule>
# END WordPress