dimanche 19 février 2012

http://sixrevisions.com/web-development/crazy-tips-help-become-better-coder/

7 Crazy Tips That Will Help You Become a Better Coder

 

 

 

http://visualstudiomagazine.com/articles/2012/02/01/2-great-javascript-data-binding-libraries.aspx

JavaScript libraries help you build powerful, data-driven HTML5 apps.

Toggle element JQuery

I don't who code this snippet but i like it :-)
(I also know there is the toggle function from JQuery)

Togger = function (e) {
    // Show the paragraph if it's hidden.
    var $paragraph = $(e.data);
    var $link = $(this);
    if ($paragraph.is(':hidden')) {
      $paragraph.show();
      $link.text('Click to hide');
     
    }
    // Hide the paragraph if it's visible.
    else {
      $paragraph.hide();
      $link.text(' Click to show');
    }
  };


$('#toggle-link-1').bind('click','#paragraph-1', Togger);
$('#toggle-link-2').bind('click','#paragraph-2', Togger);

Writing JavaScript without anonymous functions

Nice post on...

Javascript Encryption Decryption

JavaScript Encryption and Decryption

JavaScript Encryption and Decryption 2.0

vendredi 17 février 2012

Creating Checkboxes that Behave Like Radio Buttons with jQuery

Thanks to Imar for this 'tip'
http://imar.spaanjaars.com/562/creating-checkboxes-that-behave-like-radio-buttons-with-jquery

mercredi 15 février 2012

Knockout : Remove an item of an observable array

Steve shows us how to elegantly accomplish this operation

mardi 14 février 2012

Calculate an age given birthdate in Javascript

Nice tips :

jeudi 2 février 2012

KendoUI : Hiding Columns

Here is a little snippet to hide columns on dataBound event

function HideColumn(gridId,numColumn) {    
    $("#" + gridId +  " th:eq(" + numColumn + ")").hide();
    $("#" + gridId +  " td:nth-child(" + (numColumn+1) + ")").hide();
}

$(document).ready(function () {
     $("#grid").kendoGrid({

        dataBound : function(e) {          
             //RegisterGrid($("#grid").data("kendoGrid"));          
             HideColumn("grid",0);
        },
()

KendoUI : Row Selection

Here is an example which shows how to select a row and saving
a grid instance after creation.
Notice that we register the grid in 'dataBound' event, otherwise
we register an empty grid !!!

var grid;
     
function RegisterGrid(g) {
      grid = g;
      grid.select(grid.tbody.find(">tr").eq(3));         
}

$(document).ready(function () {
    var grid = $("#grid").kendoGrid({

        dataBound : function(e) {          
             RegisterGrid($("#grid").data("kendoGrid"));          
        },
        columns:
            [{
                field: "id",
                title: ""
            
           
            },
                {
                field: "Email",
               title: "Email"
            }],

        dataSource: {
            transport: {
                read: {
                    type: "POST",
                    url: "http://localhost/WebService.asmx/GetAdmin?name=Paul&age=12",
                    data: [],
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    async: true
                }
            },
            schema: {
                data: "d",
                model: {
                    fields: {
                        id: { type: "number" },
                        Email: { type: "string" }
                    }
                },
                total : function (r) {
                   
                }
            },
        },
        selectable: "row",
        navigatable: true,
        sortable: true,
        pageable: true,

        change: function (arg) {          
            var selected = $.map(this.select(), function (item) {
                alert(item.cells[0].innerHTML);                
            });
        },        
    });   
})

mardi 31 janvier 2012

Object Oriented JavaScript Class Library in C#/.NET Style

(...)Welcome to Object Oriented JavaScript class library in C#/.NET style.(...)

http://www.codeproject.com/Articles/22073/Object-Oriented-JavaScript-Class-Library-in-C-NET

Stanford Javascript Crypto Library

(...)The Stanford Javascript Crypto Library (hosted here on Stanford's server or here on GitHub) is a project by the Stanford Computer Security Lab to build a secure, powerful, fast, small, easy-to-use, cross-browser library for cryptography in Javascript.(...)

http://crypto.stanford.edu/sjcl/

jQuery Selectbox plugin

Very nice plugin.

http://www.bulgaria-web-developers.com/projects/javascript/selectbox/

KendoUI Grid and WebServices

Here is a simple example on how to do :

$(document).ready(function () {
        $("#grid").kendoGrid({
            columns: [
              {
                  field: "id",
                  title: "ID"
              },
              {
                  field: "Email",
                  title: "Email"
              }],

            dataSource: {
                transport: {
                    read: {
                        type : "POST",
                        url  : "http://localhost/WebService.asmx/GetAdmin",
                        data : null,
                        contentType : "application/json; charset=utf-8",
                        dataType: "json",
                        async: true
                    }
                },
                schema : {
                    data: "d"
                }
            }           
        });
    });

jeudi 19 janvier 2012

Ironpython hosting in SilverLight

Here is one of the simplest sample i could make to illustrate.
The only issue i encoutered was adding a reference to 'Microsoft.CSharp'

using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Scripting.Silverlight;


///
/// script.py => def Adder (x, y) : return x + y
///


namespace DLRSilverlight
{
    public partial class MainPage : UserControl
    {
        dynamic runtime = DynamicEngine.CreateRuntime().UseFile("script.py");
               
        public MainPage()
        {
            InitializeComponent();                  
        }
       
        private void button1_Click(object sender, RoutedEventArgs e)
        {            
            dynamic result = runtime.Adder(Convert.ToDouble(this.N1.Text), Convert.ToDouble(this.N2.Text));
            MessageBox.Show(String.Format("{0}", result));
        }        
    }
}

Active Directory with IronPython

Here is a little snippet

import clr
clr.AddReference("System.DirectoryServices")
from System.DirectoryServices import DirectorySearcher

class ADHelper(object):

    def __init__(self, strLDAP = "LDAP://******"):
        self.searcher  =  DirectorySearcher(strLDAP)

    def searchUserByLogin(self,user,*prop):
        """        
        searchUserByLogin("alogin","cn","sn",'SAMAccountName')
        """        
        str = ""
        self.searcher.Filter = "(sAMAccountName=%s)"%user
        self.searcher.PropertiesToLoad.Add("cn")
        self.searcher.PropertiesToLoad.Add("SAMAccountName")
        self.searcher.PropertiesToLoad.Add("givenName")
        self.searcher.PropertiesToLoad.Add("sn")   
        result = self.searcher.FindOne()
        for option in prop:
            str +=  (option + " : " + result.Properties[option][0] + " ")
        return str
    
ad = ADHelper()
print ad.searchUserByLogin("alogin","cn","sn",'SAMAccountName')

mercredi 18 janvier 2012

C# 4.0 First Look :: Dynamic Keyword and Calling Python from C#

C# 4.0 First Look :: Dynamic Keyword and Calling Python from C# « AbdulMoniem's Thoughts

Dynamic keyword, Ironpython and Silverlight

Dynamic keyword, Ironpython and Silverlight? - IronPython - Python on .NET & Mono | Google Groupes

Using an IronPython object from C#

Jorge Fioranelli: Using an IronPython object from C#

 

Calling Python from C#

Calling Python from C# « Network Programming in .NET

 

Using the Dynamic Language Runtime to Call IronPython for VS2010

Using the Dynamic Language Runtime to Call IronPython for VS2010 - Paul Kimmel's Blog

 

Using dynamic in the real world with IronPython

http://blog.filipekberg.se/2011/10/04/using-dynamic-in-the-real-world-with-ironpython/

Using MVVM to bring IronPython and WPF together

Nice sample

http://blogs.southworks.net/dschenkelman/2010/09/21/using-mvvm-to-bring-ironpython-and-wpf-together/

mardi 17 janvier 2012

IronPyhon - SilverLight Deployment

In order to make IIS serves the application
the following MIME-TYPES must be configured

.py -> text/plain
.slvx -> octet/stream

Scripting C# Silverlight apps with IronPython

From Jimmy Schementi, excelent as usual.

http://blog.jimmy.schementi.com/2009/03/scripting-c-silverlight-apps-with.html

WPF Tutorials

Great links

http://www.wpftutorial.net/

http://www.abhisheksur.com/2010/12/wpf-tutorial.html

DLR in C# - Scripting language

Little example on how to use IronPython in C#

http://www.abhisheksur.com/2011/05/dlr-in-c-using-scripting-language.html

Patterns For Large-Scale JavaScript Application Architecture

Nice article

Patterns For Large-Scale JavaScript Application Architecture

Javascript: self invoked functions

Immediately-Invoked Function Expression (IIFE)



Ben Alman » Immediately-Invoked Function Expression (IIFE)

lundi 16 janvier 2012

Extending a C# Application Through a Scripted DLR Language

Wonderful tutorial

http://visualstudiomagazine.com/articles/2011/04/26/wccsp_dlr-extensibility.aspx

Hosting IronPython in WinForms

Very nice article.
It shows how it ispossible to call method from IronPython in C#

http://www.mono-software.com/blog/post/Mono/134/Hosting-IronPython-in-WinForms/