This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns "*" if the current git branch is dirty. | |
function parse_git_dirty { | |
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "✘" | |
} | |
# print rvm version | |
function rvm_version { | |
[[ -z "${PWD//*\/var\/www\/*/}" ]] && echo "($(~/.rvm/bin/rvm-prompt v g))" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ngix + required packages | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install curl git-core nginx build-essential tcl8.5 -y | |
# Install ImageMagick | |
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev libmagic-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example get_timezone("GMT+03:00") | |
def get_timezone(offset) | |
# return false if timezone not valid | |
return false unless ActiveSupport::TimeZone.all.map(&:formatted_offset).include?(offset.gsub("GMT","")) | |
# find zone name | |
zone_name = ActiveSupport::TimeZone.all.map(&:to_s).select { |x| x.include?(offset) }.first.gsub("(#{offset}) ", "") | |
# return false if zone_name not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add those lines to deploy.rb | |
# inspired from : https://gist.github.com/doitian/1795439 | |
# solr tasks | |
namespace :solr do | |
desc "start solr sunspot server" | |
task :start do | |
on roles(:app) do | |
within release_path do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pathname' | |
require 'fileutils' | |
include FileUtils | |
# path to your application root. | |
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
def system!(*args) | |
system(*args) || abort("\n== Command #{args} failed ==") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/shared/_alerts.html.erb | |
<% if flash.any? %> | |
<% flash.each do |key, message| %> | |
<div id="flash-<%= key %>" class="alert alert-<%= alert_style(key) %> alert-dismissible fade show" role="alert"> | |
<%= message %> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%%= form_with(model: <%= model_resource_name %>, local: true) do |form| %> | |
<div class="card mb-4"> | |
<div class="card-body"> | |
<%% if <%= singular_table_name %>.errors.any? %> | |
<div id="error_explanation" class="alert alert-danger"> | |
<h2 class="h4"><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2> | |
<ul> | |
<%% <%= singular_table_name %>.errors.full_messages.each do |message| %> | |
<li><%%= message %></li> |