Skip to content

Instantly share code, notes, and snippets.

View csdear's full-sized avatar

Stuart Dear csdear

  • EBSCO
  • Birmingham AL
View GitHub Profile
@csdear
csdear / gist:c2845c146928b46be3a294ed1e68df8b
Created July 18, 2022 14:40
getStaticProps Typescript
import Link from 'next/link';
import { InferGetStaticPropsType, GetStaticProps } from "next";
import { FC, useState, useEffect } from 'react';
interface PeopleData {
name: string;
website: string;
email: string;
}
@csdear
csdear / AppSettings
Created October 11, 2016 15:03
App Settings Application Settings Configuration Settings No magic numbers
//e.g., key in the web config
<appSettings>
<add key="FromAddress" value="someEmail@gmail.com"/>
</appSettings>
***
//namespace to call.
+using System.Configuration;
// e.g., calling the value.
@csdear
csdear / EnumExtensions
Created October 5, 2016 17:30
An enum helper class IsAny() : extension method to check for any null enums being passed. e.g. usage : <!--new tickers-->@if (Model.NewsHeadlines.IsAny()) was used to prevent area from crashing N2 website in case any of the newsheadlines were not configured which would pass in nulls, crashing the site. enum dropdownlistfor method usage : @Html.E…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq.Expressions;
using System.Web.Mvc.Html;
using System.ComponentModel;
using System.Web.Mvc;
using System.Reflection;
@csdear
csdear / Checking a Enumerable Collection Null and Handling with a Extension Method
Created August 25, 2016 16:02
Checking a Enumerable Collection Null and Handling with a Extension Method
//Ref: Vulcraft project, NewsReleaseArchive.cshtml and EnumExtensions.cs class
//1. Implement the extenstion method. E.g., Helpers>>Extensions>>EnumExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Vulcraft.Web.Helpers.Extensions
{
@csdear
csdear / N2 : Parts Template
Created August 9, 2016 16:30
N2 : Parts Template
//e.g SocialMediaItemPart.cs
using Cadence.Web.Models.N2.Base;
using N2;
using N2.Details;
using N2.Persistence.Serialization;
namespace Cadence.Web.Models.N2.Parts {
//similar to the PageDefinition attribute on the page template, this attribute
//tells N2 that this is a Part with the friendly name "Social Media Link"
@csdear
csdear / N2 : : Page Template : Attributes Cheat Sheet
Last active August 9, 2016 16:29
N2 : Page Template : Attributes Cheat Sheet
/*Example with Code Explations
https://gist.github.com/davecowart/b1f448dbc7b32f1e624b#file-contentpage-cs
ContentPage.cs
Attribute|Property…Attribute|Property…Attribute|Property…
*/
//1. The N2>>Model>> Page Template
using System.Collections.Generic;
using Cadence.Web.Helpers.Attributes;
using Cadence.Web.Helpers.Extensions;
@csdear
csdear / Test SMTP server by sending a email through powershell
Last active August 9, 2016 16:19
Test SMTP server by sending a email through powershell
PS C:\Users\admin> Send-MailMessage -SMTPServer appmail -To johndoe@gmail.com -From blog@spamsource.com -Subject "This is a test email" -Body "Hi dude, this is a test email sent via PowerShell"
@csdear
csdear / Table Analysis(colHdrs,type and length) and Create Table ADV.sql
Created June 17, 2016 18:20
Table Analysis and Create Table ADV Getting all the data_types and columns from an existing table. In preparation for creating a new table with data types, width, primary key and Null -- only thing it doesnt have is relationships, which i need to figure out laster (schema maybe?) Its best to Create Table with all this info UP FRONT as later simp…
--1. The following query gets ALL the header values and ALL the associated datatypes and lengths.
-- After running this, you can copy and paste to the next query to easily create the new table.
-- just put your tablename within <<yourTableName>>
SELECT
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.precision ,
c.scale ,
@csdear
csdear / Maps - Javascript.js
Last active March 28, 2016 14:50
Maps - Javascript 1. Setting up a map of keys(english) and their associated values (translation ) 2. Test of myTranslation returns a Object, with associated k|v pairs 3. Looping through . We setup our variables, the sentry var, the key a blank string, and keys an array. 4. We assign the keys array var the Object.Keys funciton and pass in the map…
//1. Creating a Map, and looping though it.
//Create a map, a collection of key value pairs
var myTranslation = {
"my house": "mein Haus",
"my boat": "mein Boot",
"my horse": "mein Pferd"
}
// quick console test..
myTranslation
@csdear
csdear / Array - Clone.js
Created March 18, 2016 16:00
Array - Clone Using the slice(0) method.
var fruits = ['banana', 'orange', 'apple', 'mango'];
>fruits
<["banana", "orange", "apple", "mango"]
>var fruitClone = fruits.slice(0);
>fruitClone
<["banana", "orange", "apple", "mango"]