Skip to content

Instantly share code, notes, and snippets.

View ppazos's full-sized avatar
🌎
All around

Pablo Pazos Gutiérrez ppazos

🌎
All around
View GitHub Profile
@ppazos
ppazos / java_date_utils.java
Created May 19, 2018 01:03
Nice class with date utils
// source http://www.java2s.com/Code/Java/Development-Class/Returnsthegivendatewithtimesettotheendoftheday.htm
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
/**
* <p>Checks if two dates are on the same day ignoring time.</p>
* @param date1 the first date, not altered, not null
# decoder for the codes transmitted for this RF Tx/Rx: https://www.instructables.com/id/Super-Simple-Raspberry-Pi-433MHz-Home-Automation/
# se puede probar en https://www.tutorialspoint.com/execute_python_online.php
import re
# codigo leido por el receptor de radiofrecuencia
out = "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@ppazos
ppazos / ctrl+s_save_detect.js
Created May 23, 2018 05:05
detects CTRL+S and other key combinations cross browser
$(document).ready(function() {
var link = $('head').find('link:first');
window.onbeforeunload = function(){
return "Leaving this page may cause loss of your code!";
};
window.beforeunload = function(){
return "Leaving this page may cause loss of your code!";
};
$(window).bind('keydown', function(event) {
if (event.ctrlKey || event.metaKey) {
@ppazos
ppazos / object_merge.js
Created June 19, 2018 18:07
Merge attributes of two objects in JavaScript
var a = {a:'a'};
var b = {b:'b'};
// a is modified and is the merge
console.log(Object.assign(a, b));
console.log(a, b);
int Echo1 = A3; //LEFT_SENSOR ECHO
int Trig1 = A2; //LEFT_SENSOR TRIG
int Echo2 = A5; //MID_SENSOR ECHO
int Trig2 = A4; //MID_SENSOR TRIG
int Echo3 = A1; //RIGHT_SENSOR ECHO
int Trig3 = A0; //RIGHT_SENSOR TRIG
int in1 = 5;
int in2 = 6;
int in3 = 9;
@ppazos
ppazos / play_store_scrapping.groovy
Created July 4, 2018 18:22
Google Play Store GUI Scrapping for App Data
@Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.14')
import org.cyberneko.html.parsers.SAXParser
import groovy.util.XmlSlurper
// global
out = new File('/home/pablo/Desktop/play_store_scrap_20170612-5.csv')
base_url = "https://play.google.com"
similar_queue_urls = [] // queue to process similar apps, list<url:current depth>, cant make a map because I need to use list.pop to loop becaue iteration cant be done since the queue will be modified while iterating
processed_app_details_urls = [] // list of already processed to avoid loops
scrapped = new StringBuffer() // CSV accumulator
@ppazos
ppazos / process_coded_binary_tree.js
Last active July 18, 2018 19:06
Script for binary tree specification, migration from the groovy version
// BinTreeJS
(function() {
"use strict";
var expr; // expression of this bintree
var value; // value of the current node
var left; // subtrees
var right;
@ppazos
ppazos / falsy_value_test.js
Created July 7, 2018 18:42
Tests undefined falsy values
var o = {
a: undefined,
b: undefined
};
console.log( o.a && o.b );
console.log( !o.a && !o.b );
@ppazos
ppazos / criteria_builder.js
Created July 7, 2018 22:51
Complex conditon builder and validator
// CriteriaBuilderJS
// Criteria Expression Module
(function() {
"use strict";
// expression id generator
var id = 1;
@ppazos
ppazos / X12_pretty_print.html
Last active August 16, 2018 04:26
an X12 message beautifier
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script>
$(function() {
$('textarea').on('change keyup paste', function(e) {
//console.log(e.target.value);