Skip to content

Instantly share code, notes, and snippets.

View drogers98's full-sized avatar

Dan Rogers drogers98

View GitHub Profile
@drogers98
drogers98 / snippet.php
Created March 1, 2017 17:41
D7 update all pathauto checkboxes to use auto generated
<?php
// For the following query:
// UPDATE `pathauto_state` SET `pathauto`=1 WHERE `entity_type` = 'node'
$update_auto_aliases = db_update('pathauto_state')
->fields(array(
'pathauto' => 1,
))
->condition('entity_type', 'node', '=')
->execute();
?>
@drogers98
drogers98 / pipe_seperated_coutries.txt
Created May 24, 2016 16:49
Pipe separated countries list.
afghanistan|Afghanistan
albania| Albania
algeria| Algeria
american samoa| American Samoa
andorra| Andorra
angola| Angola
anguilla| Anguilla
antarctica| Antarctica
antigua and barbuda| Antigua and Barbuda
argentina| Argentina
@drogers98
drogers98 / mc_signupform.jade
Created May 19, 2016 17:43
Simplified jade formatting for a Mailchimp email signup form.
#mc_embed_signup
form#mc-embedded-subscribe-form.clear.sign-up(action='{{YOUR_MC_GENERATED_ACTION}}', method='post', name='mc-embedded-subscribe-form', target='_blank', novalidate='novalidate')
label(for='mce-EMAIL') Subscribe to our mailing list
input#mce-EMAIL.email.sign-up__email(type='email', value='', name='EMAIL', placeholder='email address', required='required')
div(style='position: absolute; left: -5000px;')
input(type='text', name='{{YOUR_MC_GENERATED_NAME}}', value='')
input#mc-embedded-subscribe.button.sign-up__submit(type='submit', value='Sign Up', name='Sign Up')
@drogers98
drogers98 / hhtpd-vhosts.conf
Created June 16, 2015 17:10
apache config
<Directory "/Users/YOURUSERNAMEHERE/Sites">
DirectoryIndex index.php index.cfm index.html index.htm
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
#Default environment variables
SetEnv ENVIRONMENT "local"
SetEnv DB1_USER "YOUR_DB_USERNAME"
SetEnv DB1_PASS "YOUR_DB_PASSWORD"
@drogers98
drogers98 / envsetup.txt
Created June 16, 2015 17:05
EnvironmentSetup
PREREQUISITES
=============
Install homebrew (if not already installed)
In terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Note: May prompt to install xcode command line tools. If so, install them
Create a Sites folder in your home directory (if you don’t already have one)
@drogers98
drogers98 / newvhost.sh
Created June 16, 2015 15:35
New vhost script
#!/bin/bash
# Config vars
sites_path="$(eval echo ~${SUDO_USER})/Sites"
conf_file="${sites_path}/_conf/httpd-vhosts.conf"
hosts_path="/etc/hosts"
# Permissions
if [ "$(whoami)" != "root" ]; then
echo "Root privileges are required to run this, try running with sudo..."
@drogers98
drogers98 / listStyling.scss
Last active August 29, 2015 14:20
Some code to fake out list syling for OL/UL's, in order to custom color bullets and numbers.
// Get tricky with some UL's!!
ul {
li {
color: $darkGray;
list-style-type: none;
&:before {
color: $brightTeal;
content:"\2022";
font-size:1.5em;
padding-right:.25em;
@drogers98
drogers98 / package.json
Created May 1, 2015 18:04
Remove .info files from node_modules, so Drupal doesn't pitch a fit. add to package.json, and NPM install removes the offenders! getting a Notice: Undefined index: name? Using NPM modules? Yeah, you probably need this...
"scripts": {
"prepublish": "find node_modules -name '*.info' -exec rm -f {} \\;"
},
//create record
$rec = $fm->createRecord('layout_name', '$data_array');
$result = $rec->commit();
//new add command
$newAdd = $fm->newAddCommand('layout_name', $data_array);
$result = $newAdd->execute();
//Second and main difference is what they return to $result variable. The 'createRecord()' statement returns an integer value to know the status of record creation process(whether succeed or failed). But the 'newAddCommand()' returns a bunch of information for the new created record along with record id.
@drogers98
drogers98 / alternateUpdatedVersion.php
Last active August 29, 2015 14:14
Drupal entity registration, see if user is already registered in order to hide/display stuff. use in the node.tpl.php. Modify line 6 to reference the particular product reference you are using.
<?php
// Hide/display stuff for users who are already registered
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'registration')
->propertyCondition('entity_id', $node->field_product_ref['und'][0]['product_id']);
$result = $query->execute();
//print_r($result['registration'][10]);
$ids = array_keys($result['registration']);
$registrations = entity_load('registration', $ids);