Skip to content

Instantly share code, notes, and snippets.

View MathRivest's full-sized avatar

Mathieu Rivest MathRivest

  • Turo
  • Montreal, QC, Canada
  • 20:44 (UTC -04:00)
View GitHub Profile
@MathRivest
MathRivest / index.html
Created July 25, 2014 17:38
Small script to toggle part of the page
<button data-target="#target">Toggle</button>
<div id="target">Toggle me</div>
@MathRivest
MathRivest / validate.js
Created July 25, 2014 17:29
jQuery Validate phone number
jQuery.validator.addMethod("phone", function(value, element) {
return this.optional(element) || /^[1-9]\d{2}([-\ /\.])?[1-9]\d{2}([-\ /\.])?\d{4}$/.test(value);
}, "wrong phone");
@MathRivest
MathRivest / main.js
Last active August 29, 2015 14:04
Module Reveal pattern
// Basic Form
var APP = {};
APP.MyModule = (function() {
var privateVariable = 1;
var publicVariable = 2;
var publicFunction = function() {return 3;}
return {
publicVariable: publicVariable,
publicFunction: publicFunction
};
@MathRivest
MathRivest / middleman.sh
Created July 25, 2014 17:21
Basic vagrant file for middleman
echo "--- Update OS package list ---"
sudo apt-get update
echo "--- Update Timezone ---"
sudo cp /usr/share/zoneinfo/America/Montreal /etc/localtime
echo "--- Installing Git-core ---"
sudo apt-get install -y git-core
echo "--- Updating default ruby ---"
@MathRivest
MathRivest / mobile_menu.html
Last active August 29, 2015 14:03
Shell to start a collapsible menu on touch devices. Demo: http://codepen.io/anon/pen/KmkGb
<div class="page">
<div class="nav-mobile-pusher">
<!-- Nav goes here -->
<nav id="nav-mobile" class="nav-mobile">Mobile menu</nav>
<!-- Content goes here -->
<div class="container">
<a href="/" id="nav-mobile-toggle" class="nav-mobile-toggle">Open/Close</a>
<br>
My content
</div>
@MathRivest
MathRivest / favicons.html
Created June 21, 2014 23:22
All Favicons
<!-- non-retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="icon57.png" sizes="57x57">
<!-- non-retina iPad pre iOS 7 -->
<link rel="apple-touch-icon" href="icon72.png" sizes="72x72">
<!-- non-retina iPad iOS 7 -->
<link rel="apple-touch-icon" href="icon76.png" sizes="76x76">
<!-- retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="icon114.png" sizes="114x114">
<!-- retina iPhone iOS 7 -->
<link rel="apple-touch-icon" href="icon120.png" sizes="120x120">
@MathRivest
MathRivest / svg_fallback.js
Created June 17, 2014 13:24
SVG fallback to javascript using modernizr.js
if(Modernizr){
if (!Modernizr.svg || !Modernizr.backgroundsize) {
Y.all("img[src$='.svg']").each(function(node) {
node.setAttribute("src", node.getAttribute('src').toString().match(/.*\/(.+?)\./)[0]+'png');
});
}
}
@MathRivest
MathRivest / gitlab.rb
Last active August 29, 2015 14:01
Dashing - Gitlab Latest Commits
GITLAB_BASE_URL = ""
GITLAB_TOKEN = ""
# Retrieve the repositories and commits in gitlab
SCHEDULER.every '5m', :first_in => 0 do |job|
uri = URI("#{GITLAB_BASE_URL}projects?private_token=#{GITLAB_TOKEN}")
response = Net::HTTP.get(uri)
data = JSON.parse(response)
@MathRivest
MathRivest / vertical_align.scss
Created April 4, 2014 01:38
Vertical align in sass ie9+
@mixin vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.element p {
@include vertical-align;
@MathRivest
MathRivest / index.html
Last active August 29, 2015 13:57
Remember cookies state
<ul class="m-items">
<li>
<input type="checkbox"/>
</li>
<li>
<input type="checkbox"/>
</li>
<li>
<input type="checkbox"/>
</li>