Posts marked with "Posts" in posts

How to remove keyring password dialog in All Ubuntu versions

You will be getting a keyring unlocker dialog to type your password to unlock the keyrings such as:

  • Password you stored in Web Browsers (Google Chrome, Chromium)
  • Passwords stored in Chat and Mail Applications (Empathy, Pidgin, Evolution)
  • and other passwords

This passwords should be unlocked each time you login but won’t automatically unlock when you login. To automatically unlock you can do as follows:
Open Terminal (CTRL + ALT + T) and do the following command:

... [READ MORE]

Facebook Hacker Cup 2013:Beautiful Strings solution in PHP

Here is the solution for FHC 2013 Beautiful Strings problem in PHP:

$ip = fopen(‘input.txt‘, "r");
$test_cases = trim(fgets($ip));
    $c=1;
    while($c!= $test_cases+1){
        $case=preg_replace(‘/[^a-z]+/’, ", strtolower(trim(fgets($ip))));
        $vals=array_count_values(str_split($case));
        arsort($vals);
        $beauty=26;
        $max_b=0;
        foreach($vals as $v){
            $max_b +=$v*$beauty;
            $beauty–;
        }
        print("Case #".$c.": ".$max_b);
        if($c < $test_cases){
            print("
");
        }
        $c++;
    }

... [READ MORE]

Advanced Rest Client : Create and Test custom HTTP requests.

I recently noticed a Google Chrome Webstore app that can be used for making a request to a web site or local site. I loved the app from the beginning. You can send a request to any site with header data, form data etc…

You can also attach a file to the form. Ain’t that Awesome.
Every web developer must have this app. Install it from Chrome Webstore

Features

  • – Integrated with Google Drive
  • – It’s own backend service to store and share data between coworkers
  • – convenient HTTP headers and payload editor thanks CodeMirror
  • – Make a HTTP request (via XmlHttpRequest level 2)
  • – Debug socket (via web socket API).
  • – JSON response viewer
  • – XML response viewer
  • – set custom headers – even does not supported by XmlHttpRequest object
  • – help with filling HTTP headers (hint + code completion)
  • – add headers list as raw data or via form
  • – construct POST or PUT body via raw input, form or send file(s) with request
  • – set custom form encoding
  • – remember latest request (save current form state and restore on load)
  • – save (Ctrl+S) and open (Ctrl+O) saved request forms
  • – history support
  • – data import/export

... [READ MORE]

Connecting database to both mysqli and mysql entension

You can use both mysql and mysqli extension for executing SQL queries. Here is a tutorial on how to connect both the extensions to a database.

Create a file named config.php where you will connect to the database. Put the following code in it:

$mysqli = new mysqli("localhost", "username", "password", "db");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$bd = mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("db",$bd) or die(mysql_error());
?>

... [READ MORE]

Check whether mysqli connection is made or not in php

This function helps to check whether connection the mysql server has been made or not.

Here is the code:

if ($mysqli->ping()) {
echo ("Our connection is ok!n");
} else {  

    printf ("Error: %sn"$mysqli->error);
}

The $mysqli variable is a connection made via mysqli function.
Know more about mysqli ping function here.
... [READ MORE]

Hide File Extensions In Browsers Using .htaccess

Many of us programmers want to hide the file extension of server files such as .php, .jsp, .py etc….

You can easily hide these extensions with the help of a .htaccess file. This feature is only available to Apache servers.
Create a file named .htaccess if your root directory of site doesn’t have one.
Add these lines to the .htaccess file :
<span style="background-color: white; font-family: inherit;"><span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteEngine</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> </span><span class="kw2" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">on</span></span>
<span style="background-color: white; font-family: inherit;"><span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME} !-d</span></span>
<span style="background-color: white; font-family: inherit;"><span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.php -f</span></span>
<span style="background-color: white; font-family: inherit;"><span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteRule</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> .* $0.php</span></span>
The above lines wll hide the PHP extension. If you want to hide the HTML and other extension too add these line after 
<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.php -f</span>
as you want. You can also replace it if you don’t want php extensions to hide.

HTML

<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.html -f</span>

JSP

<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.jsp -f</span>

ASP

<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.asp -f</span>

PY

<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.py -f</span>

JS

<span class="kw1" style="border: 0px; color: #2060a0; line-height: 18.200000762939453px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: nowrap;">RewriteCond</span><span style="line-height: 18.200000762939453px; white-space: nowrap;"> %{REQUEST_FILENAME}.js -f</span>
You really should go into each page and delete the extensions, but I believe you can redirect them by adding another rule :
<span style="color: #2060a0;">RewriteRule </span>(.*).<span style="color: red;">html</span> $1 [R=301,NC]
The above rule will redirect all .html pages to non .html extension page.
Replace the red highlighted text with any extension you want to redirect.
... [READ MORE]

Create Facebook Like System With jQuery, MySQL, PDO In PHP

Facebook have it’s own like system which pretty good. This post will tell you how to create a "Like system" like that of Facebook. All you have to need is jQueryMySQL Database and PDO PHP extension. This technic is partially used in my social network, Open. See the demo there in the social network. But you have to signup.

You should create a user table with users data including user idusernamepasswordemail etc…
<div>
  <span style="color: red; font-family: inherit;">The table should be like this:</span>
</div>
Let’s start by creating a likes table where we store the like actions by the user.

... [READ MORE]

Friendshood Update new feature – Post to Facebook

I updated Friendshood. The new feature is that the user can post status update and photos to Facebook along with posting in Friendshood. I implemented this function using Facebook PHP SDK. You can download the SDK here.

It was not quite easy. It was hard to make Picture uploading function along with the normal status update. Next I’m gonna implement twitter posting from Friendshood.

I’m gonna tell you how to post a status update in the following posts. Wait for it.

... [READ MORE]

How to get Facebook PHP SDK and install it

Download Facebook PHP SDK from here.
Extract the folder src in the zip file to a folder named fbsdk in the home directory of your app.

Installation

There is no installation. You can run the functions in the file if you put this line at top of each file you run the SDK functions :

include(‘fbsdk/facebook.php’);

Facebook SDK requires the following to work properly :

  1. JSON PHP extension.
  2. CURL PHP extension.
... [READ MORE]

How to get Current Time and date in Javascript

This tutorial will help you to get current date and time at which the function is executed. Here is the function:

function ctime(){
var currentdate = new Date();
var time=currentdate.getFullYear()+"-"+(currentdate.getMonth()+1)+"-"+currentdate.getDate()+" "+currentdate.getHours()+":"+currentdate.getMinutes()+":"+currentdate.getSeconds();
return time;
}

Just print out ctime() function to get the date and time in the format YEAR/MONTH/DAY HOUR:MINUTE:SECOND 

Explanation :

new Date() function prints out the current date and time in a disorderly way. You can order it in any way as I did in the time() function.
currentdate.getFullYear() will get the year from new Date() which is in the variable currentdate
currentdate.getMonth() will get the month from new Date() function. The program adds 1 to the month because Javascript always count the month from . So we should add a +1.
currentdate.getDate() will get the day of the month in which the function is executed.
currentdate.getHours() will give the Hour of the time.
currentdate.getMinutes() will give the Minute in which the script is executed.
currentdate.getSeconds() This function will give the seconds of the time at which the script is executed.
... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab