Skip to content

Instantly share code, notes, and snippets.

View kllaudyo's full-sized avatar

Claudio Acioli kllaudyo

View GitHub Profile
@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'
@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 / 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
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";
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;
@kllaudyo
kllaudyo / preload.js
Last active August 9, 2018 21:14
Simple preload images
const preload = () => {
const images = [];
for(let i=arguments.length;i--;){
const index = images.length;
images[index] = new Image();
images[index].src=arguments[i];
}
return images;
};
@kllaudyo
kllaudyo / hasConnection.js
Last active August 20, 2018 13:50
Verify internet connection
const HTTP_STATUS_OK = 200,
HTTP_STATUS_NOT_MODIFIED = 304,
HTTP_STATUS_MULTIPLE_CHOICE = 300,
HTTP_METHOD = "HEAD",
hasConnection = (host = window.location.protocol + "//" + window.location.hostname) => {
if(window.navigator)
return navigator.onLine;
else{
const xhr = new (window.ActiveXObject || XMLHttpRequest)("Microsoft.XMLHTTP");
xhr.open(HTTP_METHOD, host, false);
<!--#include file="adovbs.inc"-->
<%
Dim iParameter1 = 0
Dim iParameter2 = 0
Set oConn = Server.CreateObject("adodb.connection")
oConn.ConnectionString = "Provider=MSDAORA.1;Password=password;User ID=user;Data Source=service_name;Persist Security Info=True;PLSQLRSet=1"
oConn.Open
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import reducer from "../reducers";
const store = createStore(
reducer,
(localStorage['store']) ?
JSON.parse(localStorage['store']) :
{},
const
byId = id =>
document.getElementById(id)
,
byName = (name, parent=document) =>
parent.getElementsByName(name)
,
byTag = (tag, parent=document) =>
parent.getElementsByTagName(tag)
,