Skip to content

Instantly share code, notes, and snippets.

View frank184's full-sized avatar
👌
pro g[r]amer

François Bélanger frank184

👌
pro g[r]amer
View GitHub Profile
@frank184
frank184 / .bash_aliases
Created January 9, 2016 00:00
Script for booting a Rails Server in another terminal while Developing
alias rails_s="gnome-terminal -e 'bash -c \"rails s; bash\"'"
@frank184
frank184 / rails_composer
Last active May 12, 2016 05:50
My version of the railsComposer.sh script
#!/bin/bash
project_name=$1
if [ -z project_name ]; then
echo
echo "projects need names too, I'm sure you can think of a neat one!"
echo " ex: rails_composer neat_name"
echo
else
@frank184
frank184 / cloudflare.rb
Created February 15, 2016 19:17
Ruby on Rails CloudFlare gem easy connection
# Example: CloudFlare::connect { |connection| puts connection }
module CloudFlare
API_KEY = ENV['CLOUDFLARE_API_KEY']
EMAIL = ENV['CLOUDFLARE_EMAIL']
def self.connect
yield Connection.new(API_KEY, EMAIL) if block_given?
end
end
@frank184
frank184 / update
Last active May 2, 2016 21:37
Update script for Ubuntu
#!/bin/sh
# ~/bin/update
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install -f
sudo apt-get -y dist-upgrade
sudo apt-get -y autoclean
sudo apt-get -y autoremove
sudo do-release-upgrade -d
@frank184
frank184 / localtunnel.rake
Created May 21, 2016 16:44
Rake Task that controls the Ruby API for localtunnel
# lib/tasks/localtunnel.rake
namespace :localtunnel do
desc "Starts the LocalTunnel instace"
task start: :environment do
begin
if Rails.env.production?
raise "Trying to launch Localtunnel in production".red
end
default_subdomain = "whatever"
default_port = 3000
@frank184
frank184 / sba_systems_check
Last active June 4, 2016 16:26
SBA Server Statuses Checks
#!/bin/bash
# ~/bin/sba_systems_check
systemctl status mysql --no-pager
systemctl status redis_6379 --no-pager
systemctl status elasticsearch --no-pager
@frank184
frank184 / .bash_ps1
Created June 18, 2016 19:30
My bash prompt ¯\_(ツ)_/¯
# Add . "$HOME/.bash_ps1" to .bashrc
export PS1='¯\_(ツ)_/¯\w$ '
@frank184
frank184 / application.rb
Last active September 21, 2016 23:38
HasSecureToken extension for shoulda-matchers gem while using has_secure_token gem
# config/application.rb
module YourApp
class Application < Rails::Application
# ...
# Auto load lib folder
config.autoload_paths << Rails.root.join('lib')
end
end
@frank184
frank184 / application_controller.rb
Created September 21, 2016 23:35
Ruby on Rails - I18n implementation
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
include Devise::Redirects
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include Locale
end
@frank184
frank184 / datatable-ext.js
Created September 21, 2016 23:57
Extending JQuery.DataTable
$.fn.dataTableExt.oApi.reload = function(options) {
this.fnFilter(options['search'])
this.fnPageChange(options['page'])
}