Saturday, May 27, 2017
Why volatile is not enough?
Sunday, May 31, 2015
Tricks to Save Internet Data Usage
Here are some ways to save some data usage.
Browsers :
If you are doing heavy browsing, try using browsers that supports page compression & Image compression
eg. Opera browser's Turbo Mode
Downloads:
Other than videos,Images,audio:
If you are downloading documents,files then first try to compress them online by tools like CloudConvert.
eg. If you need to download file of 100MB -> Get it compressed by CloudConvert (7z has highest compression ratio) & download compressed one. I am sure you will save atlest 20-30MB's on this.
Use Download Managers;
If you are downloading big files try to use download managers like Free Download Manager, because many built in download managers in popular browser dont have proper download resuming capabilities on download failure. You can also add multiple peer locations(mirrors) to speedup download.
Many times download site has heavy load & even using downloaders you may endup in currupted download, in this case first convert that download to torrent by "Burnbit" & download that file by using torrent. So evenif some chunks of file gets currupted torrent will altomatically redownload it. This will save your re-download attempt.
Torrent Movie Downloads:
Now instead of downloading avi,mp4 format movies, try to download movies in mkv format.
Internally they use different video,audio codecs & compression schemes this makes mkv files considerably smaller than that of mp4 or avi file
eg. avi,mp4 file of 1GB may have same audio-video quality in 500-700MB mkv file
YouTube Downloads:
Instead of downloading youtube videos in mp4 or avi format, try to download them in webm or mkv format
You will have smaller filesize with same quality as mp4,avi video.
So to save some data on video-audio files try to download video compressed with VP8,VP9 Codecs & audio with vorbis audio.
Installing Debian Jessie ( i.e Debian 8 ) on Intel BayTrail Tablets
This tablet has pre-installed Windows 8.1.
Intel Bay Trail Tablets have 32bit UEFI & 64bit Intel Atom Quad Core Processor & many Linux doesn't supported these tablets until Debian Jessie 8.
Debian Jessie natively supports booting on 32bit UEFI devices & shockingly it works nice.
Steps:
- Download debian Jessie 32bit ( i386) or 64 bit iso. I downloaded LXDE Edition.
- Format Pendrive with FAT32 Filesystem & Extract files from iso & copy them to pendrive.
- Now boot from Pendrive & Start setup.
- After Installation done, Reboot & make sure you edit grub2 entry of debian 8 & add "nomodeset" option at last of linux line in entry else screen will go blank.
On My Tablet:
Working:
- Touchscreen
Not Working:
- Wifi
- Bluetooth
- Battary level
- 3D accelaration
- Audio
- HDMI
- Sensors ( Device Orientation & others )
- Power Management
Saturday, April 4, 2015
Filtering JSON – A Simple Way
Lets say you have some JSON data coming from some application and you want only some of it should go outside,filtering sensitive or irrelevant parts of it.
So overall you want :-
Input JSON -> Filtering Logic -> Output JSON
Now how to do this? Well there is simple & fast library called minimal-json.
Input JSON Structure:
Output JSON Structure :
So from above pictures you can see we need to filter input json & restructure it to form an output json.
Steps:
1) Create a maven project & add minimal-json dependency to it.
2) Now read Input json to string
String input = new Scanner(new File("input.json")).useDelimiter("\\Z").next();
3) Now create JSON parser from it.
JsonObject injsonobj = JsonObject.readFrom(input);
4) JsonObject outjson = new JsonObject(); as output json object
5) You can easily add json nodes to output json object which is outjson here
eg. outjson.add("totalcount", injsonobj.get("hits").asObject().get("total").asInt());
outjson.add("perpage",20);
6) Now library is very effective for parsing JSON nodes as Java Datatypes. Inorder to get JSON nodes it provides get(“name of node”) method which returns JsonObject as ouput,this JsonObject can be parsed as Java Datatype by asDouble(),asInteger().
7) If you want to get JSON Array there is a method called asArray() which returns JsonArray object. From this object you can get individual object from get(index_number) method
JsonArray jhits2 = jhits.get("hits").asArray();
for(int i=0;i<jhits2.size();i++)
{
JsonObject source = jhits2.get(i).asObject();
double score = source.get("_score").asDouble();
source = source.get("_source").asObject();
JsonValue prod_details = source.get("productdetails");
prod_details = ((JsonObject)prod_details).add("score", score);
outprodarray.add(prod_details);
}
8) Now at end when full filtering & restructuring done, you can now produce JSON output as outjson.toString()
To produce output from input of ~30KB it took less than 10 ms.(average 7ms) on 2GHz dual core machine. Well that means system can serve ~100 requests per second.
Wednesday, July 30, 2014
Simple GRUB2 Tutorial for making Rescue Media
GRUB2 is full featured multipurpose boot loader that can be booted from virtually any storage media and even from network ( PXE ).
Required:
Any Linux distribution with GRUB2 & Gparted package installed ( I am using Ubuntu 14.04 ) or you can download grub2 & Gparted source from Internet & build it on your Linux distribution.
Steps to Install GRUB2 on Pen Drive :-
- Make backup of all data on pen drive
- start Gparted as root ( or from Terminal as “ sudo gparted “ )
- Select Disk & then Delete all partitions on Pen drive ( usually there is only one ). Click on Green Checked button to Start.
- Now create first partition for your general use. Leave some space in according to your rescue Linux distribution size ( e.g. I want to use Porteus on second drive so its size is around 150MB so I am leaving 200MB free Space to create another partition from that space ) .
- Lets install Grub2 by typing this command on Terminal. “sudo grub-install <Disk node> –-boot-directory=<mount point of second partition>/boot”. In my case its “ sudo grub-install /dev/sdb –boot-directory=/media/ankush/System/boot ”.
Here Disk Node is what you see in fdisk output: Disk /dev/sdx : some size in MB’s or GB’s, Byte Count & its not /dev/sdxY ( means we want only device node not the partition node as GRUB2 gets installed in MBR not in VBR).
Now Mount Point is /mnt/sdxY or /media/<username>/<Volume Name> or <UUID> ( in Ubuntu ). If you don't know mount point then Google it for your Linux distribution.
- Now we need to edit this grub.cfg file to add out Rescue Linux entries.
Now we can specify partition in grub menu entry as (hdx,y) (here x is hard disk or storage device no. e.g.. if 2 hard disk attached then hd0 will be first & hd1 will be second & y is partition number.) e.g. (hd1,1) which is fine but if partition ordering changes entries will not boot as partition number has changed. ( Number will change if you delete partition or create new partition or even by BIOS ordering of devices which is different on different platforms)
We can specify partition by searching its UUID ( for NTFS & FAT its serial number ) which is best way because even if partition ordering changes they are still bootable but UUID changes every time we format that drive. ( So change UUID in menu entry after you format drive)
We can specify partition by its Name but if two partition having same name then first one will be chosen.
We are using UUID searching here.
Now to search UUID of our partition type “ sudo blkid –o full ” to know UUID.
- Now to make grub directory editable type “ sudo chmod –R 755 <path to boot folder>/* “. Now open grub.cfg by Text Editor program e.g.. vi or nano or Gedit or KEdit. To change grub2 background image search for background_image string & copy your jpg or png image to grub directory on pen drive & specify its path. Now if its jpeg then add insmod jpeg, if png then insmod png as shown in screenshot
- Now extract your Rescue Linux files to pen drive. & add its entry to grub.cfg. there is grub2 helper program to convert from syslinux/extlinux menu to grub menu entries or Google it. Now to set root variable add line “ search -–no-floppy –-fs-uuid –-set <UUID that you got from step 10> “ to set root drive variable.
- Now if everything ok then you have your bootable pen drive ready. As second partition is not gets mounted on Windows, malware cant affect it directly, different filesytem keeps it away from harm.
- To make grub2 bootable disk create folder on desktop & run “ grub-mkrescue <folder path> –o bootable.iso“. Add grub.cfg in grub folder specify root as set root=(cd) & remove search lines if any & also add rescue Linux files to folder BEFORE RUNNING COMMAND ( grub-mkrescue takes folder content & outputs bootable iso without grub.cfg so folder structure must have grub.cfg in boot/grub/grub.cfg to make it work )
Choose File system according to user operating system. E.g. Windows : NTFS or FAT32 Linux: EXT2,3 or 4 or BTRFS, ZFS…
Create Partition as Primary Partition ( Default ). (Don’t create second partition first as Windows will only detect & show First partition on Removable storage e.g. Pen drive )
Monday, March 24, 2014
Is your Computer running Hot and Slow?
If your Computer running hot, there may be one or many causes, you must identify which.
Causes:
1. There may be too much start-up Programs in your computer, each program consumes some CPU time & ram, so you must stop auto start of unimportant programs.
To do so press key with windows flag + r, this will bring Run prompt & type “msconfig” & press enter.
2. In System Configuration windows you can enable/disable may things like Services, programs, enabling/disabling services requires deeper understanding of system & computer usage so we will stick to start-up programs only.
Click on “startup” tab & uncheck program’s you don't want to Auto start, this will make system faster to start next time.
2. Your computer may have malware, first Update your Antivirus & then start scanning.
Keep windows updated.
Now below are some Hardware causes, before opening laptop first make sure that your body is earthed, static charge of body can easily damage chips inside laptop ( you can sit on floor to discharge your body & then open laptop )
3. If you can’t hear or feel your Computer or laptop’s fan then there may be problem in fan, it may be chocked by dust, try to clean open & clean fan.
If your Laptop fan is throwing too much hot air then get it clean or if you want to do yourself then open laptop ( google your laptop name & try to find video or see how other laptops are opened ) & clean mesh near fan ( this mesh filter’s air so catches dirt causing block in airflow )
4. Processor has Thermal Paste applied on it, it may become dry causing disturbance in heat flow, try to remove heat sink above processor & buy good thermal paste from store & gently apply it ( DONT APPLY TOO MUCH PASTE, DONT APPLY IT TO OTHER IC’S or CHIPS )
5. If you use high end programs that use 3D graphics try to install/upgrade Graphics Card & Processor, if you see high RAM usage in Task Manager then try to upgrade your RAM.
Umm still problem not solved, visit Computer Shoppe.
Wednesday, March 19, 2014
Using Backups to Save Time
Its always tedious job to Format Computer, Install OS, install software's & then configure them takes 2-3 hours but you can easily save this time by backing up clean system drive & then restoring it whenever there’s problem. Restoring backup will hardly takes some minutes. ( depending on backup size. Vanilla Windows 8 installation can be restored in 8-10minuts )
So Advantages of Backup are:
1. No need to waste 2-3 hours
2. No need to install & configure system that you already done in backup
3. No need to pay attention to restore process, once started do your work.
In this tutorial I am using Clonezilla as backup & restore software, its free & open source, you can read more on Wikipedia & its website.
What's Needed?
2. Unetbootin
3. Pen drive
Steps:
1. Start Unetbootin & select Clonezilla ISO file, select your pen drive letter & click OK
2. Now Unetbootin will start installing clonezilla on Pen Drive
3. You can click on reboot once installing gets done.
4. Now start clonezilla
5. Select Device image if you want to make drive or whole disk backup or restore on same disk ( backup/restore from same disk –> on same disk )
6. Select local dev to save clonezilla image on local hard disk.
7. Now Select drive where to save backup or from where to restore backup
8. Select folder where to save backup or restore.
9. Select Beginner mode if you don't want to select verbose options like backup program, compression scheme.. ( Defaults are used in this mode )
10. If you want to backup partition (e.g. system partition C drive ) select saveparts else if you want to backup whole disk including all partitions then select savedisk.
11. Enter name for backup or use default
12. Now select drive to backup ( use space to select ) & click OK
13. You can skip checking of drive that is going to backup.
14. You can also skip checking saved image ( If you sure there are no hard disk problems like bad sectors are there )
15. Backup is started now.
Now you successfully backup your drive. ( Be careful while choosing correct system drive, From Windows Vista (i think) there is 100MB partition which boots first so if you want complete backup of system drive you must backup this partition & system partition ( normally c drive), although backing up only system partition ( e.g. c drive ) alone is sufficient )
Restoration Process:
Situations:
1. System is not booting at-all :
In this case if you have Linux cd, start system from it, connect to internet & download & use Unetbootin from it.
or
Go to Friend & get pen drive bootable from him or write clonezilla cd.
2. System is booting but something is wrong :
Try to make pen drive bootable as Linux binaries are completely different from Windows malware most likely can’t affect Clonezilla files OR try to boot in Safe mode by pressing F8 at the start or system & make pen drive bootable or write cd.
3. There is beep sound at start up :
In this case clonezilla cant do anything, this is hardware problem, count beeps & Google this count to get meaning or consult hardware shop.
Steps:
1. Select partition where clonezilla backup files are stored.
2. Select folder of backup files if you given different folder while backup else leave it default ( backup folder is situated outside in drive )
3. Select mode Beginner is you don't want to see verbose options
4. Select “restoreparts” if you want to restore only specific partition not whole disk.
5. Select backup image to restore.
6. Select Target partition which will get formatted & restored from backup ( if backup is System partition then carefully select correct system partition )
7. Now press y two times to start restoration process..
Once restoration complete you can now reboot.


