Skip to content

Instantly share code, notes, and snippets.

View cdeutsch's full-sized avatar
👨‍🏭
1998 - 2026: Code Monkey | 2026 - Present: LLM Monkey

C Deutsch cdeutsch

👨‍🏭
1998 - 2026: Code Monkey | 2026 - Present: LLM Monkey
View GitHub Profile
SELECT oo.*
FROM Nop_Order oo
LEFT OUTER JOIN Nop_OrderProductVariant opv ON oo.OrderID = opv.OrderID
LEFT OUTER JOIN Nop_ProductVariant pv ON opv.ProductVariantID = pv.ProductVariantId
WHERE pv.Sku LIKE '% REN'
SELECT [Year], [Month], [Description], SUM(RenewalPrice)
FROM (
SELECT YEAR(CONVERT(datetime, Subscription__r_Renewal_Date__c)) AS [Year], MONTH(CONVERT(datetime, Subscription__r_Renewal_Date__c)) AS [Month], CONVERT(nvarchar(500), [Description]) AS [Description], Subscription__r_Renewal_Price__c AS [RenewalPrice]
FROM OPENQUERY(DBAMP, '
SELECT Id, Description, Subscription__r.Renewal_Date__c, Subscription__r.Renewal_Price__c
FROM Asset
')) AS tmp
GROUP BY [Year], [Month], [Description]
ORDER BY [Year], [Month], [Description]
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StringContent(<SOME OBJECT CONVERTED TO STRING FORMAT>);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/xml");
return response;
@cdeutsch
cdeutsch / gist:7604850
Last active December 29, 2015 02:59
Find Empty Salesforce Accounts
SELECT Id, Name, CreatedDate, LastModifiedDate
FROM (
SELECT Id, Name, CreatedDate, LastModifiedDate
FROM OPENQUERY(DBAMP, 'select * from Account')
WHERE Account_Profile__c IS NULL
AND Account_Stage__c IS NULL
AND Account_Tier__c IS NULL
AND AccountNumber IS NULL
AND Annual_Revenue_in_millions__c IS NULL
AND AnnualRevenue IS NULL
from c in charges
from componentVersion in allComponents
where c.Timestamp.Month == Month
&& c.Timestamp.Year == Year
&& !c.Refunded
&& !c.ChargeSource.Equals ("comp", StringComparison.OrdinalIgnoreCase)
&& c.ComponentID == componentVersion.ID
orderby c.Timestamp descending
select c;
@cdeutsch
cdeutsch / gist:7497163
Last active December 28, 2015 11:59
Redirect if browser is mobile
public function actionMobileLogin()
{
$this->layout = 'mobile';
Yii::app()->user->setState('loginType', 'mobile');
$this->actionLogin(true);
}
public function actionLogin($skipMobileCheck = false)
@cdeutsch
cdeutsch / gist:7378297
Created November 8, 2013 21:53
Mandrill example
var emailMessage = new EmailMessage
{
to = new List<EmailAddress>() { new EmailAddress() { email = model.Email, name = model.ShippingName } },
track_clicks = true,
track_opens = true
};
emailMessage.AddGlobalVariable("shipping_name", model.ShippingName.EmptyIfNull());
emailMessage.AddGlobalVariable("base_url", GetBaseUrl());
emailMessage.AddGlobalVariable("address1", model.Address1.EmptyIfNull());
doImageGet: function(a, b, c, d, e) {
var b = a + b + "&" + this.$.param(c), f = false, a = new Image(1, 1);
a.onload = function() {
f = true;
_MchHlpr.isDefined(e) && e()
};
a.src = b;
if (d > 0)
for (b = (new Date).getTime(); !f; )
if ((new Date).getTime() - b > d)
@cdeutsch
cdeutsch / gist:7241538
Last active December 27, 2015 00:59
Better Marketo / Salesforce munchkin.js loading that won't fire initMunchkin twice in IE.
<script type="text/javascript">
(function() {
function initMunchkin() {
Munchkin.init('YOUR-ID');
// custom handling after marketo is ready
if (typeof marketo_ready != 'undefined') marketo_ready();
}
var s = document.createElement('script');
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 4.0.30319.17020
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
using System;