Skip to content

Instantly share code, notes, and snippets.

Avatar

Gabriel H Pugliese gabrielhpugliese

View GitHub Profile
View async.js
onSubmit={this.props.handleSubmit((values) => {
return new Promise((resolve, reject) => {
this.handleSubmitTest(values)
.then(() => resolve(), err => {
reject(err);
});
}
})}
View example.js
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 Feb 3, 2016
Python Muffin + Webpack Html Plugin
View settings.py
# ...
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',
# ...
View counter.jsx
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)
View querydict.py
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 Aug 29, 2015
Logentries guest post
View logentries.md

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

View draggable_form.jsx
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) {
View SassMeister-input.scss
// ----
// 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 Jan 31, 2019
Django collectstatic + Gulp watch
View gulpfile.js
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'
View gist:e95297a54a7c24dadd6a
DetalheAnuncioIndexController = RouteController.extend({
waitOn: function () {
Meteor.subscribe('users');
return Meteor.subscribe('listarAnuncios');
},
data: function () {
return Anuncios.findOne(this.params.id);
},