Skip to content

Instantly share code, notes, and snippets.

Avatar

Vicente de Alencar vicentedealencar

View GitHub Profile
@vicentedealencar
vicentedealencar / HelloMessage.js
Last active Jun 23, 2016 — forked from steida/HelloMessage.js
React stateless components with lifecycle proposal
View HelloMessage.js
const HelloMessage = props => <div>Hello {props.name}</div>
HelloMessage.intialState = { isMounted: false }
const focusAfterAfterOneSec = el => {
setTimeout(() => {
if (!isMounted) return;
el.focus();
}, 1000);
}
@vicentedealencar
vicentedealencar / winjs bolierplate
Created Apr 14, 2016
inspired on react philosophy
View winjs bolierplate
// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
"use strict";
var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
@vicentedealencar
vicentedealencar / InspectableContext.cs
Created Jan 23, 2016
fix owin context to read/write request/response
View InspectableContext.cs
using Microsoft.Owin;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace CyberBar.BaseAPI.Infrastructure
{
public class InspectableContext : IDisposable
{
View JsonExtensions.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace CyberBar.BaseAPI.Util
{
public static class JsonExtensions
{
private static JsonSerializerSettings _settings = new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
@vicentedealencar
vicentedealencar / HttpExtensions.cs
Created Jan 23, 2016
var payload = await client.SendAsync(request).ReadAs<PayloadModel>();
View HttpExtensions.cs
using log4net;
using System;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
namespace CyberBar.BaseAPI.Util
{
public static class HttpExtensions
View main.js
import React, { Component } from 'react';
import CheckoutContainer from './containers/CheckoutContainer';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import * as reducers from './reducers';
import { pouchMiddleware, getState } from './redux-pouchdb';
getState().then(initialState =>{
const createStoreWithMiddleware = applyMiddleware(thunk, pouchMiddleware)(createStore);
View ProtocolController.cs
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyNamespace
{
View BaseUser.cs
using System;
using System.Diagnostics.CodeAnalysis;
using System.Security.Cryptography;
using System.Text;
using Raven.Client.UniqueConstraints;
namespace Miyagi.Core.Models
{
[ExcludeFromCodeCoverage]
public abstract class BaseUser
View AutoMapperExtensions.cs
using AutoMapper;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Miyagi.Common.Helpers
{
public static class AutoMapperExtensions
{
public static List<TResult> MapTo<TResult>(this IEnumerable self)
@vicentedealencar
vicentedealencar / fiddle.js
Last active Dec 16, 2015
Faça um página que calcula a área de determinadas figuras geométricas, exibindo-a. O programa deverá apresentar um menu com as opções abaixo e deverá permitir que o usuário escolha qualquer uma das opções, quantas vezes desejar até que escolha a opção de fim (5). 1 - quadrado (lado*lado) 2 - retângulo (comprimento * largura) 3 - círculo (3,14 * …
View fiddle.js
var formulas = {
q: function () {
return Math.pow(~~prompt('lado'), 2);
},
r: function () {
return ~~prompt('comprimento') * ~~prompt('largura');
},
c: function () {
return Math.PI * Math.pow(~~prompt('raio'), 2);
},
You can’t perform that action at this time.