Skip to content

Instantly share code, notes, and snippets.

@misaxi
misaxi / gist:1475275
Created December 14, 2011 04:35
run admin command via mongo C# driver
Server.RunAdminCommand(
new CommandDocument(
new Dictionary<string, object>
{
{"setParameter", 1},
{"notablescan", false}
}));
using System;
namespace RsaKeyConverter.Converter
{
public static class BytesExtensions
{
public static string ToBase64(this byte[] bytes)
{
return Convert.ToBase64String(bytes);
}
@misaxi
misaxi / ConfigIssuerNameRegistry.cs
Last active January 4, 2016 02:19
After creating an ASP.NET MVC 5 project integrate with Organisational Accounts. There are a few Windows Azure Active Directory things configured automatically. A LocalDB is used to check issuer keys and tenants which is not necessary tho. ConfigIssuerNameRegistry is used to check those things based on web.config.
using System.Configuration;
using System.IdentityModel.Tokens;
using System.Linq;
namespace Rockend.Bedrock.Web.Admin.Utils.AzureAD
{
public class ConfigIssuerNameRegistry : ValidatingIssuerNameRegistry
{
static readonly string[] TenantIds = ConfigurationManager.AppSettings["ida:TenentIds"].Split('|').Select(n => n.Trim()).ToArray();
static readonly string[] IssuerKeys = ConfigurationManager.AppSettings["ida:IssuerKeys"].Split('|').Select(n => n.Trim()).ToArray();
@misaxi
misaxi / Page.coffee
Last active August 29, 2015 13:55
A base Page object class which wraps
class Page
constructor: ->
# this is singleton
@ptor = protractor.getInstance()
get: (relativeUrl, ignoreSync) ->
# we want to ignore sync if the
# page does not use AngularJS
@ptor.ignoreSynchronization = ignoreSync or false
@ptor.get @ptor.baseUrl + relativeUrl
class Page
constructor: ->
# this is singleton
@ptor = protractor.getInstance()
get: (relativeUrl, ignoreSync) ->
# we want to ignore sync if the
# page does not use AngularJS
@ptor.ignoreSynchronization = ignoreSync or false
@ptor.get @ptor.baseUrl + relativeUrl
Page = require 'Utils/Page'
class AddOwnerPage extends Page
get: ->
super "/management/owners/create"
AddOwnerPage = require 'Pages/AddOwnerPage'
ViewOwnerPage = require 'Pages/ViewOwnerPage'
TestHelper = require 'Utils/TestHelper'
describe 'owner', ->
# login before each test starts
beforeEach ->
new LoginPage().loginToPt()
# logout after each test finishes
AddOwnerPage = require 'Pages/AddOwnerPage'
ViewOwnerPage = require 'Pages/ViewOwnerPage'
TestHelper = require 'Utils/TestHelper'
TestHelper.doAfterLogin 'owner', (it) ->
it 'should be created', ->
# test logics here
// export to GLOBAL.config so the test code
// can access your settings. i.e. login detail
GLOBAL.config = module.exports.config = {
login: {
username: 'admin',
password: 'adminpwd'
},
@misaxi
misaxi / web.config
Created September 28, 2014 10:20
web.config for IIS hosted multi-site WordPress
<!-- http://lauragentry.com/blog/2010/07/30/how-to-create-a-wordpress-3-0-multisite-network-on-a-windows-server-using-sub-directories/ -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>