mardi 27 janvier 2015

[Python] Tornado - send POST parameters in the body with AsyncHTTPClient

If you want to send POST data to an URL(a RESTful web service for example) with AsyncHTTPClient, you can do that :

import urllib
post_data = { 'data': 'test data' } #A dictionary of your post data
body = urllib.urlencode(post_data) #Make it into a post request
http_client = tornado.httpclient.AsyncHTTPClient()
http_client.fetch("http://127.0.0.1:8888", handle_request, method='POST', headers=None, body=body)
Link : http://stackoverflow.com/questions/10367981/how-to-use-post-method-in-tornado

vendredi 24 octobre 2014

[Python] pip install : gcc: error: unrecognized command line option '-mno-cygwin'

If you are on Windows and get this message :
gcc: error: unrecognized command line option '-mno-cygwin'
when you type pip install greenlet (or another lib)

Then you must :
- edit or create C:\PythonXX\Lib\distutils\cygwinccompiler.py and remove any traces of -mno-cygwin

- open an new cmd and type again your pip install greenlet (or another lib)

Have fun
:o)

mardi 14 octobre 2014

JSON Schema

The official documentation for the JSON Schema (the specification for the JSON Schema is currently published as draft) :
http://json-schema.org

An online JSON validator, using schema :
https://json-schema-validator.herokuapp.com/


A wonderful tutorial explaining the JSON Schema :
http://spacetelescope.github.io/understanding-json-schema/

mardi 23 septembre 2014

[Python] __code__ and decorator



http://stackoverflow.com/questions/1166118/how-to-strip-decorators-from-a-function-in-python

http://stackoverflow.com/a/1167248

[iOS] viewDidLoad viewDidAppear viewWillAppear

viewWillLoad/viewDidLoad - called when the view is constructed (via the first call to retrieve the view controller's UIView via it's view property - aka lazy loading)
viewWillAppear: - when the view is being prepared to appear either immediately (animated == NO) or view a transition (animated == YES)
viewDidAppear: - if the view appearance wasn't cancelled and the view controller's view fully appears
viewWillDisappear: - complements viewWillAppear:
viewDidDisappear: - complements viewDidAppear:

viewWillUnload/viewDidUnload - deprecated APIs when the view is unload due to memory constraints (don't worry about these anymore)

Source : http://stackoverflow.com/questions/22214843/ios-7-difference-between-viewdidload-and-viewdidappear

dimanche 21 septembre 2014

[iOS 8] Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead

If you have this message :
<<
Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
>>


then just write :
<<
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}
>>

vendredi 22 août 2014

[Bootstrap] Sticky left sidebar

Apply affix (http://getbootstrap.com/javascript/#affix) and scrollspy (http://getbootstrap.com/javascript/#scrollspy)


body {
   position: relative;
}

<body data-spy="scroll" data-target=".mynav">
   <div class="row">

      <div class="col-md-3 mynav">
         <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="60" data-offset-bottom="200">
            <li>
               <a href="#menu1">menu1</a>
            </li>
            <li>
               <a href="#menu2">menu2</a>
            </li>
         </ul>
      </div> <!--div col-md-3-->

      <div class="col-md-9">
         <div id="menu1">
            blabla
         </div>
         <div id="menu2">
            blabla
         </div>
      </div> <!--div col-md-9-->

   </div> <!--div row-->
</html>

jeudi 21 août 2014

[Bootstrap] Sticky footer

http://stackoverflow.com/a/25075517


 $(document).ready(function () {
//http://stackoverflow.com/a/25075517
            var $docH = $(document).height();
            // The document height will grow as the content on the page grows.
            $('.my-footer').css({
                /*
                The default height of .navbar is 50px with a 1px border,
                change this 52 if you change the height of your footer.
                */
                top: ($docH - 52) + 'px'
            });
        });



 <div id="footer" class="my-footer">
      <div class="container">
        <p class="text-muted credit">toto.com</p>
      </div>
    </div>

[Bootstrap] How to create a sticky left sidebar menu

http://www.bootply.com/82265#
http://www.bootply.com/90936#

Categories