Skip to content

Instantly share code, notes, and snippets.

View josemariagarcia95's full-sized avatar

José María josemariagarcia95

View GitHub Profile
//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));
});
@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!'); }
});
@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 / 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 / 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>';
}
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 / 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' );
};
@josemariagarcia95
josemariagarcia95 / curry.js
Last active November 23, 2018 11:46
Example of currifying functions in JavaScript
//The function we're gonna currify
let extractEmotion = function( media, callback ) {
console.log( 'This is extractEmotions' );
callback( media );
};
//The previous function receives a callback
let test = function( media ) {
console.log( 'I\'m the callback and I\'ve received ' + media );
};
@josemariagarcia95
josemariagarcia95 / git-commands.txt
Last active July 17, 2019 11:41
Nice git commands
# Created a repository with a gitignore and a LICENSE file.
# Had already a gitignore in local repository in my PC
# After the git init and git add remote, use this command (check flag) to pull stuff from Github so I could fix
# merge problems afterwards
git pull --allow-unrelated-histories
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
chrome_driver = webdriver.Chrome()
# Open the amazon photos login page
chrome_driver.get(
"https://www.amazon.es/photos?sf=1/ref=s9_acss_bw_h1_EEEESSS_bn_w?ref_=BN_ES_C_U_E_M_CD_CG_417_ADAPSI&pf_rd_m=A1AT7YVPFBWXBL&pf_rd_s=merchandised-search-1&pf_rd_r=CKMHBDSC7YCPSMXR24KE&pf_rd_t=101&pf_rd_p=d284dade-6826-459b-9042-bf7f3d7341d1&pf_rd_i=12364776031"
)