<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3451642050545042735</id><updated>2024-09-05T15:22:07.366-07:00</updated><category term="linux script"/><category term="boost build bjam jam protobuf Google"/><category term="current time linux shell script millisecond"/><category term="javascript programming"/><title type='text'>Liping&#39;s Workshop</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lipingworkshop.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://lipingworkshop.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Liping Zhang</name><uri>http://www.blogger.com/profile/00028755476382786872</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-nl7mNQDJYgqhWEEejrEG6JxfFv0k41cjR8-o39be2BKjF4aT-DtYnpR1hf7ycf3c8oqN_7x0AgGD_mRVxnygnDVAwClULBDCq0rVKD5g4biOr3Kl83_R-GZSzvFwAz8/s220/P1020774.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3451642050545042735.post-8911593547086608536</id><published>2012-01-21T00:09:00.000-08:00</published><updated>2012-02-05T23:49:00.164-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="boost build bjam jam protobuf Google"/><title type='text'>Boost.build bjam file to support Google protobuf compilation</title><content type='html'>This source code was adapted from Rodrigo Pinho Pereira de Souza ( pinhopro at gmail dot com )&#39;s code and is now published under Boost License (as it was). &lt;br /&gt;
&lt;br /&gt;
Usage: &lt;br /&gt;
&lt;br /&gt;
1. Save the following source code into a file pb.jam; &lt;br /&gt;
2. Modify boostlib/tools/build/v2/user-config.jam: &lt;br /&gt;
and make the following changes; &lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;using pb : /usr/local ;  # /usr/local is the prefix pointing to the Google protobuf installation;
&lt;/pre&gt;3. In your project jam file &lt;br /&gt;
&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;exe myexe : 
   message.proto 
   a.cpp b.cpp

    ; 
&lt;/pre&gt;&lt;br /&gt;
or &lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;lib msg1 :   message.proto  ;
 exe myexe : 
   msg1
   a.cpp b.cpp
   : &lt;implicit-dependency&gt;msg1 ;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Finally the source for pb.jam&lt;br /&gt;
&lt;pre name=&quot;code&quot; class=&quot;bash&quot;&gt;# Copyright 2012 Liping Zhang (zhanglpg at gmail dot com)
# Copyright 2010 Rodrigo Pinho Pereira de Souza ( pinhopro at gmail dot com )
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

import type ;
import generators ;
import feature ;
import common ;
import &quot;class&quot; : new ;

import modules ;
import feature ;
import project ;
import toolset : flags ;

project.initialize $(__name__) ;
project pb ;


type.register PROTO : proto ;

.project = [ project.current ] ;

# Helper utils for easy debug output
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
  .debug-configuration = TRUE ;
}

local rule debug-message ( message * )
{
  if $(.debug-configuration) = TRUE
  {
    ECHO notice: [protobuf-cfg] $(message) ;
  }
}


rule init ( prefix : condition * )
{
  project.push-current $(.project) ;

  .prefix = $(prefix) ;

  .incprefix = $(prefix)/include ;
  .libprefix = $(prefix)/lib ;
  .binprefix = $(prefix)/bin ;   

  debug-message  &quot;rule init (&quot; $(prefix) &quot;,&quot; $(condition) &quot;)&quot; ;
  debug-message &quot;include path: &quot; $(.incprefix) ;
  debug-message &quot;library path: &quot; $(.libprefix) ;
  debug-message &quot;bin path&quot; $(.binprefix) ;
  
  if ! $(.initialized)
  {
    .initialized = true ;
    debug-message &quot;initializing protobuf...&quot; ;

    debug-message &quot;registering proto type &quot; ;
    #type.register PROTO : proto ;

    debug-message &quot;registering protoc compiler &quot; ;
    generators.register [ new proto-generator pb.protoc : PROTO : CPP(%.pb) H(%.pb) ] ;

    .PREFIX = $(prefix) ;
    debug-message &quot;protobuf initialized.&quot; ;
  }

  debug-message &quot;setup path for protoc tool&quot; ;
  toolset.flags pb.protoc .BINPREFIX : $(.binprefix) ;

  local usage-requirements =
      &lt;include&gt;$(.incprefix)
      &lt;library-path&gt;$(.libprefix)
      &lt;dll-path&gt;$(.libprefix)
    ;
  debug-message &quot;usage-requirements: &quot; $(usage-requirements) ;

  local target-requirements = $(condition) ;

  lib protobuflib : 
    : # requirements 
      &lt;name&gt;protobuf
       $(target-requirements)
    : # default-build
    : # usage-requirements
      $(usage-requirements)
    ;

  lib protobuf-litelib : 
    : # requirements 
      &lt;name&gt;protobuf-lite
       $(target-requirements)
    : # default-build
    : # usage-requirements
      $(usage-requirements)
    ;

  project.pop-current ;

  debug-message &quot;module pb initialized&quot; ;
}


rule initialized ( )
{
  return $(.initialized) ;
}

class proto-generator : generator 
{
    import &quot;class&quot; : new ;

    rule __init__ ( * : * )
    {
        generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
    }

    rule run ( project name ? : property-set : sources * )
    {
        if ! $(sources[2])
        {
            # Accept only single source.
            local t = [ $(sources[1]).type ] ;
   
            if $(t) = PROTO
            {
                # The type is correct.

                # If no output name is specified, guess it from sources.
                if ! $(name)
                {
                    name = [ generator.determine-output-name $(sources) ] ;
     name = $(name)&quot;.pb&quot; ;
                }

       

    local a = [ new action $(sources[1]) : pb.protoc : $(property-set) ] ;
 # since the default CPP suffix is .cpp and protoc generates .cc files, we need to specify the exact file name for CPP
           local target1 = [ new file-target $(name).cc exact : CPP : $(project) : $(a) ] ;

    local target2 = [ new file-target $(name) : H : $(project) : $(a) ] ;
    
    
    DEPENDS all : [ $(target1).actualize ] ;
    DEPENDS all : [ $(target2).actualize ] ;

    return [ virtual-target.register $(target1) ]
     [ virtual-target.register $(target2) ]
     ;
   }
  }
    }
}

#generators.register [ new proto-generator pb.protoc : PROTO : CPP H ] ;

actions protoc
{
  cp $(&gt;[1]) . 
  $(.BINPREFIX[-1])/protoc $(&gt;[1]:B)$(&gt;[1]:S)  --cpp_out=$(&lt;[1]:D) 
  
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://lipingworkshop.blogspot.com/feeds/8911593547086608536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lipingworkshop.blogspot.com/2012/01/boostbuild-bjam-file-to-support-google.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/8911593547086608536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/8911593547086608536'/><link rel='alternate' type='text/html' href='http://lipingworkshop.blogspot.com/2012/01/boostbuild-bjam-file-to-support-google.html' title='Boost.build bjam file to support Google protobuf compilation'/><author><name>Liping Zhang</name><uri>http://www.blogger.com/profile/00028755476382786872</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-nl7mNQDJYgqhWEEejrEG6JxfFv0k41cjR8-o39be2BKjF4aT-DtYnpR1hf7ycf3c8oqN_7x0AgGD_mRVxnygnDVAwClULBDCq0rVKD5g4biOr3Kl83_R-GZSzvFwAz8/s220/P1020774.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3451642050545042735.post-5373603858595016952</id><published>2011-01-07T15:52:00.000-08:00</published><updated>2011-01-10T11:20:53.776-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux script"/><title type='text'>linux script to split ape / wav / flac + cue to individual tracks in flac / ogg / mp3 format</title><content type='html'>1. Processes files in current directory and its sub-dirs recursively, (excluding those under */converted/)&lt;br /&gt;
2. accepts input format : (1) ape, (2) flac, (3) wav ;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; must have a .cue file&lt;br /&gt;
3. tags transferred&lt;br /&gt;
4. works on linux with bash shell. &lt;br /&gt;
5. usage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; copy the following content and save it to a file (say splitter.sh), copy the script to the target directory, then use&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;splitter.sh -i ape|wav|flac|all -o flac|mp3|ogg [ -d output_dir] 
&lt;/pre&gt;If the destination dir is not specified, the splitted files will be saved to a sub dir under current working directory using the base name of the original file. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What is needed to run this script? &lt;br /&gt;
&lt;br /&gt;
To be able to decompress &quot;ape&quot; file, you need to have &lt;b&gt;&lt;a href=&quot;http://www.ffmpeg.org/&quot;&gt;ffmpeg &lt;/a&gt;&lt;/b&gt;installed, &lt;br /&gt;
For Ubuntu users, you can install it by &lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;sudo apt-get install ffmpeg&lt;/pre&gt;&lt;br /&gt;
To be able to decompress &quot;flac&quot; file, you need to have &lt;b&gt;&lt;a href=&quot;http://flac.sourceforge.net/&quot;&gt;flac&lt;/a&gt;&lt;/b&gt;installed, &lt;br /&gt;
You can also install it by typing &lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;sudo apt-get install ffmpeg&lt;/pre&gt;in Ubuntu. &lt;br /&gt;
&lt;br /&gt;
To generate mp3 outputs, you will need to install &quot;lame&quot; and &quot;mp3splt&quot;, &lt;br /&gt;
for &quot;ogg&quot; output, you will need &quot;oggenc&quot; and &quot;mp3splt&quot;.&lt;br /&gt;
While for generating flac, you will need &quot;flac&quot; and &quot;shnsplit&quot; (in package &quot;shntool&quot;) &lt;br /&gt;
&lt;br /&gt;
so to simplify things, you can install all of them for Ubuntu by typing the following&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;sudo apt-get install ffmpeg flac shntool oggenc cuetag mp3splt lame
&lt;/pre&gt;&lt;br /&gt;
(Click &quot;&lt;b&gt;View Plain&lt;/b&gt;&quot; button to copy the source code&quot;)&lt;br /&gt;
enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;#!/bin/bash
#Convert &quot;.ape or .flac&quot; to &quot;.mp3 or .ogg&quot;, using 
# 
# TOOLS: mp3split, lame, ffmpeg, flac
#
# Licence: GPL
# by Liping  Zhang
#Copyright (C) 2011  Liping Zhang - San Francisco, USA
#
#IF YOU FIND A BUG OR HAVE A SUGGESTION COMMENTO OR SIMPLY WANT TO CONTACT ME PLEASE MAIL ME TO 
#zhanglpg_*@gmail.com  REMOVING THE &quot;_*&quot;
#This is done to prevent spamming 

#This script is intended to convert ape or flac + cue files to 
#ogg vorbis or mp3 or flac files, setting the tags to the correct value,
#obtained from the cue file.
#
#(original license header from the cueape function within this script)
#IF YOU FIND A BUG OR HAVE A SUGGESTION COMMENTO OR SIMPLY WANT TO CONTACT ME PLEASE MAIL ME TO 
#rafadev_*@gmail.com  REMOVING THE &quot;_*&quot;
#This is done to prevent spamming 

#Copyright (C) 2006  Rafael Ponieman - Buenos Aires, Argentina

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

# usage:  inputoption outputoption 
#
e() { echo -e &quot;$@&quot;;tput sgr0; }
red=&quot;\033[31m&quot;
green=&quot;\033[32m&quot;
nt=&quot;\033[0m&quot;

clear


ee() {
 codee=$1
 e &quot;\033[0m&quot;
 exit $codee
}




testinstall() 
{
 if(test -x `whereis -b $1|sed -e &#39;s/[^*]*\:\ //&#39;|sed -e &#39;s/\ [^*]*//&#39;`)
 then  
  e ${green}&quot;$1: found&quot;${nt}
  return 0
 else  
  e ${red}&quot;$1: not found&quot;${nt}
  e ${red}&quot;exit...&quot;${nt}
  return  1 
 fi
}

iflag=
oflag=
ival=&quot;all&quot;
oval=&quot;mp3&quot;
dflag=
while getopts &#39;i:o:d:&#39; OPTION
do
  case $OPTION in
  i) iflag=1
  ival=&quot;$OPTARG&quot;
  ;;
  o) oflag=1
  oval=&quot;$OPTARG&quot;
  ;;
  d)    dflag=&quot; -d $OPTARGS &quot;
  ;;
  ?) printf ${green}&quot;Usage: %s: [-i input_format] [-o output format] \n&quot; $(basename $0) &amp;gt;&amp;amp;2
  printf ${green}&quot;input format supported are: flac, ape or all (default) \n&quot; $(basename $0) &amp;gt;&amp;amp;2
  printf ${green}&quot;out format supported are: mp3 (default), ogg \n&quot; $(basename $0) &amp;gt;&amp;amp;2
  ee 2
  ;;
  esac
done

if [ &quot;$iflag&quot; ]; then 
 case $ival in
 ape|flac|wav|all) 
 #all) 
  e ${green}&quot;input format is $ival &quot;${nt} 
  ;;
 ?) 
  e ${red}&quot;invalid argument $ival for -i &quot;${nt} 
  ee 1
  ;;
 esac 
fi

if [ &quot;$ival&quot; = &quot;ape&quot; ]; then 
 testinstall ffmpeg || ee 1 
fi
if [ &quot;$ival&quot; = &quot;flac&quot; ]; then 
 testinstall flac || ee 1 
fi


#testinstall cueape.sh || ee 1 

if [ &quot;$oflag&quot; ]; then 
 case $oval in
 mp3|ogg|flac) 
  e ${green}&quot;output format is $oval &quot;${nt}
  ;;
 ?) 
  e ${red}&quot;invalid argument $oval for -o &quot;${nt}
  ee 1
  ;;
 esac 
fi


if [ &quot;$oval&quot; = &quot;mp3&quot; ]; then 
 testinstall lame || ee 1 
 testinstall mp3splt || ee 1 
fi
if [ &quot;$oval&quot; = &quot;ogg&quot; ]; then 
 testinstall oggenc || ee 1 
 testinstall mp3splt || ee 1 
 of=&quot; -o &quot;
fi
if [ &quot;$oval&quot; = &quot;flac&quot; ]; then 
 testinstall flac || ee 1 
 of=&quot; -f &quot;
fi 
testinstall cuetag || ee 1 

of=&quot;$oval $dflag&quot;

e ${green}&quot;calling with $of&quot;${nt}
#set -x
#WAV=/tmp/output.wav

#
#IFILE=$(echo *.[aA][pP][eE])
#CFILE=$(echo *.[cC][uU][eE])

convertfile() 
{
 #search for &quot;converted&quot;
 dirn=&quot;$(dirname &quot;$1&quot;)&quot; 
 ldirn=&quot;$(basename &quot;$dirn&quot;)&quot; 
 if [ &quot;$ldirn&quot; = &quot;converted&quot; ]; then 
  e ${green}&quot;skip converted folder&quot;${nt}
  return 1  
 fi
 e ${green}&quot;continue conversion&quot;${nt}
 bnm=&quot;$(basename &quot;$1&quot;)&quot;
 bnm=&quot;${bnm%.[aA][pP][eE]}&quot;
 bnm=&quot;${bnm%.[fF][lL][aA][cC]}&quot;
 
 ebnm=&quot;$(printf &quot;%q&quot; &quot;$bnm&quot;)&quot;
 found=&quot;0&quot;
 find -type f -name &quot;$ebnm.[cC][uU][eE]&quot; | while read fn ; do 
  found=&quot;1&quot;
  e ${green}&quot; converting file $1 ($bnm) and $fn&quot;${nt}
  cueape &quot;$1&quot; &quot;$fn&quot; $of 
  return 2 
 done
 if ! [ $? -eq 2 ]; then
  e ${red}&quot;Could not find cue file for $1&quot;${nt}
  return 1
 fi
 return 0
}

cueape() 
{


 #scripted by deX


 case &quot;$1&quot; in
 *.[aA][pP][eE] | *[fF][lL][aA][cC] | *.[wW][aA][vV] )
  if [ ! -f &quot;$1&quot; ] ; then
   e ${red}&quot;Input file $1 doesn&#39;t exist&quot;${nt}
   return 1
  fi
  if [ ! -f &quot;$2&quot; ]; then
   e ${red}&quot;Cue input file $2 doesn&#39;t exist&quot;${nt}
   return 1
  fi ;;
 * ) 
  e ${red}&quot;Error: invalid input parameters&quot;${nt}
  return ;;
 esac

 #Testing parameters
 case &quot;$3&quot; in
 flac|ogg|mp3)
  ;;
 *)
  e ${red}&quot;Invalid parameters&quot;${nt}
  
  e &quot;Usage: cueape [input ape/wav/flac file] [input cue file] [parameters]\nParameters can be: -m for mp3 encoding or -o for ogg encoding or -f for flac encoding.\n&quot;
  return 1
 esac




 #Saving the position so as to return afterwards 
 olddir=&quot;$(pwd)&quot;

 #Going to target directory


 tmp=&quot;$(basename &quot;$1&quot;)&quot;
 tmp=&quot;${tmp##*.}&quot;
 #bnm=&quot;$tmp&quot;
 bnm=&quot;$(basename &quot;$1&quot;)&quot;
 bnm=&quot;${bnm%.[aA][pP][eE]}&quot;
 bnm=&quot;${bnm%.[fF][lL][aA][cC]}&quot;
 bnm=&quot;${bnm%.[wW][aA][vV]}&quot;

 based=&quot;$(dirname &quot;$1&quot;)&quot;
 #cd &quot;$(dirname &quot;$1&quot;)&quot;
 if [ &quot;$4&quot; = &quot;-d&quot; ] ; then
  bnm=&quot;$5&quot; 
 fi 

 #Checking for the output folder. If it&#39;s not there I create it
 [ ! -d &quot;$based/$bnm&quot; ] &amp;amp;&amp;amp; mkdir &quot;$based/$bnm&quot; 
 cp -f &quot;$2&quot; &quot;$based/$bnm/&quot; 

 convertd=&quot;$(dirname &quot;$1&quot;)/converted&quot;

 [ ! -d &quot;$convertd&quot; ] &amp;amp;&amp;amp; mkdir &quot;$convertd&quot;  

 #Decompress
 echo -en &quot;\nCueape 0.1\n\n&quot;
 echo -en &quot;\033[1;32mStarting conversion\n&quot;

 #Checking filetype by extension and decompressing
 #tmp=&quot;$(basename &quot;$1&quot;)&quot;
 #tmp=&quot;${tmp##*.}&quot;


 case &quot;$tmp&quot; in
 [fF][lL][aA][cC]) 
  e ${green}&quot;Decompressing FLAC file\n\n&quot;${nt}
  
  tm=&quot;$(basename &quot;$1&quot;)&quot;
  tm=&quot;${tm%.[fF][lL][aA][cC]}&quot;
  if [ -e &quot;$convertd/${tm}.wav&quot; ]; then 
   e &quot;$convertd/${tm}.wav already exists, skipping decompression&quot;
  else 
   out=&quot;$(flac &quot;-d&quot; &quot;$1&quot; -o &quot;/tmp/${tm}.$$.wav&quot; )&quot; 
   mv &quot;/tmp/${tm}.$$.wav&quot; &quot;$convertd/${tm}.wav&quot;
  fi
  ;;
 [aA][pP][eE])
  e ${green}&quot;\033[1;32mDecompressing APE file\n\n&quot;${nt}
  
  tm=&quot;$(basename &quot;$1&quot;)&quot;
  tm=&quot;${tm%.[aA][pP][eE]}&quot;
  #out=&quot;$(mac &quot;$1&quot; &quot;Output/${tm}.wav&quot; &quot;-d&quot;)&quot; 
  if [ -e &quot;$convertd/${tm}.wav&quot; ]; then
   e ${green}&quot;$convertd/${tm}.wav already exists, skipping decompression&quot;
  else 
   out=&quot;$(ffmpeg -i &quot;$1&quot; &quot;/tmp/${tm}.$$.wav&quot;)&quot;  
   mv &quot;/tmp/${tm}.$$.wav&quot; &quot;$convertd/${tm}.wav&quot;
  fi
  ;;
 [wW][aA][vV])
  
  tm=&quot;$(basename &quot;$1&quot;)&quot;
  tm=&quot;${tm%.[wW][aA][vV]}&quot;
  e ${green}&quot;copying wav file to converted dir&quot;${nt}
  cp &quot;$1&quot; &quot;$convertd/${tm}.wav&quot;
  #ln -s &quot;$1&quot; &quot;$convertd/${tm}.wav&quot;
  ;;
 *)
  echo &quot;Error: line 99&quot;
 esac

 #cd &quot;$bnm&quot;
 e ${green}&quot;Decompression finished\n&quot;${nt}
 e ${green}&quot;Starting reencoding\n\n&quot;${nt}

 mkdir &quot;/tmp/cueape$$&quot;
 e ${green}&quot;temp dir /tmp/cueape$$&quot;${nt}
 case &quot;$3&quot; in
 ogg)
  #Calling oggenc. Saving output for future checking
  
  if [ -e &quot;$convertd/${tm}.ogg&quot; ]; then
   e ${green}&quot;$convertd/${tm}.ogg already exists, skip reencoding&quot;${nt}
   cp &quot;$convertd/${tm}.ogg&quot; &quot;/tmp/cueape$$/$tm.ogg&quot;
  else
   out=&quot;$(oggenc -q 6 -o &quot;/tmp/cueape$$/$tm.ogg&quot; &quot;$convertd/${tm}.wav&quot;)&quot;
   mv &quot;/tmp/cueape$$/$tm.ogg&quot; &quot;$convertd/${tm}.ogg&quot;
   echo -en &quot;\033[1;32m\nReencoding finished\n&quot;
  fi
  e ${green}&quot;Splitting\n\n&quot;${nt}
  
  #out=&quot;$(mp3splt -c &quot;$(basename &quot;$2&quot;)&quot; -o &quot;$bnm/@n+-+@t&quot; &quot;$convertd/$tm.ogg&quot;)&quot;
  cp &quot;$2&quot; &quot;/tmp/cueape$$&quot;
  cd &quot;/tmp/cueape$$&quot; 
  out=&quot;$(mp3splt -c &quot;$(basename &quot;$2&quot;)&quot; -o &quot;@n+-+@t&quot; &quot;$tm.ogg&quot;)&quot;
  rm -f &quot;/tmp/cueape$$/$tm.ogg&quot;
  e ${green}&quot;transferring tags...\n\n&quot;${nt}
  cuetag &quot;$(basename &quot;$2&quot;)&quot; *.ogg
  cd &quot;$olddir&quot;
  mv /tmp/cueape$$/*.ogg &quot;$based/$bnm/&quot;
 # rm -f &quot;$tm.wav&quot; 
  ;;
 mp3)
  #Calling lame. Saving output for future checking
  if [ -e &quot;$convertd/${tm}.mp3&quot; ]; then
   e ${green}&quot;$convertd/${tm}.mp3 already exists, skip reencoding&quot;${nt}
   cp &quot;$convertd/${tm}.mp3&quot; &quot;/tmp/cueape$$/${tm}.mp3&quot;
  else
   out=&quot;$(lame --preset standard &quot;$convertd/$tm.wav&quot; &quot;/tmp/cueape$$/$tm.mp3&quot;)&quot;
   cp &quot;/tmp/cueape$$/$tm.mp3&quot; &quot;$convertd/$tm.mp3&quot; 
   echo -en &quot;\033[1;32m\nReencoding finished\n&quot;
  fi
  e ${green}&quot;Splitting\n\n&quot;${nt}
  
  #Using framemode becaus this settings are for VBR
  #out=&quot;$(mp3splt -f -c &quot;$(basename &quot;$2&quot;)&quot; -o &quot;$bnm/@n+-+@t&quot; &quot;$convertd/$tm.mp3&quot;)&quot;
  #out=&quot;$(mp3splt -f -c &quot;$2&quot; -o &quot;$based/$bnm/@n+-+@t&quot; &quot;$convertd/$tm.mp3&quot;)&quot;
 # rm -f &quot;$tm.wav&quot; 
  cp &quot;$2&quot; &quot;/tmp/cueape$$/&quot;
  cd &quot;/tmp/cueape$$&quot;
  
  out=&quot;$(mp3splt -f -c &quot;$(basename &quot;$2&quot;)&quot; -o &quot;@n+-+@t&quot; &quot;$tm.mp3&quot;)&quot;
  rm -f &quot;/tmp/cueape$$/$tm.mp3&quot;
  e ${green}&quot;transferring tags...\n\n&quot;${nt}
  cuetag &quot;$(basename &quot;$2&quot;)&quot; *.mp3
  cd &quot;$olddir&quot; 
  mv /tmp/cueape$$/*.mp3 &quot;$based/$bnm/&quot;
  ;;
 flac)
  e ${green}&quot;Splitting\n\n&quot;${nt}
  cp &quot;$2&quot; &quot;/tmp/cueape$$/&quot;
  cp &quot;$convertd/$tm.wav&quot;  &quot;/tmp/cueape$$/&quot;
  cd &quot;/tmp/cueape$$&quot;
  #out=&quot;$(shnsplit -f &quot;$(basename &quot;$2&quot;)&quot; -o &#39;flac flac -s -o &quot;%f&quot; -&#39; -t &quot;%n-%t&quot; &quot;$tm.wav&quot;)&quot;
  out=&quot;$(shnsplit -f &quot;$(basename &quot;$2&quot;)&quot; -o flac -t &quot;%n-%t&quot; &quot;$tm.wav&quot;)&quot;
  e ${green}&quot;transferring tags...\n\n&quot;${nt}
  cuetag &quot;$(basename &quot;$2&quot;)&quot; *.flac
  cd &quot;$olddir&quot; 
  rm -f &quot;/tmp/cueape$$/$tm.wav&quot;
  mv /tmp/cueape$$/*.flac &quot;$based/$bnm/&quot;
  ;;
 *)
  e ${red}&quot;unrecognized output format&quot;${nt}
  return 1
  ;;
 esac
 
 cd &quot;$oldir&quot;
 e  ${green}&quot;Processing finished successfully\n&quot;${nt}

 return 0
}


if [ &quot;$ival&quot; = &quot;ape&quot; ] || [ &quot;$ival&quot; = &quot;all&quot; ]; then
 find -type f -name &quot;*.[aA][pP][eE]&quot; | while read file ; do
  convertfile &quot;$file&quot; 
 done
fi 

if [ &quot;$ival&quot; = &quot;flac&quot; ] || [ &quot;$ival&quot; = &quot;all&quot; ]; then
 find -type f -name &quot;*.[fF][lL][aA][cC]&quot; | while read file ; do
  convertfile &quot;$file&quot; 
 done
fi 

if [ &quot;$ival&quot; = &quot;wav&quot; ] || [ &quot;$ival&quot; = &quot;all&quot; ]; then
 find -type f -name &quot;*.[wW][aA][vV]&quot; | while read file ; do
  convertfile &quot;$file&quot; 
 done
fi 

e ${green}&quot;conversion completed &quot;${nt} 
ee 0


&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://lipingworkshop.blogspot.com/feeds/5373603858595016952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lipingworkshop.blogspot.com/2011/01/linux-script-to-split-ape-wav-flac-cue.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/5373603858595016952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/5373603858595016952'/><link rel='alternate' type='text/html' href='http://lipingworkshop.blogspot.com/2011/01/linux-script-to-split-ape-wav-flac-cue.html' title='linux script to split ape / wav / flac + cue to individual tracks in flac / ogg / mp3 format'/><author><name>Liping Zhang</name><uri>http://www.blogger.com/profile/00028755476382786872</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-nl7mNQDJYgqhWEEejrEG6JxfFv0k41cjR8-o39be2BKjF4aT-DtYnpR1hf7ycf3c8oqN_7x0AgGD_mRVxnygnDVAwClULBDCq0rVKD5g4biOr3Kl83_R-GZSzvFwAz8/s220/P1020774.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3451642050545042735.post-3817045008830159654</id><published>2010-12-14T17:22:00.000-08:00</published><updated>2020-05-03T23:26:23.753-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript programming"/><title type='text'>dynamically loading Google Chart Image in an iFrame using POST request and Javascript (prototype)</title><content type='html'>Google Chart API online document gives a good example on how to write html code to load a Google Chart using POST request, you can find it&amp;nbsp;&lt;a href=&quot;http://code.google.com/apis/chart/docs/post_requests.html&quot;&gt;here&lt;/a&gt;. &amp;nbsp;The benefit of this method is the higher limit of data size that can be posted (16kB instead of 2K in the URL).&lt;br /&gt;
&lt;br /&gt;
Here I want to post an example to show how this post request can be generated from within a dynamically generated iframe. This would be useful for showing a chart using dynamic data which, say, are downloaded from another page using ajax request (&lt;a href=&quot;http://www.prototypejs.org/&quot;&gt;prototype library&lt;/a&gt;&amp;nbsp;is used).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is how the DOM document might look like:&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;&amp;lt;div id=&quot;outerdiv&quot; width=&quot;700&quot; height=&quot;400&quot;&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
and the javascript code: &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var fstr =
     &quot;&amp;lt;iframe src=&#39;&#39; id=&#39;gchart_frame&#39; width=&#39;710&#39; height=&#39;410&#39;&amp;gt;&amp;lt;/iframe&amp;gt;&quot; ;
var formstr = &quot;&amp;lt;form id=&#39;gchart_form&#39;&quot; +&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot; action=&#39;http://chart.apis.google.com/chart?chid=&quot; + 
&amp;nbsp;&amp;nbsp;&amp;nbsp;Math.random() + &quot;&#39; method=&#39;POST&#39;&amp;gt;&quot; ;&amp;nbsp;
// random chid to prevent browser caching
formstr&amp;nbsp;+= &quot;&amp;lt;input type=&#39;hidden&#39; name=&#39;cht&#39; value=&#39;lc&#39;/&amp;gt;&quot; ;
formstr&amp;nbsp;+= &quot;&amp;lt;input type=&#39;hidden&#39; name=&#39;chs&#39; value=&#39;700x400&#39;/&amp;gt;&quot; ;
formstr += &quot;&amp;lt;input type=&#39;hidden&#39; name=&#39;chd&#39; value=&#39;t:0,1,2,3,5,123&quot; ; &amp;nbsp;
&amp;nbsp;&amp;nbsp;// put your data here, can be dynamically downloaded from an ajax source.
formstr +=&quot;&amp;lt;input type=&#39;hidden&#39; name=&#39;chxt&#39; value=&#39;x,y&#39;/&amp;gt;&quot; ;
formstr&amp;nbsp;+=&quot;&amp;lt;input type=\&quot;submit\&quot;/&amp;gt;&amp;lt;/form&amp;gt;&quot; ;

$(&#39;outerdiv&#39;).innerHTML =&amp;nbsp;fstr&amp;nbsp;;&amp;nbsp;
&amp;nbsp;&amp;nbsp;// &amp;nbsp;embed the iframe ($) is from prototype library

var ff = $(&#39;gchart_frame&#39;) ;
if (! Prototype.Browser.IE) { // for other browsers
&amp;nbsp;&amp;nbsp;var y=(ff.contentWindow || ff.contentDocument);
&amp;nbsp;&amp;nbsp;if (y.document)
&amp;nbsp;&amp;nbsp;     y=y.document;
&amp;nbsp;&amp;nbsp;y.body.innerHTML = formstr;
&amp;nbsp;&amp;nbsp;y.forms[0].submit() ;  // load the chart within the iframe
}
else { // IE
&amp;nbsp;&amp;nbsp; var ffs = document.frames[&quot;gchart_frame&quot;] ;
&amp;nbsp;&amp;nbsp; var divn = ffs.document.createElement(&#39;div&#39;) ;
&amp;nbsp;&amp;nbsp; divn.innerHTML = formstr;
&amp;nbsp;&amp;nbsp;ffs.document.appendChild(divn) ;
            
&amp;nbsp;&amp;nbsp; var gchartform = ffs.document.getElementById(&#39;gchart_form&#39;) ;
&amp;nbsp;&amp;nbsp;gchartform.submit() ;
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://lipingworkshop.blogspot.com/feeds/3817045008830159654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lipingworkshop.blogspot.com/2010/12/dynamically-loading-google-chart-image.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/3817045008830159654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/3817045008830159654'/><link rel='alternate' type='text/html' href='http://lipingworkshop.blogspot.com/2010/12/dynamically-loading-google-chart-image.html' title='dynamically loading Google Chart Image in an iFrame using POST request and Javascript (prototype)'/><author><name>Liping Zhang</name><uri>http://www.blogger.com/profile/00028755476382786872</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-nl7mNQDJYgqhWEEejrEG6JxfFv0k41cjR8-o39be2BKjF4aT-DtYnpR1hf7ycf3c8oqN_7x0AgGD_mRVxnygnDVAwClULBDCq0rVKD5g4biOr3Kl83_R-GZSzvFwAz8/s220/P1020774.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3451642050545042735.post-7956563959538893144</id><published>2010-12-06T16:01:00.000-08:00</published><updated>2020-05-03T23:27:13.547-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="current time linux shell script millisecond"/><category scheme="http://www.blogger.com/atom/ns#" term="linux script"/><title type='text'>How to get current time with milliseconds using Linux shell script</title><content type='html'>This is something I believe would be useful for many people when you want to, say, log data using linux shell script, or something alike.&lt;br /&gt;
&lt;br /&gt;
The linux &quot;date&quot; command does have a parameter that gives current time in nanosecond accuracy, but not millisecond. &amp;nbsp;So what you want to do is to extract a substring from &quot;date&quot; output to convert the value into milliseconds.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;filename=&quot;/tmp/tmpfile.log&quot;

nanos=`date +%F-%T.%N`
echo -n &quot;${nanos:0:23}&quot; &amp;gt; $filename
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Code above generates a timestamp in %Y-%m-%d-%H:%M:%S.mmm format and write into a file named /tmp/tmpfile.log.&lt;br /&gt;
&lt;br /&gt;
${nanos:0:23} extracts the first 23 characters from the string generated by shell command &quot;date +%F-%T.%N&quot;, where the parameter &quot;%N&quot; generates zero-filled nano-seconds of current time.</content><link rel='replies' type='application/atom+xml' href='http://lipingworkshop.blogspot.com/feeds/7956563959538893144/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lipingworkshop.blogspot.com/2010/12/how-to-get-current-time-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/7956563959538893144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3451642050545042735/posts/default/7956563959538893144'/><link rel='alternate' type='text/html' href='http://lipingworkshop.blogspot.com/2010/12/how-to-get-current-time-with.html' title='How to get current time with milliseconds using Linux shell script'/><author><name>Liping Zhang</name><uri>http://www.blogger.com/profile/00028755476382786872</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-nl7mNQDJYgqhWEEejrEG6JxfFv0k41cjR8-o39be2BKjF4aT-DtYnpR1hf7ycf3c8oqN_7x0AgGD_mRVxnygnDVAwClULBDCq0rVKD5g4biOr3Kl83_R-GZSzvFwAz8/s220/P1020774.JPG'/></author><thr:total>0</thr:total></entry></feed>