Skip to content

Instantly share code, notes, and snippets.

View mgiulio's full-sized avatar

Giulio Mainardi mgiulio

View GitHub Profile
@mgiulio
mgiulio / lifecyclelogger.js
Created September 3, 2015 16:50
A mixin to log the lifecycle method invocations of a React component
var lifeCycleLogger = [
'componentWillMount',
'componentDidMount',
'componentWillUnmount',
'componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'componentDidUpdate'
].reduce(
(o, m) => {
@mgiulio
mgiulio / snippets.cson
Last active September 3, 2015 16:23
Atom snippet to create a React component(for Browserify)
'.source.js':
'Create React component':
'prefix': 'reactcomp'
'body': 'var React = require("react");\n\nvar $1 = React.createClass({\n\n\trender: function() {\n\t}\n\n});\n\nmodule.exports = $1;'
@mgiulio
mgiulio / Scrolling wrapper left on checking a checkbox.markdown
Created July 4, 2015 07:56
Scrolling wrapper left on checking a checkbox
@mgiulio
mgiulio / gist:dff8877d282f305edf23
Created June 15, 2015 12:18
Scripting CSS style sheets...
function installCSS() {
var styleEl = document.createElement('style');
styleEl.id = "inline-editor-css";
document.head.appendChild(styleEl);
var sheet = styleEl.sheet;
var rules = sheet.rules;
sheet.insertRule('.editor { width: 100%; position: relative; display: none; }', rules.length);
sheet.insertRule('.editor textarea { width: 100%; display: block; }', rules.length);
sheet.insertRule('.editor .button.ok { position: absolute; left: 0; top: 100%; }', rules.length);
@mgiulio
mgiulio / gist:1532629
Created December 29, 2011 07:32
post-date.js
(function($) {
var
dates = $('.entry-header .entry-meta'),
page = $('#page'),
post = $('#content > article.post')
;
$(window).on('resize', keepDateAligned);
keepDateAligned();
@mgiulio
mgiulio / gist:1532625
Created December 29, 2011 07:30
style.css
/*
Theme Name: Twenty Eleven Child
Theme URI: http: //example.com/
Description: Child theme for the Twenty Eleven theme
Author: Giulio Mainardi
Author URI: http: //mgiulio.altervista.org
Template: twentyeleven
Version: 0.1.0
*/
@mgiulio
mgiulio / gist:1528031
Created December 28, 2011 14:01
functions.php
<?php
add_action('template_redirect', 'on_template_redirect');
function on_template_redirect() {
if (!is_home())
return;
wp_enqueue_script(
'post-date',
@mgiulio
mgiulio / gist:1490037
Created December 17, 2011 11:51
jQuery Plugin to Swap two DOM Nodes
jQuery.fn.swap = function(b){
b = jQuery(b)[0];
var a = this[0];
var t = a.parentNode.insertBefore(document.createTextNode(''), a);
b.parentNode.insertBefore(a, b);
t.parentNode.insertBefore(b, t);
t.parentNode.removeChild(t);
return this;
};
@mgiulio
mgiulio / gist:840298
Created February 23, 2011 11:09
A quick'n'dirty patch for CDN hosted jQuery 1.5
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<script>
jQuery.fn.clone = function( dataAndEvents, deepDataAndEvents ) {
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function () {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
});
};
@mgiulio
mgiulio / gist:840295
Created February 23, 2011 11:06
HTML navigation list markup
<ul id="nav">
<li><a href="#" title="Home Page" rel="nofollow">Home</a></li>
<li><a href="#" title="About" rel="nofollow">About</a></li>
<li><a href="#" title="Projects" rel="nofollow">Projects</a></li>
<li><a href="#" title="Contact" rel="nofollow">Contact</a></li>
</ul>
<!--
http://en.wikipedia.org/wiki/Nofollow
-->