Skip to content

Instantly share code, notes, and snippets.

View vgaltes's full-sized avatar

Vicenç García Altés vgaltes

View GitHub Profile
@vgaltes
vgaltes / parser.fs
Last active December 13, 2015 11:35
Parsing the commit info
type CommitInfoCsv = CsvProvider<"Hash,Author,Date,Message", HasHeaders = false, Schema = "Hash,Author,Date(date),Message">
let infoRow = CommitInfoCsv.Parse(commitInfoLine).Rows |> Seq.head
let commitInfo = {Hash = infoRow.Hash; Author = infoRow.Author; TimeStamp = infoRow.Date; Message = infoRow.Message}
let isCommitInfoLine (line: string) =
line.StartsWith("[")
let commitLines = commit.Split([|lineBreak|], StringSplitOptions.RemoveEmptyEntries)
let commitInfoLine = commitLines |> Array.takeWhile(isCommitInfoLine) |> Array.last
let fileLines = commitLines |> Array.skipWhile(isCommitInfoLine)
@vgaltes
vgaltes / parser.fs
Last active December 13, 2015 11:16
Reading the log file
[<Literal>]
let lineBreak = "\r\n"
let filePath =Path.Combine(__SOURCE_DIRECTORY__, "..\..\Data\gitLog.log")
let file = File.ReadAllText(filePath)
let commits = file.Split([|lineBreak + lineBreak|], StringSplitOptions.RemoveEmptyEntries)
@vgaltes
vgaltes / parser.fs
Created December 13, 2015 11:09
Commit structure
type CommitInfo = {Hash : string; Author : string; TimeStamp : DateTime; Message : string}
type CommittedFile = {LinesAdded: int option; LinesDeleted: int option; FileName: string}
type Commit = {CommitInfo: CommitInfo; Files: CommittedFile[]}
@vgaltes
vgaltes / gitLog.log
Created December 13, 2015 11:04
Git log
[5ecc4f7],David Winchurch,2015-12-04,Merge branch 'hotfix/caching'
[f31f572],David Winchurch,2015-12-04,Disabling caching in web.config to fix css isues
0 1 src/SFA.Apprenticeships.Web.Manage/Web.config
0 1 src/SFA.Apprenticeships.Web.Recruit/Web.config
[2510743],David Winchurch,2015-12-04,Merge branch 'release/v2.6.0'
[dce63ed],David Winchurch,2015-12-04,Fixing changing employer for all paths. VacancyGuid was not being passed through
3 1 src/SFA.Apprenticeships.Web.Raa.Common/ViewModels/VacancyPosting/EmployerSearchViewModel.cs
1 1 src/SFA.Apprenticeships.Web.Recruit.UnitTests/Mediators/VacancyPosting/CloneVacancyTests.cs
2 2 src/SFA.Apprenticeships.Web.Recruit/Controllers/VacancyPostingController.cs
@vgaltes
vgaltes / git.cmd
Created December 13, 2015 11:00
Create a log
git log --pretty=format:'[%h],%aN,%ad,%s' --date=short --numstat > gitLog.log
@vgaltes
vgaltes / app.fsx
Created December 9, 2015 22:21
Gitlog parse
#r "../packages/FSharp.Data.2.2.5/lib/net40/FSharp.Data.dll"
open VGA.CodeMaatSharp
open System
open System.IO
open FSharp.Data
// Define your library scripting code here
// git log --pretty=format:'[%h],%aN,%ad,%s' --date=short --numstat > pollz.log
[<Literal>]
let lineBreak = "\r\n"
@vgaltes
vgaltes / HomeController.cs
Created December 6, 2015 22:05
Applying FillParameterFromActionName
[HttpPost]
[MultipleFormActionsButtonWithParameter(SubmitButtonActionName = "SpecifyIngredients")]
[FillParameterFromActionName(ParameterName = "ingredientIndex", ParameterType = TypeCode.Int32, SubmitButtonActionName = "SpecifyIngredients")]
public ActionResult UseIngredient(RecipeViewModel viewModel, int ingredientIndex)
{
...
}
@vgaltes
vgaltes / FillParameterFromActionName.cs
Created December 6, 2015 22:01
FillParameterFromActionName
public class FillParameterFromActionName : ActionFilterAttribute
{
public string ParameterName { get; set; }
public string SubmitButtonActionName { get; set; }
public TypeCode ParameterType { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
@vgaltes
vgaltes / MultipleFormActionsButtonWithParameterAttribute.cs
Created December 6, 2015 21:51
MultipleFormActionsButtonWithParameterAttribute
[AttributeUsage(AttributeTargets.Method)]
public class MultipleFormActionsButtonWithParameterAttribute : ActionNameSelectorAttribute
{
public string SubmitButtonActionName { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
var value = controllerContext.Controller.ValueProvider.GetValue(SubmitButtonActionName);
string realActionName;
var isValid = false;