Skip to content

Instantly share code, notes, and snippets.

@pmdgithub
pmdgithub / grab_avatars_for_git_users.pl
Created November 19, 2010 14:39
Grab avatars for github users, use for: gource --user-image-dir .git/avatar/
#!/usr/bin/perl
#fetch Gravatars
use strict;
use warnings;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
my $size = 90;
@christianchristensen
christianchristensen / OAuth_notes.mkd
Created January 11, 2012 17:25
OAuth'in with Drupal
  • Consumer: client
  • Service Provider: server
  • User: resource owner
  • Consumer Key and Secret: client credentials
  • Request Token and Secret: temporary credentials
  • Access Token and Secret: token credentials
@dhrrgn
dhrrgn / console
Last active December 12, 2021 01:24
Adding global Options/Arguments to Symfony Console Applications
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
require 'vendor/autoload.php';
$app = new Application;
@jamiemagique
jamiemagique / template.php
Last active July 18, 2024 08:31
Drupal 7 - Render an image using the picture module mappings programatically (via preprocess_node() in this gist)
// Get image settings array from a field on the node
$image = field_get_items('node', $node, 'INSERT_IMAGE_FIELD_MACHINE_NAME');
// Picture settings
$picture_mapping = picture_mapping_load('INSERT_PICTURE_MAPPING_MACHINE_NAME');
$fallback = 'INSERT_IMAGE_STYLE_MACHINE_NAME';
$breakpoints = picture_get_mapping_breakpoints($picture_mapping, $fallback);
// Create a new variable to pass through to the node template
$variables['INSERT_NEW_VARIABLE_NAME_TO_PASS_TO_NODE_TEMPLATE'] = theme('picture', array('uri' => $image[0]['uri'], 'style_name' => $fallback, 'breakpoints' => $breakpoints));
@anxp
anxp / using_limit_validation_errors.php
Last active August 23, 2022 13:35
How to correctly use #limit_validation_errors element of Form API in Drupal 7
<?php
//Sometimes we need to submit only part of the form. Sure, if form has #required fields, all they will be highlighted with red,
//and form will not be submitted if these elements have no value.
//To workaround this, we can use '#limit_validation_errors' option AND custom submit function for every 'Partial Submit' button.
//Interesting note: when we use '#limit_validation_errors', we will see ALL form fields in _validate function,
//but in _submit function will be visible ONLY elements, included in '#limit_validation_errors' array!!!
//Case 1. The most simple.
//We want to make a 'reset' button, or 'previous step' button, so it must work even if some REQUIRED form elements are empty: