Skip to content

Instantly share code, notes, and snippets.

Nicolás Herrera nicolocodev

Block or report user

Report or block nicolocodev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nicolocodev
nicolocodev / funcyCSharp.cs
Created May 8, 2017 — forked from BillWagner/funcyCSharp.cs
local functions and lambdas and expressions, oh my
View funcyCSharp.cs
static void Main(string[] args)
{
Func<int> foo = () =>
{
int M1()
{
return 19;
}
return M1() + M2();
View Free.fsx
type User = {
username : string
password : string
}
type Error = string
type UseCase<'a> =
| Notify of Error * 'a
| UserExist of User * (bool -> 'a)
@nicolocodev
nicolocodev / program.cs
Last active Feb 22, 2017
String indexers à la NancyFX
View program.cs
internal class Program
{
private static void Main()
{
//scan modules
var modules = new List<Module>
{
new FooModule()
};
View Free.fsx
type DSL<'next> =
| Get of string * (string -> 'next)
| Set of string * string * 'next
| End
with static member fmap f = function
| Get (k, c) -> Get (k, f << c)
| Set (k, v, c) -> Set (k, v, f c)
| End -> End
type FreeDSL<'a> =
@nicolocodev
nicolocodev / readme.md
Created Jan 30, 2017
Free monad interpreter
View readme.md

Free monad interpreter pattern

This code has been taken from this two awesome blog posts

I only added the code that shows how to interact with other monads (Either Validation) in several ways and compose programs. Long live to Functors!

{-# LANGUAGE DeriveFunctor #-}

module Main where
  --import Control.Monad
@nicolocodev
nicolocodev / readme.md
Created Sep 25, 2016
Preguntas comunes de EF que siempre olvido
View readme.md

Cómo actualizar una entidad solo por el ID

public void ChangePassword(int userId, string password)
{
  var user = new User() { Id = userId, Password = password };
  using (var db = new MyEfContextName())
  {
    db.Users.Attach(user);
    db.Entry(user).Property(x => x.Password).IsModified = true;
@nicolocodev
nicolocodev / command-api.ps1
Created Jul 26, 2016 — forked from jasonmitchell/command-api.ps1
PowerShell script for publishing websites to Azure using Kudu
View command-api.ps1
$username = "$my-website"
$password = "password"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$apiUrl = "https://my-website.scm.azurewebsites.net/api/command"
$commandBody = @{
command = "del /S /F /Q .\\"
dir = "site\\wwwroot"
}
View curl.sh
curl 'http://localhost:9000/api/projects' -H 'Accept: application/json' | python -m json.tool
curl 'http://localhost:9000/api/projects/c2a91da6-5e73-4ec0-89d6-4e2866134bdd' -H 'Accept: application/json'
curl -H "Content-Type: application/json" -X POST -d '{"title":"Este es el creado","description":"Esta es la descripcion"}' http://localhost:9000/api/projects
@nicolocodev
nicolocodev / global.asax.fs
Created Apr 1, 2016
using "vertical slices" on fsharp web proj
View global.asax.fs
namespace FSharpWeb1
open System
open System.Net.Http
open System.Web
open System.Web.Http
open System.Web.Mvc
open System.Web.Routing
open System.Web.Optimization
You can’t perform that action at this time.