Skip to content

Instantly share code, notes, and snippets.

View renatoeufe's full-sized avatar
🏠
Working from home

Renato E F renatoeufe

🏠
Working from home
View GitHub Profile
@renatoeufe
renatoeufe / Program.cs
Created November 10, 2017 21:44
Exemplo de criação de usuários
using IdentityModel.Client;
using Newtonsoft.Json;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Client
{
public class Program
@renatoeufe
renatoeufe / ExampleUsage.cs
Created July 24, 2017 13:05 — forked from NickCraver/ExampleUsage.cs
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Thinktecture.IdentityServer.Core;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
@renatoeufe
renatoeufe / AspNetWebFormsInvokeIdSrvChallenge.cs
Created November 18, 2015 05:16
AspNetWebFormsInvokeIdSrvChallenge
if (!Request.IsAuthenticated)
{
HttpContext.Current.GetOwinContext().Authentication.Challenge(
new AuthenticationProperties
{
RedirectUri = "http://localhost:2671/Default"
},
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
@renatoeufe
renatoeufe / gist:6547266
Created September 13, 2013 06:26
deferred
var FunctionOne = function () {
var
a = $.Deferred(),
b = $.Deferred();
// some fake asyc task
setTimeout(function () {
console.log('a done');
a.resolve();
}, Math.random() * 4000);
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
namespace DemoSignalR.Web.Hubs
{
[HubName("formaHub")]
public class FormaHub : Hub
{
public void MoverForma(int x, int y)
{
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>SignalR - Mover Forma</title>
<style>
#forma
{
width: 50px;
@renatoeufe
renatoeufe / gmaps.marker-extensions.js
Created February 25, 2013 04:57
recuperar lat e lng do google maps com marker draggable
window.google.maps.Marker.prototype.getLat = function () {
var position = this.getPosition();
return position[Object.keys(position)[0]];
};
window.google.maps.Marker.prototype.getLng = function () {
var position = this.getPosition();
return position[Object.keys(position)[1]];
};
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR.Client.Hubs;
namespace AsyncMessageSender
{
internal class Program
{
private const string PrivateKey = "bcf9f7ff-dd90-41ac-b737-dd0b93be3fc5";
private const string Url = "http://localhost:6398";
@renatoeufe
renatoeufe / async await sample c# 4.5
Created September 5, 2012 20:52
Exemplo de Async/Await C# 4.5
using System;
using System.Threading.Tasks;
namespace Exemplo.AsyncAwait
{
class Program
{
static void Main(string[] args)
{
Exec();