Skip to content

Instantly share code, notes, and snippets.

@johndobrien
johndobrien / test.cd
Created August 19, 2017 20:01
Testing SMTP
DotNetOpenMailProvider provider = new DotNetOpenMailProvider();
NameValueCollection configValue = new NameValueCollection();
configValue["smtpServer"] = "127.0.0.1";
configValue["port"] = "8081";
provider.Initialize("providerTest", configValue);
TestSmtpServer receivingServer = new TestSmtpServer();
try
{
receivingServer.Start("127.0.0.1", 8081);
/***********************************************
* Removes outdated properties from RL mongodb
*
* Run the following on the command line:
* mongo localhost:27017/recovery_library_development cleanup_rl.js
************************************************/
db.content.update({}, {$unset: {latest: ""}},{multi: true});
db.content.update({}, {$unset: {'liker_ids': ""}},{multi: true});
db.content.update({}, {$unset: {'disliker_ids': ""}},{multi: true});
sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-setuptools python-virtualenv python-dev libpq-dev libxml2-dev libxslt-dev openssl libffi-dev
sudo apt-get install redis-server
sudo mkdir /var/www
sudo adduser sentry
sudo chown sentry:sentry /var/www
sudo su - sentry
virtualenv /var/www/sentry
@johndobrien
johndobrien / sweet_potato_chili.md
Created February 15, 2016 14:31
Sweet Potato Chili

Fresh

  • 4 cups sweet potato, roughly diced (I buy a bag and call it good)
  • 1 large Haas avocado, sliced or cubed
  • 1 medium red onion, roughly chopped
  • 2 cloves garlic, minced
  • OPTIONAL 1 chipotle pepper en adobo, chopped finely
  • OPTIONAL shredded cheddar cheese

Pantry

  • 2 cans of unsalted black beans
WITH DeptList AS
(select rbc.RbcId as GroupId, CAST(NULL as BIGINT) as ParentId, d.DepartmentId, d.Description, CAST(g.Name as VARCHAR(MAX)) as Name, 1 as level
from relationship r1
INNER JOIN Rbc rbc ON r1.RightId = rbc.RbcId
INNER JOIN Department d on r1.LeftId=d.DepartmentId
INNER JOIN [Group] g on d.DepartmentId=g.GroupId
where r1.RelationshipTypeId = 2
UNION ALL
select DL.GroupId, p.DepartmentId ParentId, c.DepartmentId, c.Description, CAST(DL.Name + '>' + g.Name as VARCHAR(MAX)) as Name, DL.level + 1
from relationship r2
@johndobrien
johndobrien / gist:11008774
Created April 17, 2014 20:11
Statsd metrics
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using Common.Logging;
namespace Common.Metrics
@johndobrien
johndobrien / gist:11008731
Created April 17, 2014 20:10
PostSharp Aspect for Metrics
using System;
using System.Diagnostics;
using System.Reflection;
using PostSharp.Aspects;
using PostSharp.Extensibility;
namespace Common.Metrics
{
[Serializable]
[MulticastAttributeUsage(MulticastTargets.Method)]
ko.bindingHandlers.btnClick = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
var wrappedValueAccessor = function () {
return function (data, event) {
var txt = $(element).text();
$(element).text("Please Wait...");
valueAccessor().call(viewModel, data, event);
$(element).text(txt);
};
};
# Source accepts the protocol s3:// with the host as the bucket
# access_key_id and secret_access_key are just that
s3_file "/var/bulk/the_file.tar.gz" do
source "s3://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
group "root"
mode 0644
end
@johndobrien
johndobrien / gist:7603042
Last active January 12, 2018 13:39
A Durandal 2 DialogContext which works with Bootstrap 3
// this is based on the documentation http://durandaljs.com/documentation/Showing-Message-Boxes-And-Modals/
// create a dialog context: dialogContext.js
define(['jquery', 'knockout', 'transitions/entrance', 'plugins/dialog', 'bootstrap'],
// Create a dialog using Bootstrap 3
function($, ko, entrance, dialog) {
return {
addHost: function(theDialog) {
var body = $('body');
$('<div class="modal fade" id="myModal"></div>').appendTo(body);
theDialog.host = $('#myModal').get(0);