Skip to content

Instantly share code, notes, and snippets.

View michaelbramwell's full-sized avatar

696d656b michaelbramwell

  • Perth Australia
View GitHub Profile
@michaelbramwell
michaelbramwell / typescriptEnumToString.ts
Last active March 21, 2018 00:59
Typescript Enum to string equivalent to C#'s enum value ToString()
// given enum
export enum DairyTypes {
Cheese = 1,
Milk = 2,
Eggs = 3
}
// output 'Eggs' equivalent to c#'s DairyTypes.Eggs.ToString()
console.log(DairyTypes[DairyTypes.Eggs])
@michaelbramwell
michaelbramwell / InternalsVisibleTo.cs
Created November 29, 2017 03:03
Expose Internal Assembly for Unit Testing
[assembly: InternalsVisibleTo("Assembly.Name")]
@michaelbramwell
michaelbramwell / AddSvcAccountToAppPoolViaCMD
Created June 9, 2017 07:39
Add Svc Account to App Pool via CMD
# from https://stackoverflow.com/a/26180529
%windir%\system32\inetsrv\appcmd.exe set config /section:applicationPools /[name='APP_POOL_NAME'].processModel.identityType:SpecificUser /[name='APP_POOL_NAME'].processModel.userName:DOMAIN\USER_NAME /[name='APP_POOL_NAME'].processModel.password:PASSWORD
@michaelbramwell
michaelbramwell / modifiedMySqlWorkbenchImportScript
Created April 24, 2017 08:49
Modified MySql Workbench import from terminal
mysql --protocol=tcp --host=localhost --user=username -p --port=3306 --default-character-set=utf8mb4 --comments --database=dbname < "/path/import.sql"
@michaelbramwell
michaelbramwell / sitecore-reset-admin-password-to-default.sql
Created March 16, 2017 07:37
Sitecore Reset Admin Password to Default
UPDATE [aspnet_Membership] SET [Password]='qOvF8m8F2IcWMvfOBjJYHmfLABc=', [PasswordSalt]='OM5gu45RQuJ76itRvkSPFw==',
[IsApproved] = '1', [IsLockedOut] = '0'
WHERE UserId IN (SELECT UserId FROM dbo.aspnet_Users WHERE UserName = 'sitecore\Admin')
@michaelbramwell
michaelbramwell / pwGenUrandom
Created March 3, 2017 02:29
Password Generation
< /dev/urandom tr -db _A-Z-a-z-0-9 | head -c16
@michaelbramwell
michaelbramwell / wpdepsetup
Last active March 7, 2017 14:03
WordPress Dependencies Setup
#!/bin/bash
sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get install apache2 mysql-server mysql-client php libapache2-mod-php7.0 php-mysql mailutils mysql-workbench
mysql -u root -p -e "CREATE DATABASE demo; CREATE USER 'demo'@'localhost' IDENTIFIED BY 'passwordgoeshere'; GRANT ALL PRIVILEGES ON demo.* to 'demo' IDENTIFIED BY 'passwordgoeshere'; FLUSH PRIVILEGES;"
sudo adduser www-data www-data
sudo chown -R www-data:www-data /var/www
@michaelbramwell
michaelbramwell / SimpleRssAtomFeedSearchForHugo.js
Created January 17, 2017 13:19
Simple Rss Atom Feed Search For Hugo
var search = search || {};
(function(o, win) {
let _client = document.getElementById("client");
let _server = document.getElementById("server");
let _dateFmt = function(dateStr) {
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return new Date(dateStr).toLocaleDateString("en-US", options);
};
@michaelbramwell
michaelbramwell / idxOf.js
Last active January 14, 2017 13:40
Find the needle in the haystack
let _idxOf = function(needle){
return function(haystack){
return haystack.toLowerCase().indexOf(needle.toLowerCase()) !== -1;
};
};
// e.g
let searchTerm = "fly";
let pets = [{ name: 'George', type: 'fly' }, { name: 'Benson', type: 'dog' }];
@michaelbramwell
michaelbramwell / siteroot.cs
Created November 30, 2016 01:17
Sitecore get current site root. ref - http://stackoverflow.com/a/33161150/6264690
Item currentItem = Sitecore.Context.Item;
SiteInfo currentSiteRoot = SiteContextFactory.Sites
.Where(s => s.RootPath != "" && currentItem.Paths.Path.ToLower().StartsWith(s.RootPath.ToLower()))
.OrderByDescending(s => s.RootPath.Length)
.FirstOrDefault();