Skip to content

Instantly share code, notes, and snippets.

View tamasd's full-sized avatar

Tamás Demeter-Haludka tamasd

  • Lufthansa Systems Hungaria
  • Szeged
View GitHub Profile
--- media.module
+++ media.module
@@ -435,6 +435,19 @@ function media_page_alter(&$page) {
}
/**
+ * Implements hook_menu_local_tasks_alter().
+ */
+function media_menu_local_tasks_alter(&$data, $router_item, $root_path) {
+ // Even if there aren't any action links on admin/content/media (e.g., if
--- actions/script.action.inc
+++ actions/script.action.inc
@@ -1,6 +1,10 @@
<?php
function views_bulk_operations_script_action_info() {
+##GardensExcludeFromExportStart################################################
+// Make it impossible on Gardens sites to execute PHP scripts via VBO.
+return array();
+##################################################GardensExcludeFromExportEnd##
@tamasd
tamasd / mmap_vs_fgetln.c
Created February 23, 2012 21:43
A quick test to see if mmap() or fopen() + fgetln() is faster for linear line-by-line file processing.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <unistd.h>
@tamasd
tamasd / this.php
Created February 27, 2012 15:08
Playing around with extract()
<?php
class Foo {
protected $baz = 'baz';
public function __construct($v) {
extract($v);
var_dump($this);
var_dump($this->baz);
}
@tamasd
tamasd / pressflow_drupal_add_js.diff
Created March 2, 2012 09:21
Fixes a Pressflow bug. Fatal error happens if drupal_add_js() is called during install.
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2221,7 +2221,7 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
// We never cache authenticated user pages, so if they are logged in we
// allow setting of the has_js cookie so batch API functions use the JS
// version.
- if (!user_is_anonymous()) {
+ if (function_exists('user_is_anonymous') && !user_is_anonymous()) {
$javascript['footer']['inline'][] = array('code' => "document.cookie = 'has_js=1; path=/';", 'defer' => TRUE);
}
@tamasd
tamasd / .gitignore
Created July 1, 2012 09:01
gitignore fox xcode
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
@tamasd
tamasd / gist:3743180
Created September 18, 2012 13:43
PhpStorm Drupal info hook live template
/**
* Implements hook_$HOOKNAME$_info().
*/
function $MODULE$_$HOOKNAME$_info() {
$$$TYPE$ = array();
$$$TYPE$['$ITEM$'] = array($END$);
return $$$TYPE$;
}
@tamasd
tamasd / pocket2readability.md
Created October 11, 2012 07:57
pocket to readability

Open http://getpocket.com/a/queue/list/ Paste into the command line:

$.post("/a/x/get.php", {offset: 0, count: 1000, state: "queue", favorite: "null", sort: "oldest", search: "", tag: "", view: "list", formCheck: window.formCheck}, function (r) {var d = JSON.parse(r); var urls = []; for (var i in d.list) { urls.push(d.list[i].given_url); } alert(JSON.stringify(urls)); })

Copy the text from the popup.

Go to readability.com, log in Paste the code into the command line and replace the PASTE_HERE text with the one you have copied.

<?php
/**
* This function includes a css file based on the selected taxonomy terms.
* With this, the submitter can assign extra css for the site.
* @param $vid the vid of the taxonomy
*/
function _taxonomy_based_css_loader($vid){
$nid = null;
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
feature user test:
info:
name: Administrator user
description: an administrator needs to be able to access the admin menu.
background:
given:
- standard drupal setup
- user with administer site role
scenario link:
should see: link to admin