Skip to content

Instantly share code, notes, and snippets.

View luizpicolo's full-sized avatar
👨‍🏫
Teaching

Luiz F. Picolo luizpicolo

👨‍🏫
Teaching
View GitHub Profile
#!/usr/bin/ruby
require 'rss'
# Usage
# $ ./railscasts.rb http://railscasts.com/subscriptions/YOURRAILSCASTRSS/\/
# episodes.rss
# OR
# $ ./railscasts.rb
p 'Downloading rss index'
@luizpicolo
luizpicolo / responsive_likebox.html
Last active August 29, 2015 14:25
Responsive Facebook Like Box
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="width:100%;">
<div class="fb-like-box" data-href="https://www.facebook.com/adobegocreate" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>
</div>
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
set :ruby_version, ''
# Repository project
set :repository, ''
# Create file in config/initializer/multipart_part_limit.rb
Rack::Utils.multipart_part_limit = 0
@luizpicolo
luizpicolo / pg_dump
Last active December 30, 2020 00:45
pg_dump only inserts
pg_dump -h localhost -p 5432 -U postgres --data-only --column-inserts deltaengenhariams > table.sql
pg_dump -U db_user -W -F t db_name > /path/to/your/file/dump_name.tar

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=FreeMind
Icon=/home/picolo/Pictures/icons/Free_Mind.png
Exec=freemind %U
StartupNotify=false
OnlyShowIn=Unity;
X-UnityGenerated=true
@luizpicolo
luizpicolo / bash.sh
Last active September 1, 2016 11:53
#!/usr/bin/env bash
cp config/database.example.yml config/database.yml &&
cp config/application.example.yml config/application.yml &&
cp config/secrets.example.yml config/secrets.yml &&
value=`cat .ruby-gemset` &&
sed -i "s/db/$value/g" config/database.yml &&
gem install bundle &&
bundle install &&
rake db:create &&
@luizpicolo
luizpicolo / install-docker.sh
Created October 13, 2016 02:21 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
Estes dias fiquei pensando o motivo que levava uma árvore binária a ser um estrutura de dados perfeita para o armazenamento e
busca de dados. Isso me levou a criar um algoritmo simples para demostrar a quantidade de passos para a busca de um
elemento mediante a quantidade de dados. O(log(n)). Logo, como o crescimento é exponencial, ao dobrar a quantidade de dados o
passo so é acrescido de mais 1.
i = 16
n = 1
for j in (0..i)
puts j
puts n