Skip to content

Instantly share code, notes, and snippets.

View mahizsas's full-sized avatar

MAHIZ mahizsas

View GitHub Profile
@mahizsas
mahizsas / vs2012-empty.sln
Last active October 14, 2015 00:28 — forked from lucamilan/gist:3841570
VS2012 Empty Solution File
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
/*
* Scripts to remove data you don't need here
*/
/*
* Now let's clean that DB up!
*/
DECLARE @DBName VarChar(25)
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}
@mahizsas
mahizsas / check-piva.js
Created December 20, 2012 19:29
Controllo PIVA
function controllaPIVA(pi)
{
if( pi == '' ) return '';
if( pi.length != 11 )
return "La lunghezza della partita IVA non è\n" +
"corretta: la partita IVA dovrebbe essere lunga\n" +
"esattamente 11 caratteri.\n";
validi = "0123456789";
for( i = 0; i < 11; i++ ){
if( validi.indexOf( pi.charAt(i) ) == -1 )
@mahizsas
mahizsas / check-cfisc.js
Created December 20, 2012 19:31
Controllo Codice Fiscale
function controllaCF(cf)
{
var validi, i, s, set1, set2, setpari, setdisp;
if( cf == '' ) return '';
cf = cf.toUpperCase();
if( cf.length != 16 )
return "La lunghezza del codice fiscale non è\n"
+"corretta: il codice fiscale dovrebbe essere lungo\n"
+"esattamente 16 caratteri.\n";
validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@mahizsas
mahizsas / RouteConfig.cs
Created January 28, 2013 11:30 — forked from carolynvs/RouteConfig.cs
WebApi routing, that allow SOAP and REST style
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// GET /api/{resource}/{action}
routes.MapHttpRoute(
name: "Web API RPC",
routeTemplate: "api/{controller}/{action}",
defaults: new { },
constraints: new { action = @"[A-Za-z]+", httpMethod = new HttpMethodConstraint("GET") }
@ECHO OFF
SETLOCAL
SET VERSION=%1
SET NUGET=buildsupport\nuget.exe
FOR %%G IN (packaging\nuget\*.nuspec) DO (
%NUGET% pack %%G -Version %VERSION% -Symbols -o artifacts
)
@mahizsas
mahizsas / enumerate_status_code.cs
Created March 23, 2013 10:43
Enumerate Http StatusCodes
public class StatusCodesController: ApiController
{
public HttpResponseMessage Get()
{
var type = typeof (HttpStatusCode);
var values =
Enum.GetValues(type)
.Cast<HttpStatusCode>()
.Select(v => new {name = Enum.GetName(type, v), value = v});
@mahizsas
mahizsas / validtimes.cs
Created April 4, 2013 06:49 — forked from MisterJames/Build a list of valid times
Build a list of valid times
List<string> times = new List<string>();
Enumerable.Range(0, 24).ToList()
.ForEach(hour => Enumerable.Range(0, 2).ToList()
.Select(x => string.Format("{0}:{1:00}", hour, x * 30))
.ToList()
.ForEach(timeslot=>times.Add(timeslot)));
@mahizsas
mahizsas / DbContext.cs
Created April 5, 2013 07:05
Flat DbEntityValidationException errors
public override int SaveChanges()
{
try
{
return base.SaveChanges();
}
catch (DbEntityValidationException ex)
{
// Retrieve the error messages as a list of strings.
var errorMessages = ex.EntityValidationErrors