Skip to content

Instantly share code, notes, and snippets.

@eculver
eculver / MySQL select word count
Created February 22, 2010 20:02
MySQL select word count
SELECT SUM(LENGTH(name) - LENGTH(REPLACE(name, ' ', ''))+1) FROM table
@smasty
smasty / 01.php
Created June 6, 2011 22:33
10 PHP One Liners to Impress Your Friends - http://smasty.net/blog/10-php-oneliners
<? foreach(range(1, 10) as $i) echo $i * 2 . " ";
@nocksock
nocksock / deploy.rb
Created December 7, 2011 16:06
Capistrano Drupal(6) Deployment Recipe
#
# Capistrano recipe for deploying Drupal7 using git and ssh.
#
# Part of the explanations in the comments taken from:
# http://help.github.com/deploy-with-capistrano/
#
set :default_environment, {
# This is the $PATH for the deploymant shell. using uberpsace's recent php
# and added ~/bin for drush.
@cecilemuller
cecilemuller / gist:1973201
Created March 4, 2012 14:23
Programmatically change the active theme in Drupal 7
<?php
/**
* Defines a theme callback function per registered path.
*/
function MODULENAME_menu_alter(&$items) {
$items['node/%node']['theme callback'] = 'MODULENAME_default_node_theme';
$items['node/%node/edit']['theme callback'] = 'MODULENAME_edit_node_theme';
$items['node/%node/edit']['theme arguments'] = array(1);
}
@gagarine
gagarine / template.tpl.php
Created July 29, 2012 21:11
Working with drupal theme_menu_tree
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {
@basbl
basbl / .htaccess
Created August 10, 2012 09:13
a .htaccess with .htpasswd settings that whitelists facebook linter ip adresses
AuthName "Realm"
AuthUserFile /path/to/.htpasswd
AuthType Basic
Satisfy Any
<Limit GET POST>
Order Deny,Allow
Deny from all
#https://developers.facebook.com/docs/ApplicationSecurity/#facebook_scraper
Allow from 31.13.24.0/21
@voising
voising / gists_to_dash_db.rb
Last active October 21, 2021 21:32
Connect Gists with Dash (Code Snippet Manager)
#!/usr/bin/env ruby
if ARGV[0].nil? || ARGV[0].match(/-h/)
puts "Usage : #{$0} github_username dash_sqlite_db char_appended_to_keyword [no_comments]"
exit
end
require 'net/http'
require 'open-uri'
#require 'awesome_print'
@juampynr
juampynr / mymodule.info
Last active June 9, 2023 21:53
Drupal 7 Views 3 custom field handler
dependencies[] = ctools
; Views Handlers
files[] = views/mymodule_handler_handlername.inc
@dr-dimitru
dr-dimitru / Social RESTful URLs snippet.md
Last active January 28, 2023 03:57
Social links, +1s and shares using only HTML (no JS)