Skip to content

Instantly share code, notes, and snippets.

View vquaiato's full-sized avatar
:octocat:
am I working?

Vinicius Quaiato vquaiato

:octocat:
am I working?
View GitHub Profile
@vquaiato
vquaiato / Startup.cs
Created January 12, 2016 18:51
Startup.cs usando middleware MVC e Custom Logging
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@vquaiato
vquaiato / replica_set.sh
Created May 20, 2015 19:17
mongodb replicaset configured :bowtie:
jarvis:PRIMARY> rs.status()
{
"set" : "jarvis",
"date" : ISODate("2015-05-20T19:15:31Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "[SERVER1]:27017",
"health" : 1,
public static class MongoDynamic
{
private static System.Text.RegularExpressions.Regex objectIdReplace = new System.Text.RegularExpressions.Regex(@"ObjectId\((.[a-f0-9]{24}.)\)", System.Text.RegularExpressions.RegexOptions.Compiled);
/// <summary>
/// deserializes this bson doc to a .net dynamic object
/// </summary>
/// <param name="bson">bson doc to convert to dynamic</param>
public static dynamic ToDynamic(this BsonDocument bson)
{
var json = objectIdReplace.Replace(bson.ToJson(), (s) => s.Groups[1].Value);
@vquaiato
vquaiato / foreach_with_index.cs
Created May 15, 2015 22:27
foreach with index in C#
foreach ( var it in someCollection.Select((x,i) => new { Value = x, Index=i }) )
{
if ( it.Index > SomeNumber) {// }
}
//or
public static void Each<T>( this IEnumerable<T> ie, Action<T, int> action )
{
var i = 0;
@vquaiato
vquaiato / parameterize.py
Created May 15, 2015 17:23
.parameterize like in Python 3.4.x
def parameterize(string_to_clean, sep = '-'):
parameterized_string = unicodedata.normalize('NFKD', string_to_clean).encode('ASCII', 'ignore').decode()
parameterized_string = re.sub("[^a-zA-Z0-9\-_]+", sep, parameterized_string)
if sep is not None and sep is not '':
parameterized_string = re.sub('/#{re_sep}{2,}', sep, parameterized_string)
parameterized_string = re.sub('^#{re_sep}|#{re_sep}$', sep, parameterized_string, re.I)
return parameterized_string.lower()
@vquaiato
vquaiato / on.md
Last active August 29, 2015 14:14
working integration from git bash

1. Create the shell script

#!/bin/bash
curl -X POST --data-urlencode "task=$1" https://api.workingon.co/hooks/incoming?token={YOUR WORKING ON INTEGRATION TOKEN} >/dev/null
echo "Task sent!";

Save this wherever you want (I am saving under my $HOME folder on Windows), you don´t even need to add a file extension to it ;)

@vquaiato
vquaiato / job.ps1
Created January 29, 2015 17:39
using background jobs in powershell
$jobItems = "a", "b", "c", "d", "e"
$jobMax = 2
$jobs = @()
$jobWork = {
param ($MyInput)
if ($MyInput -eq "d") {
throw "an example of an error"
} else {
write-output "Processed $MyInput"
#------------------------------------------------------------------------------
# Rotinas para verificação de CPF e CNPJ
# Linguagem: Ruby
# Escrito por: André Camargo < andre@boaideia.inf.br > http://blog.boaideia.inf.br
# Use, copie, melhore a vontade! Patches são bem-vindos...
#------------------------------------------------------------------------------
def check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
gem 'thin'
@vquaiato
vquaiato / lotes.txt
Last active December 16, 2015 23:59
Lotes magic
Raras - 37
Incomuns - 496
Comuns - 1513
Terrenos Básicos - 152