Ubuntu tips: Add a PPA and update only that one

If you use ubuntu, you most probably have added some ppa-s in your system.
The problem is you have to update all the software sources after adding a ppa by `apt-get update` which is time consuming if you have a lot of software sources.

Y PPA Manager helps to cut down the process. You can only update that ppa easily with Y PPA Manager.

To show you how easy it is you need to execute command

update-ppa

like

sudo update-ppa ppa:videolan/stable-daily

This will add (if you haven’t already added the ppa) and update the ppa for you.

    To install Y PPA Manager:
sudo add-apt-repository ppa:webupd8team/y-ppa-manager #for the last time
sudo apt-get update #for the last time
sudo apt-get install y-ppa-manager

Android Preference: Show current value in summary

When creating android preference view, I found that the default preference like EditTextPreference does not show the current value as summary (and no way to make them do it). So I made the following class to help:

import android.content.Context;
import android.util.AttributeSet;

public class EditTextPreference extends android.preference.EditTextPreference {

	public EditTextPreference(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	@Override
	protected void onDialogClosed(boolean positiveResult) {
		super.onDialogClosed(positiveResult);
		
		setSummary(getSummary());
	}

	@Override
	public CharSequence getSummary() {
		return this.getText();
	}
}

Netbeans tip: Show Files starting with dot (.) [files like .gitignore / .hidden ] in NB Projects

By default Netbeans hides files starting with a dot (.) except the htaccess file.
You can change this behavior by going to
Tools > Options > Miscellaneous > Files
Here you will see “Ignored Files Pattern:” under “Files Ignored by the IDE”
I have changed the pattern to

^(CVS|SCCS|vssver.?\.scc|#.*#|%.*%|_svn)$|~$

and now I can see .gitignore, .hidden, etc. files in my projects.

 

PS: Thanks to Josh Pratt‘s post

Upload to Amazon S3 server directly from browser in chunk and resumable way

UPDATE: This works for AWS sdk version 2.4.0. AWS sdk version 2.4.1 throws body missing exception.

I have written some javascript and php code to make big local files to be uploaded in Amazon S3 server directly, in chunk of 5 MB (amazon web service says that the chunk size should be at least 5MB), so the upload is resumable and recover easily from upload or network error.

To make this work we need our browsers to be able to read local files and send the data to cross-domain server with XMLHttpRequest2. Most mainstream browsers’ recent versions support these operations (Firefox, Chrome, Opera, IE, etc. and some mobile browsers also)

So what do we need? We also need a signing server which will sign the request we will send to the S3 server from browser (Why signing needed? Because we should not allow anybody to upload or manipulate our S3 bucket, shall we?). In my demonstration I used php backend server, but any backend can be used.

If you need a demonstration for inspiration or a starting point for your project, you can look at these source codes here – https://github.com/ienzam/s3-multipart-upload-browser

Please put your valuable comments ans suggestions.

Thank you all for reading.

AWS S3, PHP & Javascript – Get it working

UPDATE: This works for AWS sdk version 2.4.0. AWS sdk version 2.4.1 throws body missing exception.

Let me explain what I was trying to do. I was trying to call amazon web services from javascript directly, but as I can’t (must not) embed aws secret key to javascript I have to use some kind of server to sign my requests for me. As I was working on php, I am trying to use aws-sdk-php to sign my requests. After a lot of digging on the sdk code here is the rough hack code I have came up with (you need to set cors permission on your bucket to access from javascipt)

<?php
require 'vendor/autoload.php';

use Aws\Common\Enum\DateFormat;
use Aws\S3\S3Client;
use Guzzle\Common\Event;

$client = S3Client::factory(array(
'key' => AWS_KEY,
'secret' => AWS_SECRET
));

// for all available commands, go to
// http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/service-s3.html
$command = $client->getCommand('GetBucketAcl', array(
'Bucket' => BUCKET_NAME
));

$request = $command->prepare();
$request->setHeader('x-amz-date', gmdate(DateFormat::RFC2822));

// searching for these event dispatchers wasted a great deal of my time๐Ÿ˜ก
$client->getEventDispatcher()->dispatch('command.before_send', new Event(array(
'command' => $command,
)));

$client->getEventDispatcher()->dispatch('request.before_send', new Event(array(
'request' => $request
)));
?>
<html>
<body>
<p>Open the browser console and network monitor to see the outputs</p>
<button onclick=&quot;doXMLHttpRequest()&quot;>XMLHttpRequest</button>
<button onclick=&quot;doJQueryRequest()&quot;>JQuery Request</button>
<script src=&quot;jquery-1.9.1.min.js&quot;></script>
<script>
var url = &quot;<?php echo($request->getUrl()) ?>&quot;;
var authHeader = &quot;<?php echo($request->getHeader('Authorization')) ?>&quot;;
var dateHeader = &quot;<?php echo($request->getHeader('x-amz-date')) ?>&quot;;
var methodType = &quot;<?php echo($request->getMethod()) ?>&quot;;

console.log(url);
console.log(authHeader);
console.log(methodType);

function doXMLHttpRequest() {
var request = new XMLHttpRequest();
request.open(methodType, url, true);
request.onreadystatechange = function() {
if (request.readyState === 4) {
console.log(&quot;Request complete from XMLHttpRequest, request object below&quot;);
console.log(request);
}
}
request.setRequestHeader(&quot;x-amz-date&quot;, dateHeader);
request.setRequestHeader(&quot;Authorization&quot;, authHeader);
request.send();
}

function doJQueryRequest() {
$.ajax({
url: url,
headers: {
Authorization: authHeader,
&quot;x-amz-date&quot;: dateHeader
},
type: methodType
}).done(function(data) {
console.log(&quot;Request complete from JQuery, response data below&quot;);
console.log(data);
});
}
</script>
</body>
</html>

Yes I know I have written very short description. But check out the code, that’s what matters, right? ( I am lazy๐Ÿ˜› )

How to Solve Netbeans Error “No tracked remote branch specified for local branch-name”

Short answer:
As of Git 1.7.0:
git branch --set-upstream foo upstream/foo

Long Answer:
Netbeans 7.3 introduce three new feature for git remote

  • Fetch from Upstream
  • Pull From Upstream
  • Push to Upstream

But whenever I tried to use this commands, it gave me the error
“No tracked remote branch specified for local branch-name”

After digging around for a while, I found the solution.
git branch --set-upstream branch-name remote-name/remote-branch-name

Thanks to this so answer: http://stackoverflow.com/a/2286030/472538

Now set up keyboard shortcuts for the commands and also for commit and increase your productivity๐Ÿ˜€

Facebook Extra Emoticons (Emoji)

Facebook Emoji

Facebook has given some exclusive emoticons to it’s mobile messenger (which are actully emoji). Now you can use it on desktop too. Just choose your emoticon from below and paste it in your messenger (warning: many will not work in facebook web page if you use messenger like Pidgin it will work)๐Ÿ˜€

๐Ÿ˜„๐Ÿ˜ƒโ˜บ๐Ÿ˜‰๐Ÿ˜๐Ÿ˜˜๐Ÿ˜š๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ณ๐Ÿ˜๐Ÿ˜”๐Ÿ˜Œ๐Ÿ˜’๐Ÿ˜ž๐Ÿ˜ฃ๐Ÿ˜ข๐Ÿ˜‚๐Ÿ˜ญ๐Ÿ˜ช๐Ÿ˜ฅ๐Ÿ˜ฐ๐Ÿ˜“๐Ÿ˜ฉ๐Ÿ˜ซ๐Ÿ˜จ๐Ÿ˜ฑ๐Ÿ˜ 

๐Ÿ˜ก๐Ÿ˜ค๐Ÿ˜–๐Ÿ˜†๐Ÿ˜‹๐Ÿ˜ท๐Ÿ˜ต๐Ÿ˜ฒ๐Ÿ‘ฟ๐Ÿ˜๐Ÿ‘ฒ๐Ÿ‘ณ๐Ÿ‘ฎ๐Ÿ‘ท๐Ÿ’‚๐Ÿ‘ถ๐Ÿ‘ฆ๐Ÿ‘ง๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ด๐Ÿ‘ต๐Ÿ‘ฑ๐Ÿ‘ผ๐Ÿ‘ธ๐Ÿ˜บ๐Ÿ˜ธ๐Ÿ˜ป

๐Ÿ˜ฝ๐Ÿ˜ผ๐Ÿ™€๐Ÿ˜ฟ๐Ÿ˜น๐Ÿ’€๐Ÿ‘ฝ๐Ÿ”ฅ๐Ÿ’ฉโœจ๐ŸŒŸ๐Ÿ’ข๐Ÿ’ฆ๐Ÿ’ค๐Ÿ’จ๐Ÿ‘‚๐Ÿ‘€๐Ÿ‘ƒ๐Ÿ‘…๐Ÿ‘„๐Ÿ‘๐Ÿ‘Ž๐Ÿ‘Œ๐Ÿ‘ŠโœŠโœŒ๐Ÿ‘‹โœ‹

๐Ÿ‘๐Ÿ‘†๐Ÿ‘‡๐Ÿ‘‰๐Ÿ‘ˆ๐Ÿ™Œ๐Ÿ™โ˜๐Ÿ‘๐Ÿ’ช๐Ÿ’ƒ๐Ÿ‘ซ๐Ÿ’๐Ÿ’‘๐Ÿ‘ฏ๐Ÿ™‹๐Ÿ’…๐Ÿ™๐ŸŒ‚๐Ÿ’›๐Ÿ’™๐Ÿ’œ๐Ÿ’šโค๐Ÿ’”๐Ÿ’—๐Ÿ’“๐Ÿ’–

๐Ÿ’˜๐Ÿ’‹

๐Ÿบ๐Ÿฑ๐Ÿถ๐Ÿญ๐Ÿน๐Ÿฐ๐Ÿธ๐Ÿฏ๐Ÿจ๐Ÿป๐Ÿท๐Ÿฎ๐Ÿ—๐Ÿต๐Ÿ’๐Ÿด๐Ÿ‘๐Ÿ˜๐Ÿง๐Ÿฆ๐Ÿฅ๐Ÿ”๐Ÿ๐Ÿ›๐Ÿ™๐Ÿš๐Ÿ ๐ŸŸ

๐Ÿฌ๐Ÿณ๐ŸŽ๐Ÿก๐Ÿซ๐Ÿฉ๐Ÿพ๐Ÿ’๐ŸŒธ๐ŸŒท๐Ÿ€๐ŸŒน๐ŸŒป๐ŸŒบ๐Ÿ๐Ÿƒ๐Ÿ‚๐ŸŒพ๐ŸŒต๐ŸŒด๐ŸŒฑ๐ŸŒ™โ˜€โ˜โšกโ˜”โ›„๐ŸŒ€

๐ŸŒŠ

๐ŸŽ๐Ÿ’๐ŸŽŽ๐ŸŽ“๐ŸŽ๐ŸŽ๐ŸŽƒ๐Ÿ‘ป๐ŸŽ…๐ŸŽ„๐ŸŽ๐ŸŽ‰๐ŸŽˆ๐Ÿ’ฟ๐Ÿ“€๐Ÿ’ฝ๐Ÿ’พ๐Ÿ’ป๐Ÿ“ฑ๐Ÿ“ž๐Ÿ“ ๐Ÿ“บ๐Ÿ””๐Ÿ“ฒ๐ŸŽผ๐ŸŽต๐ŸŽถ๐Ÿ‘พ

โ˜•๐Ÿบ๐Ÿธ๐Ÿ”๐ŸŽ๐ŸŠ๐Ÿ“

Will post with facebook image of the emoticons later.

Enjoy.