This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Always remember to escape "." or special characters, otherwise you cannot select/refer to the selector etc. | |
$( "#myID\\.entry\\[1\\]" ).css( "border", "3px solid red" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Bootstrap 4 doesn't have the "remote" option anymore. Little jQuery will get you an external URL in a modal | |
*Note: The "data-remote" attribute specifies the URL to open within the modal | |
--> | |
<button id='abutton' class='buttonopen' data-remote='http://your-url.com'>Click Me</button> | |
<script> | |
$('buttonopen').on('click', '[data-toggle="modal"]', function(){ | |
$($(this).data("target")+' .modal-body').load($(this).data("remote")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main(string[] args) | |
{ | |
var content = "Example test"; | |
var key = "E546C8DF278CD5931069B522E695D4F2"; | |
var encrypted = EncryptString(content, key); | |
Console.WriteLine(encrypted); | |
var decrypted = DecryptString(encrypted, key); | |
Console.WriteLine(decrypted); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Increments an INT column in MS SQL | |
*/ | |
Update MyTable | |
set testCount= ISNULL(testCount, 0) + 1 | |
where MyTableId = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Using MS SQL 2008 and above.. | |
-- Create a test table first | |
CREATE TABLE dbo.DataType | |
( | |
ID int IDENTITY(1,1), | |
TypeName nvarchar(255), | |
[TypeProperty] nvarchar(255), | |
CONSTRAINT PK_DataType PRIMARY KEY (ID) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @Sku varchar(100) = 'xyz123456' | |
;WITH CTE (Sku,StockItemId) AS | |
( | |
SELECT | |
Sku, | |
StockItemId | |
FROM | |
table_products | |
WHERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Allows you to pass in option params and select based on the combination | |
-- The trick is the WHERE (condition in brackets) AND combination below | |
ALTER PROCEDURE [dbo].[FetchTaskHistoryByClientId] | |
@ClientId int, | |
@TaskId int = 0, | |
@TaskCompleted bit = 0, | |
@TaskFailed bit = 0 | |
AS | |
BEGIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH CTE AS( | |
SELECT field_to_identify_duplicate, | |
RN = ROW_NUMBER()OVER(PARTITION BY field_to_identify_duplicate ORDER BY field_to_identify_duplicate) | |
FROM table_with_duplicates | |
) | |
DELETE FROM CTE WHERE RN > 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses NewtonSoft.Json | |
XDocument doc = XDocument.Parse(xmlData); //or XDocument.Load(path) | |
string jsonText = JsonConvert.SerializeXNode(doc); | |
dynamic dyn = JsonConvert.DeserializeObject<ExpandoObject>(jsonText); |
NewerOlder