marceloviana
marceloviana
Reputation Top 1%
Marcelo Viana
11 Snippets  (70th place)
Published
1 Channel
Created
4 Channels
Following
Mar 31, 2017
Last Visit
Sep 29, 2016
Registered
258 points  (95th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Trend Maker
Junior Autobiographer
Senior Autobiographer

Recent Snippets See all snippets by marceloviana

public by marceloviana created Mar 29, 2017  56  0  3  0

Converte string em UFT-8

byte[] bytes = Encoding.Default.GetBytes(myString);
myString = Encoding.UTF8.GetString(bytes);
;

public by marceloviana created Dec 19, 2016  201  0  3  0

Formatar double para ,00

//Converte double 

double valor = double.Parse("100".ToString());

string.Format("{0:n2}", decimal.Parse(valor.ToString())
;

public by marceloviana created Dec 5, 2016  153  3  3  1

Csharp ler Json e percorrer

var url = "http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
var sysnClient = new WebClient();
string content = sysnClient.DownloadString(url);

            
List<divida> lista_dados = new JavaScriptSerializer().Deserialize<List<cliente>>(content);

string nomecompleto = "";

foreach (divida registro in lista_dados) {
  nome_completo = registro.nome_completo;
}

txt_nomecompleto.Text = nomecompleto;
;

public by marceloviana created Nov 14, 2016  95  0  3  0

Csharp consumindo Rest + lendo JSON

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ExemploChatBot
{
    public partial class Chat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void enviar_Click(object sender, EventArgs e)
        {
            string txt_campo_texto = campo_texto.Text;

            var url = "http://128.0.0.1:5000/site?id=2542&texto_digitado="+ txt_campo_texto + "";

            var syncClient = new WebClient();
            var content = syncClient.DownloadString(url);            

            dynamic registro = JObject.Parse(content);
            campo_texto.Text = registro.pergunta;

        }
    }
}
;

public by marceloviana created Nov 10, 2016  159  1  3  0

Resolver problema de acentuação no python


import sys 
reload(sys)
sys.setdefaultencoding('utf-8')
;