Skip to content

Instantly share code, notes, and snippets.

View juareznjunior's full-sized avatar

Juarez Gonçalves Nery Junior juareznjunior

View GitHub Profile
function palindrome(str) {
str = str.toLowerCase().replace(/[^a-z0-9]/ig,'');
let strEqual = str.split('').reverse().join('');
console.log(str, strEqual)
return strEqual === str
}
console.log(
palindrome("_eye")
,palindrome("never odd or even")
function orbitalPeriod(arr) {
const GM = 398600.4418;
const earthRadius = 6367.4447;
return arr.map(obj => {
return {
"name": obj.name
,"orbitalPeriod": Math.round(2 * Math.PI * Math.sqrt(Math.pow(earthRadius + obj.avgAlt, 3) / GM))
}
});
@juareznjunior
juareznjunior / getYearDivision.sql
Created May 22, 2019 17:33
Posição do Mês referente a: bimestre, trimestre, quadrimestre e semestre
SELECT
periodo
,CASE
WHEN mes IN(1,2) THEN 1
WHEN mes IN(3,4) THEN 2
WHEN mes IN(5,6) THEN 3
WHEN mes IN(7,8) THEN 4
WHEN mes IN(9,10) THEN 5
WHEN mes IN(11,12) THEN 6
END bimestre
@juareznjunior
juareznjunior / getYearDivision.php
Last active May 21, 2019 18:22
Código das Divisões do Ano
<?php
/**
* Retorna codigo para
* - bimestre 12 34 56 78 910 1112
* - trimestre 123 456 789 101112
* - quadrimestre 1234 5678 9101112
* - semestre 123456 789101112
*
* @param integer $periodo
* @param string $tipo (bimestre|trimestre|quadrimestre|semestre)
@juareznjunior
juareznjunior / datagrid.js
Created December 19, 2014 15:50
Dúvida no UI DataGrid
$(function(){
var $dgLocal = $('#data-grid-local')
,$pesqcidade = $("#pesqcidade")
,$pesquf = $("#pesquf");
$dgLocal.datagrid({
autoLoad: false
,pagination: false
,rowNumber: true
@juareznjunior
juareznjunior / fb.duvida.sql
Created November 20, 2014 19:51
facebook.grupo.postgresql
SELECT DISTINCT ON(contrato)
contrato
,sum(hora) OVER(PARTITION BY contrato)
FROM (
SELECT
unnest(ARRAY[1,1,1,1]) contrato
,unnest(ARRAY[2,1,2,4]::numeric[]) hora
) a
@juareznjunior
juareznjunior / jquery.ui.dialog.prototype.js
Last active August 29, 2015 14:08
jQuery UI Dialog Prototype
/**
* prototype jQuery UI Dialog
* @param d jQuery
* @author: Juarez G. N. Junior
*/
;(function(d){
// options
d.extend(d.ui.dialog.prototype.options,{
autoOpen : false
,modal : true
@juareznjunior
juareznjunior / remove_accents.java
Created October 30, 2014 17:07
Pentaho Kettle - User defined Java Class
import java.text.Normalizer;
public static String removeAccents(String s)
{
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
return s.toUpperCase();
}
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
@juareznjunior
juareznjunior / array_map_private_methdo.php
Created October 17, 2014 12:55
PHP array_map, usando private method
<?php
class Foo
{
public function __construct()
{
array_map(array($this,'_bar'),explode('#','819f6a8886908b80b8b6e9f212dbeea092dd39#8c3f4db3a634aa769c0f1161219272d032ea40#8b060700f0a542a147685180b143ad61e2bd38'));
}
private function _bar($ajuste_id)
{
_createOverlay: function() {
if ( !this.options.modal ) {
return;
}
// We use a delay in case the overlay is created from an
// event that we're going to be cancelling (#2804)
var isOpening = true;
this._delay(function() {
isOpening = false;