Skip to content

Instantly share code, notes, and snippets.

View josegl's full-sized avatar
:octocat:

Jose G.L. josegl

:octocat:
View GitHub Profile
@josegl
josegl / git diff
Created October 28, 2015 10:48
passing to es6 class
diff --git a/server/modules/ventaLead/lib/VentaLead.js b/server/modules/ventaLead/lib/VentaLead.js
index 563c2bc..dede967 100644
--- a/server/modules/ventaLead/lib/VentaLead.js
+++ b/server/modules/ventaLead/lib/VentaLead.js
@@ -5,87 +5,76 @@ var Car = require('../../car');
var util = require('../../../../lib/util');
var Canalcar = require('../../../../lib/canalcarApiClient');
-var VentaLead = function (rawVentaLead){
- var self = this;
@josegl
josegl / current-actions.js
Last active November 17, 2015 10:47
Best redux way to extract an item from an array
let action = (id, items) => {
return {
type: ACTION_TYPE;
item: items.filter(i => id === i._id)[0] // item with id will always exists in the array
}
}
@josegl
josegl / ItemListContainer.js
Last active November 18, 2015 10:21
Logic in an redux action?
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { fetchItemsIfNeeded } from '../actions';
import ListItem from '../components/ListItem';
class ItemsList extends Component {
constructor(props) {
super(props);
}
@josegl
josegl / font.sh
Created November 26, 2015 20:41
How to increase a java application GUI font from terminal
java -Dswing.aatext=true -Dswing.plaf.metal.controlFont=Tahoma-20 -Dswing.plaf.metal.userFont=Tahoma-20 -jar file.jar
@josegl
josegl / LeftNav.js
Created January 28, 2016 11:30
Example of how containers should work in complex apps.
export default ({
selected_item, open, gotoIndex
}) => (¬
<List open={open} selected_item={selected_item}>¬
<ListItem value={1} onClick={e => gotoIndex(target.value)}/>¬
<ListItem value={2} onClick={e => gotoIndex(target.value)}/>¬
@josegl
josegl / Input.js
Last active January 28, 2016 12:01
export default ({
value, update
}) => (¬
<div>
<input onChange={e => update(e.target.value) value={value}}/>
</div>¬
);
@josegl
josegl / List.js
Last active January 29, 2016 09:27
working example
import React from 'react';
export default ({
items, fetchItems
}) => {
if(items.size === 0)
fetchItems();
return (<div>{items}</div>);
};
@josegl
josegl / List.js
Created January 29, 2016 23:19
Container element class with lifecycle element hooks
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { fetchItemsIfNeeded } from './actions';
import ListItem from './ListItem';
class List extends Component{
constructor(props) {
super(props);
}
@josegl
josegl / client.js
Created July 7, 2016 06:53
client route example
router.get('/', (req, res) => {
if(req.user){
if req.user.active){
if(req.query.id){
findById(req.query.id).then(fClient => {
if(fClient){
res.json(fClient);
} else {
res.json({});
}
'use strict';
var _cloneNode, _createElement, _isCanvasBlank, jsPDF, downloadPdf;
_cloneNode = function(node, javascriptEnabled) {
var child, clone;
clone = node.nodeType === 3 ? document.createTextNode(node.nodeValue) : node.cloneNode(false);
child = node.firstChild;
while (child) {
if (javascriptEnabled === true || child.nodeType !== 1 || child.nodeName !== 'SCRIPT') {
clone.appendChild(_cloneNode(child, javascriptEnabled));