Skip to content

Instantly share code, notes, and snippets.

@vctrfrnndz
vctrfrnndz / gist:4642918.php
Last active December 11, 2015 18:38
Obtain a list of videos from a Vimeo account using PHP
<?php
// Account to get the videos from
$username = 'user6002596';
// Do request to Vimeo API
$request = 'http://vimeo.com/api/v2/'. $username .'/videos.xml';
// Parse into SimpleXML object
$vimeo = simplexml_load_file($request);
@vctrfrnndz
vctrfrnndz / gist:5105351.php
Last active December 14, 2015 15:08
Youtube id regular expression (getting url from Wordpress meta tag)
$video_url = get_post_meta( get_the_ID(), 'mb_youtube_url', true );
// Parse video ID from given url
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $video_url, $match)) {
$video_id = $match[1]; // Return video ID
}
@vctrfrnndz
vctrfrnndz / gist:6526989.less
Last active December 22, 2015 20:29
Ultimate grid mixin
// Group class for clearing floats
.group {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
@mixin grid($cols: 1, $gutter: 0, $childs: ".item") {
width: auto;
margin-right: -$gutter;
#{$childs} {
float: left;
width: (100% / $cols);
padding-right: $gutter;
background-clip: content-box;
@vctrfrnndz
vctrfrnndz / jquery.accordion.defautls.js
Last active August 29, 2015 14:02
jQuery Accordion Defaults
{
transitionSpeed: 300,
transitionEasing: 'ease',
controlElement: '[data-control]',
contentElement: '[data-content]',
groupElement: '[data-accordion-group]',
singleOpen: true
}
@vctrfrnndz
vctrfrnndz / debounce.js
Last active November 8, 2019 04:23
Debounce
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
function scrollAnimated(to, duration) {
var start = $(window).scrollTop(),
change = to - start,
currentTime = 0,
increment = 20;
function easeInOut(currentTime, startValue, change, duration) {
currentTime /= duration / 2;
if (currentTime < 1) {
Avatar Generator from Name
--------------------------
A name (first name and surname) is input and output using the initials from the name and a background colour (based on the first name first letter). The background colors are from from http://flatuicolors.com/
@vctrfrnndz
vctrfrnndz / letteravatar.js
Created May 18, 2015 17:06
Generate SVG letter avatar
function drawCircle(text, size, color) {
var textSize = Math.ceil(size / 2.5);
var font = 'Proxima Nova, proxima-nova, HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif';
var colors = ["#1abc9c", "#16a085", "#f1c40f", "#f39c12", "#2ecc71", "#27ae60", "#e67e22", "#d35400", "#3498db", "#2980b9", "#e74c3c", "#c0392b", "#9b59b6", "#8e44ad", "#bdc3c7", "#34495e", "#2c3e50", "#95a5a6", "#7f8c8d", "#ec87bf", "#d870ad", "#f69785", "#9ba37e", "#b49255", "#b49255", "#a94136"];
var colorIndex = Math.floor((text.charCodeAt(0) - 65) % colors.length);
var finalColor = color || colors[colorIndex];
var template = [
'<svg height="' + size + '" width="' + size + '" style="background: ' + finalColor + '">',
'<text text-anchor="middle" x="50%" y="50%" dy="0.35em" fill="white" font-size="' + textSize + '" font-family="' + font + '">' + text.toUpperCase() + '</text>',
@vctrfrnndz
vctrfrnndz / val.js
Created July 8, 2015 17:03
input validations
function inputValidations() {
function isAlphaNumeric(val) {
var letter = /[a-zA-Z]/,
number = /[0-9]/;
var valid = number.test(val) && letter.test(val);
return valid;
}