Mažytė lėkštė makaronų

A small bowl of pasta

98 notes &

dockstar + TL-WN821N

Until now I was using Linksys 802.11g wi-fi usb stick for my Dockstar.

The idea I had was to use Dockstar as a media storage server with ability to watch movies straight from the server. But with 1-2MB/s upload/download speeds all I got was a buffering player window every couple of minutes.

So I spend some time searching for a 802.11n alternative on ebay and bought TP-LINK TL-WN821N for £11.

It did not work out of the box but with a little help from Google I managed to get it up and running.

First, I tried to follow instructions from http://www.mikrocontroller.net/topic/193795

but it turned out that I need some newer components and other wifi firmware.

Ok, I’ll just paste the short version of setup, if you need more info go to the link I mentioned above:

apt-get install wpasupplicant iw wireless-tools
apt-get install hwinfo usbutils
apt-get install linux-headers-2.6.32-5-kirkwood
cd /lib/firmware
wget http://wireless.kernel.org/download/htc_fw/1.3/htc_7010.fw
cd /usr/src
wget http://wireless.kernel.org/download/compat-wireless-2.6/compat-wireless-2011-07-01.tar.bz2
tar jxvf compat-wireless-2011-07-01.tar.bz2
cd compat-wireless-2011-07-01
./scripts/driver-select ath9k_htc
make
make install
reboot

After dockstar restarts, ssh to it again and execute

dmesg

search for usb messages about Atheros device and that it was registered.

[    4.476844] usb 1-1.4: new high speed USB device using orion-ehci and address 6
[    4.606509] usb 1-1.4: New USB device found, idVendor=0cf3, idProduct=7015
[    4.613426] usb 1-1.4: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[    4.621043] usb 1-1.4: Product: UB95
[    4.624637] usb 1-1.4: Manufacturer: ATHEROS
[    4.629040] usb 1-1.4: SerialNumber: 12345
[    4.634424] usb 1-1.4: configuration #1 chosen from 1 choice
[   14.185416] Compat-wireless backport release: compat-wireless-2011-06-28-2-g89a736d
[   14.193235] Backport based on linux-next.git next-20110701
[   14.394350] cfg80211: Calling CRDA to update world regulatory domain
[   14.872681] usb 1-1.4: ath9k_htc: Transferred FW: htc_7010.fw, size: 72992
[   14.934148] ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 45 credits
[   15.095141] ath9k_htc 1-1.4:1.0: ath9k_htc: FW Version: 1.3
[   15.100764] ath: EEPROM regdomain: 0x809c
[   15.100771] ath: EEPROM indicates we should expect a country code
[   15.100781] ath: doing EEPROM country->regdmn map search
[   15.100789] ath: country maps to regdmn code: 0x52
[   15.100798] ath: Country alpha2 being used: CN
[   15.100805] ath: Regpair used: 0x52
[   15.118507] ieee80211 phy0: Atheros AR9287 Rev:2
[   15.124269] Registered led device: ath9k_htc-phy0
[   15.129061] usb 1-1.4: ath9k_htc: USB layer initialized
[   15.134380] usbcore: registered new interface driver ath9k_htc
[   15.180192] udev[191]: renamed network interface wlan0 to wlan1

Execute

iwconfig

you should see wlan0 in the list.

Modify /etc/network/interfaces file with something like this:

auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid ENTER_YOUR_SSID
    wpa-psk ENTER_YOUR_PASSWORD

and  execute commands bellow to start wifi.

ifdown wlan0

ifup wlan0

Filed under TP-LINK dockstart seagate TL-WN821N TLWN821N wifi wi-fi wireless debian 802.11n 802.11g

2 notes &

math puzzle

In high school a classmate showed me this math puzzle:

Question: How next line should look like?
1
11
21
1211
111221
312211
13112221
<Next Line>?

Fun fact: 50th line has 894810 numbers :)

Solution:

def gen_next_line(line):
    next_line = ”
    for i in range(len(line)):
        c = line[i]
        if len(next_line) > 1 and next_line[-1] == c:
            count = int(next_line[-2])
            next_line = next_line[:-2] + str(count + 1) + c
        else:
            next_line += ‘1’ + c
    return next_line
   
   
def main(line_no):
    line = ‘1’
    if line_no > 1:
        for i in range(1, line_no):
            line = gen_next_line(line)
    print line

if __name__ == ‘__main__’:
    if len(sys.argv) != 2:
        print ‘Usage: %s line_no’ % __file__
    else:
        main(int(sys.argv[1]))

Filed under puzzle python math

9 notes &

Runas vs. schtasks

Bandžiau iš komandinės eilutės paleisti programą po kitu sistemoje esančiu vartotoju.

Bėda ta, kad komandai runas negalima perduoti slaptažodžio kaip parametro. Žinoma, galima jį išsaugoti su “runas /savecred /u:username cmd”, bet pirmą kartą vis tiek teks pačiam jį suvesti. Bandžiau ir python (su Popen iš subprocess) pagalba perduoti slaptažodį, bet nesėkmingai.

Sprendimas:

Pasinaudojus schtasks galima sukurti užduotį, kuri bus vykdoma kito vartotojo kontekste. Tam tereikia suvesti vartotojo vardą, slaptažodį, užduoties pavadinimą bei jos vykdymo laiką. Poto ją galima panašiu būdu ir pradėti vykdyti.

C:>runas.bat user passwd

runas.bat:

schtasks /create /ru %1 /rp %2 /TN start_app /TR “C:\my_program.exe” /sc ONCE /st 00:00:00 /sd 01/01/2000
schtasks /run /TN start_app

Filed under runas schtasks user batch