Skip to content

Instantly share code, notes, and snippets.

View paulovittor23's full-sized avatar

Paulo Vitor Rendeiro paulovittor23

View GitHub Profile
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@paulovittor23
paulovittor23 / ClassScanner.java
Created December 22, 2022 14:48 — forked from jrichardsz/ClassScanner.java
Find all annotated classes in a package using Spring
import java.lang.annotation.Annotation;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.web.context.support.StandardServletEnvironment;
@paulovittor23
paulovittor23 / persistence.xml
Created February 10, 2016 12:32 — forked from mortezaadi/persistence.xml
persistence xml configurations for major databases and jpa providers
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<!-- derby -->
@paulovittor23
paulovittor23 / gist:bd41fa82d440c34d5a44
Last active August 29, 2015 14:21
generate test jar for reuse in other projects
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<configuration>
<includes>
require 'rubygems'
require 'facter'
require 'json'
instance_id = Facter::Util::Resolution.exec("ec2-metadata -i | awk '{print $2}'")
unless instance_id.nil?
region = Facter::Util::Resolution.exec("ec2-metadata -z | awk '{print $2}'")
unless region.nil?
@paulovittor23
paulovittor23 / gist:9689563
Created March 21, 2014 16:05
vi / vim commands
Basics
:e filename Open filename for edition
:w Save file
:q Exit Vim
:w! Write file and quit
Search
/word Search word from top to bottom
?word Search word from bottom to top
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
cluster.name: logs
# Puppet-ism to put in the hostname and IP
node.name: <%= @hostname %>
network.host: <%= @ipaddress %>
# Turn off multicast autodiscovery
discovery.zen.ping.unicast.hosts: 172.1.1.100:9300, 172.1.1.101:9300
index.number_of_shards: 4
index.routing.allocation.total_shards_per_node: 1
@paulovittor23
paulovittor23 / memvalues
Created October 29, 2012 17:40
memcached_values
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "172.16.10.196", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end
@paulovittor23
paulovittor23 / memcached.yml
Created October 29, 2012 16:56
mecached_yml
# base config
base_cache: &base_cache
expires: 86400 #session expired after 24 hours
servers:
- '127.0.0.1:11211'
cucumber:
<<: *base_cache
# local