Skip to content

Instantly share code, notes, and snippets.

View byverdu's full-sized avatar
🤦‍♂️
lost in translation

Albert Vallverdu byverdu

🤦‍♂️
lost in translation
View GitHub Profile
@byverdu
byverdu / httpRequest.js
Last active May 15, 2016 10:59
Building the container that will append to page
/**
* responseListenerData - callback passed to de xhrHttp request,
* selects the DOM element, which will be used to append the response text
*
* @return {void} void
*/
function responseListenerData () {
// queries the parent node
const parentNode = document.querySelector( '.container' );
@byverdu
byverdu / index.html
Last active May 18, 2016 00:10
Index file for infinite scrolling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width initial-scale=1"/>
<title>infiniteScroll</title>
</head>
<body>
<div class="container">
<header class="container__header">
@byverdu
byverdu / userAgent.js
Created May 15, 2016 11:01
Checks client's user agent
/**
* whichUserAgent - Extracts a string for a later reference from the window.userAgent
*
* @param {Object} navigatorObject - browser navigator Object
* @return {String} - navigator.userAgent from user visitor's
*/
function whichUserAgent( navigatorObject ) {
const userAgent = navigatorObject.userAgent.split( ' ' );
const userAgentString = [ 'Firefox', 'AppleWebKit', 'Trident' ];
let actualUserAgent = '';
@byverdu
byverdu / main.js
Last active March 11, 2017 09:27
entry point file, imports modules and appends functions to DOM
import { whichUserAgent, isFirefoxAgent, isWebKitAgent, isOldInternetExplorer } from './modules/userAgent';
import { doHttpRequest } from './modules/httpRequest';
document.addEventListener( 'DOMContentLoaded', () => {
/**
* checkHeightBody - Calls isFirefoxAgent, isWebKitAgent or isOldInternetExplorer
* dependig on userAgent
*
* @param {Object} navigatorObject navigator Object
@byverdu
byverdu / buildIA.js
Last active March 11, 2017 09:32
post code sample
// build IA
import Human from 'forgotten/species';
import Utils from 'some/crazy/path';
@Uitls
@Human
export default IA extends Human {
constructor(type, ram) {
super(name, sex)
this.type = type;
import React, { Component } from 'react';
import { Row, Col, Progress } from 'reactstrap';
import Loading from '../components/subComponents/loading';
import ReactHtmlParser from 'react-html-parser';
export default class Success extends Component {
constructor( props ) {
super( props )
this.state = {
import React, { Component } from 'react';
import loadGoogleMapsAPI from 'load-google-maps-api'; // Única dependencia extra
// es muy importante añadirle height y width!!!
const MAP_STYLES = {
height: '450px',
width: '100%'
}
const OPTIONS = {
import Express from 'express';
import pathUtil from 'path';
import { DBDisconnect } from '../../utils';
import { rootPath } from '../../conf';
const bodyParser = require( 'body-parser' );
const allRoutes = require( './routes' );
const notFoundRoute = require( './routes/404' );
/* eslint-disable import/no-extraneous-dependencies*/
// Test cases for Mongo Schemas
import { ImdbSchema } from '../../app/server/models/ImdbSchema';
import sampleData from '../sampleData';
let movie;
let Imdb;
let connection;
require( '../../app/server/db' );
@byverdu
byverdu / gulpfile.babel.js
Last active April 12, 2018 03:22
es6 + gulp + expressjs + nodemon + browser-sync
import gulp from 'gulp';
import browserSync from 'browser-sync';
import nodemon from 'gulp-nodemon';
const browserOpts = {
proxy: 'http://localhost:3000',
port: 9000,
open: false
};