Skip to content

Instantly share code, notes, and snippets.

View franciscomxs's full-sized avatar
🏠
Working from home

Francisco Martins franciscomxs

🏠
Working from home
View GitHub Profile

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

{
    "window.zoomLevel": 0,
    "editor.minimap.enabled": false,
    "breadcrumbs.enabled": true,
    "workbench.activityBar.visible": true,
    "window.menuBarVisibility": "toggle",
    "workbench.statusBar.visible": true,
    "workbench.colorTheme": "Omni",
 "workbench.iconTheme": "material-icon-theme",
@franciscomxs
franciscomxs / curl-format.txt
Created April 4, 2018 21:57
Curl - get request time
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
@franciscomxs
franciscomxs / bash
Created September 11, 2017 14:11
Modify specific commit
$ git rebase --interactive 'SHORT_SHA^'
# In the default editor, modify `pick` to `edit` in the line whose commit you want to modify.
# Make your changes and then commit them with the same message you had before:
$ git commit --all --amend --no-edit
$ git rebase --continue
pg_dump -U <username> -W -Fc <databasename> > <filename>.dump
scp -i ~/.ssh/cx_<id>_pkey <user>@<ip>:<filename>.dump <filename>.dump
pg_restore -c -U postgres -d <databasename> <filename>.dump
#!/bin/sh
cd /home/user/app/ || exit
unset GIT_DIR
git reset --hard
git pull origin master -f
bundle install --gemfile "Gemfile" --path "bundle" --deployment --without development test
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake assets:precompile
touch tmp/restart.txt
@franciscomxs
franciscomxs / MainActivity.java
Created December 15, 2015 17:28
Android - Binding Service to Activity
// ...
private MyService myService;
private boolean messengerBound = false;
@Override
protected void onStart() {
super.onStart();
Intent intent = new Intent(this, PlayerService.class);
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
@franciscomxs
franciscomxs / rails-ubuntu12.04.sh
Last active October 9, 2015 17:58
Instalação do Rails em redes restritas no Ubuntu 12.04
#!/usr/bin/env bash
sudo apt-get install build-essential zlib1g-dev curl git-core libgeoip-dev imagemagick vim libxslt-dev mysql-server mysql-client libmysql-ruby libmysqlclient-dev -y
cd
git clone https://github.com/sstephenson/rbenv.git .rbenv
cd .rbenv
mkdir plugins
cd plugins
git clone https://github.com/sstephenson/rbenv-vars.git
git clone https://github.com/sstephenson/ruby-build.git
git clone https://github.com/fesplugas/rbenv-installer.git
@franciscomxs
franciscomxs / ubuntu_steps.sh
Created July 5, 2012 17:06 — forked from johnrees/_ubuntu_steps.sh
Standard Rails 3.* setup for Ubuntu 10.04 LTS 32
# As root user
# Update the OS
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
# Setup Hostname & TimeZone
echo "{{HOSTNAME}}" > /etc/hostname
hostname -F /etc/hostname
dpkg-reconfigure tzdata
@franciscomxs
franciscomxs / rename.rb
Last active September 13, 2015 04:42
Rename my animes and series to use Episode.Extension format
REGEX = /([0-9]{2,3}).*([\.mp4|\.mkv|.rmvb|.avi]{4,5})/
Dir['*'].each do |file_name|
if (match = REGEX.match(file_name)) && File.exist?(file_name)
new_name = "#{match[1]}#{match[2]}"
File.rename(file_name, new_name)
end
end