Skip to content

Instantly share code, notes, and snippets.

@cdmwebs
cdmwebs / friendly_urls.markdown
Created September 11, 2011 15:50 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@kany
kany / sendmail_setup.md
Last active June 3, 2024 20:13
Setup SENDMAIL on Mac OSX Yosemite
@xjamundx
xjamundx / blog-webpack-2.md
Last active April 21, 2024 16:20
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@jayu
jayu / babel.config.js
Created May 2, 2020 17:35
Linaria with Gatsby without plugins
module.exports = {
presets: [
'babel-preset-gatsby',
[
'linaria/babel',
{
evaluate: true,
displayName: process.env.NODE_ENV !== 'production'
}
],
@ffdead
ffdead / WistiaEmbed.js
Created November 2, 2020 09:43
React component for Wistia embed
import React, { useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import classNames from 'classnames/bind'
import s from './WistiaEmbed.module.scss'
const cn = classNames.bind(s)
const WistiaEmbed = ({ id, play = false, style, options }) => {
// const el = useRef()