Skip to content

Instantly share code, notes, and snippets.

View gabrielhpugliese's full-sized avatar

Gabriel H Pugliese gabrielhpugliese

View GitHub Profile
onSubmit={this.props.handleSubmit((values) => {
return new Promise((resolve, reject) => {
this.handleSubmitTest(values)
.then(() => resolve(), err => {
reject(err);
});
}
})}
import { connect } from 'react-redux';
import { todos } from './reactive-redux';
const mapStateToProps = ({ todos }) => ({ todos });
@connect(mapStateToProps)
export default class TodoMain extends Component {
render() {
const { todos } = this.props;
@gabrielhpugliese
gabrielhpugliese / settings.py
Last active February 3, 2016 12:46
Python Muffin + Webpack Html Plugin
# ...
BASE_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') # go one folder behind, but configure yours
JINJA2_TEMPLATE_FOLDERS = '../react-app/dist'
STATIC_FOLDERS = '../react-app/dist',
# ...
import { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as CounterActions from '../actions/counter';
const counterProps = ({ counter }) => ({ counter });
const dispatchToActionCreators = dispatch => bindActionCreators(CounterActions, dispatch);
@connect(counterProps, dispatchToActionCreators)
@gabrielhpugliese
gabrielhpugliese / querydict.py
Created March 26, 2015 14:41
QueryDict with lists
In [23]: query_string = u'fields%5Bcategories%5D%5B%5D=1&fields%5Bcategories%5D%5B%5D=3'
In [24]: QueryDict(query_string)
Out[24]: <QueryDict: {u'fields[categories][]': [u'1', u'3']}>
In [25]: QueryDict(query_string).dict()
Out[25]: {u'fields[categories][]': u'3'}
In [26]: QueryDict(query_string).items()
Out[26]: [(u'fields[categories][]', u'3')]
@gabrielhpugliese
gabrielhpugliese / logentries.md
Last active August 29, 2015 14:17
Logentries guest post

There are a lot of implicit computation going on with Meteor's reactivity. Tracker, Session variables, Cursors, Templates etc. They create lots of implicit recalculations that we can easily lose their tails and create a seven-headed dragon that will haunt you! For me, the immediate valuable technique is logging everything that is going to recompute on reactive data contexts (see more here: http://docs.meteor.com/#/full/reactivity).

On CodersTV, I'm starting to send my logs to Logentries, from both client and server. It is useful if you don't want to care about log rotation and other hard disk concerns on small machines. Also valuable if you have a balancer with autoscale and need to send logs to the same entry point. Or maybe if you are using meteor.com server, where it is most valuable.

On Meteor's servers, you can access your logs running the command meteor logs .meteor.com, but it will give you only the latest logs and you can't tail it making it a hell to cross old and ne

define(function (require) {
'use strict';
var React = require('react');
var _ = require('underscore');
var DragDropMixin = require('react-dnd').DragDropMixin;
var ItemTypes = require('components/ItemTypes');
var dragSource = {
beginDrag: function (component) {
@gabrielhpugliese
gabrielhpugliese / SassMeister-input.scss
Created March 3, 2015 14:49
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
.btn { color: white;}
.btn-primary { color: blue; }
.btn-disabled { color: grey; }
.simple-form {
@gabrielhpugliese
gabrielhpugliese / gulpfile.js
Last active January 31, 2019 09:08
Django collectstatic + Gulp watch
var gulp = require('gulp');
var shell = require('gulp-shell');
var changed = require('gulp-changed');
gulp.task('collectstatic', function () {
return gulp.src('static/**/*.*')
.pipe(changed('YOURAPP/static/'))
.pipe(shell([
'python manage.py collectstatic --noinput'
DetalheAnuncioIndexController = RouteController.extend({
waitOn: function () {
Meteor.subscribe('users');
return Meteor.subscribe('listarAnuncios');
},
data: function () {
return Anuncios.findOne(this.params.id);
},