Skip to content

Instantly share code, notes, and snippets.

View grammakov's full-sized avatar
🎯
Focusing

Denis grammakov

🎯
Focusing
View GitHub Profile
@the-bass
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on https://github.com/turbolinks/turbolinks/issues/73.
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<head>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@rkjha
rkjha / nginx-passenger-ssl.conf
Last active March 25, 2021 15:47
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
# for redirecting to non-www version of the site
server {
listen 80;
@Epigene
Epigene / MB puma + Nginx settings
Last active December 28, 2020 19:35
MB puma + Nginx settings
# /config/puma.rb
app = "manabalss" # App-specific
root = "/home/deployer/apps/#{app}"
workers 5
threads 1, 1 # relying on many workers for thread-unsafe apps
rackup DefaultRackup
port 11592
@henrik
henrik / images_helper.rb
Created February 11, 2015 07:57
Rails image_set_tag_3x helper for srcset.
module ImagesHelper
# Example usage:
#
# image_set_tag_3x "foo_1x.png", alt: "foo"
#
# Will assume there is a 2x and 3x version and provide those automagically.
#
# Based on https://gist.github.com/mrreynolds/4fc71c8d09646567111f
def image_set_tag_3x(source, options = {})
srcset = [ 2, 3 ].map { |num|
@jalquisola
jalquisola / Install Phantomjs
Last active August 29, 2015 14:08
Install phantomjs in Yosemite
A. Install Using homebrew
brew install phantomjs
If you encounter error this error, phantomjs: OS X Mavericks or older is required for stable,
you can download phantomjs binary.
B. Install using binary
1. Download phantomjs binary, http://phantomjs.org/download.html
@vkurennov
vkurennov / production.rb
Last active February 23, 2024 08:12
Пример конфига unicorn
# paths
app_path = "/home/deployer/qna"
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "#{app_path}/shared/tmp/sockets/unicorn.qna.sock", backlog: 64
# logging
stderr_path "log/unicorn.stderr.log"
@vkurennov
vkurennov / monit.rc
Last active February 23, 2024 08:12
Пример конфига для запуска процессов через monit
### Nginx ###
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
@bomberstudios
bomberstudios / sketch-plugins.md
Last active February 26, 2024 07:02
A list of Sketch plugins hosted at GitHub, in no particular order.
@stevenchanin
stevenchanin / digitalocean.md
Last active December 20, 2021 17:18 — forked from JamesDullaghan/digitalocean.md
Setup instructions for Digital Ocean VPS using Ubuntu and Rails 3.2 #digitalocean #vps #setup

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create Droplet

Create droplet of your liking (ubuntu 12.04 x32) Use an xx.04 LTS version

Setup DNS

On Digital Ocean, create a DNS entry for your server (xyz.com)

Make sure it has NS records that use digital oceans nameservers

@rceee
rceee / User_slugs_without_database.rb
Last active December 14, 2015 03:29
How I set up my Rails 3 User model to have a pretty URL/ID "slug" without adding a slug field to the database
#This is how I set up my Rails 3 User model to have a pretty URL/ID "slug" without adding a slug field to the database