7 Crazy Tips That Will Help You Become a Better Coder
Links for the community by Salvatore DI DIO (salvatore didio at gmail com )
JavaScript libraries help you build powerful, data-driven HTML5 apps.
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);
JavaScript Encryption and Decryption
JavaScript Encryption and Decryption 2.0
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); }, (…)
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); }); }, }); })
$(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" } } }); });
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)); } } }
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')
http://blog.filipekberg.se/2011/10/04/using-dynamic-in-the-real-world-with-ironpython/
.py -> text/plain .slvx -> octet/stream
Immediately-Invoked Function Expression (IIFE)