Skip to content

Instantly share code, notes, and snippets.

@markhalliwell
markhalliwell / gist:5249012
Last active March 11, 2016 11:44
Redirect local sand-boxed Drupal file requests to a development server. This helps avoid having to sync (sometimes, very huge) file structures onto your local machine.
### Apache Rewrite
# Request resides in your 'sites/default/files' folder.
RewriteCond %{REQUEST_URI} ^/sites/default/files/(.*)$
# File doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-f
# Directory doesn't exist.
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect request to your development or production server.
RewriteRule ^/sites/default/files/(.*)$ http://dev.example.com/sites/default/files/$1 [L]
@Stanback
Stanback / nginx.conf
Last active August 21, 2025 07:32 — forked from michiel/cors-nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@benosman
benosman / example_style.inc.php
Last active December 27, 2015 07:29
Example Panels style plugin with substyles. You add this to your module or theme in the normal way for ctools / panels plugins. FIlename should end in .inc.
<?php
/**
* @file
* Definition of the 'bootstrap_style' panels style plugin.
*/
$plugin = array(
'title' => t('Example Parent Style'),
'description' => t('Example style providing substyles'),
@morewry
morewry / _debug-map.scss
Created March 13, 2014 06:21
Sass print-map function and mixin for quick debugging of maps
/*
# Print Map
Usage:
// option 1
.debug {
@include print-map($map);
}
@travist
travist / gist:11381206
Last active August 29, 2015 14:00
Shell Command line to return all of PHP configurations in a list.
php -i | grep 'Configure Command =>' | awk '{for(i=5; i<=NF; i++) {print substr($i, 2, (length($i) - 2))}}'
@FrostyX
FrostyX / FacebookDebugger.php
Last active December 11, 2024 20:33
Facebook API - Force facebook to reload cache from your website
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
@pandafulmanda
pandafulmanda / Python3 Virtualenv Setup.md
Last active August 6, 2025 13:42 — forked from akszydelko/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
@crittermike
crittermike / per_table.sql
Created August 18, 2016 13:22
Determining size of MySQL DB dump and individual tables before dumping it
SELECT
TABLE_SCHEMA,
TABLE_NAME,
DATA_LENGTH / POWER(1024,1) Data_KB,
DATA_LENGTH / POWER(1024,2) Data_MB,
DATA_LENGTH / POWER(1024,3) Data_GB
FROM information_schema.tables WHERE table_schema NOT IN ('information_schema','performance_schema','mysql') ORDER BY DATA_LENGTH;
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active April 17, 2025 11:09
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@JeffTomlinson
JeffTomlinson / MyService.php
Last active August 7, 2024 11:28
Drupal 8 Configuration Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Config\ConfigFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services