Skip to content

Instantly share code, notes, and snippets.

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

Shah Zaib shah743

🏠
Working from home
  • Islamabad, PK
View GitHub Profile
@shah743
shah743 / rails_confirm_override.js.coffee
Last active January 26, 2016 04:37 — forked from stevenspiel/rails_confirm_override.js.coffee
Replace Rails confirm with sweetalert2 popup. (https://github.com/limonte/sweetalert2). It overrides the default javascript (from jquery_ujs), which skips any other popup.
$.rails.allowAction = (link) ->
if link.data('confirm')
$.rails.showConfirmationDialog(link)
false
else
true
# User click confirm button
$.rails.confirmed = (link) ->
link.data('confirm', null)
@shah743
shah743 / compression.rb
Created August 31, 2016 09:45 — forked from remino/compression.rb
Ruby on Rails: Minify HTML, CSS, & JS, and compress with gzip https://remino.net/rails-html-css-js-gzip-compression/
# config/initializers/compression.rb
Rails.application.configure do
# Use environment names or environment variables:
# break unless Rails.env.production?
break unless ENV['ENABLE_COMPRESSION'] == '1'
# Strip all comments from JavaScript files, even copyright notices.
# By doing so, you are legally required to acknowledge
# the use of the software somewhere in your Web site or app:
@shah743
shah743 / NoVNC_Paste.js
Created October 19, 2017 05:41 — forked from byjg/NoVNC_Paste.js
How to Paste code to NoVNC.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
window.sendString = function (str) {
f(str.split(""));
function f(t) {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = character.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/);
@shah743
shah743 / deploy.rb
Created October 26, 2018 12:43 — forked from yanyingwang/deploy.rb
mina+puma+nginx
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
require 'mina/rvm' # for rvm support. (http://rvm.io)
require 'mina/puma'
require 'mina/nginx'
# Basic settings:
@shah743
shah743 / 00_README.md
Created November 20, 2020 19:28 — forked from mikechau/00_README.md
Logging Rails 4 to Syslog, formatted w/ Logstash

Logging Rails 4 to Syslog, formatted w/ Logstash

Getting Started

Steps to get Rails 4 saving its output to Syslog via Rsyslog. This assumes you are on CentOS, but should be pretty adaptable to any other distribution. Ruby 2.0+ is also required.

  1. Add the gems lograge and logstash-event to your Gemfile. Feel free to remove from production if you'd like to test it in development as well or something.
  2. Update production.rb with the lograge settings and set the logger to Syslog::Logger.
  3. Add the conf files to /etc/rsyslog.d/. /etc/rsyslog.conf should have $IncludeConfig /etc/rsyslog.d/*.conf enabled, so it will load any additional configs from /etc/rsyslog.conf.
@shah743
shah743 / ror-api.markdown
Created June 9, 2022 05:22 — forked from withoutwax/ror-api.markdown
Guide on how to create an API-Only Application with Ruby on Rails 5

Creating an API-Only Application with Ruby on Rails

01 - Create a new API-only Rails app

rails new ror-app-name --api

02 - Basic Scaffold

01 - Model

This step is for creating a very basic level of model for us to work in. If you know already, or wish to apply your own custom models with relationships you can skip this step.