Skip to content

Instantly share code, notes, and snippets.

View lelandsmith's full-sized avatar

Leland Smith lelandsmith

View GitHub Profile
<?php
function urlsafe_b64encode($string) {
return str_replace(array('+','/','='),array('-','_',''), base64_encode($string));
}
$timestamp=time();
$ampBaseUrl = "https://www-domain-com.cdn.ampproject.org";
$signatureUrl = '/update-cache/c/s/www.domain.com/amp/page-url?amp_action=flush&amp_ts='.$timestamp;
@yokolet
yokolet / gist:2176753
Created March 24, 2012 00:34
Rails 3: How to add a new field to an existing database table
Existing schema is below:
ActiveRecord::Schema.define(:version => 20120130161449) do
create_table "movies", :force => true do |t|
t.string "title"
t.string "rating"
t.text "description"
t.datetime "release_date"
t.datetime "created_at"
@hofmannsven
hofmannsven / README.md
Last active October 30, 2022 16:31
Virtual Hosts with MAMP on OS X

Virtual Hosts

Update the hosts file in /etc/hosts to maintain multiple domains/hostnames on a local machine for 127.0.0.1 and setup a VirtualHost container in /Applications/MAMP/conf/apache/extra/httpd-vhost.conf via /Applications/MAMP/conf/apache/httpd.conf for a name-based virtual host.

Only suitable for MAMP users under OS X Lion, OS X Mountain Lion, and OS X Mavericks on Apache-Port 80 and MySQL-Port 3306.

@tegansnyder
tegansnyder / hhvm_magento_setup.md
Last active July 14, 2023 22:30
HHVM Magento Server Setup

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
@yratof
yratof / functions.php
Created March 10, 2015 14:37
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@ifamily
ifamily / wp-config.php
Last active January 8, 2024 05:06
A universal WordPress wp-config.php which works on local development to staging and production server environments.
<?php
/*
One wp-config for local development to staging to production.
*/
// Define Environments
$environments = array(
@hofmannsven
hofmannsven / README.md
Last active April 7, 2024 09:28
Git CLI Cheatsheet
@arosenhagen
arosenhagen / magento-code-snippets.md
Last active April 8, 2024 09:21
[magento] - code snippets

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@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/