Feed JS Widget

Best online JS HTML and CSS editors...

Best online JS HTML and CSS editors...

JSFIDDLE

jsFiddle is a fresh tool that not only displays the code and highlights it but also executes its code within the browser for even better debugging. 

http://jsfiddle.net/


JSBIN

http://jsbin.com/

JS Bin is an open source collaborative web development debugging tool.
  • Write code and have it both save in real-time, but also render a full preview in real-time
  • Help debug other people's JavaScript, HTML or CSS by sharing and editing urls
  • CodeCast - where you share what you're typing in JS Bin in real-time
  • Remote rendering - view the output of your JS Bin on any device on any platform, updating in real-time
  • Processors, including: coffee-script, LESS, Markdown and Jade.
  • Debug remote Ajax calls




CODEPEN

http://codepen.io/pen/

CodePen is a playground for the front end side of the web. It's all about inspiration, education, and sharing.
Need to build a reduced test case to demonstrate and figure out a bug? CodePen is great for that. Want to show off your latest creation and get feedback from your peers? CodePen is great for that. Want to find example of a particular design pattern for you project? CodePen is great for that.
 


 Erbix

http://erbix.com/

Erbix offers productivity web apps for small businesses using an online apps platform (based on the JavaScript language). The apps offered include Pluto – an online team organizer and to-do manager, Eris – an interactive online form creator, and Meeting Planner – a new way to organize events and meetups democratically.
Anybody can write apps using JavaScript (and our browser-based IDE if they choose to). The JavaScript engine is based on RingoJS, an open-source server-side JavaScript engine. Erbix supports a web-based console which can interact via git and svn commands with external source version control repositories, or via SQL statements with a dedicated PostgreSQL database.

 CSSDESK


CSS Desk is an online free editing tool that combines the HTML and CSS concurrently. It’s very helpful for the beginners who are passionate towards web designing. This nifty tool provides you a real time output of how your code looks like as you type.
You can edit the CSS and HTML on the left panel and view the output on right. CSS Desk provides options to choose a default background color, reset your document and download your work as an HTML file. It also allows you to share the code with others.
Try this free handy tool !!

 

N2j

http://www.n2j.com/

JSconsole

 http://jsconsole.com/
 

repl.it - Best python online interpreter

http://repl.it

Its simple n I just love it :)

If you ever want to run python code and share it ?

Supports languages like Python Ruby, cofeescript, Javascript and many more.

With nice interface for writing code and also console..
Save your code and get unique URL to share it with frnds.
No login required.


Here is a screenshot of it.


Justify lines in python


How to Justify lines in python.
Want to align string center or left or right ?
ljust, center, rjust takes two parameter length of the output string and padding char.
Padding char is optional and default val is “ ”.



Examples.
  • rjust
     >>> a.rjust(40, "_")
     '___________________________________heloo'
     >>> a.rjust(40)
      heloo”

  • ljust
     >>> a.ljust(40, "_")
     'heloo___________________________________'
     >>> a.ljust(40)
     heloo '”


  • center
     >>> a.center(40, "_")
     '_________________heloo__________________'
     >>> a.center(40)
     heloo ”

write and execute python + shell script



Write n execute shell n python script in same file same time !!!!


Yes you can combine shell and python script in same file and also execute them.
All you need to do is open file write shebang line pointing to shell interpreter then write your shell script at last put this line exec python "$0" "$@" , When shell reaches the line exec python "$0" "$@", it causes the shell process to end and Python interpreter to be executed rest of the python code.


The lines between """:" and " """ are seen as a Python multi line string and ignored by python interpreter. And also it ignores shebang line #!/bin/sh looks like comment.



1 #!/bin/sh
2
3 """:"
4 echo "This is shell script.”
5 exec python "$0" "$@"
6 """
7
8 import sys, platform
9 print "You can write python script here !!!"
10 print "Python version: " + sys.version
11 print "Platform: " + platform.system() + platform.release()
12 sys.exit (0)



Play with python String, tricks


Play with String.

String Interpolation or inline assignment is the best and efficient way to concatenate strings rather than using + operator.
Some of the interesting tricks with string interpolation are listed below with console output.

  • You can write comments  between code, python Concatenates string even when strings are across multiple lines, provided braces.
        >>> ('Test ' 'this '  # this is comment
        ... 'in new line')
        'Test this in new line'

        >>> 'Test  this %s' %('string')
        'Test  this string
  •  Concatenates string on its own when they are in single line
        >>> 'Test '    'this '     'string'         Test this string'
  • Simply use Plus operator to concatinate.
        >>> 'Test '+'this '+'string'
        'Test this string' 
  • Supports * operator to multiply them.
        >>> 'string ' * 10        'string string string string string string string string string string '
  • Interpolate across lines
        >>> ('Test  this %s '        ...   'in multiple lines') %('string')
        'Test  this string in multiple lines'
  • Write comments between statements while doing interpolation.
        >>> ('Test this %s '  # this is comment         ... 'in new line') %('new string')        'Test this new string in new line'
  • Use dictionary to interpolate.
        >>> "This is %(old)s and this is another %(new)s" % {'old': 'string', 'new': 'trick'}
        'This is string and this is another trick'
  •  If you have many declared variable in your local scope, Just do this.
        >>> var_one = "Heloo"        >>> var_two = "Haaiii"
        >>> 'What are we sayin ? %(var_one)s %(var_two)s' % locals()
        'What are we sayin ? Heloo Haaiii'



  • A new formatting way by using format method in string class.
      >>> name = "Naren"
      >>> age = 24
      >>> place = "Bengaluru"
      >>> a = "My name is {name} ,my age is {age} and i live in {place}" 

      >>> a.format(name=name, age=age, place=place)
      'My name is Naren ,my age is 24 and i live in Bengaluru'

Python needs help :( ( :) Resolved, thanks veber)

We need to save python!!  we need your help.

python trademark is at risk in Europe, If you are working in  EUROPE help PSF.

More : http://pyfound.blogspot.in/2013/02/python-trademark-at-risk-in-europe-we.html

There is a company in the UK that is trying to trademark the use of the term "Python" for all software, services, servers... pretty much anything having to do with a computer.........


What can you do?
1. Do you work for a company that uses Python? Are in the EU, do you hire in the EU, or do you have an office in the EU? Could you write a letter on company letterhead that we can forward to our EU counsel? 

We would want: 


  1. just a brief description of how Python is used at your company, 
  2. how your company looks for and recognizes "Python" as only coming from the PSF, and 
  3. your view that another company using term Python to refer to services, software, and servers would be confusing
This doesn't need to be long - just a couple of paragraphs, but we would want any description of how you use Python for software, web hosting, Internet servers, VPNs, design and development of computer hardware or software, hosting websites, renting servers (like Openstack), or backup services. For those who are interested the specific class descriptions are at the bottom of this message. [1][2]

You can send a PDF copy of the letter to psf-trademarks@python.org

2. Do you have, or know of, anything that was published in the EU and uses "Python" to refer to Python-the-language? Can we get copies, pictures, or scans? This includes:

  • Books
  • Pamphlets
  • Conference programs or talks
  • Job listings
  • Magazines or other publications
  • Prospectuses
You can send a PDF scan of the materials to psf-trademarks@python.org

3. You can also help protect the Python intellectual property with financial support.

Since the costs of a trademark opposition are in the range of tens of thousands of dollars, we will need to find a way to refinance the legal costs of the opposition.

Please consider donating to the Python Software Foundation at:

    http://www.python.org/psf/donations/



Finally resolved. :)

 Thanks veber.

The trademark of Python will remain free after a copyright issue was resolved due to a withdrawn request by hosting solution company Veber.

Javascript optimization

1.  Best practice to optimize for loop in Javascript

The .length property of an array is checked at each enumeration if it's constructed asfor(var i=0; i<array.length; i++). For micro-optimisation, it's efficient to store the length of an array in a temporary variable

for(var i = 0, var len = array.length; i < len; i++) {  
   //...
}
More @ 
http://stackoverflow.com/questions/8452317/do-loops-check-the-array-length-every-time-when-comparing-i-against-array-length

Use Session variables without cookies

More @ :
http://www.thomasfrank.se/sessionvars.html

2.  Send data from one page to another page without server scope.

Using the cookies.js library from Recipe 1.9, you can use the onunload event handler of one page to store from one to twenty name/value pairs on the user's machine. The following example captures a text input field's value and saves it to a cookie that stays on the visitor's computer for 180 days:

<script language="JavaScript" type="text/javascript" src="cookies.js"></script>
<script language="JavaScript" type="text/javascript" >
function saveData( ) {
    var data = document.forms[0].userName.value;
    var expDate = getExpDate(180, 0, 0);
    setCookie("userName", data, expDate); 
}
</script>
...
<body onunload="saveData( )">
 
In the second document, an onload event handler retrieves the cookie data and assigns the value to a text input field with the same name located on the second page:

<script language="JavaScript" type="text/javascript" src="cookies.js"></script>
<script language="JavaScript" type="text/javascript" >
function readData( ) {
    var data = getCookie("userName");
    document.forms[0].userName.value = data; 
}
</script>
...
<body onload="readData( )">
 
More @ : 
http://docstore.mik.ua/orelly/webprog/DHTML_javascript/0596004672_jvdhtmlckbk-chp-10-sect-5.html
 
 
  3. Another way using HTML :

How to Do ?

Example :

<FORM METHOD="LINK" ACTION="jspass2.html">
Type your first name: <INPUT TYPE="text" NAME="FirstName">
Type your last name: <INPUT TYPE="text" NAME="LastName">
<INPUT TYPE="submit" VALUE="Click and See">
</FORM>

 
     Look first at the main FORM flag. The METHOD is set to LINK and the ACTION simply points toward another page. Nowhere in there does it say to send the user information anywhere. When you set up the form in this manner, what the user inputs is carried along in the URL.
     The information is separated from the actual address by a question mark so it doesn't harm the movement to another page. This little quirk of the browser allows us to go to a totally new page and carry the user's input right along with us in the URL.


How to retrieve ?

<FORM NAME="joe">
<INPUT TYPE="hidden" NAME="burns">
</FORM>

<SCRIPT LANGUAGE="javascript">

var locate = window.location
document.joe.burns.value = locate

var text = document.joe.burns.value

function delineate(str)
{
theleft = str.indexOf("=") + 1;
theright = str.lastIndexOf("&");
return(str.substring(theleft, theright));
}
document.write("First Name is " +delineate(text));

</SCRIPT>


More @ :
http://www.developer.com/lang/jscript/article.php/639611/Passing-Variables-Between-Pages-With-JavaScript.htm

4. persistent storage Library :

supports persistent client-side storage through the following backends:
  • flash: Flash 8 persistent storage.
  • gears: Google Gears-based persistent storage.
  • localstorage: HTML5 draft storage.
  • whatwg_db: HTML5 draft database storage.
  • globalstorage: HTML5 draft storage (old spec).
  • ie: Internet Explorer userdata behaviors.
  • cookie: Cookie-based persistent storage.
More @ :
http://pablotron.org/?cid=1557

Override default jquery methods.

Override default jquery methods.

Helps alot when you wand to do custom animations and mock methods to write your mock methods to do unit testing jsunit.

JQuery.fn.hide = function() {
                                            alert("Its working");
                                            }
or

$.fn.hide = function() {
                                    alert("overrided");
                                    }

Break lengthy words HTML CSS. Get through Chrome word-wrap problem in tables.

Break lengthy words HTML CSS.

Get through Chrome word-wrap problem in tables.


Force lengthy words to break and fit in to <div>, Use CSS property.
This avoids lengthy words in table cell to push other cells and scramble whole table.

.break-word { word-wrap: break-word; }

Note:

In chrome break-word inside trable wont work untill you set table-layout: fixed.
so use

word-wrap: break-word;
table-layout: fixed;


Or If you are using Djanog use truncate words or truncate chars.

{{ value|truncatechars:9 }} Django 1.4

trucatechars included in Django 1.4 so

{{ value|slice:"5" }}{% if value|length > 5 %}...{% endif %} in former django (djanog 1.2 or 1.3)

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#truncatechars

Guido van rossum says bye to Google!!!! Dropbox welcomes

Guido van Rossum the one who created Python has left Google to work for Dropbox !!!!

Any how Dropbox says it relied on python for so many things !!! Now it would be happy for them to have GVR on DropBox team. 


I wish all the best for him were ever he is :)  

Epoch


Get Epoch time, time in python and Django
Epoch Wiki   In simple words Epoch Time is number of ticks since 1970.

How to get current epoch time ?

time.time()  -->  1353060315.441321
int(time.time()) -->  1353060315

now = datetime.datetime.now()
time.mktime(now.timetuple())  --> 1353060315


My Notes:

time.gmtime()
time.struct_time(tm_year=2012, tm_mon=11, tm_mday=16, tm_hour=10, tm_min=6, tm_sec=44, tm_wday=4, tm_yday=321, tm_isdst=0)

datetime.datetime.now()
datetime.datetime(2012, 11, 16, 15, 34, 35, 433184)


In Django Application

mysql time field's should be  DATETIME
Eg.        allocate_time     | datetime      | YES  |     | NULL    |    

In models.py  field type should be models.DateTimeField()