Skip to content

Instantly share code, notes, and snippets.

@Quilted
Quilted / gist:7487840
Created November 15, 2013 17:04
Drupal 7 dates with proper timezone handling
<?php
// Assumes date field is $variables['field_event_date']
$dateObj = new DateObject($variables['field_event_date'][0]['value'], new DateTimeZone($variables['field_event_date'][0]['timezone_db']));
$dateObj->setTimezone(new DateTimeZone($variables['field_event_date'][0]['timezone']));
$date = $dateObj->getTimestamp();
#!/usr/bin/env sh
brew update
brew install rbenv
brew install ruby-build
brew install openssl
RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
rbenv install 2.0.0-preview1
@Quilted
Quilted / README.md
Last active December 12, 2015 01:38
Drupal 7: Setting up bulk WordPress to Drupal migration redirects

Drupal 7: Setting up bulk WordPress to Drupal migration redirects

When would I use this?

If you have a database of WordPress URLs that need to be redirected in Drupal 7.

What do I do?

  1. Install Redirect module.
  2. Install path_redirect_import module.
@Quilted
Quilted / README.md
Last active December 12, 2015 01:38
Drupal 7: Allowing anonymous users access to Media module's browser

Drupal 7: Allowing anonymous users access to Media module's browser

What's up with Media module defaults?

To give anonymous users media permissions, know that Media module's permissions don't work as you might expect:

  • Import media files from the local filesystem: this is not for the media widget. You don't need to turn this on.
  • Edit media: You need this to upload files via the media widget.
  • Add media from remote services: straightforward.

The Library tab is not protected by any permissions. It's always included with the media browser plugin (aka the media widget).

@Quilted
Quilted / gist:1346548
Created November 7, 2011 23:35
National CAPACD Footer Block
<div class="col col-1">DC Office: National Coalition for Asian Pacific American Community Development<br />1628 16th Street, NW - 4th Floor, Washington DC 20009<br />t 202-223-2442 | f 202-223-4144</div><div class="col col-2">CA Office: National Coalition for Asian Pacific American Community Development<br />310 8th Street, Suite 303, Oakland, CA 94607<br />t 510-452-4800 | f 510-981-3840</div>
@Quilted
Quilted / gist:1340711
Created November 4, 2011 22:57
National CAPACD Social Networking Block
<ul class="social-media-buttons"><li><a href="http://facebook.com/capacd"><img alt="Like NationalCAPACD on Facebook" src="http://www.searac.org/sites/all/themes/searac/images/facebook.png" /></a></li><li><a href="http://twitter.com/#!/CAPACD"><img alt="Follow CAPACD on Twitter" src="http://www.searac.org/sites/all/themes/searac/images/twitter.png" /></a></li><li><a href="http://vimeo.com/user6427743"><img alt="Follow NationalCAPACD on Vimeo" src="http://esenkay.com/socialmedia/vimeo-32x32.png" /></a></li></ul>
@Quilted
Quilted / patch with git
Last active September 26, 2015 14:27
Patching with git
// Making a patch
// When patching core, cd to www. When patching a module, cd to the module directory.
$ git diff --relative > file.patch
// Applying a patch
// From the git root directory
$ git apply -v --directory www/sites path/to/file.patch
@Quilted
Quilted / db update
Created July 8, 2011 22:57
D6: Update a single db value for all users based on a regex
$result = db_query("SELECT uid FROM {users}");
while ($row = db_fetch_object($result)) {
$user = user_load($row->uid);
$new_state_profile = preg_replace('/^(\S){2}\s/', '', $user->profile_state);
update_sql("UPDATE {profile_values} SET value = '$new_state_profile' WHERE uid = $user->uid AND fid = 6");
}
// Clear caches
@Quilted
Quilted / no_context_content_type.inc
Created July 5, 2011 01:25
CTools custom content pane example
<?php
/**
* @file
* "No context" sample content type. It operates with no context at all. It would
* be basically the same as a 'custom content' block, but it's not even that
* sophisticated.
*
*/