Skip to content

Instantly share code, notes, and snippets.

View xhezairbey's full-sized avatar

Arian Xhezairi xhezairbey

View GitHub Profile
@xhezairbey
xhezairbey / portfolio-post-type.php
Created August 4, 2015 23:25
No Slug Portfolio Post Types
<?php
/**
* No Slug Portfolio Post Types
*
* @package No_Slug_Post_Types
* @author Devin Price
* @license GPL-2.0+
* @link http://vip.wordpress.com/documentation/remove-the-slug-from-your-custom-post-type-permalinks/
*
* @wordpress-plugin
@xhezairbey
xhezairbey / custom-search-acf-wordpress.php
Last active August 29, 2015 14:26 — forked from charleslouis/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}
@xhezairbey
xhezairbey / .htaccess
Last active August 29, 2015 14:20 — forked from satooshi/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# skip existent files
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule index.php - [QSA,L,C]
RewriteRule .* - [QSA,L]
# deny access php files
* -A in SSH enables agent forwarding.
* -p 2122 is not needed if you use the default port of 22.
* Replace SSH_USER and example.com with your own values.
* Example run: $ envoy run deploy_demo
* --no-scripts because Laravel composer.json's post-install-cmd includes optimize, which is already done by php artisan dump-autoload
@servers(['test' => '-A -p 2122 -l user test.example.com', 'prod' => '-A -p 2122 -l user example.com'])
@task('install_test', ['on' => ['test']])
cd project
/* Android stock browser won't let you set font-size smaller than 8px unless you apply this. */
:root {
-webkit-text-size-adjust: none;
-moz-text-size-adjust: none;
-ms-text-size-adjust: none;
-o-text-size-adjust: none;
text-size-adjust: none;
}

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.

class ApplicationController < ActionController::Base
# stuff
private
# These groups are equivalent:
#
# render action: :new, locals: { item: x }
# render :new, locals: { item: x }
@xhezairbey
xhezairbey / nav_link.rb
Created December 8, 2014 22:10
Helper method for 'active' class to links
@xhezairbey
xhezairbey / Plugins.md
Last active August 29, 2015 14:10
My Sublime Text 3 Configuration
@xhezairbey
xhezairbey / xdebug_osx.sh
Created November 22, 2014 02:55
OS X Mavericks built-in PHP w/ Xdebug
# get xdebug
git clone https://github.com/derickr/xdebug.git
cd xdebug
phpize
./configure --enable-xdebug
# run
make
# move to it's own palce