Skip to content

Instantly share code, notes, and snippets.

@mrded
mrded / gist:114e8bf44fae48e16123
Created October 20, 2015 20:16
Weird Holidays
events[1][1] = "Celebrate those whose last names begin with Z";
events[1][2] = "National Run it Up the Flagpole and See if Anyone Salutes Day";
events[1][3] = "Festival of Sleep Day";
events[1][4] = "Trivia Day";
events[1][5] = "Bird Day";
events[1][6] = "Bean Day";
events[1][7] = "Old Rock Day";
events[1][8] = "Bubble Bath Day";
events[1][9]
events[1][10] = "Peculiar People Day";
@mrded
mrded / phantomjs
Last active December 24, 2020 12:10
Run phantomjs as a deamon
#! /bin/sh
# /etc/init.d/phantomjs
case "$1" in
start)
phantomjs --webdriver=4444 &
;;
stop)
pkill phantomjs
@mrded
mrded / gist:f3da092554b35b2faa06
Created October 13, 2015 21:09
cucumber definitions
Given /^I am viewing an existed "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
Given /^an existed "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
Then /^(?:|I )should be on "(?P<url>[^"]+)" address$/
Given /^users with profile:$/
When /^I am viewing profile for "(?P<user_name>[^"]*)" user$/
Given /^a "(?P<type>[^"]*)" node with "(?P<title>[^"]*)" title belongs to "(?P<company_title>[^"]*)" company$/
Given /^I am logged in as an employer of the "([^"]*)" company$/
Given /^(?:that I|I) am at "(?P[^"]*)"$/
When /^I visit "(?P[^"]*)"$/
When /^I click "(?P<link>[^"]*)"$/
@mrded
mrded / gist:85e52dd2b4b18e4a5ccb
Created September 23, 2015 08:56
Proposed Solution For Recruiting More Mentors and Contributors

The problems:

  • Useful modules are being abandoned because maintainers are not supporting them
  • New Drupal contributors are creating “useless” modules just to get access for creating full projects

Solutions:

  • New members may find a module they would like to support, and become a maintainer by solving issues and submitting patches
  • A page listing abandoned modules that is well promoted
@mrded
mrded / keybindings.json
Last active January 17, 2017 14:28
VS Code config.
[
{ "key": "shift+cmd+backspace", "command": "editor.action.deleteLines", "when": "editorTextFocus" },
{ "key": "cmd+d", "command": "editor.action.copyLinesDownAction", "when": "editorTextFocus" },
{ "key": "shift+cmd+down", "command": "editor.action.moveLinesDownAction", "when": "editorTextFocus" },
{ "key": "shift+cmd+up", "command": "editor.action.moveLinesUpAction", "when": "editorTextFocus" },
{ "key": "cmd+shift+n", "command": "workbench.action.quickOpen" },
{ "key": "cmd+1", "command": "workbench.view.explorer" },
{ "key": "cmd+5", "command": "workbench.view.debug" }
]
@mrded
mrded / gist:5f62cb52e60f1173cdb5
Created February 12, 2015 15:45
Drupal: Get wildcard (node/%node/edit) of the path (node/5/edit).
<?php
/**
* Get menu wildcard from path.
*
* @param $path
* The path, for example node/5/edit.
*
* @return
* Returns wildcard node/%node/edit.
@mrded
mrded / gist:c832366d58848f0ff11d
Created February 6, 2015 10:15
Drupal: Create a Node in Code
<?php
function my_create_a_node() {
global $user;
// entity_create replaces the procedural steps in the first example of
// creating a new object $node and setting its 'type' and uid property
$values = array(
'type' => 'YOUR_NODE_TYPE',
'uid' => $user->uid,
'status' => 1,
@mrded
mrded / qtsconverter.rb
Last active August 29, 2015 14:14
Ruby: QuickTapSurvey to MailChimp converter.
#!/usr/bin/env ruby
# https://gist.github.com/mrded/17317466b3ebf71eb07a
require 'csv'
class MailChimpConverter
attr_accessor :columns
COLUMNS_HEADER = {
@mrded
mrded / foo.php
Created January 21, 2015 15:24
Drupal: Set header data (title, metatags).
<?php
// Insert into page callback.
drupal_add_html_head(array(
'#tag' => 'title',
'#value' => 'new header title',
), 'foo_title');
drupal_add_html_head(array(
'#tag' => 'meta',
'#attributes' => array(
@mrded
mrded / foo.js
Created January 15, 2015 12:49
JS: Remove Duplicates from JavaScript Array
jobtypes = jobtypes.filter(function(item, pos, self) {
return self.indexOf(item) == pos;
});