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
// We extend the string object with a little helper function | |
// to convert a boolean value from a string to bool. | |
// var flag = "true"._toBool | |
Object.defineProperty(String.prototype, "_toBool", { | |
get : function() { | |
return (/^(true|1)$/i).test(this); | |
} | |
}); |
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
// go inside that folder: | |
cd /d "C:\$Windows.~BT" | |
// take over ownership | |
takeown /f *.* /R /D Y | |
// (go for coffee, takes a minute) | |
// grant full rights to everyone | |
icacls *.* /grant Everyone:(OI)(CI)F /T |
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
SELECT | |
GETUTCDATE() AS [DateTime], | |
[s_tst].[session_id], | |
[s_es].[login_name] AS [Login Name], | |
DB_NAME (s_tdt.database_id) AS [Database], | |
[s_tdt].[database_transaction_begin_time] AS [Begin Time], | |
[s_tdt].[database_transaction_log_bytes_used] AS [Log Bytes], | |
[s_tdt].[database_transaction_log_bytes_reserved] AS [Log Rsvd], | |
[s_est].text AS [Last T-SQL Text], | |
[s_eqp].[query_plan] AS [Last Plan] |
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
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 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
use mysql; | |
update user set password=PASSWORD("UlE3x:rtRt$12") where User='vhost_4711'; | |
flush privileges; |
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
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 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 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 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 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 |
OlderNewer