Skip to content

Instantly share code, notes, and snippets.

@gregmercer
gregmercer / Views Query
Created July 15, 2015 17:58
Dumps the Query used by a View
<?php
/**
* Implements hook_views_pre_execute().
*/
function gsb_feature_alumni_reunion_agenda_item_display_views_pre_execute(view &$view) {
if ($view->name == 'gsb_event') {
dpm($view);
dpm('view name: ' . $view->name);
$query = &$view->build_info['query'];
$query_string = (string)$query;
/**
* Gets the custom section titles - with separated paths.
*
* @return array
* An array of custom section titles - with separated paths (cause you 'gotta keep'em separated).
*/
function gsb_custom_section_title_get_sections_separate_paths() {
$section_titles = gsb_custom_section_title_get_sections();
$titles_out = array();
foreach($section_titles as $title) {
function _wrapper_debug($w) {
$values = array();
foreach ($w->getPropertyInfo() as $key => $val) {
$values[$key] = $w->$key->value();
}
return $values;
}
diff --git a/field_collection.module b/field_collection.module
index 3a8f9e9..4f216db 100644
--- a/field_collection.module
+++ b/field_collection.module
@@ -554,7 +554,11 @@ class FieldCollectionItemEntity extends Entity {
$delta = $this->delta();
if ($this->item_id && isset($delta)) {
unset($this->hostEntity->{$this->field_name}[$this->langcode][$delta]);
- entity_save($this->hostEntityType, $this->hostEntity);
+ // Do not save when the host entity is being deleted. See
@gregmercer
gregmercer / program_instance_faculty_info
Created April 14, 2016 23:19
Looks up the faculty for a program and it's upcoming program_instance
// use the following to get the list of programs with the list of keywords(field_tag) and the list of program categories(field_program_category)
$programs = array();
$query = db_select('node', 'n');
$query->fields('n', array('nid', 'status', 'type', 'created'));
if (!empty($tag_ids)) {
$query->innerJoin('field_data_field_tag', 't', "n.nid = t.entity_id AND t.entity_type = 'node'");
$query->fields('t', array('field_tag_tid'));
@gregmercer
gregmercer / gist:dd59204d52fa5229bcfd0af6599c6ee5
Created October 4, 2016 17:54
find /Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build
Xamarin.iOS.Tasks.Core $ find /Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/.DS_Store
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/.DS_Store
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/MonoTouch
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/MonoTouch/.DS_Store
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/MonoTouch/updateinfo
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/MonoTouch/usr
/Users/macgmercer/Desktop/projects/xamarin/xamarin-macios/_ios-build/Developer/MonoTouch/usr/.DS_Store
Xamarin.iOS.Tasks.Core $ make install -C /Users/macgmercer/Desktop/projects/xamarin/xamarin-macios
Checking system...
Found OSX 10.11.5 (at least 10.11 is required)
Found Xcode 8.0 in /Applications/Xcode8-GM.app
Found autoconf (GNU Autoconf) 2.69 (no specific version is required)
Found glibtool (GNU libtool) 2.4.6 (no specific version is required)
Found automake (GNU automake) 1.15 (no specific version is required)
Found Mono 4.6.1.3 (at least 4.4.0.148 and not more than 4.9.99 is required)
Found Xamarin Studio 6.1.1.15 (at least 6.1.0.4373 and not more than 6.2.0.9999 is required)
Found CMake 3.6.2 (at least 2.8.8 is required)
@gregmercer
gregmercer / gist:65841bc66e5c97a7091a633590557435
Created October 4, 2016 18:03
make all -j8 && make install -j8
xamarin-macios $ make all -j8 && make install -j8
llvm is up-to-date.
mono is up-to-date.
watch-mono is up-to-date.
fsharp is up-to-date.
MonoTouch.Dialog is up-to-date.
Touch.Unit is up-to-date.
opentk is up-to-date.
Xamarin.MacDev is up-to-date.
guiunit is up-to-date.
find . -name "*.cs" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done
@gregmercer
gregmercer / DroidNeedUpdate.cs
Created July 5, 2017 15:58
Xamarin Android - Checks if App needs to be updated, and if so takes the user to the Google Play Store.
private void GetUpdate()
{
try
{
StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + PackageName)));
}
catch (ActivityNotFoundException e)
{
// Default to the the actual web page in case google play store app is not installed
StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=" + PackageName)));