Skip to content

Instantly share code, notes, and snippets.

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

Shah Zaib shah743

🏠
Working from home
View GitHub Profile
@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 / ssl_puma.sh
Created April 13, 2016 05:36
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
# config/routes.rb
%w( 404 422 500 ).each do |code|
get code, :to => "errors#show", :code => code
end
# app/views/errors/404.html.haml
%h1 404 - Not Found
class ErrorsController < ApplicationController
@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 / twitter_widget_id_extractor.rb
Last active May 11, 2016 14:42
Get twitter embed widget's ID dynamically
class TwitterWidgetIdExtractor
WIDGET_SETTING_URL = "https://twitter.com/settings/widgets/new/user?screen_name="
SIGNIN_URL = "https://twitter.com/login"
attr_accessor :screen_name, :twitter_username, :twitter_password
def initialize(screen_name, twitter_username, twitter_password)
@screen_name = screen_name
@twitter_username = twitter_username
@twitter_password = twitter_password