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 / 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"
@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 / 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()
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 / 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,
@vquaiato
vquaiato / asyncJqueryFormSubmit.js
Created December 9, 2010 21:00
submeter um form de maneira assíncrona usando JQuery
$(function () {
$('#contato').submit(function (e) {
e.preventDefault();
validar();
$.post($(this).attr("action"), $(this).serialize(), function (json) {
alert(json);
}, "json");
});
@vquaiato
vquaiato / gist:745910
Created December 17, 2010 23:40
trecho html
<nav class="sharing">
<ul>
<li class="facebook"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="/" show_faces="true" width="450"></fb:like></li>
<li><a href="#" class="compartilhe">Compartilhe</a></li>
<li><a href="#" class="mail">Enviar por E-Mail</a></li>
<li><a href="#" class="print">Versão para impressão</a></li>
</ul>
</nav>
..
...
@vquaiato
vquaiato / Teste muitas coisas
Created January 7, 2011 22:13
Testa muitas coisas
[Test]
20 public void GetMovesOneSquareForward_A7_ReturnsPromotions()
21 {
22 var wp = new WhitePawns(new Bitboard().Set(new Square("A7")));
23 var m = wp.GetMovesOneSquareForward();
24 var moves = m.GetEnumerator();
25
26
27 moves.MoveNext();
28 var f1 = moves.Current;
@vquaiato
vquaiato / build.proj
Created January 16, 2011 16:59
MSBuild file for the MVCTestsEx project
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="default">
<UsingTask AssemblyFile="$(MSBuildProjectDirectory)\..\lib\NuGetTasks\NuGet.MSBuild.dll" TaskName="NuGet.MSBuild.NuGet" />
<PropertyGroup>
<Configuration Condition="'$(Configuration)'==''" >Release</Configuration>
<BaseDir>$(MSBuildProjectDirectory)\..</BaseDir>
<BuildDir>$(BaseDir)\build</BuildDir>
<BuildDirBin>$(BaseDir)\build\bin</BuildDirBin>
@vquaiato
vquaiato / Sharepoint_select.cs
Created January 25, 2011 16:55
selecionando arquivos de uma biblioteca Sharepoint
StringBuilder str = new StringBuilder();
str.Append("<OrderBy> ");
str.Append(" <FieldRef Name='Data' Ascending='False' /> ");
str.Append("</OrderBy> ");
str.Append("<Where> ");
str.Append(" <Eq> ");
str.Append(" <FieldRef Name='Visivel' /> ");
str.Append(" <Value Type='Boolean'>1</Value> ");
str.Append(" </Eq> ");