Skip to content

Instantly share code, notes, and snippets.

View neilsonlima's full-sized avatar

Neilson Lima neilsonlima

  • Belo Horizonte - MG/Brasil
View GitHub Profile
@neilsonlima
neilsonlima / service_ member_action_create.rb
Last active January 18, 2018 01:43
refatoração action create
class Members::Create
attr_accessor :member
def self.create(member_params,user_params, session)
account = Account.find(session[:account_id])
user = User.new(user_params)
user.password = user.password_confirmation = '123456'
@neilsonlima
neilsonlima / update_tx.js
Last active September 13, 2018 14:04
Cadastra os elementos que não estão cadastrados e atualiza os que forem diferentes
'use strict'
const knex = require('../database')
module.exports = {
update: async list => {
list.forEach(element => {
if (element['data'] !== undefined) {
let params = element.data
return knex('tb_name')
.transacting(params)
@neilsonlima
neilsonlima / main.js
Created June 27, 2019 13:21
Nodejs e MongoDB
'use strict'
const Model = require('model')
const mongoose = require('mongoose')
const log = require('ololog').noLocate
mongoose.connect(
'mongodb://localhost/mydb',
{ useNewUrlParser: true, useCreateIndex: true },
function (err) {
public class ExFormatationDate {
public static void main(String[] args) {
String dt1 = "20200124";
StringBuilder sb = new StringBuilder(dt1)
.insert(4,"-")
.insert(7,"-");
String output = sb.toString();
System.out.println(output);
@neilsonlima
neilsonlima / ExemploSubstring.java
Created February 13, 2020 11:57
Substitui os caracteres com acento por caracteres sem
import java.text.Normalizer;
public class ExemploSubstring {
public static void main(String[] args) {
String str = "Caiô sérgio evidência saída";
str = Normalizer.normalize(str, Normalizer.Form.NFD);
str = str.replaceAll("[^\\p{ASCII}]", "");
'use strict'
const moment = require('moment')
moment.locale('pt-BR')
let now = moment()
let hour = Number(now.format('HH'))
now.set({'hour': 21, 'minute': 0, 'second': 0, 'millisecond': 0})