Skip to content

Instantly share code, notes, and snippets.

View Morasta's full-sized avatar

Matt Viehdorfer Morasta

View GitHub Profile
@Morasta
Morasta / gist:dc98d19645f7ef124e6a7fa662c7b233
Created July 25, 2016 21:16
MACS: Mobile Anchor Capacity System iOS Support Page
The MACS: Mobile Anchor Capacity system app is provided as-is. The full license and EULA is included in the app.
For support inquiries please email web.osha <at> oregon.gov and include "MACS iOS support" in the subject line.
@Morasta
Morasta / d7_keyvalue_taxonomy_term_list.php
Created May 20, 2015 23:19
Drupal 7 - key/value (machine_name/display_name) taxonomy term list
function keyvalue_taxonomy_term_list($vocabMachineName){
$tax = taxonomy_vocabulary_machine_name_load($vocabMachineName);
$termTree = taxonomy_get_tree($tax->vid);
$terms = array();
foreach ($termTree as $idx => $term) {
$terms[str_replace($vocabMachineName.'/', '', drupal_lookup_path('alias', 'taxonomy/term/'.$term->tid, 'und'))] = $term->name;
}
return $terms;
@Morasta
Morasta / getCurrentBoostrapViewport
Last active August 29, 2015 14:19
Script to print current Bootstrap viewport breakpoint size
<script src="https://rawgit.com/maciej-gurban/responsive-bootstrap-toolkit/master/js/bootstrap-toolkit.min.js"></script>
<script>
function getCurrentVP(viewport) {
var currentViewport= 'n/a';
if( viewport.is('xs') ) {
currentViewport = 'xs';
}
else if( viewport.is('sm') ) {
currentViewport = 'sm';
@Morasta
Morasta / d7_display_suite_hide_labels_function.php
Last active September 2, 2016 02:10
Drupal 7 - Hide labels for empty display suite fields
/**
* Implements hook_field_attach_view_alter().
*
* Hide label of display suite fields if field content is empty.
*/
function cof_directory_field_attach_view_alter(&$output, $context) {
$displaySuiteFields = array("graduate_students","office_location");
foreach ($output as $field_name => $field) {
if (!empty($field['#label_display'])) {
@Morasta
Morasta / changeFirefoxSearchProvider.ps1
Created March 9, 2015 16:52
Change Firefox Search Provider Script
# Originally from http://www.adminarsenal.com/admin-arsenal-blog/powershell-silently-change-firefox-default-search-providers-for-us
$Provider = "Google"
# Default valid provider options:
# Amazon.com, Bing, DuckDuckGo, eBay, Google, Twitter, Wikipedia (en), Yahoo
# This disclaimer is required verbatim...
$Disclaimer = "By modifying this file, I agree that I am doing so only "
$Disclaimer += "within Firefox itself, using official, user-driven search "
$Disclaimer += "engine selection processes, and in a way which does not "
@Morasta
Morasta / csvtolookups.py
Created November 20, 2014 23:52
CSVToLookups
#Separates columns in a CSV into individual files with unique values per field
# Useful for generating lookup tables with unique values from the original csv's field
#
# Room for implementation improvement, but this works as a quick and dirty solution
#!/usr/bin/python
import csv
from distutils.util import strtobool
@Morasta
Morasta / jqueryGetUrlVars
Created October 22, 2014 19:02
jquery getUrlVars extension
//adapted from http://stackoverflow.com/questions/6001839/check-whether-a-url-variable-is-set-using-jquery
//modified to return empty array when no ? params are set
$.extend({
getUrlVars: function(){ //return all vars set in $_GET
var vars = [], hash;
if (window.location.href.indexOf('?') != -1) {
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
@Morasta
Morasta / drupal_importable_node_export
Created October 2, 2014 21:50
Drupal: Export node for reimport
<?php
// Enter node NID to export.
$nid = 1234;
// Use Drupal's export utility to convert the object to code.
include_once DRUPAL_ROOT . '/includes/utility.inc';
$export = drupal_var_export(node_load($nid));
// Strip node NIDs and VIDs, so it imports cleanly.
@Morasta
Morasta / applescript_wine_launcher
Created July 21, 2014 22:36
AppleScript Homebrew Wine Launcher
-- main.scpt
-- Cocoa-AppleScript Applet
tell application "Terminal"
activate
do shell script "/usr/local/bin/wine '/Users/<user>/.wine/drive_c/Program Files/<programdir>/<program.exe>'"
end tell
<?php
function win_time($timestr) {
return substr($timestr, 4, 2) . "/" . substr($timestr, 6, 2) . "/" .
substr($timestr, 0, 4) . " " . substr($timestr, 8, 2) . ":" .
substr($timestr, 10, 2) . ":" . substr($timestr, 12, 2) . " " .
substr($timestr, -4);
};
?>