Skip to content

Instantly share code, notes, and snippets.

Jose G.L. josegl

  • Madrid, Spain
Block or report user

Report or block josegl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dom-to-image.js
'use strict';
var util = newUtil();
var inliner = newInliner();
var fontFaces = newFontFaces();
var images = newImages();
// Default impl options
var defaultOptions = {
// Default is to fail on error, no placeholder
View dom-to-pdf.js
'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));
@josegl
josegl / client.js
Created Jul 7, 2016
client route example
View client.js
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({});
}
@josegl
josegl / List.js
Created Jan 29, 2016
Container element class with lifecycle element hooks
View List.js
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 / List.js
Last active Jan 29, 2016
working example
View List.js
import React from 'react';
export default ({
items, fetchItems
}) => {
if(items.size === 0)
fetchItems();
return (<div>{items}</div>);
};
View Input.js
export default ({
value, update
}) =>
<div>
<input onChange={e => update(e.target.value) value={value}}/>
</div>¬
);
@josegl
josegl / LeftNav.js
Created Jan 28, 2016
Example of how containers should work in complex apps.
View LeftNav.js
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 / font.sh
Created Nov 26, 2015
How to increase a java application GUI font from terminal
View font.sh
java -Dswing.aatext=true -Dswing.plaf.metal.controlFont=Tahoma-20 -Dswing.plaf.metal.userFont=Tahoma-20 -jar file.jar
@josegl
josegl / ItemListContainer.js
Last active Nov 18, 2015
Logic in an redux action?
View ItemListContainer.js
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 / current-actions.js
Last active Nov 17, 2015
Best redux way to extract an item from an array
View current-actions.js
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
}
}
You can’t perform that action at this time.