Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| <?php | |
| function ernest_marples($postcode) { | |
| $postcode = str_replace(" ", "", $postcode); | |
| $url = "http://www.uk-postcodes.com/postcode/". urlencode($postcode) .".csv"; // Build the URL | |
| $file = file_get_contents($url); | |
| if (strpos($file, "html") === FALSE) { // Some error checking - if the file contains html, then we've been redirected to the homepage and something has gone wrong |
| stage { "pre": before => Stage["main"] } | |
| class python { | |
| package { | |
| "build-essential": ensure => latest; | |
| "python": ensure => "2.6.6-2ubuntu1"; | |
| "python-dev": ensure => "2.6.6-2ubuntu1"; | |
| "python-setuptools": ensure => "latest"; | |
| } | |
| exec { "easy_install pip": | |
| path => "/usr/local/bin:/usr/bin:/bin", |
| // | |
| // Regular Expression for URL validation | |
| // | |
| // Author: Diego Perini | |
| // Created: 2010/12/05 | |
| // Updated: 2018/09/12 | |
| // License: MIT | |
| // | |
| // Copyright (c) 2010-2018 Diego Perini (http://www.iport.it) | |
| // |
| <?php | |
| include 'config.core.php'; | |
| include MODX_CORE_PATH . 'model/modx/modx.class.php'; | |
| $modx = new modX(); | |
| $modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML'); | |
| $modx->initialize('mgr'); | |
| $modx->setLogLevel(modX::LOG_LEVEL_INFO); |
| require 'rubygems' | |
| require 'yaml' | |
| # A demonstration of YAML anchors, references and handling of nested values | |
| # For more info, see: | |
| # http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/ | |
| stooges = YAML::load( File.read('stooges.yml') ) | |
| # => { | |
| # "default" => { |
| $less-column-width: 68px; | |
| $less-gutter-width: 24px; | |
| @function column-width($columns) { | |
| @return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1)); | |
| } | |
| @function grid-padding-px($columns) { | |
| @if $columns == 10 { | |
| @return 48px; |
| import re | |
| import simplejson | |
| from django.http import HttpResponse | |
| from django.conf import settings | |
| class JSONResponse(HttpResponse): | |
| def __init__(self, request, data): | |
| indent = 2 if settings.DEBUG else None |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
| <IfModule mod_rewrite.c> | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteCond %{REQUEST_FILENAME} !-s | |
| RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L] | |
| RewriteCond %{REQUEST_FILENAME} -d | |
| RewriteRule ^(.*)$ rest/index.php [QSA,NC,L] | |
| </IfModule> |
| <?php | |
| $mailto = (isset($mailto)) ? $mailto : '@@ DEFAULT EMAIL HERE @@'; | |
| $warningMail = '@@ EMAIL TO SEND WARNING TO IN CASE OF A SMALL BACKUP FILE @@'; | |
| include MODX_CORE_PATH.'/config/'.MODX_CONFIG_KEY.'.inc.php'; | |
| $host = $database_server; // database host | |
| $dbuser = $database_user; // database user name | |
| $dbpswd = $database_password; // database password | |
| $mysqldb = $dbase; // name of database |