Skip to content

Instantly share code, notes, and snippets.

View c3ry5's full-sized avatar

Cerys Williams c3ry5

  • London, United Kingdom
View GitHub Profile
body {
background: #000;
}
.countdown {
background: #000;
color: #fff;
display: table;
margin: 0 auto;
text-align: center;
font-family: arial;
@c3ry5
c3ry5 / getVideoId.js
Last active November 3, 2020 10:53
Regex Map/loop for getting the video id from youtube, vimeo, vine and instagram
getVideoId = {
siteMap : {
"youtube" : {
r : /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/,
id : 5
},
"vimeo" : {
r : /https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/,
id : 3
},
@c3ry5
c3ry5 / helpers.checkUrl.js
Last active January 12, 2016 16:40
Url Validation
var checkUrl = function(url) {
var regex = new RegExp("(https?://(?:www.|(?!www))[^s.]+.[^s]{2,}|www.[^s]+.[^s]{2,})");
return url.match(regex) ? !0 : !1
};
@c3ry5
c3ry5 / combineMediaQueriesAndSelectors.rb
Created March 31, 2014 21:27
compass callback to restructure css files on stylesheet saved
require 'fileutils'
on_stylesheet_saved do |filename|
fileContents = File.read filename
File.open(filename, 'w+') do |f|
mediaQueryObject = {}
regexMedia = /@media([^{]*){((?:(?!}\s*}).)*}.*?)}/xoim
regexSelector = /\s*([^{]*){(.*?)}/xoim
regexSpace = /\n+|\r+/xoim
bodyContents = fileContents.gsub(regexMedia,'')
mediaQueryArray = fileContents.scan(regexMedia)
@c3ry5
c3ry5 / getMediaQuery.css
Created March 17, 2014 09:13
How to get the media query of your page
body #currentMediaQuery {
display: none;
}
@media only screen and max-width 479px {
body #currentMediaQuery {
font-family: xxs;
}
}
fileList="
FILE 1 URL
FILE 2 URL
FILE 3 URL
ETC
"
for fileName in $fileList
do
echo "$fileName"
String.prototype.toCapitalize = function() {
return this.toLowerCase().replace(/^\.|\s\S/g, function(a) {
return a.toUpperCase();
});
};
@c3ry5
c3ry5 / eventListener.js
Last active August 29, 2015 13:55
native js event listener
(function () {
'use strict';
var fo = window.fo = window.fo || {},
eventHandler = fo.eventHandler = fo.eventHandler || {};
eventHandler.events = {};
eventHandler.publish = function (event, data) {
var events = event.split(' '),
key, func;
@c3ry5
c3ry5 / mergeObjects.es6.js
Last active November 4, 2018 11:24
Merging two js objects without jquery
Object.prototype.assign = Object.assign || function(obj1, obj2) {
var obj3 = obj1;
for (var attrname in obj2) {
if (typeof(obj2[attrname]) !== 'function') {
obj3[attrname] = obj2[attrname];
}
}
return obj3;
@c3ry5
c3ry5 / web.sql.js
Last active December 19, 2015 19:49
Web sql setup using underscore js
(function () {
db = {};
db.map = {
'jobs': {
'create': {
'sql': 'CREATE TABLE "jobs" (id unique, json)'
},
'insert': {
'sql': 'INSERT INTO "jobs" (id, json) VALUES (?,?)'