Skip to content

Instantly share code, notes, and snippets.

View krlsdu's full-sized avatar

Carlos krlsdu

View GitHub Profile
module LuckyTicket
def self.half
initial = 0
length = 4
min = 10
max = ('9' * length).to_i
luck_ticket = 0
(min..max).each { |value|
Begin;
create table public.gastos_diretos(
Codigo_Orgao_Superior text,
Nome_Orgao_Superior text,
Codigo_Orgao text,
Nome_Orgao text,
Codigo_Unidade_Gestora text,
Nome_Unidade_Gestora text,
Codigo_Grupo_Despesa text,
Nome_Grupo_Despesa text,
for i in {01..12} ; do
wget --content-disposition "http://arquivos.portaldatransparencia.gov.br/downloads.asp?a=2015&m=$i&consulta=GastosDiretos"
done
unzip \*.zip -d extraidos
for f in *.csv ; do
FILE="$f"
tail -n +2 "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE" ; done
@krlsdu
krlsdu / askbot_docker
Last active November 4, 2016 18:56
Dockerfile
FROM postgres
FROM memcached
FROM python:2
RUN apt-get update -y
RUN apt-get install -y vim
RUN mkdir /site/
WORKDIR /site/
@krlsdu
krlsdu / askbot_requirements.txt
Last active November 4, 2016 18:56
requirements.txt
askbot
psycopg2
python-memcached
@krlsdu
krlsdu / askbot_run.sh
Created November 4, 2016 18:35
Script to up and launcher a instace from askbot using docker
docker build -t askbot .
docker run --name postgres -e POSTGRES_PASSWORD=askbot -e POSTGRES_USER=askbot -e POSTGRES_DB=askbot -d postgres
docker run --name memcached -d memcached
docker run --name askbot -t -i --link memcached --link postgres -d askbot
sleep 7
docker exec askbot python manage.py syncdb --noinput
docker restart askbot
@krlsdu
krlsdu / clean.sh
Last active January 17, 2017 23:23
#!/bin/bash
cd /srv/
rm -rf *
cd /usr/local/share/ca-certificates/
rm -rf *
cd /etc/docker/certs.d/
rm -rf *
#Gilabci. Executar dentro do container
mkdir -p /etc/gitlab/ssl/ && \
chmod 700 /etc/gitlab/ssl && \
openssl req \
-newkey rsa:4096 -nodes -sha256 -keyout /etc/gitlab/ssl/gitlabci.key \
-x509 -days 3650 -out /etc/gitlab/ssl/gitlabci.crt && \
vim /etc/gitlab/gitlab.rb
gitlab-ctl reconfigure && gitlab-ctl restart
version: '2'
services:
gitlabci:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlabci'
container_name: gitlabci
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlabci'
@krlsdu
krlsdu / Daemon,Cron,Background
Created August 2, 2017 03:38
Daemon, Cron, Backgroun Job
If you think you want to create a daemon process you should ask yourself one basic question: Does this process need to stay responsive forever?
If the answer is no then you probably want to look at a cron job or background job system. If the answer is yes, then you probably have a good candidate for a daemon process.