Skip to content

Instantly share code, notes, and snippets.

View pedronauck's full-sized avatar
:electron:

Pedro Nauck pedronauck

:electron:
View GitHub Profile
// ================================================================================================
//
// Components » <%= font_name.capitalize.gsub(/-/, ' ') %>
//
// ================================================================================================
<%= font_face(:rails).gsub(/"\//, '"') %>
[class*="icon-"] {
display: inline-block;
@pedronauck
pedronauck / gulpfile.js
Created January 13, 2014 03:04
A sample gulp file to using in many projects
var gulp = require('gulp'),
pkg = require('./package.json'),
path = require('path'),
connect = require('connect'),
http = require('http'),
open = require('open'),
compass = require('gulp-compass'),
@pedronauck
pedronauck / vim_commands.md
Created January 14, 2014 17:48
A list containing some vim commands

Vim Commands

Commands

:tabe - open file in new tab	
:e - open file	
,t - find a file in directory		
cmd+shift+n - open NerdThree	
ctrl+(h,j,k,l): navigation in screen
@pedronauck
pedronauck / model.js
Last active April 23, 2020 20:21
Model file for mongoose
'use strict';
var mongoose = require('mongoose'),
timestamp = require('timestamp'),
Schema = mongoose.Schema,
ObjectId = Schema.Types.ObjectId;
var ModelSchema = new Schema({
name: { type: String }
});

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 / controlAsyncFlow.js
Created September 7, 2014 05:58
Example using async library to avoid callback hell
var async = require('async');
var Product = require('../model/Product');
var Category = require('../model/Category');
var Attribute = require('../model/Attributes');
// bad idea
exports.index = function() {
Product.find(function(err, products) {
Category.find(function(err, categories) {
Attribute.find(function(err, attributes) {
@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);