Skip to content

Instantly share code, notes, and snippets.

View bdombro's full-sized avatar

Brian Dombrowski bdombro

View GitHub Profile
@bdombro
bdombro / php_rss_feed.php
Created April 18, 2014 17:12
PHP RSS Feed
<?php
$rss = new DOMDocument();
$rss->load('http://www.newsfromota.com/category/ota-members/government-affairs-policy/feed/');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
@bdombro
bdombro / zcatp
Last active August 29, 2015 14:01
#!/bin/bash
if [[ "$#" == 0 ]]; then
echo "
Version 1.0
Fancy zcat that shows progress.
Arg should be a gziped file ending in .gz
Syntax: bzcat <path_to_file_or_folder>
"
exit
#!/bin/bash
usage() {
echo "
Version 1.0
Fancy mysqldump for full DBs that shows progress.
Syntax: bmysqldump [-u <username>] [-p] [-h <hostname>] <database>
"
exit 0
}
#!/bin/bash
echo "
Installing Brian's custom server tools
Installer Version 1.4"
mkdir ~/bin &>1 /dev/null
echo "" >> ~/.bashrc
echo "PATH=\$PATH:~/bin" >> ~/.bashrc
@bdombro
bdombro / delete_en_mass.php
Last active August 29, 2015 14:01
Drush Delete Nodes in Mass Script
<?php
// ************ This script can be run from drush, like `drush scr <name of script>`
print "\n*************** Delete Nodes en mass V1.1 *******************";
print "\nThis program will delete nodes en mass.\nBe very careful when configuring to not accidently delete nodes.\n";
global $count1;
global $total;
$count1 = 0;
<?php
// Will parse queries and redirect appropriately
// Version 1.0
// Setup .htaccess to redirect certain links here
// Example: RedirectMatch /wiki* /legacy_file_redirect.php
if(isset($_GET["media"])) {
// handle http://dev.americanwhitewater.org/wiki/lib/exe/fetch.php?media=projects:gauley_project.jpg
# Base gitignore for drupal projects
# Version 1.0
htdocs/*
!htdocs/profiles
htdocs/profiles/*
!htdocs/profiles/aww
!htdocs/sites
@bdombro
bdombro / duplicate_alias.php
Created June 4, 2014 20:06
Run with drush to duplicate the primary alias for pages
<?php
// This script duplicates all existing basic page primary aliases
// $nids = db_query("SELECT nid FROM node WHERE type = 'page' "); // not as good
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'page')
// ->propertyCondition('status', 1)
// ->fieldCondition('body', 'value', '%media/%', 'like')
@bdombro
bdombro / aw_flexslider.php
Created June 10, 2014 20:16
Flexslider used on river pages
<?php
function relation_get_related_entities($entity_type, $entity_id, $relation_type = NULL, $r_index = NULL) {
$query = relation_query($entity_type, $entity_id, $r_index);
if ($relation_type) {
$query->propertyCondition('relation_type', $relation_type);
}
$results = $query->execute();
$relations = array();
@bdombro
bdombro / aw_usa_map.html
Created June 10, 2014 20:17
Clickable USA map for aw
<div id="vmap" style="height: 400px;">&nbsp;</div>
<script>
var state_to_term_code = {
'CA': 183,
'HI': 184,
'DC': 186,
'DE': 187,
'MD': 188,
'NJ': 189,
'PA': 190,