Skip to content

Instantly share code, notes, and snippets.

@mattlima
mattlima / 01_rails_6_on_beanstalk.config
Last active February 1, 2024 19:22
Beanstalk config script for Rails 6
# Beanstalk ain't ready for Rails 6. This fix is courtesy of https://austingwalters.com/rails-6-on-elastic-beanstalk/
# Additional node 6 cleanup courtesy of https://github.com/nodesource/distributions/issues/486
commands:
00_remove_node_6_if_present:
command: "/bin/rm -rf /var/cache/yum && /usr/bin/yum remove -y nodejs && /bin/rm /etc/yum.repos.d/nodesource* && /usr/bin/yum clean all"
ignoreErrors: true
01_download_nodejs:
command: "curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -"
02_install_nodejs:
@nathanhornby
nathanhornby / typeform-velocity.js
Created December 4, 2015 11:37
Scroll to active field in form (typeform style animation) using velocity.js
// Insert into some kind of 'focus' action
var parent = $(this).parent().parent('.fieldWrap'); // Target a wrapper
// Reset active state
$('.fieldWrap').removeClass('active');
// Add active state to current field
parent.addClass('active');
@wosephjeber
wosephjeber / ngrok-installation.md
Last active November 14, 2024 09:06
Installing ngrok on Mac

Installing ngrok on OSX

For Homebrew v2.6.x and below:

brew cask install ngrok

For Homebrew v2.7.x and above:

@danharper
danharper / gulpfile.js
Last active September 25, 2024 09:04
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@serv
serv / rails_cors_support_example.rb
Created July 19, 2014 07:11
Example of setting header to support CORS on Rails 4 API server side
module Api
module V0
class LinksController < ApplicationController
# THIS
before_action :set_headers
def show
@link = Link.find(params[:id])
render json: @link
end
@hopsoft
hopsoft / db.rake
Last active September 17, 2024 06:23
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@staltz
staltz / introrx.md
Last active November 14, 2024 11:27
The introduction to Reactive Programming you've been missing
@agendor
agendor / hapijs-rest-api-tutorial.md
Last active August 31, 2021 08:31
A practical introduction to building a RESTful API with the hapi.js server framework for Node.js
@joshuachestang
joshuachestang / auth_mailer.rb
Last active November 24, 2015 18:09
Using SendWithUs with Custom Devise Mailer and sendwithus_ruby gem
class AuthMailer < Devise::Mailer
require 'rubygems'
require 'send_with_us' #after installing sendwithus_ruby gem, require the send_with_us.rb initializer file
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
default from: "[email protected]"
def confirmation_instructions(record, token, opts={})
@mebezac
mebezac / application.html.erb
Created February 11, 2014 21:06
Rails Ajax Flash Messages
<div id="main" role="main">
<div class="container">
<div class="row">
<div class="span12" id="top-div"> <!--! added "top-div" id to help with ajax -->
<%= render 'layouts/messages' %>
<%= yield %>
</div>
</div>
<footer>
</footer>