Skip to content

Instantly share code, notes, and snippets.

View weslley39's full-sized avatar
🤘
Awesome

Weslley Neri weslley39

🤘
Awesome
View GitHub Profile
@weslley39
weslley39 / Identificação_Comentarios
Created April 9, 2014 14:37
Identificação_Comentarios
Marcador: Significado
TODO: Elementos ainda não implementados
FIXME: Código que sabidamente apresenta problemas
HACK: Solução admitante deselegante para um problema
XXX: Perigo! Há um grande problema aqui
@weslley39
weslley39 / Geerate_Mongodb_Id_C#
Created April 10, 2014 13:16
Geerate_Mongodb_Id_C#
(string)StringObjectIdGenerator.Instance.GenerateId(null, null)
@weslley39
weslley39 / BaseController MVC
Created April 18, 2014 17:53
BaseController MVC
public class BaseController : Controller
{
protected override void Initialize(RequestContext requestContext)
{
base.Initialize(requestContext);
ViewBag.Title = "SpedStock";
ViewBag.Footer = "<p class='pull-right'>Designed by <a href='http://arcnet.com.br/' target='_BLANK'>ARCNET</a></p>" +
"<p>SPEDSTOCK® " + DateTime.Now.Year + ". Todos os direitos Reservados.</p>";
}
@weslley39
weslley39 / Show Img Mongo C#
Created May 8, 2014 15:18
Show Img Mongo C#
public FileContentResult MostraImagem(string id)
{
var imagem = FileService.BuscarPorId(id).OpenRead();
byte[] imagemEmBytes = new byte[imagem.Length];
using (BinaryReader leitor = new BinaryReader(imagem))
{
imagemEmBytes = leitor.ReadBytes((int)imagem.Length);
}
@weslley39
weslley39 / Update SubDocument in Mongo
Created June 3, 2014 14:26
Update Sub document in mongodb with mongoc# driver
Repository.Update(Query<Ecf>.EQ(x => x.Id, id),Update<Ecf>.Push(x => x.Totalizadores, totalizador));
Repository.UpdateById(id, Update<Ecf>.Push(x => x.Totalizadores, totalizador));
@weslley39
weslley39 / DecimalWorkaspMvc
Created June 27, 2014 18:11
Work W/ Decimal ASP MVC
public class DecimalModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext,
ModelBindingContext bindingContext)
{
ValueProviderResult valueResult = bindingContext.ValueProvider
.GetValue(bindingContext.ModelName);
ModelState modelState = new ModelState { Value = valueResult };
object actualValue = null;
try
@weslley39
weslley39 / Call_Angular_Controller
Created June 30, 2014 19:53
Call angular controller from outside
var controller = angular.element('[ng-controller="CatController"]').scope();
controller.CarregaEcfs();
@weslley39
weslley39 / Resize-Image-C#
Created July 1, 2014 18:41
Resize the image in C# for the size that you want, in format of PNG
int newHeight = 110;
int newWidth = 110;
//REDIMENCIONA A IMAGEM PARA 110X110 EM PNG
if (!string.IsNullOrEmpty(avatarIdAntigo)) _fileService.ExcluirPorId(avatarIdAntigo);
Image streamToImage = Image.FromStream(imagem.InputStream);
Bitmap newImageResized = new Bitmap(newWidth, newHeight);
using (Graphics gr = Graphics.FromImage(newImageResized))
{
gr.SmoothingMode = SmoothingMode.HighQuality;
@weslley39
weslley39 / Firefox_Hack_Css
Created July 16, 2014 15:32
Firefox Hack
@-moz-document url-prefix() {
.selector {
color:lime;
}
}
@weslley39
weslley39 / Install-Node-Ubuntu
Created July 22, 2014 14:49
Installing the latest version of NodeJs on Ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs