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
-- List all the connections to a particular database. | |
SELECT spid, loginame, hostname, program_name | |
FROM master..sysprocesses [sysprocesses] | |
INNER JOIN sys.sysdatabases [sysdatabases] | |
ON [sysprocesses].dbid = [sysdatabases].dbid | |
INNER JOIN sys.sysusers [sysusers] | |
ON [sysprocesses].uid = [sysusers].uid | |
WHERE [sysprocesses].dbid = DB_ID('Catalog name') | |
-- Kill the connection. |
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
struct MutableStruct | |
{ | |
private int x; | |
public int Mutate() | |
{ | |
this.x = this.x + 1; | |
return this.x; | |
} | |
} |
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
DECLARE @dtmDATETIME DATETIME | |
SET @dtmDATETIME = '2009-08-09' -- '1901-12-14', '2038-01-19' | |
DECLARE @intResult INT; | |
-- NULL if outside of valid UNIX Time range (-2,147,483,648 to 2,147,483,647) | |
IF (@dtmDATETIME < '1901-12-14') OR (@dtmDATETIME > '2038-01-19 03:14:07.497') | |
SELECT NULL | |
ELSE | |
SELECT DATEDIFF(second ,25567, (DATEADD(millisecond, ROUND(DATEPART(millisecond, @dtmDATETIME),-3) - DATEPART(millisecond, @dtmDATETIME), @dtmDATETIME)) ) |
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
DECLARE @intUNIXTime INT | |
SET @intUNIXTime = 1249776000 --1249776000, 2147472000 | |
SELECT DATEADD(second, @intUNIXTime, 25567) |
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
-- Part 1 - Roll back a table transaction | |
CREATE TABLE MyTable ( Column1 VARCHAR(5), Column2 VARCHAR(5)) | |
INSERT INTO MyTable (Column1, Column2) VALUES ('A', 'Foo') | |
BEGIN TRANSACTION | |
UPDATE MyTable SET Column2 = 'Bar' WHERE Column1 = 'A' | |
ROLLBACK TRANSACTION | |
SELECT * FROM MyTable -- OUTPUTS 'A', 'Foo' because the transaction was rolled back. | |
DROP TABLE MyTable |
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
/// <summary> | |
/// Note: Need [FromUri] to tell the model binder to pull the model from the URI and not the body. | |
/// </summary> | |
[HttpGet] | |
public HttpResponseMessage Get([FromUri]BarFilterParameters parameters) | |
{ | |
// ... | |
} | |
public class BarFilterParameters |
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
// Data type constructor function. JavaScript does not have classes. | |
function Pet(config) { | |
this.name = config.name; | |
this.species = config.species; | |
} | |
// Define methods on prototype so all pet objects and any data types that inherit from pet have this method. | |
Pet.prototype.getSpecies = function() { | |
return this.species; | |
}; |
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
// Javascript doesn't have private variables but closures can be used to hide data. | |
var myClass = (function() { | |
var privateInfo | |
setPrivateInfo = function(privateInfoToSet) { | |
this.privateInfo = privateInfoToSet; | |
console.log("Set privateInfo: " + this.privateInfo); | |
}; |
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
// The Prototype pattern allows objects to be created | |
// based on a template of an existing object using cloning. | |
var Dragon = { | |
name: "TROGDOR" | |
}; | |
//Object.create takes its first argument and applies it to the prototype of your new object. | |
var myDragon = Object.create(Dragon); |
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
using System; | |
using System.Collections; | |
public class NaiveFibonacciSequenceGenerator : IEnumerable | |
{ | |
private readonly int sequenceSize; | |
public NaiveFibonacciSequenceGenerator(int sequenceSize) | |
{ | |
this.sequenceSize = sequenceSize; |
OlderNewer