Skip to content

Instantly share code, notes, and snippets.

@miglrodri
miglrodri / gist:2322b2fc3b92fd57271459857eea057f
Created November 15, 2019 21:36
arduino matraquilhos matrecos fussball table soccer
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
@miglrodri
miglrodri / gist.js
Last active February 26, 2019 11:14
js async await
// Promise that takes 5 sec to resolve an array of data
const fetchData = new Promise((resolve, reject) => {
console.log("fetchData, called");
setTimeout(() => {
resolve(["1", "2", "3", "4", "5"]);
}, 5000);
});
const getData = async number => {
console.log("getData, called");
@miglrodri
miglrodri / restful_api.txt
Last active September 14, 2018 17:50
RESTful APIs
---------------------------------
# REST
Http Method | Request Payload | Sample URI | Response Payload
GET | - | /api/authors | author collection
/api/authors/{authorId} | single author
POST | single author | /api/authors | single author
PUT | single author | /api/authors/{authorId} | single author or empty
PATCH | JsonPatchDocument on author | /api/authors/{authorId} | single author or empty
@miglrodri
miglrodri / gist:7b140aaf9ff384f3ac7215d4f1c6ac14
Created September 19, 2017 15:52
difference between jquery element data and attr
//https://www.peterbe.com/plog/data-and-attr-in-jquery
I learned something today thanks to my colleague Axel Hecht; the difference between $element.data('foo') and $element.attr('data-foo').
Basically, the .data() getter/setter is more powerful since it can do more things. For example:
<img id="image" data-number="42">
// numbers are turned to integers
@miglrodri
miglrodri / gist:7c49c5651038a972abf76daa0df3ceb5
Created September 19, 2017 11:47
listen for a element/node text change
//https://stackoverflow.com/questions/39221775/trigger-for-span-text-html-on-changed
//you can use DOMSubtreeModified to track changes on your span element i.e(if text of your span element changes dynamically ).
$('.user-location').on('DOMSubtreeModified',function(){
alert('changed')
})
@miglrodri
miglrodri / gist:fdea5e7162a6d5b07eb9
Created March 10, 2016 01:14
Hide div when you click outside of the div
$(document).on('click', function(event) {
if (!$(event.target).closest('#menucontainer').length) {
// Hide the menus.
}
});
// source: https://css-tricks.com/dangers-stopping-event-propagation/
// author: Philip Walton (@philwalton)
@miglrodri
miglrodri / gist:05a84a352fce89d2329d
Last active March 4, 2016 04:39
Customizable Select Box
<!DOCTYPE html>
<html>
<head>
<!--
Author: Miguel Jesus
Email: migl.rodri@gmail.com
Copyright: You can freely use this snippet and if you could leave a comment.
About:
Well, in some of my projects i run into a problem of customizing a select input box.