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
static string GetPrettyDate(DateTime d) | |
{ | |
// 1. | |
// Get time span elapsed since the date. | |
TimeSpan s = DateTime.Now.Subtract(d); | |
// 2. | |
// Get total number of days elapsed. | |
int dayDiff = (int)s.TotalDays; |
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 stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("<PackageName>.<Filename>"); | |
var bytes = new byte[stream.Length]; | |
stream.Read(bytes, 0, bytes.Length); | |
string certPassword = ""; | |
var cert = new X509Certificate2(bytes, certPassword); |
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
static void WriteDataTableToCSV(DataTable dt, string fileName, char separator) | |
{ | |
System.IO.StreamWriter sw = new System.IO.StreamWriter(fileName); | |
foreach (DataColumn column in dt.Columns) | |
{ | |
sw.Write(column.ColumnName); | |
sw.Write(separator); | |
} | |
sw.WriteLine(); |
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
string u = Request.ServerVariables["HTTP_USER_AGENT"]; | |
Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline); | |
Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp |
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
CREATE FUNCTION [dbo].[ufn_GetDaysInYear] ( @pDate DATETIME ) | |
RETURNS INT | |
AS | |
BEGIN | |
if (@pDate is null) | |
SET @pDate = GETDATE() | |
DECLARE @IsLeapYear BIT | |
SET @IsLeapYear = 0 |
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
#!/usr/bin/python | |
from __future__ import with_statement | |
from fabric.api import local, settings, abort, run, cd,env,sudo | |
from fabric.contrib.console import confirm | |
env.hosts = ['<server>'] | |
env.user = '<user>' | |
salt_interface = '0.0.0.0' #Bind to all | |
salt_master = 'salt.<domain>' #Set up your subdomain salt, I like this version. |
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
MessageQueue queue = new MessageQueue("FormatName:DIRECT=OS:<queue_address>") | |
{ | |
MessageReadPropertyFilter = new MessagePropertyFilter | |
{ | |
ArrivedTime = true, | |
Body = true | |
} | |
}; | |
Console.WriteLine(queue.CanRead.ToString()); | |
Console.WriteLine(queue.CanWrite.ToString()); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
//Dependent on your Nvidia graphics card. Mine had a BLOCK_SIZE of 32. | |
#define BLOCK_SIZE 32 | |
#define TILE_SIZE 32 | |
//Rounds the value up to a multiple of BLOCK_SIZE. | |
//Usage found down south: dim3 dimGridProj(iDivUp(rowCount,BLOCK_SIZE), iDivUp(columnCount,BLOCK_SIZE)); |
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.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Security.Cryptography.X509Certificates; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; |