marceloviana
marceloviana
Reputation Top 1%
Marcelo Viana
10 Snippets  (79th place)
Published
1 Channel
Created
4 Channels
Following
Dec 23, 2016
Last Visit
Sep 29, 2016
Registered
228 points  (104th 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 Dec 19, 2016  100  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  97  2  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  57  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  97  1  3  0

Resolver problema de acentuação no python


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

public by marceloviana created Oct 4, 2016  164  3  3  1

Python acessando banco de dados SQL Server

----------------INSTALAR--------------------------
apt-get install python freetds-common
apt-get install python-pymssql

apt-get purge python-pymssql
apt-get install freetds-dev
pip install Cython
pip install pymssql

--------------------TESTE.PY------------------------------
import pymssql

conn=pymssql.connect(host='xx.xx.xx.xx', user='sa', password='xxxxxxxx', database='teste')
cur=conn.cursor()	
cur.execute("SELECT  nomes from usuarios")

for row in cur:
	print row

conn.commit()	
conn.close()

	
;