Skip to content

Instantly share code, notes, and snippets.

View diego-aslz's full-sized avatar
🏠
Working from home

Diego Selzlein diego-aslz

🏠
Working from home
View GitHub Profile
module BootstrapHelper
ALERT_TYPES = [:success, :info, :warning, :danger]
def glyph(icon)
content_tag :span, nil, class: "glyphicon glyphicon-#{icon}"
end
def bootstrap_tags_from_flash
content_tag :div, id: ApplicationHelper::FLASH_MESSAGES_TAG_ID do
flash.each do |type, message|
-- Edit Query. Adicionar abaixo de:
-- AND
-- V.DT_CANCELAMENTO IS NULL
-- A seguinte SQL:
AND
DATEADD(-3 HOUR TO DT_EMISSAO) BETWEEN :DT_INICIO
AND DATEADD(1 DAY TO :DT_FIM)
@diego-aslz
diego-aslz / left_join.rb
Last active May 10, 2016 15:59
Method to do a LEFT OUTER JOIN on an ActiveRecord model class.
class ActiveRecord::Base
# Does a left join through an association. Usage:
#
# Book.left_join(:category)
# # SELECT "books".* FROM "books"
# # LEFT OUTER JOIN "categories"
# # ON "books"."category_id" = "categories"."id"
#
# It also works through association's associations, like `joins` does:
#
procedure VarreItens(MenuItem: TMenuItem; List: TStringList; Nivel: Integer = 0);
var
str: String;
i: Integer;
begin
str = '';
i := 0;
while i < Nivel do
begin
str = str + ' ';
@diego-aslz
diego-aslz / dotfiles_install.sh
Last active August 29, 2015 14:05
Unila dotfiles installation
#!/bin/bash
if [[ `whoami` == "root" ]]; then
echo "Você está logado como root. Por favor, execute este comando com seu próprio usuário."
exit 1
fi
sudo apt-get install git -y
git clone git@lab.unila.edu.br:dsis/dotfiles.git ~/.dotfiles && cd ~/.dotfiles && script/bootstrap
@diego-aslz
diego-aslz / DomainClass.java
Created December 12, 2013 12:00
Proc in Java
package main;
public class DomainClass {
public void doSomething(Object arg0, Proc block) {
// do something
block.run(arg0);
}
}
@diego-aslz
diego-aslz / Desnecessarios.pas
Last active December 29, 2015 04:59
Impressao via Bematech MP4000 TH.
// Essa função você nao precisa, use-a só para ver como a classe é instanciada, pode instanciar direto a impressora USB.
// Esse objeto Configuracoes lê de um arquivo INI, vc pode, em vez de usar algo assim, passar a porta fixa. No caso da USB, a impressora vai procurar sozinha todas as portas COM caso a que você passou não funcione.
function ObterImpressora: TImpressora;
begin
if Configuracoes.TipoImpressora = tiSerial then
begin
Impressora.Porta := Configuracoes.Porta;
Result := Impressora;
end
else
# -*- encoding : utf-8 -*-
puts "Cities..."
City.transaction do
ro = Province.find_by_uf('RO')
City.create(province_id: ro.id, id: '1100015', lat: -11.9284, lng: -61.9951, name: 'Alta Floresta D\'Oeste')
City.create(province_id: ro.id, id: '1100023', lat: -9.91375, lng: -63.044, name: 'Ariquemes')
City.create(province_id: ro.id, id: '1100031', lat: -13.4864, lng: -60.5411, name: 'Cabixi')
City.create(province_id: ro.id, id: '1100049', lat: -11.4315, lng: -61.4477, name: 'Cacoal')
package br.com.clouded.web.service.support;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@diego-aslz
diego-aslz / modal_dialog_helper.rb
Created October 23, 2013 12:09
Bootstrap Helpers for Rails.
module ModalDialogHelper
def modal_dialog(options={},&block)
content_tag :div, {class: 'modal hide fade', tabindex: -1, role: 'dialog'}.merge(options), &block
end
def modal_header(options={},&block)
content_tag :div, {class: 'modal-header'}.merge(options), &block
end
def modal_body(options={},&block)