Skip to content

Instantly share code, notes, and snippets.

View waldothedeveloper's full-sized avatar
🎖️
Never give up!

Waldo Lavaut waldothedeveloper

🎖️
Never give up!
View GitHub Profile
@dbonates
dbonates / rails_on_lion.sh
Last active October 27, 2017 01:44
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:
@jcasimir
jcasimir / filters.markdown
Created July 22, 2011 18:14
Controller Filters
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
@alDuncanson
alDuncanson / index.js
Created April 20, 2020 17:31
Convert military and standard times
View index.js
// 3:30 pm => 15:30
const standardToMilitary = standardTime => {
const [time, period] = standardTime.split(' ')
const [hours, minutes] = time.split(':')
if (period === 'am') {
return `${hours == 12 ? 24 : hours}:${minutes}`
} else {
return `${parseInt(hours) === 12 ? 12 : parseInt(hours) + 12}:${minutes}`
}
@gragland
gragland / use-auth.jsx
Last active August 27, 2022 15:16
React Hook recipe from https://usehooks.com
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 June 22, 2023 12:09
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');
@gaearon
gaearon / Classes.js
Created May 27, 2020 17:38
Beneath Classes: Prototypes
View Classes.js
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
@flangofas
flangofas / ConvertMS.js
Last active October 29, 2023 12:25
JS: Convert Milliseconds to days? minutes? seconds? or all!
View ConvertMS.js
function convertMiliseconds(miliseconds, format) {
var days, hours, minutes, seconds, total_hours, total_minutes, total_seconds;
total_seconds = parseInt(Math.floor(miliseconds / 1000));
total_minutes = parseInt(Math.floor(total_seconds / 60));
total_hours = parseInt(Math.floor(total_minutes / 60));
days = parseInt(Math.floor(total_hours / 24));
seconds = parseInt(total_seconds % 60);
minutes = parseInt(total_minutes % 60);
@jaysonrowe
jaysonrowe / FizzBuzz.js
Created January 11, 2012 01:39
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);
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
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>