Simple Binary Bash Clock  
Saturday, October 1, 2011, 12:01
Posted by Administrator
I've been meaning to post this for a while, but recently I made a small binary clock in bash in order to add it to my conky configuration.

The script that follows below basically all it does is get the current hour minute and second fields and then convert it to display in binary.
It then clears the screen and updates once a second to look exactly like I want it to.


#!/bin/bash
while true;
do
clear
hour=$(date +%H)
minute=$(date +%M)
second=$(date +%S)
hour_binary=$(echo "ibase=10;obase=2;$hour" | bc)
minute_binary=$(echo "ibase=10;obase=2;$minute" | bc)
second_binary=$(echo "ibase=10;obase=2;$second" | bc)
printf "%06d\n" "$hour_binary"
printf "%06d\n" "$minute_binary"
printf "%06d" "$second_binary"
sleep 1
done


Here is an example of the clock in action with the font blown way up:



The more I work with scripting things the more ways I can think of to apply scripts.

Its an ongoing cycle.
add comment ( 8641 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 5251 )
Pi Memorization Javascript 
Sunday, August 14, 2011, 12:07
Posted by Administrator
I've been memorising digits of pi off and on for years now. Not really sure why other than it is a fun challenge to be able to recite a long string of numbers.

A while back I had found a program that helped me memorise more digits by having a little box to enter the numbers into which would validate each digit as you typed it. The main thing I didn't like about it was that it would erase the entire field of digits if you got one wrong. This was fine up until I got over about 150 digits or so and it just became too painstaking to retype the first hundred or so digits each time to get to the ones I was stuck at.

I decided to use a few days at the end of this summer vacation to put together this web based pi memorisation tool with Javascript. View the source here.

I've added such features as a digit counter to show what place you are at, tips for what the next digits would have been if you make a mistake, and the ability to go back variable amounts when you get one wrong.

I'm totally up for ideas on how to add to this more or make it more useful. I've tested it on multiple browsers but would be very curious to know if its still having bugs with anyone's particular setup.

<brag> And with the added encouragement of making and testing this tool I'm now up over 200 digits. </brag>
add comment ( 6427 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 5274 )
Python is Awesome 
Saturday, August 6, 2011, 12:08
Posted by Administrator
Case in point:

def fahrenheit(celsius):
fahr = (9.0/5.0)*celsius + 32
return fahr
for temp_c in range (0, 41):
temp_f = fahrenheit(temp_c)
print temp_c,"C" , "| %.1f F" % temp_f


Its almost like too-perfect of a language. I feel like I avoid using it because it is just too nice. Its like some sort of super perl that transforms everything into awesomesauce.

add comment ( 5910 views )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 77 )

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Next> Last>>