Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
@jrgcubano
jrgcubano / build.cake
Last active December 23, 2017 20:20
build.cake ASCII Colored Logo
/// Start Colors.Net
/// paste code to because the original libray is using NetStandard 2.0
/// https://github.com/ahmelsayed/Colors.Net
public static class StringStaticMethods
{
public static string Black(string value)
{
var color = Data.ConsoleColorToUnicode[ConsoleColor.Black];
return $"{color}{value}{color}";
}
@jrgcubano
jrgcubano / day1.cs
Last active December 15, 2017 16:13
Advent of Code 2017: Programmed with C# using Linqpad and RoslynPad
// http://adventofcode.com/2017/day/1
var input = "51629928149116951271942527619459642429126871269715586365184693792592845695881362442815621846833142385842261347196216575642383775685651975452498575976374755971125797736122835767829357269883975444475289883531339981574856251995832992791186165478421635548931999556629749983629598594389937361522337527123112891474527318449891524148839376167679991438526545998392374314655546517788649197996246591888839666423369324398396941268256179962878956929437455457567736821972414253678964912175858299134553763988885811376373851851118443985422338686876418913396454372194116978627478177565899132933175967994334221757853264351961529642439648766945145372811311474821717782687495346643543612916529537915722634578675689993574733678516174548793372152723939411872151719584918667681423288741317558732721414487689824857124851712179676624881736661433391515479698361217428123784616512911498845318884474511979864331485787152775783126529884683332786378134155938123845832278619237948745567156375712353425
@jrgcubano
jrgcubano / DispatchBenchmark.cs
Created December 13, 2017 08:47 — forked from heemskerkerik/DispatchBenchmark.cs
Benchmark of different double dispatch methods in C#
// depends on BenchmarkDotNet 0.10.10
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Running;
@jrgcubano
jrgcubano / main.cs
Created November 22, 2017 14:45
New Public Gist
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
public class GithubRepository
{
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public string Homepage { get; set; }
@jrgcubano
jrgcubano / multiUpdatePullExample.js
Last active November 8, 2017 20:20
Mongo collection multiple update with pull test
// candidate a producto
// get elemecodes from candidate
var canditateId = "";
var elemCodes = [ "1", "2", "3"];
// var candidates = monnog.
candidates.update(
{ _id: { $ne: canditateId }, elems: { code: { $in: elemCodes } } },
{ $pull: { elems: { $elemMatch: { code: { $in: elemCodes } } } } } ,
{ multi: true },
function (err) {
@jrgcubano
jrgcubano / Roslyn.CodeGeneration.Program.cs
Created October 31, 2017 09:00 — forked from cmendible/Roslyn.CodeGeneration.Program.cs
Create a class with dotnet core and roslyn with using statements outside the namespace
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Roslyn.CodeGeneration
{
public class Program
{
public static void Main(string[] args)
@jrgcubano
jrgcubano / prettiervscode.json
Created September 28, 2017 15:36
Prettier vscode settings
{
/* Prettier */
// Fit code within this line limit
"prettier.printWidth": 80,
// Number of spaces it should use per tab
"prettier.tabWidth": 2,
// If true, will use single instead of double quotes
"prettier.singleQuote": true,
// Controls the printing of trailing commas wherever possible. Valid options:
@jrgcubano
jrgcubano / create_github_tag.sh
Created September 23, 2017 00:19 — forked from cliffparnitzky/create_github_tag.sh
Simple way to create a tag via git shell and push it to repo
# creat a tag (more infos at: http://git-scm.com/book/de/ch2-12.html)
git tag -a 1.0.0 -m 'Version 1.0.0'
git push origin 1.0.0
git tag -a 1.0.0.alpha1 -m 'Version 1.0.0 alpha1'
git push origin 1.0.0.alpha1
# delete a tag
git tag -d 1.0.0
git push origin :refs/tags/1.0.0
// library or otherwise
// {
type Func<T, TResult> = (value: T) => TResult;
type Predicate<T> = Func<T, boolean>;
function compose<TIn, TMiddle, TOut>(f: Func<TMiddle, TOut>, g: Func<TIn, TMiddle>) {
return (value: TIn) => f(g(value));
}
@jrgcubano
jrgcubano / app.component.html
Last active August 22, 2017 06:29
Angular geo directive test (suncalc, https://stackblitz.com/edit/angular-fkdp2e) WIP
<div class='app-container'>
<span geo>
My love
</span>
</div>