This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.netty.channel.ChannelException; | |
import io.netty.channel.ChannelOption; | |
import io.netty.handler.timeout.ReadTimeoutHandler; | |
import io.netty.handler.timeout.WriteTimeoutHandler; | |
import lombok.Getter; | |
import lombok.Setter; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.context.properties.ConfigurationProperties; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FormURLEncodedToJSON(str) { | |
"use strict"; | |
var obj, i, pt, keys, j, ev; | |
if (typeof FormURLEncodedToJSON.br !== 'function') { | |
FormURLEncodedToJSON.br = function(repl) { | |
if (repl.indexOf(']') !== -1) { | |
return repl.replace(/\](.+?)(,|$)/g, function($1, $2, $3) { | |
return FormURLEncodedToJSON.br( $2 + '}' + $3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
URL url = new URL("http://127.0.0.1/scripts/download.php"); | |
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); | |
FileOutputStream fileOutputStream = new FileOutputStream("resourceFileName.db"); | |
fileOutputStream.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); | |
} catch (Exception ex) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStream; | |
import java.net.InetAddress; | |
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.net.UnknownHostException; | |
import java.util.EventListener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.nio.file.Files; | |
public class UploadResource { | |
// Uploading some binary file to http server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
Date.prototype.toYyyymmddhhmmss = function() { | |
var yyyy = this.getFullYear(), | |
mm = this.getMonth() < 9 ? ("0" + (this.getMonth() + 1)) : (this.getMonth() + 1), | |
dd = this.getDate() < 10 ? ("0" + this.getDate()) : this.getDate(), | |
hh = this.getHours() < 10 ? ("0" + this.getHours()) : this.getHours(), | |
min = this.getMinutes() < 10 ? ("0" + this.getMinutes()) : this.getMinutes(), | |
ss = this.getSeconds() < 10 ? ("0" + this.getSeconds()) : this.getSeconds(); | |
return "".concat(yyyy).concat("-") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM(TABLE_ROWS) AS 'Total de Linhas', COUNT(*) AS 'Total de Tabelas' | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE TABLE_SCHEMA = 'databaseName'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ("undefined"===typeof jQuery) throw new Error("This function requires jQuery."); | |
function table(element, data) { | |
var g, a, b, r, i, e, l, | |
s = Date.now(); | |
g = $("<table class='table table-responsive table-hover'/>").appendTo(element); | |
a = $("<thead />").appendTo(g); | |
/* Generates the table thead */ | |
r = data[0]; // Some element of any position, use the element with more atributtes | |
for (i in r) { | |
if (r.hasOwnProperty(i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"codigo_uf": 11, | |
"unidade_federacao": "Rondônia", | |
"sigla": "RO", | |
"area_km2": 237765.376, | |
"regiao": "Norte" | |
},{ | |
"codigo_uf": 12, | |
"unidade_federacao": "Acre", | |
"sigla": "AC", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* It's of unspecified quality and not RFC4122. | |
* Very slow due to string replaces | |
*/ | |
var objectId = function () { | |
var timestamp = (Date.now() / 1000 | 0).toString(16); | |
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() { | |
return (Math.random() * 16 | 0).toString(16); | |
}).toLowerCase(); | |
}; |
NewerOlder