Skip to content

Instantly share code, notes, and snippets.

@codex73
codex73 / gist:ad84929efb44ab7f10ae
Created October 22, 2015 15:45 — forked from seanmcn/gist:62a021a765ad4f8e593b
The Perfect Web Server - Nginx, Ajenti, Ubuntu
#Insall Ajenti
apt-get update
wget http://repo.ajenti.org/debian/key -O- | apt-key add -
echo "deb http://repo.ajenti.org/ng/debian main main ubuntu" >> /etc/apt/sources.list
apt-get update
apt-get install ajenti
service ajenti restart
# Uninstall Apache2
sudo apt-get autoremove && sudo apt-get remove apache2*
@codex73
codex73 / .htaccess
Created November 9, 2015 16:57 — forked from ScottPhillips/.htaccess
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/
@codex73
codex73 / widget.js
Created February 10, 2016 22:47 — forked from lukencode/widget.js
Starter template for creating jsonp embeddable widgets.
(function () {
var scriptName = "embed.js"; //name of this script, used to get reference to own tag
var jQuery; //noconflict reference to jquery
var jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var jqueryVersion = "1.8.3";
var scriptTag; //reference to the html script tag
/******** Get reference to self (scriptTag) *********/
var allScripts = document.getElementsByTagName('script');
@codex73
codex73 / gist:1eeb20bb744b2b52e955436b82b21247
Created April 20, 2016 01:54 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@codex73
codex73 / gist:26f59f9350d3c237e8e6786d816d3615
Created September 3, 2016 02:30 — forked from gyrus/gist:3332597
Override a WordPress 404 with a specific template
<?php
/**
* Override a 404
*
* @param string $template If passed, this template will be included and
* the request will be terminated if the inclusion
* was successful
* @param string $type If not a 404, what type of request should this be
* flagged as? Must correspond to one of the
@codex73
codex73 / basic-usage.php
Created September 9, 2016 17:28 — forked from joshuadavidnelson/basic-usage.php
Create custom theme features with theme feature support
<?php
/**
* Basic Theme Support usage. Add this to your functions.php file
*/
add_theme_support( 'custom-footer-text' );
/**
* Elsewhere in your theme...
*/
if( current_theme_supports( 'custom-footer-text' ) ) {
@codex73
codex73 / redirect.php
Created February 8, 2017 16:25 — forked from gopeter/redirect.php
A simple snippet to remove trailing numbers at the end of wordpress urls. For example: redirect http://example.com/foobar/2024/ to http://example.com/foobar/. Don't use it if your permalink structure ends with "%post_id%"! This will return an infinite redirect-loop!
<?php
// get the url
$url = 'http://' . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];
// check if there are any slashes inside the url string
if (strpos($url, '/')) {
// split the string in pieces
// use "/" as separator
@codex73
codex73 / php-webscraping.md
Created March 7, 2017 13:49 — forked from anchetaWern/php-webscraping.md
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}

@codex73
codex73 / AWS-config.md
Created July 10, 2017 20:25
Fucking Yes! AWS setup for Wordpress Server

Fucking Yes! AWS setup for Awesome Fast Wordpress Server

Ramblings and notes of my experiments with AWS which I will later turn into more coherent instructions.

Sooo... I'm about to be released into the wild as a free roaming web developer. I won't have the company hosting anymore and it's damn well about time I got my own shit sorted. After a little reading I have decided to give Amazon Web Services a try. So far I am loving it.

I have oooooooodles of control. It's super nerdy and more importantly, it's super fast. Seriously - I had fun.

When I first set this up i tried following some third party tutorials to get a wordpress server setup and running on Amazon Web Services. After some trial and error I found the proper documentation and everything when much more smoothly (I know right)! The AWS docs are very detailed and easy to follow.

@codex73
codex73 / states_hash.json
Created March 5, 2018 15:44 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",