ohmkara 1.0

a technical blog.

split / join files in linux

leave a comment »

I was looking for a way to split and join files in linux.

“split” command splits — online man

“join” command joins — online man

Another way to join files is (say join two files file1, file2 to a combinedfile)

cat file1 file2 > combinedfile

You can specify sizes. Ex. If you want to split a bigfile (of size 820Mb) to an 700Mb file and the rest

the following ‘may’ work

split -b 734003200  bigfile

And so on see the manpage

Written by deepak

January 26, 2010 at 8:53 am

Posted in linux, my notes, tools

Tagged with

linux — display off / prevent display off

leave a comment »

I keep my laptop on most of (all) the time. To turn the display off when I sleep etc. I have the following alias in my ~/.bashrc

alias doff=’sleep 5; xset dpms force off’

doff command then gives me enough time to ctrl+alt+L before the display switches off.

To prevent turning off the display / screen blanking etc. while the system is idle and I am thinking / watching movies etc. I have the following alias

alias don=’xset -dpms; xset s off’

I did not invent these by any means, to know more — link

Written by deepak

January 3, 2010 at 7:03 am

Posted in linux

Tagged with , , ,

enqueue file(s) in audacious (and other linux media players)

with 2 comments

Problem statement: I “NEED” the feature — right click on the media file (say .mp3) and have a “enqueue in player-x” option / functionality

Solution: The following was tried out in audacious2 but I think that this would work for others like xmms beep etc.

Hope the following description is clear enough. Basically we are changing program-file association, this could be done in multiple places, following is one method.

Right click on any mp3 file and select “Properties”

Select the “Open With” (Tab)

Click “Add” (Button)

Click on “Use a custom command”

Enter the following text in the field — “audacious2 -e” (without the quote)

-e option exists for other media players (or some equivalent option / flag) with that change this process could work for other players as well, But I have only tested with audacious2.

I have deleted every other player listed in the above mentioned “Open With” (for mp3, flac etc.) only two was left — the default option is audacious2 (without the enqueue option) and right click on the media file provides me the audacious2 (with enqueue option).

Thought that I might as well share it because I spend some time to figure out a way to do this. There are some nautilus scripts available to do this, but I thought that this (“my” :P) method might work even in KDE etc. (not tested there though)

Please comment if you have any ideas about better enqueuing methods (I am a noob).

Written by deepak

January 2, 2010 at 6:44 pm

Posted in linux

silence MP3 (ringtone / alarmtone)

leave a comment »

I have created 60 seconds of silence encoded as MP3 (pretty low sampling rate though, but hey…  its silence :P). Originally created for personal use (see problem statement below), in case you are searching for something similar here is the link.

Download link: [archive.org]. Applicable license CC0 (do whatever you want).

For those of you who love the story behind the act…

Problem statement: My nokia phone (5800 Express Music) seems to “sound” the alarm even in silent mode. I believe that this is general behavior for Nokia phones [citation needed], and may well be the required behavior in typical cases. I was looking for a MP3 recoding of silence to use as alarm-tone.

The killer-app for this feature request — catnap @ workplace.

Solution: Create one using audacity. There might be some other easier way to do this, say a phone setting that I am missing. If you know – do share. 60 is an arbitrary number could have reduced the duration ….

Not rocket science by any means (direct menu option in audacity), but now that I have it, might as well share — my contribution to world peace :).

Written by deepak

December 12, 2009 at 10:46 pm

Posted in free lunch

Tagged with ,

is technology an evolution hack?

leave a comment »

Here’s an interesting TED talk by Kevin Kelly on how technology evolves: link (the TED video embedding does not seem to work because the share – link to the talk gives a wrong TED ID)

I wonder…. whether the blind watchmaker (as in the book title) has been one-upped.With technology evolution we can bring in elements of both biological evolution and design. Interestingly there is no extinction since everything is recorded and can be resurrected. What may not be a good tech proposition today may become so tomorrow and can proliferate. Interesting idea…. biological life too may pass out of vogue, giving room for technological life….

Is technology the next evolutionary step for the process of evolution itself? Is resistance futile? :)

Written by deepak

September 13, 2009 at 7:55 am

Posted in takes

Tagged with ,

verilog synchronous fifo (code)

with 3 comments

I would have preferred a log2() user defined function and fifo depth parameter as a decimal integer. But icarus verilog does not seem to let me — hence the inelegance for now…

///////////////////////////////////////////////
// Author: (28/03/2009 08:54)
// Module: sync_fifo.v
// Project:
// Description: Synchronous FIFO
//    data output (dout) is un-registered.
// Version: 1.0
/////////////////////////////////////////////////
module sync_fifo
   #(
      parameter DATA_WIDTH = 8,
      parameter LOG2_DEPTH = 3 // i.e. fifo depth=2**LOG2_DEPTH
   )
   (
      input [DATA_WIDTH-1:0]  din,
      input wr_en,
      input rd_en,
      output [DATA_WIDTH-1:0] dout,
      output full,
      output empty,
      input clk,
      input reset
   );

   parameter MAX_COUNT = 2**LOG2_DEPTH;
   reg   [LOG2_DEPTH-1 : 0]   rd_ptr;
   reg   [LOG2_DEPTH-1 : 0]   wr_ptr;
   reg   [DATA_WIDTH-1 : 0]   mem[MAX_COUNT-1 : 0];   //memory size: 2**LOG2_DEPTH
   reg   [LOG2_DEPTH : 0]     depth_cnt;

   always @(posedge clk) begin
      if(reset) begin
         wr_ptr <= 'h0;
         rd_ptr <= 'h0;
      end // end if
      else begin
         if(wr_en)begin
            wr_ptr <= wr_ptr+1;
         end
         if(rd_en)
            rd_ptr <= rd_ptr+1;
      end //end else
   end//end always

   assign empty= (depth_cnt=='h0);
   assign full = (depth_cnt==MAX_COUNT);

   //comment if you want a registered dout
   assign dout = rd_en ? mem[rd_ptr]:'h0;

   always @(posedge clk) begin
      if (wr_en)
         mem[wr_ptr] <= din;
   end //end always

   //uncomment if you want a registered dout
   //always @(posedge clk) begin
   //   if (reset)
   //      dout <= 'h0;
   //   else if (rd_en)
   //      dout <= mem[rd_ptr];
   //end

   always @(posedge clk) begin
      if (reset)
         depth_cnt <= 'h0;
      else begin
         case({rd_en,wr_en})
            2'b10    :  depth_cnt <= depth_cnt-1;
            2'b01    :  depth_cnt <= depth_cnt+1;
         endcase
      end //end else
   end //end always

endmodule

errata / addendum:
A better synchronous fifo might be — code below…

</pre>
///////////////////////////////////////////////
// Author: Deepak (28/03/2009 08:54)
// Module: fifo.v
// Project:
// Description: Synchronous FIFO
//    data output (dout) is un-registered.
// Version: 1.1 (not icarus verilog compatible)
//
///////////////////////////////////////////////

module sync_fifo
#(
 parameter DATA_WIDTH = 8,
 parameter DEPTH = 8</pre>
)
(
 input [DATA_WIDTH-1:0]  din,
 input wr_en,
 input rd_en,
 output [DATA_WIDTH-1:0] dout,
 output reg full,
 output reg empty,

 input clk,
 input reset
);

function integer log2;
 input integer n;
 begin
 log2 = 0;
 while(2**log2 < n) begin
 log2=log2+1;
 end
 end
endfunction

parameter ADDR_WIDTH = log2(DEPTH);
reg   [ADDR_WIDTH : 0]     rd_ptr; // note MSB is not really address
reg   [ADDR_WIDTH : 0]     wr_ptr; // note MSB is not really address
wire  [ADDR_WIDTH-1 : 0]  wr_loc;
wire  [ADDR_WIDTH-1 : 0]  rd_loc;
reg   [DATA_WIDTH-1 : 0]  mem[DEPTH-1 : 0];

assign wr_loc = wr_ptr[ADDR_WIDTH-1 : 0];
assign rd_loc = rd_ptr[ADDR_WIDTH-1 : 0];

always @(posedge clk) begin
 if(reset) begin
 wr_ptr <= 'h0;
 rd_ptr <= 'h0;
end // end if
else begin
 if(wr_en & (~full))begin
 wr_ptr <= wr_ptr+1;
 end
 if(rd_en & (~empty))
 rd_ptr <= rd_ptr+1;
 end //end else
end//end always

//empty if all the bits of rd_ptr and wr_ptr are the same.
//full if all bits except the MSB are equal and MSB differes
always @(rd_ptr or wr_ptr)begin
 //default catch-alls
 empty <= 1'b0;
 full  <= 1'b0;
 if(rd_ptr[ADDR_WIDTH-1:0]==wr_ptr[ADDR_WIDTH-1:0])begin
 if(rd_ptr[ADDR_WIDTH]==wr_ptr[ADDR_WIDTH])
 empty <= 1'b1;
 else
 full  <= 1'b1;
 end//end if
end//end always

always @(posedge clk) begin
 if (wr_en)
 mem[wr_loc] <= din;
end //end always

//comment if you want a registered dout
assign dout = rd_en ? mem[rd_loc]:'h0;
//uncomment if you want a registered dout
//always @(posedge clk) begin
//   if (reset)
//      dout <= 'h0;
//   else if (rd_en)
//      dout <= mem[rd_ptr];
//end
endmodule

Written by deepak

March 29, 2009 at 9:28 am

Posted in hdl

Tagged with

gnome — send to USB drive / removable disk

leave a comment »

You can add a right-click able send to USB drive option in gnome with the “Send To” script available here: link; the target/ destination could be any writeable file-system mounted at /media.  . Such a feature is available in xfce, I was missing the same in gnome, I feel that it is a mighty nice feature to have.

You have to copy the link to ~/gnome2/nautilus-scripts and make it executable (chmod). Right clicking will thereafter present an option called ‘Scripts’ which is the required action.

Ack: I got this info @ this site: link.

Written by deepak

March 21, 2009 at 9:07 pm

Posted in links, linux

Tagged with