Get an element by index in jQuery

$(…)[index] // gives you the DOM element at index $(…).get(index) // gives you the DOM element at index $(…).eq(index) // gives you the jQuery object of element at index DOM objects don’t have css function, use the last… $(‘ul li’).eq(index).css({‘background-color’:’#343434′}); docs: .get(index) Returns: Element Description: Retrieve the DOM elements matched by the jQuery object. See: … Read more

How are POST and GET variables handled in Python?

suppose you’re posting a html form with this: <input type=”text” name=”username”> If using raw cgi: import cgi form = cgi.FieldStorage() print form[“username”] If using Django, Pylons, Flask or Pyramid: print request.GET[‘username’] # for GET form method print request.POST[‘username’] # for POST form method Using Turbogears, Cherrypy: from cherrypy import request print request.params[‘username’] Web.py: form = … Read more

How to “perfectly” override a dict?

You can write an object that behaves like a dict quite easily with ABCs (Abstract Base Classes) from the collections.abc module. It even tells you if you missed a method, so below is the minimal version that shuts the ABC up. from collections.abc import MutableMapping class TransformedDict(MutableMapping): “””A dictionary that applies an arbitrary key-altering function … Read more

Passing base64 encoded strings in URL

There are additional base64 specs. (See the table here for specifics ). But essentially you need 65 chars to encode: 26 lowercase + 26 uppercase + 10 digits = 62. You need two more [‘+’, “https://stackoverflow.com/”] and a padding char ‘=’. But none of them are url friendly, so just use different chars for them … Read more

How to retrieve GET parameters from JavaScript [duplicate]

With the window.location object. This code gives you GET without the question mark. window.location.search.substr(1) From your example it will return returnurl=%2Fadmin EDIT: I took the liberty of changing Qwerty’s answer, which is really good, and as he pointed I followed exactly what the OP asked: function findGetParameter(parameterName) { var result = null, tmp = []; … Read more