Skip to content

Instantly share code, notes, and snippets.

View fredyfx's full-sized avatar
💭
With all the power 2.0!

Fredy R. Guibert フレディ fredyfx

💭
With all the power 2.0!
View GitHub Profile
@fredyfx
fredyfx / ejemplo.js
Created July 16, 2016 04:53
Ayuda para los desarrolladores que tenemos la "suerte" de toparnos con DevExpress en ASP.net MVC y que necesitamos jugar con las validaciones en el lado del cliente
HabilitarInputDevExpress(NombreDelElemento);
function DeshabilitarInputDevExpress(element) {
element.SetEnabled(false);
$(element.GetMainElement()).css('background-color', '#F2F2F2');
$(element.GetInputElement()).css('background-color', '#F2F2F2');
}
function HabilitarInputDevExpress(element) {
element.SetEnabled(true);
@fredyfx
fredyfx / NVARCHAR-DateTime.sql
Created July 29, 2016 18:18
Cuando guardan la fecha en formato NVARCHAR y necesitas trabajarla como DateTime
/*Obtenemos todos los datos por separado*/
declare @anio nvarchar(4) = substring('20140120201508',1,4)
declare @mes nvarchar(2) = substring('20140120201508',5,2)
declare @dia nvarchar(2) = substring('20140120201508',7,2)
declare @hora nvarchar(2) = substring('20140120201508',9,2)
declare @minuto nvarchar(2) = substring('20140120201508',11,2)
declare @segundo nvarchar(2) = substring('20140120201508',13,2)
/*Le damos el formato que buscamos*/
declare @cadenaAFormatear nvarchar(20) = concat(@anio,'-',@mes,'-', @dia,' ',@hora,':',@minuto,':',@segundo)
select FORMAT(cast(@cadenaAFormatear as datetime),'yyyy-MM-dd HH:mm:ss') as FechaFormateada
@fredyfx
fredyfx / BundleInstall.md
Created December 15, 2016 09:40 — forked from jkarsrud/BundleInstall.md
How to use ASP.NET Bundling and Minifications in Umbraco

How to use ASP.NET Bundling and Minifications in Umbraco

Using the ASP.NET bundling and minifications is pretty straight forward, but here is a small guide that take care of a few gotchas when implementing bundles in your Umbraco project.

Installing ASP.NET Bundling and Minifications

ASP.NET Bundling and Minifications is part of the Microsoft ASP.NET Web Optimization Framework and is installed via NuGet;

PM> Install-Package Microsoft.AspNet.Web.Optimization

Once this is done, you need to create a BundleConfig.cs in your App_Start1 folder. This is where you register your different bundles. It can be extremely simple, or it can be more complex, but the gist of it is this;

function format1(n, currency) {
return currency + " " + n.toFixed(2).replace(/./g, function(c, i, a) {
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
});
}
function format2(n, currency) {
return currency + " " + n.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,");
}
var date = new Date("01/21/2017");
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd = date.getDate().toString();
// CONVERT mm AND dd INTO chars
var mmChars = mm.split('');
var ddChars = dd.split('');
// CONCAT THE STRINGS IN YYYY-MM-DD FORMAT
@fredyfx
fredyfx / generarTabla.js
Created August 9, 2017 00:15
Crear tabla HTML a partir de JSON con un orden especifico
function RenderizarTabla(dataJsonParaRender) {
var tabla = $("#resultado");
var tabla = $("#resultado").html("");
$.each(dataParaRender, function (rowIndex, r) {
var row = $("<tr/>");
//Aqui viene el detalle:
//el JSON puede estar desordenado y lo forzamos a trabajar con el orden que definamos
var myCustomIndex = ["columna1", "columna3", "columna4", "columna8", "columna11"];
myCustomIndex.forEach(function (index, value) {
row.append($("<td/>").text(r[index]));
@fredyfx
fredyfx / googleMaps.html
Created August 21, 2017 18:54
This open a marker from an anchor which technically could be any kind of event listener.
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
var markers = [];
function initialize() {
var mapOptions = {
zoom: 10,
center: new google.maps.LatLng(40.714364, -74.005972),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
@fredyfx
fredyfx / LICENSE.txt
Created September 7, 2017 23:30 — forked from jed/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@fredyfx
fredyfx / generateUUID.js
Created September 7, 2017 23:32
Genera Unique Identifiers en javascript. Extraído desde: https://stackoverflow.com/a/2117523/3613462
//Update, 2017-06-28: A good article from Chrome developers discussing the state of Math.random PRNG quality in Chrome, Firefox, and Safari. tl;dr - As of late-2015 it's "pretty good", but not cryptographic quality. To address that issue, here's an updated version of the above solution that uses ES6, the crypto API, and a bit of JS wizardy I can't take credit for:
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
console.log(uuidv4());
@fredyfx
fredyfx / crypt.cs
Created October 5, 2017 21:23
encriptar y desencriptar, código gracias a mi hermano @flxtr de StackOverflow en Español.
public class Security
{
static readonly string PasswordHash = "Fr4m3w0rk@#H4sH";
static readonly string SaltKey = "Fr4m3w0rk@#K3Y";
static readonly string VIKey = "@Fr4m3w0rk@#V1K3Y";
public static string Encrypt(string plainText)
{
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);