Pages

Showing posts with label url. Show all posts
Showing posts with label url. Show all posts

Thursday, February 14, 2019

Load mnist dataset from a local file in jupyter

Recently while trying AI coding behind a proxy I was unable to load data from minist dataset from cloud.
So I manually downloaded the file "mnist.npz" kept it in {username}/.keras/datasets/ on my local machine and used the following command to load it

(X_train,y_train),(X_test,y_test)=mnist.load_data(path='mnist.npz');

And this block executed without any errors.

Tuesday, April 22, 2014

Change default wordpress login URL

Change default Login URL-Wordpress

Add the following line to the end of .htaccess

RewriteRule ^login$ http://YOUR_SITE.com/wp-login.php[NC,L]

Thursday, January 2, 2014

Wordpress-Get Post ID in functions.php

  $url = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);  
   $ID = url_to_postid($url[0]);  
   echo $ID;  

Sunday, September 29, 2013

CodeIgniter-Seo Urls

1. I am using ubuntu 13.04. To setup mod_rewrite on debian based machines ubuntu is in concern here go through my this post

http://itfeast.blogspot.in/2013/09/cakephpubuntu-setting-up-cakephp-on.html

If you are assured that mod_rewrite is working perfectly on your Apache Server Proceed Further.

Now We will proceed with configuring CodeIgniter for seo urls

2. Remove Index.php

Your root .htaccess should look like this

 <IfModule mod_rewrite.c>  
 # Turn on URL rewriting  
 RewriteEngine On  
 # If your website begins from a folder e.g localhost/my_project then   
 # you have to change it to: RewriteBase /my_project/  
 # If your site begins from the root e.g. example.local/ then  
 # let it as it is  
 RewriteBase /ci/  
 # Protect application and system files from being viewed when the index.php is missing  
 RewriteCond $1 ^(application|system|private|logs)  
 # Rewrite to index.php/access_denied/URL  
 RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]  
 # Allow these directories and files to be displayed directly:  
 RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)  
 # No rewriting  
 RewriteRule ^(.*)$ - [PT,L]  
 # Rewrite to index.php/URL  
 RewriteRule ^(.*)$ index.php/$1 [PT,L]  
 </IfModule>  

3. Now in application/config/config.php

change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';

In some cases you may also need to configure

$config['uri_protocol'] = 'AUTO';

To

$config['uri_protocol'] = 'PATH_INFO';

Or To

$config['uri_protocol'] = 'REQUEST_URI';

4. Now your folder structure should look like this

website_folder/ 
–––– application/ 
–––– system/ 
–––– user_guide/ 
====>.htaccess
–––– index.php 
–––– license.txt
 
You might also go for custom routing further as
 
$route['default_controller'] = 'webpages'; //Our default Controller

//Get rid of the first segment (in our case we get rid of webpages)
$route["about"] = 'webpages/about'; 
$route["blog/(.*)"] = 'webpages/blog/$1';
$route["view/(.*)"] = 'webpages/view/$1';
 
Source: http://www.web-and-development.com/codeigniter-remove-index-php-minimize-url/ 

Wednesday, July 17, 2013

Web Development/Jquery/Javascript-Set a menu Link "selected" class if its href matches page url

Here is a simple js code with HTML to set a "seected" class to menu item when its corresponding page is open.

 <dl class="sidebarBox">  
   <dt>Mailboxes</dt>  
   <dd>  
     <ul class="mailbar">  
       <li><a href="inbox"><b>Inbox</b></a></li>  
       <li><a href="sent">Sent</a></li>  
       <li><a href="trash">Trash</a></li>  
     </ul>  
   </dd>  
 </dl>  
 <script type="text/javascript">  
   var winpath=window.location.pathname;  
   $(".mailbar li a").each(function(index)  
   {  
     var menupath=$(this).attr('href');  
     if(menupath==winpath)  
       $(this).parent().addClass("current");  
     else  
       $(this).parent().removeClass("current");  
   });  
 </script>  

Sunday, June 9, 2013

PHP-How to generate Youtube like video url's



 <?php  
 $encoded=base64_encode(Uniqid().$myVideosValue['Uservideo']['id']);  
 ?>  


and then send this along with URL and at receiving end decode it as follows

 <?php  
 $decoded= substr(base64_decode($paramstr),13);  
 ?>  




Sunday, December 9, 2012

Hiding Controller from cakephp Url

In routes.php add the following code

  Router::connect('/*', array('controller' => 'Site', 'action' => 'display'));

What this does is each time you fire a url with "/parameter" it redirects to Site controller and display action

Now under site controller in display action add this

class SiteController extends AppController
{
    public $name="Site";
   
    public function display()
    {
        $path = func_get_args();
        //print_r($path);
        $count = count($path);
        if (!$count)
        {
             $this->redirect('/');
        }
        else
        {
            $this->render(implode('/', $path));
        }
    }
}

Sunday, July 8, 2012

Javascript to automatically add wpmode behind your video url

//javascript
$(document).ready(function()
{
    $('#id_of_iframe').each(function()
    {
        var url = $(this).attr("src"winking smiley
        $(this).attr("src",url+"?wmode=transparent"winking smiley
    }
    );
}
;