Skip to content

Instantly share code, notes, and snippets.

View kllaudyo's full-sized avatar

Claudio Acioli kllaudyo

View GitHub Profile
const ajax = (url, {method="GET", body=null, headers={}, mode}, onProgress=()=>{}, onStartProgress=()=>{}, onStopProgress=()=>{}) => {
return new Promise((result, reject) => {
const ajax = new XMLHttpRequest();
ajax.open(method, url, true);
for(let [key, value] of headers)
ajax.setRequestHeader(key, value);
if(mode==='cors')
ajax.withCredentials = false;
const print_log = (object, err=false) => {
const log = document.createElement("pre");
log.innerHTML = print_r(object);
let border ="1px solid #d6d8db",
radius = ".25rem",
color = "#383d41" ,
background = "#e2e3e5",
padding = ".75rem 1.25rem";
@kllaudyo
kllaudyo / fetching_cursor.sql
Last active August 13, 2018 21:01
Exemple for fetching cursor in Oracle
declare
cursor get_states_and_cities(pId_country number) is
select c.nm_country,
s.nm_state,
ct.nm_city
from countries c,
states s,
cities ct
where ct.id_state = s.id_state
and s.id_country = c.id_country
@kllaudyo
kllaudyo / print_r.js
Created July 19, 2018 11:53
JavaScript print_r like php
const print_r = object => JSON.stringify(object, null, 2);
@kllaudyo
kllaudyo / upload.html
Last active August 6, 2018 18:12
Realizar upload utilizando fetch
<html>
<body>
<input type="file" name="picture" id="picture" />
<pre></pre>
</body>
<script>
window.onload = function(){
const getRequestHeaders = () => new Headers({
'Accept': 'application/json'