Sunday, 5 January 2014

Locating mysql sock file

Locating mysqld.sock file :

Its a simple step but may give you a hard time when you are a beginner.

Simply open : vim /etc/mysql/my.cnf

#Content of the file---

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

here is the default port and default sock file

==========

I found the need for this file when i had to connect to mysql db from my rails app

to configure database.yml 

development:
    adapter: mysql
    encoding: utf8
    database: application
    username: appuser
    password: password
    socket: /var/run/mysqld/mysqld.sock

Hope you found what you were looking for
--Cheers

Friday, 20 December 2013

Download list of songs from grooveshark

A simple Js to download the list of song from grooveshark.

Here is the GitHub Link for this Project : https://github.com/vi3k6i5/grooveshark-song-list

Steps:

1. Copy js from the linked source.

2. Open grooveshark page that has a song list.




3. Open the JavaScript Console from chrome developer tools. 



4. Paste the JS in the console and Press Enter.




5. Leave it for some time as the process for downloading the list of songs is lengthy and takes time.

6. At the end of the script execution a list of songs will be printed on console in JSON format.



6. Copy the list and you may organize the list at your favorite Json Processor.      
    



Thanks,

PS: I did this project because grooveshark does not provide a direct means to download the list of songs. Also at any point of time they only load 40 songs on the page. Hence it was a little challenging to download the list, and so this JS came into being.

Cheers 

Sunday, 24 November 2013

Highlight HTML Element on page

Demo: Click on Highlight



How
you
doin?


Code: How to achieve this effect :

JavaScript:
var transitionTime = 1000,

transitionEffect = 'box-shadow 1s',

shadowEffect = 'inset 0px 0px 7px 0px #FF0000, 0px 0px 7px 0px #FF0000',

removeShadow = function(element) {
    $(element).css({
        boxShadow: 'inset 0px 0px 0px 0px #000, 0px 0px 0px 0px #000' 
    });
},

resetShadow = function(element) {
    $(element).css({
       boxShadow: ''
    });
},

removeTransition = function(element) {
    $(element).css({
        transition: ''
    });
},

highlight = function(element) {
    $(element).css({
        transition: transitionEffect, boxShadow: shadowEffect 
    });
    setTimeout(function() {
        removeShadow(element);
        setTimeout(function() {
            resetShadow(element);
            removeTransition(element);
        }, transitionTime);
    }, transitionTime );
},

highlightFunction = function() {
    var elements = $(".highlight-ele");
    for(var i = 0; i < elements.length; i++) {
        highlight(elements[i]);
    }
}

HTML:
<div class="container-div">
    <div class="margin-div">
        <div class="inline-div highlight-ele" id="div1">
            How
        </div>

        <div class="inline-div highlight-ele" id="div2">
            you
        </div>

        <div class="inline-div highlight-ele" id="div3">
            doin?
        </div>
   </div>
   <div class="margin-div">
        <div class="new-div">
            <input class="highlight-ele" style="border : 1px solid black">                   </input>
        </div>
   </div>
   <div class="margin-div">
        <button onclick="highlightFunction()" style="height: 25px; width: 153px;">
            Highlight
        </button>
   </div>
</div>


CSS:
.inline-div{
    display: inline-block;
    text-align: center;
    height: 50px;
    width: 50px;
    vertical-align: middle;
    line-height: 50px;
}

.new-div {
    display: inline-block;
}

.margin-div {
    margin:10px 10px 10px 10px;
}

.container-div {
    margin: 0px auto;
    width: 178px;
    border: 1px groove;
}





jquery plugin:

I have created a jquery plugin to achieve the same effect Highlighter Plugin for jquery

Just include the js in your code and call highlight method on your selector $(".highlight-ele").highlight();

It is hosted on Github : jquery-highlighter on GitHub

Wednesday, 2 October 2013

SoftWare List for Linux.

picture Communication

picture Productivity

picture Drawing

picture Games

picture Multimedia

picture Audio

picture Engineering

picture Financial

picture Utility

Leave a comment with any software you think should be On this list.

Sunday, 4 August 2013

Fix for identifier of an instance of was altered from [parameters... = values...] to null

Recently while using hibernate with java and Mysql i got this error.

java.lang.RuntimeException: identifier of an instance of <class> was altered from PrimaryKeyClass [parameters... = values...] to null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

The error was simple to resolve but time taking to figure out.

The mistake that i made was in the setter for the primary key.

I had the code as :

private void setPk(Pk pk)
{
    pk = pk;
}

While the correct code should be :

private void setPk(Pk pk)
{
    this.pk = pk;
}

so if you get a error like this don't forget to take a closer look at the setters too.

Friday, 7 June 2013

Configuring JAD decompiler and jadclipse for Eclipse in Ubuntu 13.04 / Linux

How to setup Jad and Jadclipse for Eclipse on a Linux machine. 

Personally i have had problems with this setup many times in the past So i have put together this guidelines to do the setup in a hassle free manner.

Though this guidelines have been tested only on Ubuntu 13.04 and 12.04. They should work on generally any Linux machine.

Now i am assuming you have eclipse Installed. If not please install that first.

Step 1

Download jad from this location JAD Java Decompiler Download Mirror and extract the file.


  • Download the Linux version Jad 1.5.8e for Linux on Intel platform [For me this didn't work]
  • Jad 1.5.8e for Linux (statically linked) So i downloaded this one. 
  • [don't worry about it being 32Bit/64bit.]

Step 2

Testing that Jad is working. [Optional but Recommended] 

  • Arrange for any .class file. It ok to either make one by yourself.
  • Or copy any eclipse path/plugins/*.jar file and extract it and you will find many .class there.
  • put the class file in the jad folder
  • Then go to the folder 
      cd jad158e.linux.static/ 

      ./jad <class file name>
  • A .jad file should have gotten created as classFileName.jad.
  • [If not please post a comment i will try to help you out]

Step 3

  • Move the extracted jad folder to a proper location. I recoment /opt/
      sudo mv ~/Downloads/jad158e.linux.static /opt/

Step 4 [install jadclipse]

      sudo mv ~/Downloads/net.sf.jadclipse_3.3.0.jar /opt/eclipse/plugins/net.sf.jadclipse_3.3.0.jar


Step 5

  • Change working directory to eclipse directory.  Mine is 
      cd /opt/eclipse 
      
      eclipse -clean 
  • This should start eclipse 

Step 6

  • Go to Window -> Preferences Select Java-> JadClipse 
  • set Path to de-compiler as 
      /opt/jad158e.linux.static/jad 


  • [I renamed my folder for ease so its looking a little different in the screen shot] 
  • Apply changes 

Step 7 [This is the most important step]



  •  Select General->Editors ->File Associations 
  • Ensure that you have selected the "*.class without sources" in the upper box. This is where i make mistake most of the time.
  • Select class without source on the top box Select "jadClipse Class File Viewer". 
  • Set it as "default" viewer for class files without sources. This is also very important step. 
  • Apply changes 

Step 8



  • Now close this window and open any java library file.

 
  • De-compiler should be working fine now. 


Please leave comment, any Question below. I Will be happy to answer. 
-- 
Dasvidaniya 

Wednesday, 8 May 2013

Installing Google Chrome in Arch Linux/KDE while keeping it Simple

The Actual process to get this done is very simple.

Open address : https://aur.archlinux.org/packages/google-chrome/

in the right side you will find Package Actions

Download tarball.

Extract the tarball.

Open this location on terminal (konsole).

    Type : makepkg

    [ This command executes the file PKGBUILD, if you are interested in what it does then simply open the
      file and look at the commands. They are simple to understand and you may run those commands directly
     on the terminal doing the same process by yourself.]

    then

    as root : pacman -U google-chrome-stable....pkg.tar.xz

  [ makepkg command will build a .pkg.tar.xz file which may be used to install the software using the command written above.]

or

    makepkg -i


This should get your chrome installed.