Skip to content

Instantly share code, notes, and snippets.

View wheresrhys's full-sized avatar

Rhys Evans wheresrhys

View GitHub Profile
@wheresrhys
wheresrhys / gist:1405171
Created November 29, 2011 15:28 — forked from philhawksworth/gist:1393999
centered dynamic menu
<html>
<head>
<title></title>
<style type="text/css">
.primary-nav {
width:1000px;
border:solid 1px red;
text-align:center;
}
@wheresrhys
wheresrhys / longestIncreasingSequence
Last active October 15, 2021 16:46
Javascript function for finding the longest increasing subsequence within a sequence of numbers (stored as an array) . Also included is a derivative function which finds the longest decreasing sequence.
//
// longestIncreasingSequence
// ---
//
// Javascript function for finding the longest increasing subsequence within a sequence of numbers
//
// @param {Array} arr The array containng the sequence
// @param {Boolean} strict Boolean specifying whether to use strict (`<`) inequality (default is to use `<=`)
// @return {Array}
//
@wheresrhys
wheresrhys / gist:4581989
Created January 20, 2013 21:46
Simple templating engine
var Template = function() {
var pattern = /\{{([\w-]+)\}}/g,
replacements = {
"\\" : "\\\\",
"\\r\\n": "\n",
"'": "\'",
"\"":"\\\""
},
cleanupRX = function() {
@wheresrhys
wheresrhys / .jshintrc
Created February 1, 2013 16:33
Jshint sublime config file
{
"node": true,
"browser": true,
"es5": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
@wheresrhys
wheresrhys / css-rules-regex
Last active December 14, 2015 09:29
Regex for removing (most) style rules from within CSS selectors - useful for copying all your selectors into a different stylesheet section using a media query
(^\s+[a-z\-]+\s?\:[a-z0-9#\s\-,\'"%\(\)]+;\n?\r?)+
/* modernizr-test_position_fixed_ios.js
* Original by Daniel Ott (https://gist.github.com/1333800)
* 3 March 2011
* Updated by Philipp Söhnlein 3 November 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
@wheresrhys
wheresrhys / gist:5822860
Last active November 15, 2019 14:51
Vertical and horizontally centered overlay using just css (flexbox)
.overlay-mask {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-flex-align: center;
-ms-flex-align: center;
@wheresrhys
wheresrhys / gist:5823198
Created June 20, 2013 14:28
Adds outer/innerHeight/Width methods to Zepto Adapted from https://gist.github.com/alanhogan/3935463
(function($) {
// Add inner and outer width to zepto (adapted from https://gist.github.com/alanhogan/3935463)
var ioDim = function(dimension, includeBorder) {
return function (includeMargin) {
var sides, size, elem;
if (this) {
elem = this;
size = elem[dimension]();
sides = {
width: ["left", "right"],
@wheresrhys
wheresrhys / gist:8731722
Created January 31, 2014 13:03
Sublime settings
//Keybindings
[
{ "keys": ["ctrl+e"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} }
]
@wheresrhys
wheresrhys / page.html
Last active August 29, 2015 13:56 — forked from triblondon/page.html
<script>
(function() {
if (Modernizr.classlist && Modernizr.queryselector && Modernizr.localstorage && Modernizr.eventlistener) {
var j = document.createElement('script');
j.type = 'text/javascript';
j.async = true;
j.src = '/resources/javascript/bundle.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(j, s);
document.documentElement.className += ' o--js';