Skip to content

Instantly share code, notes, and snippets.

View mjunior's full-sized avatar

Maurício Júnior mjunior

View GitHub Profile
@mjunior
mjunior / autoincrement.js
Created November 18, 2021 14:02
It suggest the type of bump
const conventionalRecommendedBump = require('conventional-recommended-bump');
conventionalRecommendedBump({
preset: `angular`
}, (error, recommendation) => {
console.log(recommendation.releaseType); // 'major'
});
// your commits must be semantic
https://github.com/conventional-changelog/commitlint
@mjunior
mjunior / launch.json
Created March 17, 2021 11:33 — forked from zbarbuto/launch.json
Unit Test Debug - Angular Karma launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "attach",
"name": "Attach to Karma",
"address": "localhost",
"port": 9222,
"timeout": 600000,
require 'net/http'
http = Net::HTTP.new("api")
get = Net::HTTP::GET.new("/")
get['username'] = 'abc'
response = http.request(get)
puts response
{
"elenco": [
{
"nome": "Neymar da Silva Santos Júnior",
"nome_popular": "Neymar",
"fotos": {
"35x35": "https://s.glbimg.com/es/sde/f/2017/10/31/b8f51e4f3f4e9f4cdc24bbb5f5b8a54a_35x35.jpeg",
"220x220": "https://s.glbimg.com/es/sde/f/2017/10/31/b8f51e4f3f4e9f4cdc24bbb5f5b8a54a_220x220.jpeg",
"50x50": "https://s.glbimg.com/es/sde/f/2017/10/31/b8f51e4f3f4e9f4cdc24bbb5f5b8a54a_50x50.jpeg",
"80x80": "https://s.glbimg.com/es/sde/f/2017/10/31/b8f51e4f3f4e9f4cdc24bbb5f5b8a54a_80x80.jpeg",

Tenho os modelos abaixo que fazem um relacionado N<->N através de uma JoinTable. Minha duvida é como fazer uma busca por itens no model Ad, usando um AND e não um IN.

Quero obter todos os anuncios que tenho os Itens [1,2,3,4]. Estou utilizando a gem RanSack para facilitar as buscas, o SQL que esta sendo executado é o seguinte...

Parameters: {"utf8"=>"✓", "q"=>{"city_id_eq"=>"", "category_id_eq"=>"", "items_id_in"=>["1", "2", "3", "4", ""]}, "commit"=>"Buscar"}
Ad Load (617.7ms) SELECT "ads".* FROM "ads" LEFT OUTER JOIN "features" ON "features"."ad_id" = "ads"."id" LEFT OUTER JOIN "items" ON "items"."id" = "features"."item_id" WHERE "items"."id" IN (1, 2, 3, 4)
@mjunior
mjunior / BatchService.rb
Last active November 26, 2017 21:04
criação do lote e processamenot do lote
class BatchService
def self.create params
Batch.create({breeds: params[:breeds],
status: BATCH_STATUS[0]
})
end
def self.process batch
batch.update(status: BATCH_STATUS[1])
batch.breeds.each do |breed|
//
// GET: /api/v1/im.list
{
"ims": [
{
"_id": "Mjho6TFcCgS3KGeCFNcrwxgLnTXJZJizso",
"_updatedAt": "2017-05-05T11:30:22.345Z",
"t": "d",
"msgs": 4,
// Interceptador
//==============================================================
dashboardApp.factory('auth', function($cookies,$window) {
var sessionInjector = {
request: function(config) {
a = $cookies.get('id_user');
b = $cookies.get('email_user');
if(a && b){
return config;
}else{
[ActiveJob] [ActionMailer::DeliveryJob] [71cd7a59-f5b9-44f8-a5ba-6fced0fa85bb] Performed ActionMailer::DeliveryJob from Inline(mailers) in 4077.6ms
Completed 500 Internal Server Error in 4144ms (ActiveRecord: 14.6ms)
EOFError - end of file reached:
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/protocol.rb:167:in `rbuf_fill'
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/protocol.rb:136:in `readuntil'
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/protocol.rb:146:in `readline'
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/smtp.rb:946:in `recv_response'
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/smtp.rb:932:in `block in getok'
/home/mjunior/.rbenv/versions/2.3.3/lib/ruby/2.3.0/net/smtp.rb:956:in `critical'
@mjunior
mjunior / bootbox-rails.js
Created January 7, 2017 20:22 — forked from jacksonpires/bootbox-rails.js
Sobrescreve o data-confirm do Rails pelo bootbox.js
$.rails.allowAction = function(element) {
var message = element.attr('data-confirm');
if (!message) { return true; }
var opts = {
title: "Confirmação",
message: message,
buttons: {
confirm: {
label: 'Sim',