Skip to content

Instantly share code, notes, and snippets.

View pedronauck's full-sized avatar
:electron:

Pedro Nauck pedronauck

:electron:
View GitHub Profile

Regular Expressions

Basic Syntax

  • /.../: Start and end regex delimiters
  • |: Alternation
  • (): Grouping

Sublime Text 2 Cheat Sheet

Edit

Command Description
CMD+SHIFT+V Paste and indent
CMD+] Indent
CMD+[ Unindent
CMD+CTRL+Arrow Up Swap line up
@pedronauck
pedronauck / Posts.jsx
Last active August 29, 2015 14:06
A simple structure example to use React with a router
/* file path: ./views/Posts */
'use strict';
var React = require('react');
var PostIndex = React.createClass({
render: function() {
var posts = this.props.posts.map(function(post, index) {
return (
@pedronauck
pedronauck / react-todo-app.jsx
Last active August 29, 2015 14:07
Sample React todo app without LinkState()
/** @jsx React.DOM */
var TodoAdd = React.createClass({displayName: 'TodoAdd',
getInitialState: function() {
return { text: '' };
},
changeText: function(e) {
this.setState({ text: e.target.value });
e.preventDefault();
},
@pedronauck
pedronauck / average-sum.js
Last active August 29, 2015 14:07
Example of matrix manipulate with ES6
/*
* Function that calculate the average of a number
*
* @param {Number} num
* @param {Number} divisor
* @return {Number} simple arithmetic average of num
*
*/
var calcAverage = (num, divisor) => (num / divisor).toFixed(2);
@mixin all-retina-sprites($map, $map2x) {
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 1.5dppx) {
$base-class: sprite-map-name($map);
.#{$base-class}-all-retina-sprites {
@pedronauck
pedronauck / enquire.js
Created May 16, 2013 18:50
EnquireJS base script
var query_960 = 'screen and (min-width: 45em)';
enquire.register($query_960, {
deferSetup : true,
setup : function() {
// load content via AJAX
},
match : function() {
// show sidebar
module.exports = function(grunt) {
var config = {};
// Set all the tasks you want to load.
var tasks = [
, "grunt-contrib-concat"
, "grunt-contrib-uglify"
, "grunt-contrib-jshint"
, "grunt-contrib-watch"
];
@pedronauck
pedronauck / closure.js
Last active December 31, 2015 16:59
A closure function template
'use strict';
(function(window, document) {
// Your starting point. Enjoy the ride!
})(window, document);