Skip to content

Instantly share code, notes, and snippets.

View mamift's full-sized avatar

Muhammad Miftah mamift

View GitHub Profile
@mamift
mamift / package.json
Last active June 27, 2022 01:12
webpack 5 and npm package.json configuration file for SASS only entries
{
"name": "sass-only-webpack-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js"
},
"author": "",
@mamift
mamift / sp_dynamicDBSnapshotCreator.sql
Created May 19, 2021 22:46
sp_dynamicDBSnapshotCreator DDL - A copy of the DDL for a stored procedure that easily creates snapshots of a database in SQL server (no specifying filename etc.) - modified to include date & time in the snapshot name.
USE [WW2_DEV]
GO
/****** Object: StoredProcedure [dbo].[sp_DynamicDBSnapshotCreator] Script Date: 20/05/2021 8:42:18 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*******************************************************************************************************************************************
Dynamically Create SQL Server Database Snapshots v1.0 (2016-04-11)
@mamift
mamift / CollectionViewHeightBehavior.cs
Last active November 3, 2020 22:58
A custom behaviour for Xamarin's CollectionView control that modulates its height based on how many items it's showing. Taken from https://forums.xamarin.com/discussion/158425/collectionview-included-additional-space-at-the-bottom. Addresses: https://github.com/xamarin/Xamarin.Forms/issues/6497
public class CollectionViewHeightBehavior : Behavior<CollectionView>
{
bool hasHeightChanged = false;
public CollectionView CollectionViewObject
{
get;
private set;
}
protected override void OnAttachedTo(CollectionView bindable)
{
<#
.SYNOPSIS Execute SQL Script in order
.Parameter Server Provide SQL Server Name
.Parameter DatabaseName Provide database name
.Parameter UserName Provide a windows user name or SQL Server user name
.Parameter Password Provide password as a secure string
.Parameter ScriptPath Provide the path where all the SQL scripts are located
.Parameter ContineOnException Enable this switch to continue even if one of the script failed to execute
.EXAMPLE
$SecurePass = ConvertTo-SecureString "MyPassword"
@mamift
mamift / incrementNugetPackageBuildNumber.ps1
Last active February 7, 2020 03:06
Increments the last digit of the nuget version number for a given .csproj file. Intended for the VS2017 project file format and newer.
param(
[parameter(Mandatory=$True)]
[string] $csprojFile
)
# to invoke from visual studio as a post-build event:
# C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command incrementNugetPackageBuildNumber.ps1 -csprojFile "$(ProjectPath)";
$projXml = new-object xml
$projXml.Load($csprojFile)
[string]$versionNumberString = $projXml.Project.PropertyGroup.Version
@mamift
mamift / CodeDomExtensionAddDefaultGetter.cs
Last active September 23, 2019 23:00
Extension method to add a get property that returns a default value (extends the CodeTypeDeclaration type).
public static class CodeDomExtensionMethods {
/// <summary>
/// Adds a get property that returns a default value.
/// </summary>
/// <param name="type"></param>
/// <param name="typeName"></param>
/// <param name="propertyName"></param>
/// <param name="attrs"></param>
/// <returns></returns>
public static CodeMemberProperty AddDefaultGetter(this CodeTypeDeclaration type, string typeName,
@mamift
mamift / ToDelimitedStringExtensions.cs
Created September 4, 2019 04:43
Extension methods that converts a sequence (IEnumerable<>) of objects to a delimited string. Includes a generic method.
public static class ExtensionMethods
{
/// <summary>
/// Converts an <see cref="IEnumerable{T}"/> of <see cref="string"/>s to a flat string, delimited by a delimiter string.
/// </summary>
/// <param name="stringEnumerable"></param>
/// <param name="delimiter">Defaults to comma with a space (, )</param>
/// <param name="openEncloseString">Enclose each string in the IEnumerable inside two other strings. e.g. an apostrophe will produce: ('a', 'b', 'c')</param>
/// <param name="closeEncloseString"></param>
/// <returns></returns>
@mamift
mamift / vss_snapshot_c.bat
Created March 18, 2019 23:34
Invoke VSS snapshot manually for C drive (Windows 7+)
wmic shadowcopy call create volume='C:\'