Skip to content

Instantly share code, notes, and snippets.

@fernandezja
fernandezja / autocomplete-jqueryui-rendermenu
Last active August 29, 2015 14:02
Como agregar un item mas sobreescribiendo el _renderMenu de jQuery Autocomplete
var jedisAutoComplete = $('#jedis').autocomplete({
minLength: 0,
source: ['Yoda', 'Obi-Wan Kenobi', 'Qui-Gon Jinn', 'Anakin Skywalker', 'Ki(-Adi - Mundi)']
}).focus(function () {
$(this).autocomplete('search', this.value);
});
//En versiones anteriores de jQueryUI 1.9 o anterior se obtenia la configuracin jedisAutoComplete.data('autocomplete')
jedisAutoComplete.data('uiAutocomplete')._renderMenu = function (ul, items) {
var self = this;
var atributosFormateados =
HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
var atributos = new StringBuilder();
foreach (var atributo in atributosFormateados)
{
atributos.AppendFormat("{0}=\"{1}\"", atributo.Key, atributo.Value);
}
...
//from System.Web.Mvc.HtmlHelper
public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes)
{
RouteValueDictionary result = new RouteValueDictionary();
if (htmlAttributes != null)
{
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(htmlAttributes))
{
result.Add(property.Name.Replace('_', '-'), property.GetValue(htmlAttributes));
@fernandezja
fernandezja / HexToStringConverter.cs
Created February 14, 2018 11:57
Converter de String to Hexadecimal / Convertidor de cadena a hexadecimal
using System;
using System.Text;
namespace HexToStringConverter
{
class Program
{
static void Main(string[] args)
{
var hex = StringToHexConvertidor("StarWars!");
@fernandezja
fernandezja / SerializeObjectToByteArray.cs
Created February 14, 2018 15:16
Serialize and Deserialize Object To Byte Array (with use Generics) / Serializar y deserializar object to byte array (utilizando Generics)
using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace SerializeObjectToByteArray
{
class Program
{
static void Main(string[] args)
@fernandezja
fernandezja / Details.cshtml
Created March 5, 2018 23:40
Controller ASP.NET Core With route attribute and anchor with TagHelper Route #aspnetcore asp-rute
@model Starwars.App.Web.Entities.Jedi
@{
ViewData["Title"] = "Details";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Details</h2>
Jedi: <strong>@Model.Name</strong>
@fernandezja
fernandezja / sparql-nodejs-virtuoso
Created November 21, 2018 22:12
Example connection NodeJS a OpenLink Virtuoso and query with Sparql > virtuoso-sparql-client
const {Client} = require('virtuoso-sparql-client');
const conn = new Client('http://192.168.0.102:8890/sparql');
conn.setOptions(
"application/json",
{"foaf": "http://xmlns.com/foaf/0.1/"}
);
var query = 'SELECT ?nombre ?edad WHERE { ?s foaf:name ?nombre; foaf:age ?edad}';
@fernandezja
fernandezja / completar-valores-columna-con-CTE.sql
Created January 29, 2019 21:10
Completar valores de columnas, basadas en valores anteriores
DECLARE @DemoTable TABLE (
ID INT NULL,
F_Inicio DATE NOT NULL
)
INSERT INTO @DemoTable
VALUES (1 , '2001-01-01'),
(NULL , '2001-02-02'),
(NULL , '2001-02-03'),
(2 , '2001-02-04'),
@fernandezja
fernandezja / completar-valores-columna-con-CTE.sql
Created January 29, 2019 21:11
Completar valores de columnas, basadas en valores anteriores . Ejemplo para https://es.stackoverflow.com/questions/233669/completar-valores-columna
DECLARE @DemoTable TABLE (
ID INT NULL,
F_Inicio DATE NOT NULL
)
INSERT INTO @DemoTable
VALUES (1 , '2001-01-01'),
(NULL , '2001-02-02'),
(NULL , '2001-02-03'),
(2 , '2001-02-04'),
@fernandezja
fernandezja / VerifyMSIinstalled.ps1
Created September 19, 2019 20:11
Verify if MSI is installed via powershell
#----------------------------------------------------------------------------------
# Verify if MSI is installed via powershell
#
# Example from https://stackoverflow.com/questions/4753051/how-do-i-check-if-a-particular-msi-is-installed
#----------------------------------------------------------------------------------
function Get-VerifyMSIinstalled([string]$DisplayName)
{
# paths: x86 and x64 registry keys are different
if ([IntPtr]::Size -eq 4) {