Hypertufa Mix, Hypertufa Garden Pots @ 10 years

Read More

Add users from a text file to a Drupal User Role

#!/bin/bash

# Add Users To a Specific Role
# Setup These Variables

# Set Site Path
sitepath="/opt/var/www/htdocs/"

# Set Site Name
site="example.com"

# add user to ContentAuthor
#echo "Add users to ContentAuthor role"
cat example-users.txt | while read line
do
drush -d -r $sitepath -u 1 -l $site user-add-role "ContentAuthor" $line

#echo $line
done

###
# Command user-add-role needs a higher bootstrap level to run - you    [error] will need to invoke drush from a more functional Drupal environment to run this command

echo 'export PATH=/usr/bin:$PATH' >> ~/.profile
source ~/.profile
 

#####################
#
# Drupal 7 Example - used for printing fields in template files
# Check if a field exists, then do something

$public_field_location = field_get_items('node', $node, 'field_public_display_location');

if ($public_field_location) {
// do something
echo "<div id=\"node_section\"><h2> Where: </h2><div id=\"node_section_text\"> ";
print render($content['field_public_display_location']);
echo "</div></div>";
} else {
echo " No public location Set" ;
}

# Rename a Drupal user with Drush
drush sql-query "update users set name='new_name' where uid=4087"

 

Hypertufa Batch Mix, Poor Man's Rebar

Read More

Shell Script From PPH

# Simple PHP / Bash Shell Sample

# FOOBAR.php
# php code
echo "Running Pull.sh Shell Script";
$output = shell_exec('/html/scripts/pull.sh');
echo "<pre>$output</pre>";


# FOOBAR.sh
#!/bin/bash
touch temp/FOOBAR.txt
echo "FOO-BAR-Script-Output" > temp/FOOBAR.txt
cat temp/FOOBAR.txt

###############

# More Complex PHP / Bash
# PHP code to run script with parameter variables from page node

drupal_set_message(t('We are running a PHP rule to create a QR code for this node'));
$mynode =(token_replace('[node:nid]', array('node' => $node)));
$mytitle = $node->title;
$backgroundcolor = $node->field_background_color[0]['value'];
$foregroundcolor =$node->field_foreground_color[0]['value'];
$qrsize =$node->field_qr_size[0]['value'];
shell_exec('/opt/www/{SITENAME}/html/{SCRIPT_PATH}/qr_build_script.sh'." ".escapeshellarg($mynode)." ".escapeshellarg($mytitle)." ".escapeshellarg($backgroundcolor) ." ".escapeshellarg($foregroundcolor)." ".escapeshellarg($qrsize));

Base Mold Pour 3 of 4

Read More

Random Drupal 7 Cheat Sheet Notes - Drupal show roles and Profile Data

/* List a user's roles */

foreach($user->roles as $role) {
print "Role: ".$role." ";
}

/* Check if user is in role *>

if (in_array('Web Manager', $user->roles)) {$display ="on";}


global $user;
$uid = user_load($user->uid);
$profile = profile2_load_by_user($uid, 'main');
$full_name = " ";
$full_name = $profile->field_profile_full_name;
if (isset($full_name['und'][0]['value'])) {
echo $profile->field_profile_full_name['und'][0]['value'];
} else {
print '<div class=messages--error>WARNING: We do not appear to have your Full Name on file. Please update your contact details to include this information. Thank You.</div>' ;
}


/* Logging out of Cosign / Drupal - EAT COOKIES */

global $user;

 watchdog('user', 'Session closed for %name.', array('%name' => $user->name));

  // Eat the cookies
  foreach($_COOKIE AS $key => $value)
  {
    setcookie($key,$value,1);
    unset($_COOKIE[$key]);
  }

  // Destroy the current session:
  session_destroy();
  $_SESSION = array();

  // Only variables can be passed by reference workaround.
  $null = NULL;
  user_module_invoke('logout', $null, $user);

  // Load the anonymous user
  $user = drupal_anonymous_user();

header('Cache-Control: no-cache');
header('Expires: -1');
$query_string = $_SERVER['QUERY_STRING'];
$service_name = $_SERVER['COSIGN_SERVICE'];
$central = "https:// COSIGN SEVER /logout/logout.cgi";

setcookie($service_name, "null", time()-3600, '/', "", 1 );
setcookie("logoutcookie",logout, time()+110);
setcookie("browseropen","open");
header( "Location: $central?$query_string" );

 

Fire Brick Test Fix / Rocket Stove

Read More

Random Code Notes - Raspberry Pi

mac: diskutil list
Cntl-t : dd disk status

Tux Junior on Raspberry Pi, BZ Flag on Raspberry Pi, Penny Penguin, BZFLAG Arcade

Read More

Tux Junior on Raspberry Pi 2 , now running full Open GL on Raspbian Jessie

This is a test run of games that use/need OpenGL for 3D rendering. The output is a 52" HDMI TV.

The Raspberry Pi has a brand new "GL desktop driver" that opens up a bunch of new software possibilities!

Without this driver we were limited to a "lighter" mobile version of the Open GL 3-D tools. Many games built around the full desktop driver would compile and run but they were rendered in (slow & unplayable) software.  With this new driver we get hardware rendered 3-D which is totally playable.

Want to try some fun? Try running Bzflag on a Pi 2 hooked up to a big screen TV, it rocks. With a couple of networked Pi you can now have a low cost LAN party, where the hardware is inexpensive and the playing field is level.

In the past we've had to turn to a Mac mini for our arcade projects, the Raspberry Pi 2 is now ready to power some really, really, ridiculously small arcade cabinets.

Game On.

http://downloads.raspberrypi.org/raspbian/release_notes.txt


From the release note :

2016-02-03
* optional experimental GL desktop driver (can be enabled using advanced options in command-line raspi-config)
 

Pages

Subscribe to Front page feed