Skip to content

Instantly share code, notes, and snippets.

@munirwanis
munirwanis / UsingTestMethods
Created June 11, 2015 17:53
Projeto de testes no VisualStudio
[TestClass]
public class UnitTest1 {
[TestMethod]
public void TestCalcSoma() {
int x = 10;
int y = 20;
int result;
Calc calc = new Calc();
@munirwanis
munirwanis / ConsoleMenu
Created June 11, 2015 17:59
Menu em console application
#region Menu
public static void Menu(AuthenticateRequestDTO authRequest, AuthenticateResponseDTO authResponse)
{
var readKey = Console.ReadKey(false).GetHashCode() - 48; // -48 porque está em hashcode, e 1 em hash é 49, por exemplo.
Console.WriteLine("---- Main Menu ----\n");
switch (readKey)
{
case 1:
authResponse = AuthenticatePost(authRequest);
break;
// A variável de entrada pode ser qualquer outra coisa, ou nada, é só trocar o item abaixo
// Função para montar o body do email
public string GetMailBody(List<T> resultToMail) {
var body = new StringBuilder();
body.AppendLine("<html><head>");
body.AppendLine(@"<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
@munirwanis
munirwanis / quote_comma.sublime-macro
Created November 14, 2016 16:30
Every time you want to run queries on SQL and have a lot of items without the ' ', caracteres you can run this macro on sublime and it'll do the job
[
{
"command": "select_all"
},
{
"command": "split_selection_into_lines"
},
{
"args": {
"extend": false,
using System.Linq;
using System.Collections.Generic;
public static class Groups
{
// "()" "{}" or "[]"
private static Dictionary<char, char> matches = new Dictionary<char, char> {
{ '(', ')' },
{ '{', '}' },
{ '[', ']' },
};
@munirwanis
munirwanis / get_cocoapods_token.sh
Last active June 19, 2017 17:05
iOS Development helpers
# Search for token
pod trunk me --verbose
# or use this command instead
cat ~/.netrc
# will result:
# machine trunk.cocoapods.org
# login user@example.com
# password 0000000011111111
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@munirwanis
munirwanis / LocaleExtension.swift
Last active December 8, 2017 00:52
Used to bring all country names directly from NSLocale
//
// LocaleExtension.swift
//
//
// Created by Munir Wanis on 02/11/17.
// Copyright © 2017 Munir Xavier Wanis. All rights reserved.
//
import Foundation
@munirwanis
munirwanis / ArrayExtension.swift
Created December 9, 2017 18:50
Reduce String array to a single String separated by new lines.
extension Sequence where Iterator.Element == String {
var reduced: String {
return self.reduce("", { $0 == "" ? $1 : $0 + "\n" + $1 })
}
}
@munirwanis
munirwanis / estados-cidades.json
Created December 23, 2017 14:08 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",