Skip to content

Instantly share code, notes, and snippets.

View josemariagarcia95's full-sized avatar

José María josemariagarcia95

View GitHub Profile
@josemariagarcia95
josemariagarcia95 / upload-to-ftp.js
Created November 9, 2018 11:13
Code snippet to upload files to FTP server using Node.js
const Ftp = require( 'ftp' );
const ftpClient = new Ftp();
ftpClient.on( 'ready', function() {
ftpClient.put( './prueba.jpg', '/www/img/prueba.jpg', function( err, list ) {
if ( err ) throw err;
ftpClient.end();
} );
} );
@josemariagarcia95
josemariagarcia95 / template-pattern.js
Created November 7, 2018 10:23
Template Method Pattern in Javascript using prototypes
/**
* Parent Class A
*/
function A() {
this.name = 'Clase A';
}
A.prototype.function2 = function() {
console.log( 'Function 2 in A' );
};
import numpy as np
import scipy.stats
#train - DataFrame
relevant_features = ["duration", "src_bytes", "dst_bytes"]
means = np.mean(train[relevant_features].values, axis=0)
stds = np.std(train[relevant_features].values, axis=0)
#creates norm distribution for each data
@josemariagarcia95
josemariagarcia95 / debugging.php
Created May 14, 2018 22:38
Debugging function to check data
function console_log( $data ){
echo '<script>';
echo 'console.log('. json_encode( $data ) .')';
echo '</script>';
}
@josemariagarcia95
josemariagarcia95 / join-pdf.tex
Last active May 13, 2018 16:57
Joining PDF files with LaTeX
%Whatever doc settings
\documentclass[11pt,a4paper,sans]{article}
\usepackage{pdfpages}
\begin{document}
%pages = - means all the pages of the file
\includepdf[pages=-]{file1} % ./file1.pdf
\includepdf[pages=-]{file2} % ./file2.pdf
\end{document}
@josemariagarcia95
josemariagarcia95 / pandas-numpy.py
Created April 30, 2018 19:58
Pandas Numpy framework
import pandas as pd
import numpy as np
df_movies = pd.read_csv("datos/movies.csv", sep=',')
@josemariagarcia95
josemariagarcia95 / sensor-ajax.js
Last active April 27, 2018 10:42
jQuery snippet for retrieving data from the sensor
$.ajax({
type: 'GET',
dataType: 'JSONP',
url: 'http://your_app_url',
success: function (result) { alert(result); console.log(result);},
error: function(result) { console.log(result); console.log('Uh Oh!'); }
});
//This should be somewhere at the beginning of the file
//var express = require("express");
//var app = express();
//...//
app.get("/api/sensor", function(request, response) {
var res = {};
res.noise = Math.random() * 30 + 40;
response.send(response.jsonp(res));
});