Skip to content

Instantly share code, notes, and snippets.

Cerys Williams c3ry5

  • London, United Kingdom
Block or report user

Report or block c3ry5

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@c3ry5
c3ry5 / eventListener.js
Last active Aug 29, 2015
native js event listener
View eventListener.js
(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;
View Capitalize.js
String.prototype.toCapitalize = function() {
return this.toLowerCase().replace(/^\.|\s\S/g, function(a) {
return a.toUpperCase();
});
};
View akamai.curl.sh
fileList="
FILE 1 URL
FILE 2 URL
FILE 3 URL
ETC
"
for fileName in $fileList
do
echo "$fileName"
@c3ry5
c3ry5 / getMediaQuery.css
Created Mar 17, 2014
How to get the media query of your page
View getMediaQuery.css
body #currentMediaQuery {
display: none;
}
@media only screen and max-width 479px {
body #currentMediaQuery {
font-family: xxs;
}
}
@c3ry5
c3ry5 / combineMediaQueriesAndSelectors.rb
Created Mar 31, 2014
compass callback to restructure css files on stylesheet saved
View combineMediaQueriesAndSelectors.rb
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 / cq.triggercallback.js
Last active Aug 29, 2015
An exjs trigger callback xtype for AEM/CQ
View cq.triggercallback.js
var triggerCallback = CQ.Ext.extend(CQ.Ext.form.TriggerField, {
initComponent: function() {
triggerCallback.superclass.initComponent.call(this)
},
triggerClass: "x-form-search-trigger",
onTriggerClick: function() {
if(this.callback) {
this.callback.call(this);
}
},
@c3ry5
c3ry5 / mixins.sass
Last active Dec 19, 2015
Retina sprite generation using sass
View mixins.sass
@mixin sprite-background($name)
background-repeat: no-repeat
background-image: $standardImg
background-position: sprite-position($sprites, $name)
height: image-height(sprite-file($sprites, $name))
width: image-width(sprite-file($sprites, $name))
@media (-webkit-min-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 1.5)
background-image: $retinaImg
background-position: 0 round(nth(sprite-position($sprites2x, $name), 2) / 2)
height: round(image-height(sprite-file($sprites2x, $name)) / 2)
@c3ry5
c3ry5 / backbone.replaceHash.js
Created Jul 5, 2013
override backbone.js _updateHash to replace location.replace for old devices with window.history.replaceState
View backbone.replaceHash.js
var oldBrowser = (reContainsAll([/mozilla\/5.0/i, /android/i, /applewebkit/i], navigator.userAgent)
|| reContainsAll([/mozilla\/5.0/i, /iphone os (5|4|3|2|1){1}/i, /applewebkit/i], navigator.userAgent))
&& !reContainsAll([/chrome/i], navigator.userAgent);
Backbone.History.prototype._updateHash = function(location, fragment, replace) {
var base = location.toString().replace(/(javascript:|#).*$/, '') + '#';
if (replace) {
if (oldBrowser) {
window.history.replaceState({}, document.title, base + fragment);
} else {
@c3ry5
c3ry5 / web.sql.js
Last active Dec 19, 2015
Web sql setup using underscore js
View web.sql.js
(function () {
db = {};
db.map = {
'jobs': {
'create': {
'sql': 'CREATE TABLE "jobs" (id unique, json)'
},
'insert': {
'sql': 'INSERT INTO "jobs" (id, json) VALUES (?,?)'
View helpers.checkUrl.js
var checkUrl = function(url) {
var regex = new RegExp("(https?://(?:www.|(?!www))[^s.]+.[^s]{2,}|www.[^s]+.[^s]{2,})");
return url.match(regex) ? !0 : !1
};
You can’t perform that action at this time.