Skip to content

Instantly share code, notes, and snippets.

View alexsandro-xpt's full-sized avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
var pFp = new PluralFormatProvider();
Console.WriteLine(string.Format(pFp, "Lendo página {0} com {1:bloco;blocos} de imagem", page.Key, page.Value.Length));
<script>
export default {
props: {
title: {
required: true,
type: String,
},
open: false,
},
computed: {},
Imports System.Data
Imports System.DirectoryServices
Imports System.Globalization
Public Class MainWindow
#Region " Fields "
Private WithEvents bgWorker As System.ComponentModel.BackgroundWorker
@alexsandro-xpt
alexsandro-xpt / ContainerModule.cs
Created July 18, 2016 18:14
IoC PerHttpRequestLifetime
using System;
using System.Configuration;
using System.IO;
using Application.Interfaces.ApplicationServices;
using Application.Services;
using Domain;
using Domain.Interfaces.Context;
using Domain.Interfaces.Repository;
using Infrastructure.Context;
using Infrastructure.Crosscutting.Validator;
@alexsandro-xpt
alexsandro-xpt / PluralFormatProvider.cs
Last active July 14, 2016 15:40
Base at http://stackoverflow.com/questions/3875312/clever-way-to-append-s-for-plural-form-in-net-syntactic-sugar -> Console.WriteLine(String.Format( new PluralFormatProvider(), "You have {0:life;lives} left, {1:apple;apples} and {2:eye;eyes}.", 1, 0, 2) );
public class PluralFormatProvider : IFormatProvider, ICustomFormatter
{
public object GetFormat(Type formatType)
{
return this;
}
public string Format(string format, object arg, IFormatProvider formatProvider)
@alexsandro-xpt
alexsandro-xpt / loopElements.cs
Created June 16, 2016 19:52
Buffering reading like a stream read.
for (int i = 0, k = 0; i < xElements.Length; i += k)
{
var list = new List<XElement>();
var blocktype = xElements[i].Attribute("blocktype").Value;
list.Add(xElements[i]);
for (var j = i + 1; j < xElements.Length && blocktype == xElements[j].Attribute("blocktype").Value; j++)
{
list.Add(xElements[j]);
}
@alexsandro-xpt
alexsandro-xpt / DataflowDemo.cs
Last active June 7, 2016 20:49
Processando 10 itens de uma vez dado uma lista com DataFlow, inspirado em http://blog.stephencleary.com/2012/11/async-producerconsumer-queue-using.html
class Program
{
static int index = 0;
private static async Task Produce(BufferBlock<string> queue, IEnumerable<string> values)
{
foreach (var value in values)
{
await queue.SendAsync(value);
}
@alexsandro-xpt
alexsandro-xpt / System Design.md
Created May 5, 2016 21:30 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@alexsandro-xpt
alexsandro-xpt / squash-commits.sh
Created February 29, 2016 15:33 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@alexsandro-xpt
alexsandro-xpt / gist:11a0e0b5f74c77bfb594
Last active September 11, 2015 14:20 — forked from ctolkien/gist:719c6ce5861c9155289c
ASP.Net 5 Gulp + Webpack
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var ts = require('gulp-typescript');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var dnx = require("gulp-dnx");
gulp.task('webpack', function(){
return gulp.src('./src/client/main.ts')
.pipe(webpack({
output:{