Skip to content

Instantly share code, notes, and snippets.

View juanjoseijas's full-sized avatar
💭
I may be slow to respond.

Juanjo Seijas juanjoseijas

💭
I may be slow to respond.
View GitHub Profile
@stevecondylios
stevecondylios / contact-form-rails-6.md
Last active April 2, 2024 15:50
Create a Contact Form in Rails 6

How to make a contact form in rails 6

This is a quick walk through on how to:

  1. make a contact form in rails 6,
  2. test it locally, and
  3. move it into production using heroku and the MailGun addon

This uses the free heroku and mailgun plans. If you get stuck on any part, check the full code here.

@parthpower
parthpower / !WhatsApp On Web Monitor.md
Last active June 20, 2024 08:17
Simple JS to monitor offline and online time of a contact.

WhatsApp On Web Monitor

What It does

It gives notifications when someone goes online or offline or typing. Open chat of the contact you want to monitor and start script.

Simple Way

@woloski
woloski / payment.html
Last active October 1, 2020 15:46
Stripe Checkout + webtask
<button class="pay">Pay</button>
<script src="https://checkout.stripe.com/checkout.js">
<script>
var handler = StripeCheckout.configure({
key: window.STRIPE_PUBLICK_KEY,
image: 'https://yourlogo.png',
locale: 'auto',
token: function(token) {
$('.pay').prop("disabled", true);
@indiesquidge
indiesquidge / subdomain-localhost-rails-5.md
Created January 19, 2016 07:42
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@xeraa
xeraa / helper.rb
Created August 4, 2015 23:48
Middleman: Fully automated alternate language links
# Returns a hash of localized paths for a given page
def localized_paths_for(page)
localized_paths = {}
(langs).each do |locale|
# Loop over all pages to find the ones using the same templates (proxied_to) for each language
sitemap.resources.select do |resource|
if resource.proxied_to == page.proxied_to && resource.metadata[:options][:lang] == locale
localized_paths[locale] = resource.url
break
@Joseworks
Joseworks / contact_batch_email.html.erb
Created April 10, 2015 03:19
Send batch emails on ActiveAdmin Rails 4.2.0
<!-- Contact batch email -->
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<div>Name: <%= @name %></div>
<br>
<div>Subject: <%= @subject %></div>
@ssaunier
ssaunier / db.rake
Last active January 8, 2021 11:46 — forked from abstractcoder/import.rake
Rake task to back up heroku database and restore it locally.
namespace :db do
desc "Backs up heroku database and restores it locally."
task import_from_heroku: [ :environment, :create ] do
HEROKU_APP_NAME = nil # Change this if app name is not picked up by `heroku` git remote.
c = Rails.configuration.database_configuration[Rails.env]
heroku_app_flag = HEROKU_APP_NAME ? " --app #{HEROKU_APP_NAME}" : nil
Bundler.with_clean_env do
puts "[1/4] Capturing backup on Heroku"
`heroku pg:backups capture DATABASE_URL#{heroku_app_flag}`

Integrating Stripe with Rails

This written tutorial covers building a payment system into a Rails app using Stripe.js. It assumes a basic familiarity with Ruby on Rails, Git and the command-line.

There is a slightly contracted version of this tutorial available here.

What's covered

  • Setting up a basic Rails app with a scaffold generator
  • Integrating Stripe charges
@phawk
phawk / config.ru
Created September 1, 2014 19:40
Middleman config.ru for usage with pow/anvil for mac
# From: https://github.com/middleman/middleman/pull/560
require "rubygems"
require "middleman-core/load_paths"
Middleman.setup_load_paths
require "middleman-core"
require "middleman-core/preview_server"
@mikeadeleke
mikeadeleke / gist:59519ca92f702a188394
Created June 5, 2014 16:24
Rake tasks, automated emails, and whenever gem
email_reminders.rake
namespace :email_reminders do
desc "reminds the user to complete their profile"
task :founder_welcome => :environment do
if Rails.env == "production"
if @user.profile.present?
ConfirmMailer.founder_welcome(@user).deliver
end
end