Skip to content

Instantly share code, notes, and snippets.

View michaelbramwell's full-sized avatar

696d656b michaelbramwell

  • Perth Australia
View GitHub Profile
@michaelbramwell
michaelbramwell / timePickerValidation
Created November 5, 2012 06:15
Time Picker Validation Regex Pattern
string patt = @"^\d{2}:\d{2} (AM|PM)$";
@michaelbramwell
michaelbramwell / SpriteInfo.cs
Last active October 9, 2021 18:01
C# Sprite Generator / Maker (zero config) - generates a sprite-sheet with css classes outputted as a string
internal class SpriteInfo
{
public string Name { get; private set; }
public int X { get; private set; }
public int Y { get; private set; }
public int W { get; private set; }
public int H { get; private set; }
public SpriteInfo(string name, int x, int y, int w, int h)
{
@michaelbramwell
michaelbramwell / httpRequestPost.cs
Last active June 13, 2018 11:47
Http Request POST
string getUrl = "http://whatevatreva.kwom";
string postData = String.Format("organization_id={0}&subscriber_firstname={1}", "313", "Treva");
HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(getUrl);
getRequest.Method = WebRequestMethods.Http.Post;
getRequest.ContentType = "application/x-www-form-urlencoded";
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
getRequest.ContentLength = byteArray.Length;
Stream newStream = getRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
@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 / ddlCountries.aspx
Created October 11, 2012 03:04
.NET drop down list of countries
<asp:DropDownList ID="ddlCountryOrigin" runat="server">
<asp:ListItem Selected="true">Select Country</asp:ListItem>
<asp:ListItem>United States</asp:ListItem>
<asp:ListItem>Afghanistan</asp:ListItem>
<asp:ListItem>Albania</asp:ListItem>
<asp:ListItem>Algeria</asp:ListItem>
<asp:ListItem>American Samoa</asp:ListItem>
<asp:ListItem>Andorra</asp:ListItem>
<asp:ListItem>Angola</asp:ListItem>
<asp:ListItem>Anguilla</asp:ListItem>
@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 / 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