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 / sb-struct-hello-world.json
Last active February 6, 2024 13:56
sb-struct-hello-world.json
{"element":"section","dataset":{"state":"hello-world.view","example":"hello-word"},"shadow":{"mode":"closed","styles":"\"html { width: 100%; max-width: 100%; height: 100%; max-height: 100%; box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background-color: #fff; overflow: hidden;}*,*::before,*::after { width: fit-content; height: fit-content; min-width: auto; min-height: auto; max-width: inherit; max-height: inherit; box-sizing: border-box; margin: 0; padding: 0; outline: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background: transparent;}body { background-color: inherit; color: #000; width: 100%; height: 100%; overflow: auto;}h1, h2, h3, h4, h5, h6 { font-weight: 500;}strong,b { font-weight: bold; line-height: inherit;}em,i { font-style: italic; line-height: inherit;}ul, ol { list-style: disc inside;}ul[role=list],ol[role=list] { list-style: none;}a {
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 / 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");
@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 / 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();
}