Skip to content

Instantly share code, notes, and snippets.

View shammelburg's full-sized avatar

Sander Hammelburg shammelburg

View GitHub Profile
@shammelburg
shammelburg / encrypt-decrypt-web.config.txt
Last active November 26, 2015 16:02
Encrypt / Decrypt web.config
On the server locate folder
a. C:\Windows\Microsoft.NET\Framework64\v4.0.30319
b. Check "aspnet_regiis.exe" exists
Run cmd
a. cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
To Encrypt:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis –pef "connectionStrings" "path"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis –pef "appSettings" "path"
@shammelburg
shammelburg / convert-base64string-to-file
Created November 26, 2015 16:08
Convert Base64String to File
public void Convert(string Base64String)
{
string fileName = "test.jpg";
string rootpath = Server.MapPath(Path.Combine("~", "Image", fileName));
ConvertBase64ToFile.ConvertToFile(rootpath, Base64String.Split(',')[1]);
}
public class ConvertBase64ToFile
{
public static void ConvertToFile(string location, string file)
@shammelburg
shammelburg / server.js
Created November 26, 2015 21:20
Node.js Static Serve Connect
/*
npm install serve-static
npm install connect
http://localhost:5000/
*/
var connect = require("connect"), serveStatic = require("serve-static");
var server = connect();
server.use(serveStatic("."));
@shammelburg
shammelburg / css-table-pivot.css
Last active November 26, 2015 21:22
CSS Table Pivot
/* Add data-title to the <td> element like this <td data-title="column header here"></td> */
media only screen and (max-width: 900px) {
/* Force table to not be like tables anymore */
#no-more-tables table,
#no-more-tables thead,
#no-more-tables tbody,
#no-more-tables th,
#no-more-tables td,
@shammelburg
shammelburg / angular-webapi-access.txt
Last active November 26, 2015 21:26
Angular Web API Access
// Add to Global.asax.cs
protected void Application_BeginRequest()
{
if (Request.Headers.AllKeys.Contains("Origin") && Request.HttpMethod == "OPTIONS")
{
Response.Flush();
}
}
@shammelburg
shammelburg / azure-sendgrid-smtp
Last active December 3, 2015 15:07
Azure SendGrid SMTP
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.sendgrid.net" port="587" defaultCredentials="false" userName="azure_{{guid}}@azure.com" password="*********" />
</smtp>
</mailSettings>
</system.net>
@shammelburg
shammelburg / sql-param-or-everything
Created January 4, 2016 12:25
SQL Parameter Or Everything
-- return matching param or everything if null
where (Product = @myParam or @myParam is null)
@shammelburg
shammelburg / resizing-image-console-app.text
Last active January 21, 2016 14:09
Resize Image in Console App Keeping Aspect Ratio
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
@shammelburg
shammelburg / woff-woff2-browser-iis-error-fix.xml
Created February 16, 2016 11:22
woff-woff2 IIS Browser Fix
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<!-- In case IIS already has this mime type -->
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<remove fileExtension=".woff2" />
<!-- In case IIS already has this mime type -->
<mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" />
</staticContent>
</system.webServer>
select ListPrice
, Name
, row_number() over (order by ListPrice desc) as 'row_number'
, rank() over (order by ListPrice desc) as 'rank'
, dense_rank() over (order by ListPrice desc) as 'dense_rank'
, ntile(5) over (order by ListPrice desc) as 'ntile'
from Production.Product
where ProductSubcategoryID = 1
order by ListPrice desc