Skip to content

Instantly share code, notes, and snippets.

View sadiqmmm's full-sized avatar

Mohammed Sadiq sadiqmmm

View GitHub Profile
@sadiqmmm
sadiqmmm / paperform-get-form-page-url.js
Last active March 19, 2024 22:53
Get your form’s URL when it’s embedded in another page - With Paperform, you have the capability to automatically retrieve the URL of your form's page, enabling you to discern the origins of your submissions when they're integrated into other web pages. Gain fresh insights into where your customers are completing your forms!
<div data-paperform-id="jwps"></div>
// Note: Please don't change/format the below line no 3. Keep as it is.
<script>(function () { var script = document.createElement('script'); script.src = "https://paperform.co/__embed.min.js"; document.body.appendChild(script); })()</script>
<script>
(function () {
const currentPageUrl = window.location.href;
const form = document.querySelector("[data-paperform-id='jwps']");
// formsubmiturl is your custom Pre-fill key:
form.setAttribute('prefill', "formsubmiturl=" + currentPageUrl);
@sadiqmmm
sadiqmmm / 1 SETUP Ubuntu 20.04 LTS (DigitalOcean)
Created September 22, 2023 19:31 — forked from VasylShevchenko/1 SETUP Ubuntu 20.04 LTS (DigitalOcean)
Deploy Rails to VPS(Ubuntu 20.04LTS). Nginx mainline + pagespeed, Puma with Jungle, Capistrano3, PostgreSQL, RVM, Certbot
//------ ROOT --------
root# apt-get update
root# apt-get upgrade
// Dependencies
apt-get install -y git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev \
libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev \
libpcre3-dev unzip htop zip

Add puma to you Gemfile:

gem "puma"

Install Puma Gem

change to project directory
bundle install
@sadiqmmm
sadiqmmm / gist:17a85b94ff96ad1ad41113dd2e6b1a8e
Created November 23, 2022 20:06 — forked from BjornDCode/gist:5cb836a6b23638d6d02f5cb6ed59a04a
Tailwind - Fixed sidebar, scrollable content
// Source: https://twitter.com/calebporzio/status/1151876736931549185
<div class="flex">
<aside class="h-screen sticky top-0">
// Fixed Sidebar
</aside>
<main>
// Content
</main>
@sadiqmmm
sadiqmmm / _form.html.erb
Created November 15, 2022 15:52 — forked from dalezak/_form.html.erb
Stimulus.js Toggle Controller to show and hide form elements based on select value
<div class="form-group">
<%= form.label :type, "Type", class: "font-weight-bold" %>
<%= form.select :type, ['TextQuestion', 'UrlQuestion'], { include_blank: true }, { class: "form-control", data: { action: "input->toggle#changed", target: "toggle.select" } } %>
</div>
<div class="form-group">
<%= form.label :name, "Name", class: "font-weight-bold" %>
<%= form.text_field :name, class: "form-control" %>
</div>
<div class="form-group" data-target="toggle.element" data-values="UrlQuestion">
<%= form.label :url, "URL", class: "font-weight-bold" %>
<?php
$countries =
array(
"AF" => "Afghanistan",
"AL" => "Albania",
"DZ" => "Algeria",
"AS" => "American Samoa",
"AD" => "Andorra",
"AO" => "Angola",
@sadiqmmm
sadiqmmm / generate-certificate.sh
Created December 3, 2021 14:20 — forked from dorianmariecom/generate-certificate.sh
Generate certificate for HTTPS on localhost macOS / Rails / Puma
#!/bin/bash
set -e
echo "> Removing certificate"
sudo security delete-certificate -c localhost || true
echo "> Generating .key"
sudo openssl genrsa -out config/localhost.key 4096
@sadiqmmm
sadiqmmm / gist:aac0bc187ad84be9c35528500bdeb876
Created November 1, 2021 12:09 — forked from pglombardo/gist:7206464
The War on ActionView with Russian Doll Caching

Rails 4 is out featuring Russian Doll caching (AKA Cache Digests). In this article, I apply Russian Doll caching to one of my poorer performing Rails 3 pages using the cache_digests gem.

ActionView templates are great. They are easy to code, manage and extend but the one thing they are not is fast...at least not out of the box.

In this article, I'll be using AppNeta's TraceView to time ActionView performance. If you haven't used TraceView before, checkout my previous article Instrumenting Ruby on Rails with TraceView.

ActionView is Slow; Pitfalls Ahead

ActionView puts forth a great development pattern of views and partials that is easy to understand, implement and maintain but that comes at a cost: The rendering process is complex and slow.

@sadiqmmm
sadiqmmm / 20130822132243_change_product_long_description.rb
Created October 16, 2021 09:34 — forked from jenheilemann/20130822132243_change_product_long_description.rb
Rails migrations: String to Text and back again. It's kind of complicated to update a database column that is currently a "string" and convert it into "text." Well, it's not hard to update the column, but it can be dangerous if you need to rollback the migration - Postgresql and other databases don't like adding a limit to the column, and the `r…
class ChangeProductLongDescription < ActiveRecord::Migration
def up
# simple and straightforward
change_column :products, :long_description, :text
end
# but why cant it just be:
# change_column :product, :long_description, :string
# ???
# because effin databases don't like you, that's why.
@sadiqmmm
sadiqmmm / reclaimWindows10.ps1
Created June 1, 2021 16:09 — forked from alirobe/reclaimWindows10.ps1
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
##########
# Tweaked Win10 Initial Setup Script
# Primary Author: Disassembler <disassembler@dasm.cz>
# Modified by: alirobe <alirobe@alirobe.com> based on my personal preferences.
# Version: 2.20.2, 2018-09-14
# Primary Author Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
# Tweaked Source: https://gist.github.com/alirobe/7f3b34ad89a159e6daa1/
# Tweak difference:
#
# @alirobe's version is a subset focused on safely disabling telemetry, some 'smart' features and 3rd party bloat ...