Skip to content

Instantly share code, notes, and snippets.

View jamilservicos's full-sized avatar
👽
between lines and thoughts

Gervasio Junior jamilservicos

👽
between lines and thoughts
View GitHub Profile
@jamilservicos
jamilservicos / client.js
Last active December 22, 2020 19:46
socket.io multiples fix
'use strict';
var reconnection = true,
reconnectionDelay = 5000,
reconnectionTry = 0;
function initClient() {
connectClient();
}
@jamilservicos
jamilservicos / autoincrement.js
Created March 5, 2017 15:34
auto update id for nedb
'use strict';
const Datastore = require('nedb'),
db = {},
dbfunc = {};
db.autoincrement = new Datastore({filename: 'data/autoincrement.db', autoload: true});
dbfunc.autoId = function getUniqueId(nameDb, cb) {
db.autoincrement.findOne({name: nameDb}, function (err, doc) {
if (err) {
@jamilservicos
jamilservicos / database.js
Last active March 9, 2017 00:22
basics function for nedb
'use strict';
const Datastore = require('nedb'),
db = {},
myId = require('./autoincrement'), //my autoincrement function: https://gist.github.com/jamilservicos/bbf838037475b7c4796373da6cee724d
dbfunc = {};
db.mainDb = new Datastore({filename: 'data/maindb.db', autoload: true});
dbfunc.insert = function insert(req, cb) {
const dbName = eval("db." + req.body.database + "Db");
const doc = [
{"status":"1","name":"Item5","order":0,"submenuId":"0","subid":1},
{"status":"1","name":"Item1","order":2,"submenuId":"0","subid":5},
{"status":"1","name":"Item2","order":1,"submenuId":"0","subid":2}
];
/* Ascending: (order field)
output sort:
{"status":"1","name":"Item5","order":0,"submenuId":"0","subid":1},
{"status":"1","name":"Item2","order":1,"submenuId":"0","subid":2},
@jamilservicos
jamilservicos / arrayupdate.js
Created March 11, 2017 11:29
update array from other array
const data = {};
data.final = [
{ "id": 0, "name": "Fleming James" },
{ "id": 1, "name": "Everett Johnson" },
{ "id": 2, "name": "Brock Owens" }
];
data.update = [
{ "id": 0, "name": "Catherine Cooley" },
{ "id": 1, "name": "Mavis Grant" },
@jamilservicos
jamilservicos / convertToMiota.php
Created April 18, 2018 10:27
Convert Brazilian Real (BRL) to MIOTA
<?php
/**
* Name: BRL to MIOTA
* Description: Convert Brazilian Real (BRL) to MIOTA
* Author: Jamil Serviços
* Author URI: https://fb.com/JamilServicos/
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*
@jamilservicos
jamilservicos / languagechoose.js
Last active October 1, 2020 07:23
simple example of language choose
/*
css example
.hide {
display: none !important;
}
//==
simple HTML example
<div class="language">
<span data-lang="pt-br">PT-BR</span>
<span data-lang="en">EN</span>
@jamilservicos
jamilservicos / apache-escape.js
Created October 2, 2020 03:56
simple example of HTML escape with and without break line. With list of chars based on the Apache Foundation's module
/*
based on the Apache Foundation module
https://github.com/apache/commons-lang/blob/7bbbdd2477305992e4d809db5288d6f62718124b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java
*/
const apache = {
"\u00A0": "&nbsp;",
"\u00A1": "&iexcl;",
"\u00A2": "&cent;",
"\u00A3": "&pound;",
"\u00A4": "&curren;",
@jamilservicos
jamilservicos / capitaLize.js
Last active October 6, 2020 15:53
simple example of uppercase, lowercase and capitalize text
/*
simple example to capitalize
*/
function capitaLize() {
const textbox = document.getElementById("text-box"); //textarea
const textresult = document.getElementById("text-result"); //result element "<pre>";
if ((textbox) && (textbox.value) && (textbox.value.toString().trim().length > 0)) {
textresult.innerText = "";
const str = textbox.value.toString().trim().toLowerCase(); //turns everything to lowercase
@jamilservicos
jamilservicos / README.md
Created October 10, 2020 04:37 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store