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
type LoginResponse struct {
SessionID string `json:"sessid"`
SessionName string `json:"session_name"`
}
func get(path string, cookie *http.Cookie) *http.Response {
req, err := http.NewRequest("GET", BASE_PATH + path, nil)
if err != nil {
log.Fatal(err)
}
req.AddCookie(cookie)
resp, err := http.DefaultClient.Do(req)
if err != nil {
class UserTest extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Administrator user', 'description' => 'an administrator needs to be able to access the admin menu.',
'group' => 'Drucumber',
);
} public function setUp() {
parent::setUp();
$user = $this->drupalCreateUser(array('administer site',));
$this->drupalLogin($user);
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
<?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);
@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.

@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 / .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 / 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 / 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);
}