Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Waldo Lavaut waldothedeveloper

🏠
Working from home
View GitHub Profile
@gaearon
gaearon / Classes.js
Created May 27, 2020
Beneath Classes: Prototypes
View Classes.js
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
View use-auth.jsx
// Top level App component
import React from "react";
import { ProvideAuth } from "./use-auth.js";
function App(props) {
return (
<ProvideAuth>
{/*
Route components here, depending on how your app is structured.
If using Next.js this would be /pages/_app.js
@stevebowman
stevebowman / AWSLambdaSimpleSMS.js
Last active Feb 27, 2020
AWS Lambda Function to send an SMS message via the Twilio API
View AWSLambdaSimpleSMS.js
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active Apr 25, 2021
Remove node_modules from git repo
View gist:0052fab554b14bbfa3ef
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@dbonates
dbonates / rails_on_lion.sh
Last active Oct 27, 2017
Ruby on Rails + rbenv + sqlite3 + mysql + postgresql on Mac
View rails_on_lion.sh
# install Command Line Tools for Xcode (*** if not yet!)
#Install Homebrew
$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
# Add Homebrews binary path to the front of the $PATH
$ echo "export PATH=/usr/local/sbin:$PATH" >> ~/.bash_profile
$ source ~/.bash_profile
# checar instalação do homebrew e possíveis pendências:
@jaysonrowe
jaysonrowe / FizzBuzz.js
Created Jan 11, 2012
FizzBuzz JavaScript solution
View FizzBuzz.js
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
View filters.markdown

Controller Filters

The Rails REST implementation dictates the default seven actions for your controllers, but frequently we want to share functionality across multiple actions or even across controllers. Controller filters are the easiest way to do that.

Before, After, and Around

There are three types of filters implemented in Rails:

  • a before_filter runs before the controller action
  • an after_filter runs after the controller action