Posts Tagged sourcecode

Weather Underground forecast data in text display

One of the uses I found for my Raspberry Pi was using it to display weather data. I retrieved the weather data from Weather Underground using their API, parsed it, and displayed it on my RPi’s small LCD. This gave me an always-on view of the weather, which was nifty, and it was done all in bash scripting with a few external programs to parse the data.

This script is very customizable and extensible. You could use it to do any number of weather-related tasks.

I reduced the font size on the LCD to Terminus 6×12 using the following command:

sudo dpkg-reconfigure console-setup

This helped make room for all the forecast data on the tiny LCD. If you are running this on a PC, it’s not necessary.

For the smoothest updates, I have found it ideal to run the script under ‘watch’, as so:

watch ./weather.sh

I tired doing a ‘while true; do… clear… done’ loop, but the refresh rate was too low and the updates were not smooth.

Here is the script:

UPDATE : This has moved to github, here.

Last updated: 11-21-2015

Advertisements

, , , , ,

2 Comments

Build and install Mozilla Spider Monkey (spidermonkey-bin) on Ubuntu Linux

Here’s how to quickly and easily build spidermonkey-bin from source on Ubuntu Linux.

sudo apt-get install mercurial autoconf2.13
hg clone http://hg.mozilla.org/mozilla-central spidermonkey
cd spidermonkey/js/src
autoconf2.13
./configure
make
sudo make install

Enjoy!

, , , ,

Leave a comment

WordPress visual editor mangling sourcecode

I tend to post quite a bit of sourcecode, such as bash scripts and PHP scripts. I use the SyntaxHighlighter Evolved plugin to highlight and colorize the sourcecode, as well as make it easy to copy.

Unfortunately, I’ve noticed that the WordPress built-in visual editor does a great job of mangling the code, especially by HTML-escaping certain characters.

I’ve found that installing the TinyMCE Advanced plugin has fixed the cause of it, as well as providing a ‘replace’ function which I can quickly use to clean up previously-mangled code.

I’ve gone through my posts and hopefully corrected any previously mangled sourcecode. I’d like to say thank you to everyone who has brought a piece to my attention.

I strongly recommend the above plugins.

,

Leave a comment

Bash script to send contents of file containing URLs to Synology Download Station via API

This bash script will read a file containing a list of URLs line-by-line and send each of those URLs to a Synology DiskStation’s Download Manager via the published API.

Read the comments.

Note that, in user land, it might be easier to simply upload the text file to the Download Station. The below is useful if you want to programatically pass download tasks to Download Station, such as on the update of a web page, etc, etc.

UPDATE: This has been moved to github, here.

If you have any questions or comments on this script, please feel free to comment below. Thank you!

, , ,

2 Comments

How to move the SymformContribution directory from one volume to another on a Synology NAS

So you’ve got Symform all set up and running on your Synology NAS, and you’ve been contributing space, but now the volume that has your contribution folder is getting full, adn you’d like to move it without disrupting the data that other Symform users like yourself have trusted you with. How to do it? Easily.

In this example, I’ll show you how to move it from volume1 to volume2.

First, stop the Symform service from Package Center.

symform_stopped

Next, SSH into your Synology box and move the target directory to it’s new location, in this case, /volume2/SymformContribution

mv /volume1/SymformContribution/ /volume2

Next, edit the /volume1/@symform/lib/node.config file using vi and update the location by finding the line similiar to the following…

<contribution enabled="True" fragmentStorePath="/volume1/SymformContribution" port="53432" />

… and changing volume1 to volume2.

(Note, this is the same file that’s used to update the incoming port, see this post for more information.)

Save the file, and restart the Symform service.

symform_running

That’s it!

Questions or comments are welcome in the comments section below. Thank you for reading!

, , , , , ,

Leave a comment

Controlling fan speed and hard drive APM settings on Synology DiskStation

There is a file in /usr/syno/etc/scemd.xml which controls the fan speeds and trigger temperatures corresponding to the setting at Control Panel > Power, as well as drive APM settings (for hard drive head parking issues. More information for this issue can be found by reading this post). Feel free to edit the file to your needs, but remember that settings may not be preserved during DSM updates.

On my DS211j running DSM 4.1-2668 the file contains the following:

<?xml version="1.0" encoding="UTF-8"?>
<scemd>
 <fan_config period="20" threshold="6" type="DUAL_MODE_HIGH" hibernation_speed="STOP">
 <disk_temperature fan_speed="ULTRA_LOW" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="VERY_LOW" action="NONE">52</disk_temperature>
 <disk_temperature fan_speed="LOW" action="NONE">54</disk_temperature>
 <disk_temperature fan_speed="ULTRA_HIGH" action="NONE">58</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
 </fan_config>
 <fan_config period="20" threshold="6" type="DUAL_MODE_LOW" hibernation_speed="STOP">
 <disk_temperature fan_speed="STOP" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="ULTRA_LOW" action="NONE">40</disk_temperature>
 <disk_temperature fan_speed="VERY_LOW" action="NONE">52</disk_temperature>
 <disk_temperature fan_speed="LOW" action="NONE">54</disk_temperature>
 <disk_temperature fan_speed="ULTRA_HIGH" action="NONE">58</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
 </fan_config>

<fan_config hw_version="Synology-DX5" period="20" threshold="6" type="DUAL_MODE_HIGH_EBOX" hibernation_speed="UNKNOWN">
 <disk_temperature fan_speed="FULL" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="FULL" action="NONE">45</disk_temperature>
 <disk_temperature fan_speed="FULL" action="NONE">55</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
</fan_config>

<fan_config hw_version="Synology-DX5" period="20" threshold="6" type="DUAL_MODE_LOW_EBOX" hibernation_speed="UNKNOWN">
 <disk_temperature fan_speed="FULL" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="FULL" action="NONE">45</disk_temperature>
 <disk_temperature fan_speed="FULL" action="NONE">55</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
</fan_config>

<fan_config hw_version="Synology-DX510" period="20" threshold="6" type="DUAL_MODE_HIGH_EBOX" hibernation_speed="LOW">
 <disk_temperature fan_speed="MIDDLE" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="HIGH" action="NONE">48</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
</fan_config>

<fan_config hw_version="Synology-DX510" period="20" threshold="6" type="DUAL_MODE_LOW_EBOX" hibernation_speed="LOW">
 <disk_temperature fan_speed="MIDDLE" action="NONE">0</disk_temperature>
 <disk_temperature fan_speed="HIGH" action="NONE">48</disk_temperature>
 <disk_temperature fan_speed="FULL" action="SHUTDOWN">61</disk_temperature>
</fan_config>
<disk_control>
 <disk model="ST9120821A">APM_255</disk>
 <disk model="HTS722020K9SA00">APM_255</disk>
 <disk model="ST980811AS">APM_255</disk>
 <disk model="MHV2060BH">APM_255</disk>
 <disk model="MK6034GSX">APM_254</disk>
 <disk model="ST9100824AS">APM_255</disk>
 <disk model="HM250JI">APM_255</disk>
 <disk model="MK1637GSX">APM_254</disk>
 <disk model="ST9100824AS">APM_255</disk>
 <disk model="ST9120822AS">APM_254</disk>
 <disk model="ST9160821AS">APM_254</disk>
 <disk model="WD2500BEVS-75UST0">APM_254</disk>
 <disk model="HM250JI">APM_254</disk>
 <disk model="WD2500BEVS">APM_254</disk>
 <disk model="WD1600BEVT">APM_255</disk>
 <disk model="HTS543232L9A300">APM_255</disk>
 <disk model="WD1600BEVE">APM_255</disk>
 <disk model="MK2546GSX">APM_254</disk>
 <disk model="MHV2080BHPL">APM_255</disk>
 <disk model="WD1200BEVE">APM_255</disk>
 <disk model="HTS543225L9A300">APM_255</disk>
 <disk model="WD3200BEVT">APM_254</disk>
 <disk model="MK8025GAS">APM_254</disk>
 <disk model="ST9200420AS">APM_254</disk>
 <disk model="WD3200BEVT">APM_254</disk>
 <disk model="HTS543216L9SA00">APM_254</disk>
 <disk model="MK4058GSX">APM_254</disk>
 <disk model="WD6400BEVT">APM_254</disk>
 <disk model="ST32000542AS">APM_255</disk>
 <disk model="ST95005620AS">APM_255</disk>
</disk_control>

</scemd>

, , , , ,

6 Comments

Disable and remove .DS_Store files stored on network locations

So today I was going through my Synology NAS and noticed .DS_Store files all over the place.

These are actually files containing extended attributes created by Finder in Mac OS X. But, since they get written out to network locations, they can cause backup and versionining issues.

To disable them from being created on network locations, open a Terminal and run the following

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

(Note: This only affects the currently-logged-in user)

Now in my case, I had these files all over my Synology NAS, so I was able to easily get rid of them by SSHing into the box and running the following:

find / -name .DS_Store -delete

And… done.

, , , , ,

3 Comments

Disable indexing and generation of @eaDir directories on Synology NAS

Various forums throughout the Internet have users stating that even though they’ve disabled media indexing the @eaDir folders are still being generated, and even outside the indexed folders.

In order to completely stop the generation of @eaDir folders, it’s necessary to disable the services that are generating them.

Note that after a DSM update, these services may be re-enabled.

To disable these services, log in to your Synology NAS via SSH, then do the following:

cd /usr/syno/etc.defaults/rc.d/
chmod 000 S66fileindexd.sh S66synoindexd.sh S77synomkthumbd.sh S88synomkflvd.sh S99iTunes.sh

After disabling the services, you may want to delete all the created @eaDir directories.

Any feedback on the above is welcome, please leave it in the comments section below. Thank you!

, , , ,

9 Comments

Getting rid of the @eaDir folders on Synology NAS DSM

The @eaDir directories contain extended attributes and thumbnails that take up quite a bit of space, not unlike Windows Thumbs.db files.

Here’s how to get rid of them easily from the command line.

First, SSH into your Synology NAS box and log in as root, then type this to locate the @eaDir folders:

find . -name "@eaDir" -type d | more

If you’re happy you’re not going to accidentally delete something important, then make it happen:

find . -name "@eaDir" -type d -print0 | xargs -0 rm -rf

Note that after deleting the directories, you may also want to disable the services that created them.

Do you have any feedback on the above? Please leave it in the comments section below. Thank you!

, , , ,

4 Comments

Controlling the front LEDs of a Synology NAS via ttyS1

You can control the front LEDs (as well as triggering other hardware events) on a Synology NAS by sending certain values to /dev/ttyS1, either from a script of from the CLI via Telnet or SSH.

These commands “force” the LED state, and therefore the LEDs can’t be used as status indicators after being forced. You can, however, simply reboot the NAS to restore normal operation; the settings do not survive a reboot.

Below are a list of commands that can be run from the command line (if you are logged in as root) or incorportated into a script. Note that the # character and everything after it are comments, and some characters require escaping.

These are only the commands I could get to work on my NAS.

echo 1>/dev/ttyS1 # Immediate power off (not graceful)
echo 4>/dev/ttyS1 # Power LED on solid
echo 5>/dev/ttyS1 # Power LED flash
echo 6>/dev/ttyS1 # Power LED off
echo 7>/dev/ttyS1 # Status LED off
echo 8>/dev/ttyS1 # Status LED on solid green
echo A>/dev/ttyS1 # USBCopy LED flash
echo @>/dev/ttyS1 # USBCopy LED on solid
echo B>/dev/ttyS1 # USBCopy LED off
echo C>/dev/ttyS1 # Immediate reset (not graceful)
echo :>/dev/ttyS1 # Status LED on solid amber
echo ;>/dev/ttyS1 # Status LED flashing amber

If you know if any other values to send to ttyS1, or anything else you’d like to share regarding this, please feel free to do so in the comments below. Thank you!

, , ,

1 Comment