Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DCCoder90
DCCoder90 / Extensions.cs
Created January 18, 2018 04:48
A few extension methods for rounding
public static class Extensions{
/**
* Rounds the supplied number to the nearest multiple of the parameter
* @param this int The number to round
* @param int The multiple to use
* @return int
* @static
* @extension
*/
@DCCoder90
DCCoder90 / AddressPOCO.cs
Created February 26, 2018 17:22
A quick and dirty address validator using Google's Geocoding API. Could be easily expanded upon.
using System;
using System.Collections.Generic;
using System.Text;
namespace Validation
{
public class AddressComponent {
public string long_name { get; set; }
public string short_name { get; set; }
public List<string> types { get; set; }
@DCCoder90
DCCoder90 / Readme.txt
Last active March 22, 2018 16:07
A small, quick, and simple method of verify fields in a form.
Name: restrictInput
Signature: restrictInput(string type, event keypress);
Description: Restricts input to fields to specified values
Usage: $("#myfieldID").keydown(function(e)){
restrictInput("alpha",e);
};
Types:
alphanumeric - All letters and numbers
@DCCoder90
DCCoder90 / NightmareJSInfiniteScroll.js
Created March 25, 2018 17:21
Scroll to the bottom of an infinite scroll page with NightmareJS
var previousHeight, currentHeight=0;
while(previousHeight !== currentHeight) {
previousHeight = currentHeight;
var currentHeight = yield nightmare.evaluate(function() {
return document.body.scrollHeight;
});
yield nightmare.scrollTo(currentHeight, 0)
.wait(3000);
}
@DCCoder90
DCCoder90 / getFullyQualifiedName.sql
Created August 20, 2018 13:56
Get fully qualified object name from object id
create function dbo.getFullyQualifiedName(
@objectid int
) returns sysname
begin
declare @fqn sysname
select
@fqn = CONCAT(
QUOTENAME(@@SERVERNAME), '.',
QUOTENAME(DB_NAME()), '.',
@DCCoder90
DCCoder90 / detectBlocking.sql
Created August 27, 2018 17:48
Query to detect any blocking queries
SELECT blocked_query.session_id AS blocked_session_id,
blocking_query.session_id AS blocking_session_id,
sql_text.text AS blocked_text,
sql_btext.text AS blocking_text,
waits.wait_type AS blocking_resource
@DCCoder90
DCCoder90 / columnSearch.sql
Created August 27, 2018 17:49
Query that searches system tables to identify a table that has a specified column name
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%COLUMN NAME%'
ORDER BY TableName
,ColumnName;
@DCCoder90
DCCoder90 / truncate.sql
Created August 27, 2018 17:51
Truncate tables with respect to FKs
SET NOCOUNT ON
GO
DECLARE @table TABLE(
RowId INT PRIMARY KEY IDENTITY(1, 1),
ForeignKeyConstraintName NVARCHAR(200),
ForeignKeyConstraintTableSchema NVARCHAR(200),
ForeignKeyConstraintTableName NVARCHAR(200),
ForeignKeyConstraintColumnName NVARCHAR(200),
PrimaryKeyConstraintName NVARCHAR(200),
@DCCoder90
DCCoder90 / Startup.cs
Created September 19, 2018 21:30
For micro-api tutorial
using System.Web.Http;
using Owin;
namespace SelfHosted{
public class Startup{
public void Configuration(IAppBuilder app){
// Configure Web API for self-host.
var config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
@DCCoder90
DCCoder90 / Controller.cs
Created September 19, 2018 21:32
For micro-api tutorial
using System.Collections.Generic;
using System.Web.Http;
namespace SelfHosted{
public class HelloController : ApiController{
// GET api/hello
public IEnumerable Get(){
return new string[] { "Hello", "World" };
}