Skip to content

Instantly share code, notes, and snippets.

@lxneng
lxneng / gist:741932
Created December 15, 2010 13:21
install PostgreSQL 9 in Mac OSX via Homebrew
install PostgreSQL 9 in Mac OSX via Homebrew
Mac OS X Snow Leopard
System Version: Mac OS X 10.6.5
Kernel Version: Darwin 10.5.0
Install notes for PostgreSQL 9.0.1 install using Homebrew:
sh-3.2# brew install postgresql
@demonbane
demonbane / makeapp.sh
Created July 5, 2011 20:05
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@stevenharman
stevenharman / routes-www.rb
Created August 28, 2012 16:24
Redirect from www.* to your apex domain. Or from your apex domain to a www. subdomain.
Brewhouse::Application.routes.draw do
constraints(host: /^(?!www\.)/i) do
match '(*any)' => redirect { |params, request|
URI.parse(request.url).tap { |uri| uri.host = "www.#{uri.host}" }.to_s
}
end
resource :drink_up, only: [:show]
root :to => redirect('/drink_up')
@ricardoalcocer
ricardoalcocer / script.php
Created April 19, 2013 21:17
PHP Script to migrate HubSpot blog to Wordpress
<?php
// php setup
error_reporting(E_ALL);
ini_set('display_errors', 'On');
date_default_timezone_set('America/Los_Angeles');
//
// grab input data
if (isset($_GET['max'])){
$max=$_GET['max'];
@ericrasch
ericrasch / Collapsable Content functions.php
Last active July 4, 2017 03:55
Create collapsable content sections using WordPress' the_content().
/* =BEGIN: Add Class to first Paragraph in WordPress the_content();
Source: http://wordpress.stackexchange.com/a/51682/28826
---------------------------------------------------------------------------------------------------- */
function first_paragraph($content){
// Finding the 1st p tag and adding a class.
$content = preg_replace('%<p([^>]+)?>%', '<p$1 class="intro">', $content, 1);
// Finding the 1st closing p tag and adding a div tag to the rest of the content so we can separate it.
$content = preg_replace('%</p>%', '</p> <div id="collapsable-content">', $content, 1);
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active July 7, 2024 19:32
A badass list of frontend development resources I collected over time.
@afischoff
afischoff / pardot-form-handler-iframe.html
Last active December 1, 2022 20:51
Example of using a hidden iframe to pass data to a Pardot form handler before continuing with normal form submission.
<html>
<head>
<title>Pardot Example Form Handler Submit</title>
<!-- Include jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Post to Pardot function -->
<script type="text/javascript">
// set the pardot form handler url and form element id
@Warbo
Warbo / gist:9d8425fcdd7c026c795a
Last active August 29, 2015 14:01
Array/object lookup function, especially for Drupal
<?php
/**
* Looks up values from deep inside a container (object or array) in a safe way.
* For example:
*
* lookup(
* array('foo' => array('bar' => 'baz')),
* array('foo', 'bar')
* ) === 'baz'
@nuxodin
nuxodin / focusin focusout support for firefox.js
Last active February 7, 2024 16:40
focusin focusout support for firefox
/* Copyright (c) 2016 Tobias Buschor https://goo.gl/gl0mbf | MIT License https://goo.gl/HgajeK */
/* focusin/out event polyfill (firefox) */
!function(){
var w = window,
d = w.document;
if (w.onfocusin === undefined) {
d.addEventListener('focus' ,addPolyfill ,true);
d.addEventListener('blur' ,addPolyfill ,true);
d.addEventListener('focusin' ,removePolyfill ,true);