Skip to content

Instantly share code, notes, and snippets.

View pinalbhatt's full-sized avatar
💭
from the desk of Pinal Bhatt

Pinal Bhatt pinalbhatt

💭
from the desk of Pinal Bhatt
View GitHub Profile
@pinalbhatt
pinalbhatt / Angular.Controller.js
Last active August 29, 2015 14:17
AngularJS SideWaffle Templates
(function () {
'use strict';
angular
.module('app')
.controller('controller2', controller2);
controller2.$inject = ['$scope'];
function controller2($scope) {
@pinalbhatt
pinalbhatt / npm-commands.sh
Last active May 3, 2016 16:07
Upgrade Node.js via NPM
npm cache clean -f
npm i -g <package> # -S --save
npm i -S <package> # -S --save
npm i -D <package> # -D --save-dev
@pinalbhatt
pinalbhatt / EFSqlDebug
Created March 9, 2015 14:14
How to see the actual SQL query generated by Entity Framework in Visual Studio Debug Windows
using (TailspinToysEntities context = new TailspinToysEntities())
{
context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
var products =
from product in context.Products
where product.BasePrice > 5.00m
select product;
}
@pinalbhatt
pinalbhatt / Generate-MachineKey.cs
Last active February 22, 2017 15:34
Generate MachineKey
# Generates a <machineKey> element that can be copied + pasted into a Web.config file.
function Generate-MachineKey {
[CmdletBinding()]
param (
[ValidateSet("AES", "DES", "3DES")]
[string]$decryptionAlgorithm = 'AES',
[ValidateSet("MD5", "SHA1", "HMACSHA256", "HMACSHA384", "HMACSHA512")]
[string]$validationAlgorithm = 'HMACSHA256'
)
process {
@pinalbhatt
pinalbhatt / rename git branch locally and remotely
Last active August 29, 2015 14:12 — forked from lttlrck/gist:9628955
Rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
#Set of commands i use to rename feature/15.0 to feature/SignupRefactor locally and remotely
#rename local feature/15.0 to feature/SignupRefactor
git branch -m feature/15.0 feature/SignupRefactor
#delete remote feature/15.0
@pinalbhatt
pinalbhatt / SendEmail.cs
Last active August 29, 2015 14:06
SendEmail
//using System.Net;
//using System.Net.Mail;
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("<smtp host address>");
mail.From = new MailAddress("me@mydomain.com");
mail.To.Add("u@urdomain.com");
mail.Subject = "Subject";
mail.Body = "body";
@pinalbhatt
pinalbhatt / package.json
Last active August 29, 2015 14:05
NodeJS-Simple-Website
{
"name": "WebApp",
"version": "0.0.0",
"description": "WebApp NodeJS Simple WebSite",
"main": "server.js",
"author": {
"name": "Pinal Bhatt",
"email": "pinalbhatt@gmail.com"
},
"dependencies": {
@pinalbhatt
pinalbhatt / ChocolateyCmds
Created August 3, 2014 13:51
Chocolatey Commands
//Chocolatey Install Package
cinst packageName
//Chocolatey Update
cup packageName
cup all
clist -lo
/*
C# Generic String Parser Extension Method
Code Snippet By: Pinal Bhatt [www.PBDesk.com]
http://blogs.pbdesk.com/c-generic-string-parser-extension-method/
Working Example at http://ideone.com/ZP5xo
Usage:
string s = "32";
int i = s.As<int>();
*/
/*
C# Generic Enum Parser With Extension Methods
Code Snippet By: Pinal Bhatt [www.PBDesk.com]
*/
public static class EnumUtils
{
#region String to Enum