Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

  • Pablo Bandin 7:30 AM on 3 January 2012 Permalink | Reply  

    knockoutjs – Cool javascript framework 

    Im starting to learn more about knockoutjs, the tutorials are awesome, very didactive. So far, looks great, i’m getting convinced to use it and go for it… i still have to figure out how to handle multiple view-models and the templating workflow. I’m very used to just create the elements with jquery and go from there… but after reading the documentation, im starting to get very interested in knockoutjs.

    Check it out

    PS: i write “im” or “i’m” too often… lol…

     
  • Pablo Bandin 11:56 AM on 20 December 2011 Permalink | Reply  

    Php Obfuscator / Compressor 

    This is a class i made to compress and obfuscate php code, it is designed with specific coding style in mind, nothing crazy, everything should be easy to find by a Regular expression.

    https://gist.github.com/1501834

    Variables, functions & classes are minifyed, spaces removed. The replacement pattern is $foo –>  $_1   and the number will be incrementing each match.

    Enjoy.

     
  • Pablo Bandin 8:59 AM on 14 December 2011 Permalink | Reply  

    Abstracting database manipulation and other stuff…. 

    I’m currently working on a medium-to-large website for the agency i’m currently working, and i stumble upon a very interesting situation.

    Apparently, i will have to code this site without knowing yet which database engine we are going to use. So now my only option to avoid affecting my job is to do implement a Factory pattern on the data structures i will have to use.

    So i will create a RepositoryFactory object which will return repositorie’s interfaces, which in turn will return concrete data objects.

    This way i think it will be the best option, so now i will be able to create a FakeRepository and create the data object by hand, so when the engine war ends, all i will have to do is to implement the final database engine chosen.

    I write this because this is the first time i have to implement a design pattern by a real need, i generaly do it but because i try to code the best i can, but this time, the pattern MUST be used. And what a cool solution!

    So the final product should look something like:  RepoRacotry::getXXXRepo()->getSomeData() 

    A repo who will return repositories interfaces… and initially, i will implement fake concrete repositories. The data objects will be plain php objects ( no methods or anything, just vars )

    –Also: I’m starting to use the Symfony Components by picking and implementing just the ones i like, and it’s a very fun process. Symfony2 is a very cool framework.

     
  • Pablo Bandin 12:07 AM on 26 October 2011 Permalink | Reply  

    Status update. 

    I haven’t been posting here because i’m busy working on http://weightxreps.net/ my site.

     
  • Pablo Bandin 11:30 AM on 26 September 2011 Permalink | Reply  

    weightxreps.net 

    Yesterday i uploaded a new version of the site, it’s mostly a re-code and a few added features. Internally now everything is more structured and is easyer to add new features.

    http://weightxreps.net/

    The next addition will be  a system to create “virtual competitions”.

     
  • Pablo Bandin 11:21 PM on 27 August 2011 Permalink | Reply  

    PHP date()… finding Sunday… 

    This one is simple, but for some reason i was using too many lines of code to get to this same result in just 1 line… U_U :

    $fecha = '2011-08-23';
    echo date("Y-m-d", strtotime($fecha .' sunday') ); // = 2011-08-21
    

     
  • Pablo Bandin 11:44 AM on 23 August 2011 Permalink | Reply  

    Symfony2: Working with Assetic 

    Well, i finally took the time to read something about Assetic and let me tell you, it’s awesome. This is how it works:

        {% javascripts '@yourBundle/Resources/js/*' output='js/combined.js' %}
        <script src="{{ asset_url }}"></script>
        {% endjavascripts %}
    

    The code above ( used inside a Twigg template ) will pack all the javascripts inside Resources/js folder and put them all inside a single file called combined.js inside the web/js folder.

    While developing, that process will take a lot of time each time you refresh the page, that’s why you will want to call this command to make Assetic watch for changes every X time to generate a physical version of each file so the files can be served directly to the browser rather than being generated at runtime:

    php app/console assetic:dump --watch

    That will create a bunch of javascripts in the web/js folder, and everytime you change a file in your Resources/js it will be automatically updated in your web/js folder. So now page load times will be optimal.

    Also, on production, one javascript per javascript will be generated, this is fine because this way you can debug them easily. On Development, assetic will pack all the javascript on a single file (in the case of the example above).

    That’s for when you are developing. When deploying to production, you can delete all the files inside the web/js folder (generated by assetic on development) and run this command:

    php app/console assetic:dump --env=prod --no-debug

    That will generate the FINAL version of all the javascripts so that from now on, the browser will be served with physical javascripts and assetic will not be used anymore.

    Remember that everytime you make a change on the javascripts, you will have to run the command above to generate the final version and that will be the files you will have to upload to production.

    For more information go to http://symfony.com/doc/current/cookbook/assetic/asset_management.html

     
    • phicheth 4:52 PM on 9 September 2011 Permalink | Reply

      you write to get asset from any folder not need to import from bundle.

      If you place js files in /web/assets/js/jquery.js you can use this by example.

      <script src="{{ asset('assets/js/jquery.js') }}" type="text/javascript"></script>

      —————————————————————————————————
      doSymfony2.0.1-20110909 Ready Edition is a full repo package include all vendors including in symfony 2.0.1 standard edition. Ready Edition – No git request. all you need already include in pack. Accept share hosting, VPS or your own server.

      Detail of work:

      remove ‘/web/’ folder with edit vendors file. can run on share hosting without any issue from remove ‘/web/’ folder.
      update all vendors via git to build a package. you can use git update symfony with ‘ php bin/vendors install ‘ anytime you wanted. to update to new version you must replace ‘deps’ and ‘deps.lock’ files before update new version of Symfony2
      all feature, API and docs please follow from http://www.symfony.com

      Download : http://code.google.com/p/dohew-opensource/

      This is Symfony2 package include all vendors needed ***

      This package update by Phicheth Kijtaow @doHew Media!

  • Pablo Bandin 8:02 PM on 25 July 2011 Permalink | Reply  

    Symfony2: SecurityBundle 

    Outline of how it’s involved in Symfony2:

    1. AppKernel -> handle  is called ( look app.php )
    2. FrameworkBundle :: HttpKernel’s -> handle is called
    3. Component :: HttpKernel’s handle is called. Which then calls handleRaw
    4. The HttpKernel dispatches an kernel.request event.
    5. The event is captured by a Firewall previously set as a listener by the SecurityBundle’s security.xml
    6. The onKernelRequest method of this Firewall is called.
    7. The firewall loops trough all the AuthenticationListeners which where set here ( lines 213 to 225 ) as part of the Firewall and call it’s handle method.
    8. If a security violation is detected ( the authentication listeners will throw this exceptions ), a kernel.exception is detected by an ExceptionListener previosuly set in security_listeners.xml and registered in the Firewall at the time of the Request.
    So that’s an overview of how the SecurityBundle intercepts Requests and based on the reaction of the AuthenticationListeners will do nothing or throw an exception informing about the security violation.
    Step 4 is where the magic happens, as you can see, the Request is intercepted before reaching the actual controller. As described here:
    (The numbers in the image are NOT related with the numbers in this article, they are part of the image form the Symfony book)
     
    • nabil 9:40 AM on 18 August 2011 Permalink | Reply

      Hi, I need to insert in my augmented reality action script in flash builder a preloader for my 3D.DAE model, can u help me?

  • Pablo Bandin 3:38 PM on 25 July 2011 Permalink | Reply  

    Symfony2: Custom Authentication Provider 

    Source: How to create a custom Authentication Provider

    Regarding Security, in Symfony you have 2 providers. One is an Authentication provider and the other is an UserProvider.

    • An authentication provider is used to extract information from a request to be used  to identify the user.
    • An user provider is used to check if the user found by the authentication provider exists on our pool of users.
    So basically, the authentication provider finds information about an user on the Request and creates a TOKEN with that information. This token contains the credentials of the users. With that token, the security bundle tries to find a user using the available user Provider and tries to see if it finds one that has/match the currently found user Token. If nothing is found, an error is thrown telling so.
    Easy to understand example ( AP = Authentication provider. UP = User Provider ):
    AP:  -Hey UP, i think i found an user on the request, take a look at this token-
    UP:  -let me see… Mmhh.. yeah, i found one, your token is valid!-
    AP: -Ok, thanks. Hey Symfony Security layer, this token is valid!-
    Overview:
     
  • Pablo Bandin 8:28 AM on 14 July 2011 Permalink | Reply  

    Symfony2 & CSS url References. 

    I was having problems when designing my website, i was linking to images and then on the development enviroment i wasn’t able to see them.

    For example, when working on localhost/website/web/app_dev.php and you have something like this:

    .someDiv {
       background: url(images/logo.png) no-repeat;
    }
    

    The browser would search for localhost/website/web/app_dev.php/images/logo.png which would throw a 404.

    So after trying to find out the “correct” way of solving this, i just said: -fuck it, just do it- and i edited the file app.php in the web directory and added this at the very begining of the file (i would remove when going to production):

     

    <?php
    
    #-----------------------------
    include "app_dev.php";
    exit;
    #-----------------------------
    
    require_once __DIR__.'/../app/bootstrap.php.cache';
    require_once __DIR__.'/../app/AppKernel.php';
    
    use Symfony\Component\HttpFoundation\Request;
    
    $kernel = new AppKernel('prod', false);
    $kernel->handle(Request::createFromGlobals())->send();
    

    it get the job done and doesn’t make you lose time trying to figure out anything weird.
    If someone knows the correct way of solving this, please let me know.

     
    • Pawel 2:08 PM on 9 August 2011 Permalink | Reply

      Hi

      You shouldn’t use relative urls in css files unless you know how they work.

      Try this instead:

      background: url(/images/logo.png) no-repeat;

      not this

      background: url(images/logo.png) no-repeat;

      • Pablo Bandin 4:53 PM on 9 August 2011 Permalink | Reply

        i know how relative paths work, the urls are relative to the CSS file. And there’s a long reason why i dont use absolute urls, but thanks for the comment :)

    • Anush 7:05 AM on 23 September 2011 Permalink | Reply

      I usually just update the .htaccess file (change app.php to app_dev.php). If you do this, make sure you don’t include the .htaccess file as part of your deployments (i.e you’d have separate .htaccess files per environment).

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel
Follow

Get every new post delivered to your Inbox.