Skip to content

Instantly share code, notes, and snippets.

View carlosspohr's full-sized avatar

Carlos Spohr carlosspohr

View GitHub Profile
Jan 02, 2017 4:46:33 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:dindinweb' did not find a matching property.
Jan 02, 2017 4:46:33 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.5.9
Jan 02, 2017 4:46:33 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Dec 5 2016 20:18:12 UTC
Jan 02, 2017 4:46:33 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.5.9.0
Jan 02, 2017 4:46:33 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 10
@carlosspohr
carlosspohr / reset-row-count-by-groupby.sql
Created January 2, 2017 15:36
How to reset a row counter by `group by` of main query.
select
if(@idc <> tmp.id, @nr:= 1, (@nr:=@nr+1)) as rownum,
@idc:=tmp.id as xxx,
tmp.*
from
(
select
f.id,
f.foo
from
@carlosspohr
carlosspohr / crontab.sh
Last active November 24, 2016 18:16
Cron routine to check every minute of day if some java process is running.
sudo su
crontab -e
# put this if you check every minute of day if some java process is running.
*/1 * * * * sudo /bin/sh /etc/init.d/javarunning.sh
Loading mirror speeds from cached hostfile
* base: mirror.trouble-free.net
* epel: mirror.math.princeton.edu
* extras: mirror.netdepot.com
* updates: mirrors.tripadvisor.com
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php-pecl-solr2.x86_64 0:2.3.0-1.el6 will be installed
--> Processing Dependency: php(zend-abi) = 20090626 for package: php-pecl-solr2-2.3.0-1.el6.x86_64
DELIMITER $$
drop trigger if exists `bla` $$
CREATE TRIGGER `bla` BEFORE INSERT ON `your_table`
FOR EACH ROW
BEGIN
IF (new.id = 1) THEN
SIGNAL SQLSTATE '01000' SET MESSAGE_TEXT = 'message', MYSQL_ERRNO = 1000;
END IF;
public byte[] runReportToPdf(String reportFile,Map<String, Object> parameters) throws GenericException{
InputStream is=getReportFile(reportFile);
Connection conn=getConnection();
byte[] bi=null;
try {
parameters.put("P_REPORTS_PATH", Application.getInstance().getReportsPath());
parameters.put(JRParameter.REPORT_LOCALE, new Locale("pt", "BR"));
@carlosspohr
carlosspohr / jquery.validate.custom-methods.js
Last active June 21, 2016 23:58
Collection of useful jquery.validate methods.
$.validator.addMethod("dateGreaterThan", function(value, element, params) {
var start = moment($(params).val(), "DD/MM/YYYY");
var end = moment(value, "DD/MM/YYYY");
return end.diff(start) >= 0;
}, "End date must be greater than start one.");
$.validator.addMethod("isValidDate_pt_BR", function(value, element) {
return moment(value, "DD/MM/YYYY").isValid();
@carlosspohr
carlosspohr / mask_money.sql
Last active June 21, 2016 13:32
Função marota pra auxilar quando você precisar formatar um valor monetário dentro de uma query qualquer. Não usei o método FORMAT(val, casas, locale) devido ao CentOS 6.5 não vir com essa função, apenas a versão básica dela FORMAT(val, locale)...que não atende esse meu problema.
DELIMITER $$
DROP FUNCTION IF EXISTS `mask_money` $$
CREATE FUNCTION `mask_money`(valor DOUBLE) RETURNS VARCHAR(50) DETERMINISTIC
BEGIN
declare tamanho int;
declare comeco int;
declare str varchar(50);
drop table if exists tmp_date_interval;
create temporary table tmp_date_interval(data_tmp date not null primary key)ENGINE=MEMORY;
DELIMITER $$
drop procedure if exists `get_date_interval` $$
create procedure get_date_interval(inicio date, fim date)
begin
!SESSION 2016-05-30 21:35:57.473 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_77
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en
Command-line arguments: -os win32 -ws win32 -arch x86_64
!ENTRY org.eclipse.equinox.preferences 4 2 2016-05-30 21:35:58.223
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.preferences".
!STACK 0