This file contains hidden or 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
| function Test-IsAdmin { | |
| try { | |
| $identity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
| $principal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $identity | |
| return $principal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) | |
| } catch { | |
| throw "Failed to determine if the current user has elevated privileges. The error was: '{0}'." -f $_ | |
| } | |
| <# |
This file contains hidden or 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
| internal static class SqlMvaLibExtensions { | |
| private static readonly DateTime _minSqlDateTime = new DateTime(1753, 1, 1); | |
| private static readonly DateTime _maxSqlDateTime = new DateTime(9999, 12, 31, 23, 59, 59, 997); | |
| internal static bool IsValidSqlDateTime(this System.DateTime dt) { | |
| return (dt >= _minSqlDateTime && dt <= _maxSqlDateTime); | |
| } | |
| } |
This file contains hidden or 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
| curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"userid": "mohit", "password":"password"}' http://mmedwebdemo.ddns.comp.nus.edu.sg:8080/comp.nuhs.jaxb/api/usr/login |
This file contains hidden or 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
| /** | |
| * WiFiAutoSelector.h - Include file for class WiFiAutoSelector | |
| * Copyright (c) 2016 Andreas Schaefer <[email protected]> | |
| * | |
| * A class to pick a wifi network from a list, based on the | |
| * highest receive signal strength, and connect to it. | |
| * Inspired by "WiFiMulti" | |
| * | |
| * This source code is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU Lesser General Public |
This file contains hidden or 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
| var mixColor = function(hexColorStart, hexColorEnd, percent) { | |
| /* Example: | |
| var startColor = '#FF8000'; | |
| var endColor = '#0080FF'; | |
| var t = []; | |
| for(var i=0; i < 100; i += 10 ) { | |
| var mix = mixColor(startColor, endColor, i); | |
| t.push('<span style="display: inline-block; width: 20px; height: 60px; background-color: ' + mix + '"> </span>'); | |
| } | |
| document.getElementById('demo').innerHTML = t.join(''); |
This file contains hidden or 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
| <?php | |
| // Protect agains direct calls from the web browser | |
| if(1 == count(get_included_files())) { | |
| http_response_code(404); | |
| die( '<h1>404 Not Found</h1><p>The page that you have requested could not be found.</p>'); | |
| } | |
| // More library code here |
This file contains hidden or 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
| -- Pageing in SQL Server like mysql (LIMIT + OFFSET) | |
| DECLARE @Offset INT = 3 | |
| DECLARE @Limit INT = 10 | |
| ;WITH Results_CTE AS | |
| ( | |
| SELECT | |
| COUNT(*) OVER () as TotalRows, | |
| ROW_NUMBER() OVER (ORDER BY name) AS RowNum, | |
| id, name, crdate, refdate |
This file contains hidden or 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
| -- This sql snippet converts a base2 string (0 and 1 bits) | |
| -- into an integer value | |
| DECLARE @bitmask VARCHAR(8) = '10000000' | |
| -- Bitposition: 76543210 | |
| DECLARE @intValue INT | |
| ;WITH bits(pos) AS ( | |
| select 1 union select 2 union select 3 union select 4 union |
This file contains hidden or 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
| { | |
| "FormattingOptions": { | |
| "NewLine": "\n", | |
| "UseTabs": false, | |
| "TabSize": 2, | |
| "IndentationSize": 2, | |
| "SpacingAfterMethodDeclarationName": false, | |
| "SpaceWithinMethodDeclarationParenthesis": false, | |
| "SpaceBetweenEmptyMethodDeclarationParentheses": false, | |
| "SpaceAfterMethodCallName": false, |
This file contains hidden or 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
| !function() { | |
| function _dynamicSortMultiple(attr) { | |
| /* | |
| * save the arguments object as it will be overwritten | |
| * note that arguments object is an array-like object | |
| * consisting of the names of the properties to sort by | |
| */ | |
| var props = arguments; | |
| return function (obj1, obj2) { |