Skip to content

Instantly share code, notes, and snippets.

-- get all latest the finished progresses of all individuals
SELECT *
FROM progresses pr
WHERE id = (
SELECT id
FROM progresses p
WHERE p.individual_id = pr.individual_id AND p.procedure_id = pr.procedure_id AND p.finished
ORDER BY p.created_at DESC LIMIT 1 )
ORDER BY pr.created_at DESC;
@edivandecastro
edivandecastro / javascript-get-first-last-date
Created June 12, 2015 12:35
get-first-and-last-date-of-current-month-with-javascript-or-jquery
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
Baixe o tema Seti UI, coloque dentro da pasta package do sublime text e renomei a pasta para "Theme - Soda" para adicionar icones ao tema soda dark
@edivandecastro
edivandecastro / gist:a53c2b907dbc3ccc46a0
Created July 20, 2015 18:11
Instalando Fontes do mac no linux
wget http://dl.dropbox.com/u/26209128/mac_fonts.tar.gz
tar zxvf mac_fonts.tar.gz
sudo mv fonts /usr/share/fonts/
sudo fc-cache -f -v
@edivandecastro
edivandecastro / preferences-sublime
Last active January 26, 2017 17:54
preferences-sublime-settings
{
"color_scheme": "Packages/Boxy Theme/schemes/Boxy Tomorrow.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_face": "monaco",
"font_size": 10,
"rulers": [122],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"tab_size": 2,
Listando Processo no Linux
ps -f -u postgres
REF -> [http://canaltech.com.br/tutorial/linux/conheca-6-comandos-para-gerenciar-processos-do-linux/]
Listando endereços TCP/IP e portas do PostgreSQL
sudo lsof -n -u postgres |grep LISTEN
REF -> [http://www.vivaolinux.com.br/dica/O-comando-lsof]
@edivandecastro
edivandecastro / BlockParameters.rb
Created December 17, 2015 19:10
Little Things: Introspecting Block Parameters
class Hash
module Using
def using(&block)
values = block.parameters.map do |type, name|
self[name]
end
block.call(*values)
end
end
require "rubygems"
require "mechanize"
agent = Mechanize.new
page = agent.get("http://esaj.tjce.jus.br/cpopg/open.do")
form = page.form_with(:name => "consultarProcessoForm")
page.form_with(:name => "consultarProcessoForm") do |form|
form.fields.each do |field|
field.value = field.options.detect { |option| option.value == "NUMPROC"}.value if field.name == "cbPesquisa"
# Listar as chaves que começam com redis_user_permission
KEYS redis_user_permission*
# Listar um determinado número de elementos de uma lista (Somente para valores que sejam lista)
LRANGE redis_user_permission:1:engines 0 9
# Obtem o valor da chave informada (Somente para valores que sejam string)
GET redis_user_permission:1:user_id
# Apaga um chave no Redis
DEL nome_da_chave
Ex. DEL redis_user_permission:1:engines
psql -U postgres -h localhost base_development < ~/Desktop/dump_user-27072016