Skip to content

Instantly share code, notes, and snippets.

View martyMM's full-sized avatar

Marty McKenna martyMM

View GitHub Profile
@martyMM
martyMM / spawn.js
Last active August 15, 2019 22:27
[MarkLogic] spawn background task
///
/// @param moduleUri
/// @param vars
/// @param config
xdmp.spawn(
"/triggers/background-trigger.sjs",
{"URI": ""},
{"modules" : xdmp.modulesDatabase()}
);
@martyMM
martyMM / opsdirector-update-endpoint.xqy
Created August 14, 2019 23:27
XQuery script to fix MarkLogic OpsDirector in the event that the underlying EC2 instance gets a new IP address or hostname
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
let $config := admin:cluster-set-opsdirector-session-endpoint($config,
"http://172.20.6.19:8009/v1/opsdirector/session")
return
@martyMM
martyMM / nginx.conf
Created July 14, 2017 06:52 — forked from calebwoods/nginx.conf
Sample Nginx config for deployment of Angular.js app
server { listen 80;
server_name example.com;
access_log /var/log/example.com/nginx.access.log;
error_log /var/log/example.com/nginx.error.log;
root /var/www/apps/example.com/public;
charset utf-8;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
@martyMM
martyMM / edit.controller.js
Created October 28, 2016 14:25
Navigation Service Sync Tree
angular.module("umbraco")
.controller("My.Workshop.EditController", function ($routeParams, notificationsService, workshopResource, assetsService, navigationService) {
vm.save = function() {
vm.buttonState = "busy";
workshopResource.save(vm.workshop).then(function (response) {
vm.buttonState = "success";
vm.workshop = response.data;
notificationsService.success("Workshop saved!");
navigationService.syncTree({ tree: 'workshopTree', path: ["-1", response.id], forceReload: false, activate: true });
@martyMM
martyMM / Provider.cs
Last active September 15, 2015 15:26
How to link interface documentation to implementation in C#
interface IOrderProvider
{
/// <summary>
/// Gets a list of orders for the given date
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
void GetOrderList(DateTime dateTime);
}
@martyMM
martyMM / auth.php
Created February 24, 2015 19:33
php basic auth
<?php
$loginSuccessful = false;
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($username == '' && $password == ''){
$loginSuccessful = true;
}
@martyMM
martyMM / homepage_conditional.php
Created December 22, 2014 21:52
Magento homepage conditional
<?php
// IF WE ARE ON HOMEPAGE
if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) : ?>
// Put your homepage-only code in here.
<?php endif; ?>
@martyMM
martyMM / maps.js
Created October 31, 2014 13:56
Google Maps Embed Scroll/Click Problem Solution
// Disable scroll zooming and bind back the click event
var onMapMouseleaveHandler = function (event) {
var that = $(this);
that.on('click', onMapClickHandler);
that.off('mouseleave', onMapMouseleaveHandler);
that.find('iframe').css("pointer-events", "none");
}
var onMapClickHandler = function (event) {
@martyMM
martyMM / token_authenticatable.rb
Created October 13, 2014 14:02
Devise Token Authentication
module TokenAuthenticatable
extend ActiveSupport::Concern
module ClassMethods
def find_by_authentication_token(authentication_token = nil)
if authentication_token
where(authentication_token: authentication_token).first
end
end
end
@martyMM
martyMM / gist:6a9c4d6c308c2121de35
Last active August 29, 2015 14:06
Checkout GA Ecom Tracking
// code for the shopping cart page
// "Proceed to Checkout" button HTML
<button type="button" title="Proceed to Checkout" class="button btn btn-danger btn-proceed-checkout btn-checkout" onclick="onCheckout()">Proceed to Checkout</button>
// JS
<script>
function onCheckout() {
dataLayer.push({
'event': 'checkout',