Posts tagged scripting
Vanity Bitcoin Keys
1So it’s been a while since I’ve talked about bitcoin and I’ve recently gotten more interested now that the prices have grown significantly. So I started explaining it to some friends at school and have gotten them interested as well. So of course I wanted a nice and custom key to show off, and it’s really quite easy with tools like vanitygen by samr7 over on the bitcoin forums which is the tool that we will be using for this post.
Because it’s actually doing alot of math to figure out (or more correctly guess) at the key, the longer you want your custom key to be, the longer you will have to crunch these numbers so don’t get too crazy with it.
The tool has several options but most of them won’t be used, in fact I only use one of the possible flags below, but there are more, you can view them by running vanitygen.exe with the “-h” flag, or just save this as something like help.bat in the same folder as vanitygen.exe and double-click the .bat file to run the help command for you.
|
1 2 3 |
@echo off vanitygen.exe -h pause |
Now that you have read the options the batch file below might make more sense, we are going to ask you for the pattern you want your custom key to have, and decided if you want it case-sensitive which takes MUCH longer, and might have strings that are not allowed, but it’ll error out if it does so you can try something different.
So save this file as something like vanity.bat in the same folder as vanitygen and run it. (Change the highlighted lines 19 and 23 to reflect the executable you are going to use for your system. (ie: if on a 64 bit system you would use vanitygen64.exe, on a gpu you would use oclvanitygen.exe)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
@echo off echo You can always press ctrl+c to stop this script from running. CALL :GETINPUT GOTO :EOF :GETINPUT set /p Name=Enter your desiered pattern (The leading 1 has been added for you): 1 set /p ConfirmName=Your pattern will be 1%name% Is this correct [y/n]?: if "%ConfirmName%"=="" (GOTO GETINPUT) if "%ConfirmName%"=="y" (GOTO STRICTNESS) else (GOTO EXIT) :STRICTNESS set /p Eieye=Do you require your pattern to be CaSe SenSitvE [y/n]? if "%Eieye%"=="y" (GOTO CASEYES) if "%Eieye%"=="n" (GOTO CASENO) else (GOTO EXIT) :CASEYES vanitygen.exe 1%name% (GOTO EOF) :CASENO vanitygen.exe -i 1%name% (GOTO EOF) :EOF pause :EXIT exit |
Here is what the output of the script does (note, I’ve highlighted the user input for clarity, there is no color in the actual script results, and No this key should NOT be used!):
Then create a shortcut on your desktop for vanity.bat and change the icon to something that you prefer, I’ve added the image I use below for fun, and then just run this anytime you (or a friend) want a custom wallet key!
As for wallet’s, I use the Armory wallet but for most users I would recommend multibit as it’s much faster, and much smaller, but you do give up some freedom and security relying on others where armory can offer a true TNO security standpoint, just my 2 bitcents on that topic, now get mining!
Auto Start your WiFi on Raspberry Pi
7So I just got my new Hawking HWUN3 USB wireless N adapter that I purchased for my Raspberry Pi, and wanted it to connect on boot being I only access it via SSH and to plug it in to a wired adapter in order to start the wireless connection so that I can unplug it just didn’t make sense. So here’s how I got it installed and starting on boot.
This network adapter is perfect, I didn’t need to compile a thing, it was recognized right out of the box. LOVE IT!
I ran ifconfig and it was right there, happy and waiting.
[codesyntax lang="bash" lines="no" title="ifconfig output"]
wlan0 Link encap:Ethernet HWaddr 00:0e:3b:1e:b8:4d
inet addr:192.168.0.51 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:464 errors:0 dropped:0 overruns:0 frame:0
TX packets:267 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:68999 (67.3 KiB) TX bytes:40100 (39.1 KiB)
[/codesyntax]
Then you’ll need to do a little bash scripting, you can create a script in “/etc/init.d/” and then run “update-rc.d scriptname defaults” to install it, however I decided to instead just add it to the end of “/etc/rc.local” as this will run after everything else has already loaded after a reboot. Of course you can have init start your script at the end of the boot cycle (or anywhere in between) but the rc.local just takes less planning.
By default the “/etc/rc.local” file does nothing, but I left the existing code in and just commented it out. You can do what you like of course. Here is the contents of my rc.local file
[codesyntax lang="bash" lines="normal" title="rc.local"]
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0″ on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
## Print the IP address
#_IP=$(hostname -I) || true
#if [ "$_IP" ]; then
# printf “My IP address is %s\n” “$_IP”
#fi
echo “Starting WiFi…”
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
sleep .5s
dhclient wlan0
echo “WiFi should be started”
exit 0
[/codesyntax]
The code doesn’t actually do anything until line 18. On line 19 you’ll see that we’re starting the wpa_supplicant in the background (-B) for interface wlan0 (-i wlan0) using the configuration file found at “/etc/wpa_supplicant.conf” (-c)
We will need to create that file. Also I should note, wpasupplicant was already installed on my image, however if you need it installed, just issue the following command.
[codesyntax lang="bash" lines="no" title="install wpa supplicant"]
|
1 |
sudo apt-get install wpasupplicant |
[/codesyntax]
now let’s create the ever important wpa_supplicant.conf file. This will hold your ssid name and pre-shared key (password) of course replace YOURSSID and YOURPASSWORD with your own info respectively.
[codesyntax lang="bash" lines="fancy" title="create wpa_supplicant.conf file"]
|
1 |
sudo nano /etc/wpa_supplicant.conf |
[/codesyntax]
and the contents of that file should look something like this:
[codesyntax lang="bash" lines="fancy" title="wpa_supplicant.conf"]
|
1 2 3 4 |
network={ ssid="YOURSSID" psk="YOURPASSWORD" } |
[/codesyntax]
That’s it! You should be connected! Go ahead and reboot, and then run iwconfig and you should be connected to your designated access point, all without using the GUI!
Here’s a pic of my pi, with the usb stick, and some ram heat sinks I picked up at Frys for like $10 ( and I still have 6 more lying around now.. guess I’ll need more pi!)
And here’s a screen dump showing it recognized by my pi.
[codesyntax lang="text" lines="fancy" title="pi screendump"]
Using username “pi”.
pi@192.168.0.51′s password:
Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Type ‘startx’ to launch a graphical session
Last login: Wed Jul 25 19:45:17 2012 from 192.168.0.119
pi@raspberrypi ~ $ iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
wlan0 IEEE 802.11bgn ESSID:”editedformysaftey”
Mode:Managed Frequency:2.452 GHz Access Point: BC:C5:C3:6C
Bit Rate=65 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=70/70 Signal level=-37 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:47 Invalid misc:3 Missed beacon:0
pi@raspberrypi ~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:16:60
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)
wlan0 Link encap:Ethernet HWaddr 00:3b:1e:b8
inet addr:192.168.0.51 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:464 errors:0 dropped:0 overruns:0 frame:0
TX packets:267 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:68999 (67.3 KiB) TX bytes:40100 (39.1 KiB)
pi@raspberrypi ~ $ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0e66:0013 Hawking Technologies HWUN3 Hi-Gain Wireless-N Adapter [Ralink RT3070]
pi@raspberrypi ~ $
[/codesyntax]
One thing to note, your network led’s wont be working, because your not using your nic…. You’ll want to watch the led on the actual usb stick to see if there’s activity. If it’s up and online, the light will be steady green, and only flash with transmissions. If it’s constantly off and only blinks every few seconds, something’s wrong and you’ll need to do some troubleshooting.
Hope this helps someone, and if not, at least I can forget about how I did it until my next pi comes in a few more days!
Spellcheck using the commandline
3If your anything like myself, I find I use google as a spellchecker more often then anything else, however having to wait for firefox to load when I’m trying to type in irc and don’t know the spelling of a word takes up alot of my time and slows the conversation down as well.
A great post from Stormdragon has shown me a great and easy way to do this using a program called hunspell.
Following most of his steps you can do this as well on any debian / Ubuntu / Linux Mint pc.
First install hunspell and it’s english library.
|
1 |
sudo apt-get install hunspell hunspell-en-us |
then cd over to your ~/bin/ directory
|
1 |
cd ~/bin/ |
create and edit a file named “spellcheck”
|
1 2 |
sudo touch spellcheck sudo gedit spellcheck |
Enter in the following script
|
1 2 3 |
#!/bin/bash echo “$@” | hunspell exit 0 |
then save and close gedit.
Now we need to make the file executable
|
1 |
sudo chmod 755 spellcheck |
Then just close and reopen your terminal of choice (I prefer terminator myself) and try out your new spellchecker!
|
1 |
spellcheck whatever you cant spell |
Correctly spelled words will just respond with an “*” if a word is misspelled it will offer you suggestions! Just that easy! Yea BASH!



