Skip to content

Instantly share code, notes, and snippets.

View djalmajr's full-sized avatar

Djalma Júnior djalmajr

View GitHub Profile
@djalmajr
djalmajr / capitalize.js
Created March 4, 2022 19:49
Capitalize Test
/**
* capitalize.js
*
* @param {string} str
* @returns string
*/
function capitalize(str) {
}
module.exports = { capitalize };
@djalmajr
djalmajr / get.js
Last active March 4, 2022 19:54
Get Test
/**
* get.js
*
* @param {string | string[]} path
* @param {object} data
* @returns unknown
*/
function get(path, data) {
}
// Exemplo de padrão modular usando IIFE
var contador = (function () {
var num = 0;
return {
incrementar: function () {
return ++num;
},
resetar: function () {
@djalmajr
djalmajr / csv2bib.sh
Last active April 16, 2020 18:04
SpringerLink CSV to BIB converter
#!/bin/bash
# csv2bib.sh
#
# SpringerLink CSV to BIB
#
# Author: Djalma Jr.
# Site: djalmajr.com
#
# v0.3.0: Updated download link
# v0.2.0: Added command line options
@djalmajr
djalmajr / loader-1.html
Created November 20, 2018 15:37
App Loader
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>App Loader</title>
<style media="screen">
html,
body {
background-color: #F2F2F4;
}
@djalmajr
djalmajr / router.js
Last active November 3, 2018 17:57
Tiny Router lib
var Router = {
routes: [],
mode: null,
root: '/',
config: function(options) {
this.mode = options && options.mode && options.mode == 'history'
&& !!(history.pushState) ? 'history' : 'hash';
this.root = options && options.root ? '/' + this.clearSlashes(options.root) + '/' : '/';
return this;
},
@djalmajr
djalmajr / router.html
Created November 3, 2018 16:29 — forked from joakimbeng/router.html
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@djalmajr
djalmajr / dom-helpers.js
Created October 6, 2018 14:46
DOM Helpers
(() => {
window.createElement = (name, attrs = {}) => {
const element = document.createElement(name);
Object.keys(attrs).forEach(key => (element[key] = attrs[key]));
return element;
};
window.loadStyle = href => {
return new Promise((onload, onerror) => {
const style = createElement("link", { onload, onerror, href, rel: "stylesheet" });
@djalmajr
djalmajr / console-save.js
Created October 2, 2018 00:45
console.save
(function(console) {
console.save = function(data, filename) {
if (!data) {
console.error("Console.save: No data");
return;
}
if (!filename) filename = "console.json";
if (typeof data === "object") {
import { html, render } from "https://unpkg.com/lit-html?module";
export * from "https://unpkg.com/lit-html?module";
export function createProperty(prototype, propertyName, options = {}) {
if (!prototype.constructor.hasOwnProperty("properties")) {
Object.defineProperty(prototype.constructor, "properties", { value: {} });
}
prototype.constructor.properties[propertyName] = options;