Skip to content

Instantly share code, notes, and snippets.

View juanmaguitar's full-sized avatar

JuanMa juanmaguitar

View GitHub Profile
@juanmaguitar
juanmaguitar / program.js
Last active August 2, 2017 10:35
Socket TCP demo
var net = require('net')
var PORT = process.argv[2]
var strftime = require('strftime')
var server = net.createServer( function(socket) {
var formattedDate = strftime('%Y-%m-%d %H:%M') + '\n'
socket.end(formattedDate)
})
server.listen(PORT)
@juanmaguitar
juanmaguitar / index.html
Created July 23, 2017 22:28
Mark duplicates ng-repeat angular
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.highlight {
background: yellow;
}
</style>
@juanmaguitar
juanmaguitar / duplicates.js
Created July 23, 2017 22:27
Detect duplicates in an array
const isDuplicated = (element, i, array) => {
return array.filter( item => item === element).length > 1
}
const countries = ['Namibia','Niger','Palau','Macedonia','Brazil','Czech Republic','Mauritania','Canada','Sweden','Afghanistan','Singapore','Azerbaijan','Turkmenistan','Sao Tome and Principe','Denmark','Mongolia','Switzerland','St. Lucia','Nauru','Slovenia','Papua New Guinea','Cameroon','Iraq','Portugal','Zambia','Italy','Afghanistan','Burkina Faso','Dominica','Iceland','Serbia','Myanmar','Canada','Oman','United Kingdom','Tanzania','Jordan','Timor-Leste','Kosovo','Lithuania','Tuvalu','Palau','Latvia','Andorra','Belarus','Tajikistan','Indonesia','Hungary','Cambodia','Israel','Bangladesh','Peru','Moldova']
countries
.map( isDuplicated )
@juanmaguitar
juanmaguitar / ionic-app-structure.md
Last active July 13, 2017 10:37
Ionic Application Structure

# Ionic Application Structure

After running the ionic start command, the Ionic CLI will generate a handful of files & folders for your new app. They span across a couple of different aspects of your hybrid app development and are worth being aware of.

Lets break them down one by one:

  • bower.json: Used for managing your app's dependencies via the bower package management tool. By default, the Ionic Framework is the only dependency, but you can add more as needed.
  • config.xml: This is the configuration file for Cordova. It's used for Cordova plugin management and app settings.
  • gulpfile.js: This file is used for compiling SASS and other Ionic Framework specific tasks via the gulp task runner.
@juanmaguitar
juanmaguitar / UserList.js
Last active February 15, 2017 17:52
Events Demo node.js | Constructor function inheriting from EventEmitter to "produce" objects w/ events
var util = require("util");
var EventEmitter = require("events").EventEmitter;
util.inherits(UserList, EventEmitter);
var users = [];
function UserList() {}
UserList.prototype.addUser = function(user) {
@juanmaguitar
juanmaguitar / README.md
Last active February 15, 2017 08:49 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@juanmaguitar
juanmaguitar / .babelrc
Created November 24, 2016 19:39 — forked from ifraixedes/.babelrc
Generators & Async function - Source files used for talks (meetups, etc)
{
"env": {
"development": {
"presets":["es2015-node5"],
"plugins": ["transform-async-to-generator"]
}
}
}
@juanmaguitar
juanmaguitar / app.js
Last active November 17, 2016 15:43
Demo jQuery POST - Express
const express = require('express');
const bodyParser = require('body-parser')
const app = express()
const PORT = 3000;
app.use( express.static('public') )
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))