<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<?xml-stylesheet type="text/css" href="http://linuxevolution.org/styles/feed.css"?>


<title type="html">LINUXEVOLUTION.ORG</title>
<subtitle type="html"></subtitle>
<link rel="alternate" type="text/html" href="http://linuxevolution.org"/>
<link rel="self" type="application/atom+xml" href="http://linuxevolution.org/atom.xml"/>
<updated>2010-03-09T22:08:12-05:00</updated>
<author>
<name>orvtech</name>
<uri>http://linuxevolution.org</uri>
</author>
<id>http://linuxevolution.org/</id>
<generator uri="http://nanoblogger.sourceforge.net" version="3.4">
NanoBlogger
</generator>

<entry>
<title type="html">Latest URL for all your NanoBlogger websites.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/03/09/latest_url_for_all_your_nanoblogger_websites/index.html"/>

<id>http://linuxevolution.org/archives/2010/03/09/latest_url_for_all_your_nanoblogger_websites/index.html</id>
<published>2010-03-09T20:39:46-05:00</published>
<updated>2010-03-09T20:39:46-05:00</updated>
<category term="Scripts" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
So I kinda participate a lot in these community forums and I wanted to keep my signature linking to my latest post without having to change my signature on all of them each time, I created this script that will get the latest entry submitted and will create a .htaccess file redirecting requests to a previous determined directory to the latest entry.
</p>
<textarea  style="height: 95px"  class="bashcode">
#!/bin/bash
DocummentRoot="/var/www/linuxevolution.org/htdocs /var/www/orvtech.com/htdocs"

for virtualhost in $DocummentRoot
do cat $virtualhost/rss.xml  | grep link | grep archives |\
head -n1 | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' |\
awk '{print "RewriteEngine on\nRewriteRule (.*) "$0" [R=301,L]"}' > $virtualhost/latest/.htaccess
done</textarea>
<br />
<p>In order for this to work you will have to create the 'latest' directory inside your root directory or modify the script.</p>
<p>In my case I have 2 websites, and this script keeps the '/latest/' directory pointing to the latest entry on each of them (<a href="http://www.linuxevolution.org/latest/">http://linuxevolution.org/latest</a> and <a href="http://www.orvtech.com/latest/">http://orvtech.com/latest</a> the spanish version of this website)</p>
</div>
</content>

</entry>
<entry>
<title type="html">Find MS-DOS Formatted Files. </title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2010/02/23/find_ms-dos_formatted_files/index.html"/>

<id>http://linuxevolution.org/archives/2010/02/23/find_ms-dos_formatted_files/index.html</id>
<published>2010-02-23T11:18:30-05:00</published>
<updated>2010-02-23T11:18:30-05:00</updated>
<category term="Scripts" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>I recently came across a problem where I had a bunch of perl scripts that were modified under MS Windows and had the MS-DOS format. I found a bunch of errors on the crond logs since these scripts were being called by a crontab. Long story short I had to find all these scripts so I used this recursive grep inside the directory where this files were uploaded.</p>

<textarea style="height: 35px" class="bashcode" readonly wrap="off">grep -IUl --color '^M' -R ./*</textarea>
<br />
<p>The output of this command will generate a list of files that are formatted as DOS files.
<a class="DiggThisButton">('<img src="http://digg.com/img/diggThisCompact.png" height="18" width="120" alt="DiggThis" />’)</a>
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></p>
</div>
</content>

</entry>
<entry>
<title type="html">The NSLU2 as a last.fm to twitter bridge.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/30/the_nslu2_as_a_last_fm_to_twitter_bridge/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/30/the_nslu2_as_a_last_fm_to_twitter_bridge/index.html</id>
<published>2009-11-30T16:57:10-05:00</published>
<updated>2009-11-30T16:57:10-05:00</updated>
<category term="Scripts" />
<category term="Last_FM" />
<category term="NSLU2" />
<category term="Linux" />
<category term="Twitter" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This simple script came from the need of updating <a href="http://twitter.com/m1n1m3">my twitter</a> 
status with the songs that I am playing, the trick is that it will only update my profile 
if the song has been tagged as 'loved' on last.fm. It will also detect if it is Monday 
and will add the <a href="http://twitter.com/#search?q=%23mm"><i>#mm</i> hash</a>.</p>

<textarea class="bashcode" readonly wrap="off">twitter_user="<your_twitter_user_here>"
twitter_passwd="your_twitter_password_here"
URL="http://twitter.com/statuses/update.xml"
tags="#lastfm"
lastfm_api="<your_api_from_lastfm_here>"
lastfm_user="<your_lastfm_user_here>"
bit_ly_user="<your_bit.ly_user_here>"
bit_ly_apikey="<your_bit.ly_api_key_here>"

fmtwitted=`cat /tmp/lastfm2twitter.tmp | \
sed -e 's/status=Just played: //g' -e 's/#.*//g' | \
grep '[a-z]'|sed -e 's/\ //g' -e 's/\-/./g'`

fmcurrent=`curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" | \
grep -E '<name>|</name>|<artist\ |</artist>' |\
head -n2| sed -e 's/<[^>]*>//g' | tr '\n' '.' |\
sed -e 's/\ //g' -e 's/.$//g'`


lastfm_song_url=`curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" |\
grep -E '<url>|</url>' | sed -e 's/<[^>]*>//g' |\
head -n1| tr '\n' '.' | sed -e 's/\ //g' -e 's/.$//g'`
bit_ly_url=`curl -s "http://api.bit.ly/shorten?version=2.0.1&longUrl=$lastfm_song_url&login=$bit_ly_user&apiKey=$bit_ly_apikey" | \
grep shortUrl | sed -e 's/\"/\ /g' | awk '{print $3}'`

today_mm=`date +%A`
if [[ $today_mm == "Monday"  ]] 
  then tags="$tags #mm"
fi


if grep $fmcurrent /tmp/lastfm_loved.tmp  > /dev/null
  then if [[ "$fmtwitted" == "$fmcurrent" ]]
      then exit 0
        else curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&limit=1&user=$lastfm_user&api_key=$lastfm_api" | \
	grep -E '<name>|</name>|<artist\ |</artist>' |\
	head -n2| sed -e 's/<[^>]*>//g' | tr '\n' '-' | \
	sed -e 's/^[ \t]*//' -e 's/-/\ -\ /g' -e 's/- $//g' -e 's/\ $//g' |\
	awk '{print "status=Just played: "$0}' > /tmp/lastfm2twitter.tmp
	lastfm2twitter=`cat /tmp/lastfm2twitter.tmp; 
	echo $bit_ly_url 
	echo $tags | tr '\n' ' '`
	echo $lastfm2twitter > /tmp/lastfm2twitter.tmp
	curl -s -u $twitter_user:$twitter_passwd -d @/tmp/lastfm2twitter.tmp $URL > /dev/null
	  fi
	  else exit 0
fi</textarea>
<br />
<p>As you can see I am using bit.ly to shorten the urls of the song, you will need a bit.ly API for this to work. 
I think what is left is to optimize the script storing the curl requests in a file sort of like a cache 
and add a routine to detect if it is longer than the 140 charaters allowed by twitte and shorten the text 
to be posted as the status.r</p> 
</div>
</content>

</entry>
<entry>
<title type="html">Monitoring Script for resources </title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/03/monitoring_script_for_resources/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/03/monitoring_script_for_resources/index.html</id>
<published>2009-11-03T11:37:17-05:00</published>
<updated>2009-11-03T11:37:17-05:00</updated>
<category term="Scripts" />
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This is a small script to display the resources utilization of a NSLU2 running linux on a web page
in plain HTML, It is coded in BASH and some JavaScript in orther to display the information. Here is what the 
output looks like:
<br />
<script src="http://www.orvtech.com/resources.js" type="text/javascript"></script>
</p>

<br /><p>Source Code of resources.sh:</p>
<textarea class="bashcode" readonly wrap="off">#!/bin/bash

#GETTING THE DAYS OF UPTIME
let UP_TIME=`uptime | awk '{print $3" "$5}' | sed 's/:/ /g' |\
awk '{print "("$1"*24)+"$2}'`

#CALCULATING FREE RAM PERCENTAGE
mem_total=`grep MemTotal /proc/meminfo|awk '{print $2}'`
mem_free=`grep MemFree /proc/meminfo|awk '{print $2}'`
percent=$(echo "scale=2; $mem_free/$mem_total*100" | bc -l)

#GETTING THE AVERAGE LOAD OF THE SERVER 
load_10=`uptime | awk '{print $11}'|sed 's/,//g'`

#BUILDING THE *.js FILE
echo "var resources=\"<b>Last Updated: </b> `date`<br /><b>UP Days: 
</b>$UP_TIME<br /><b>Free RAM:</b> $percent% ($mem_free kB)<br />
<b>Load: </b>$load_10<br />\";"
echo "document.write(resources);"</textarea>

<p>You then direct the output of that script to a file in your RootDirectory, in my case I am using  /resources.js and I execute resources.sh every 5 minutes from a cronjob.</p>
<br /><p>Source Code of resources.js:</p>

<textarea style="height: 55px" class="bashcode" readonly wrap="off">var resources="<b>Last Updated: </b> Tue Nov  3 12:00:02 EST 2009<br />
<b>UP Days: </b>2549<br /><b>Free RAM:</b> 5.00% (1552 kB)<br /><b>Load: 
</b>0.21<br />";
document.write(resources);</textarea>

<p>I use the following code to display the information:</p>
<textarea style="height: 35px" class="bashcode" readonly wrap="off">
<script src="http://www.orvtech.com/resources.js" type="text/javascript"><
/script></textarea>
</div>
</content>

</entry>
<entry>
<title type="html">Almost There.</title>
<author>
<name>orvtech</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/01/almost_there/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/01/almost_there/index.html</id>
<published>2009-11-01T20:08:45-05:00</published>
<updated>2009-11-01T20:08:45-05:00</updated>
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>
Almost two years have gone by since I last updated the site, we have migrated from a plain HTML site that had to be edited and managed using vim to the previous template but using nanoblogger as the back end for content manager. There are still some issues that I need to address like maintaining the same CSS between the old content and the new content... ultimately the old content will need to be migrated. 
</p><p>
I have also been working on a picasa albums plug-in that I will release as soon as it gets properly tested. The ability to have a multilingual content is also something that I have been thinking of. 
</p><p>
In 2 weeks I should finally have internet at home and should not need to 'borrow' it from my neighbors, by then I should be working again in to getting a gentoo stage3 of the latest release possible  for the NSLU2.
</p>
</div>
</content>

</entry>
<entry>
<title type="html">Linux on the NSLU2</title>
<author>
<name>iDontknow</name>
</author>
<link rel="alternate" type="text/html" href="http://linuxevolution.org/archives/2009/11/01/linux_on_the_nslu2/index.html"/>

<id>http://linuxevolution.org/archives/2009/11/01/linux_on_the_nslu2/index.html</id>
<published>2009-11-01T13:16:16-05:00</published>
<updated>2009-11-01T13:16:16-05:00</updated>
<category term="NSLU2" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
The Linksys NSLU2 (aka "slug") is sold as a NAS device but in reality it is much more useful than that. It is a complete, cheap, embedded Linux system. Best of all is the fact that the official Linksys firmware uses the Linux kernel, and so Linksys released the <a href="http://localhost">source code</a>. This led to some excellent custom firmware projects like Unslung and OpenSlug. 
</div>
</content>

</entry>

</feed>
