четвер, 18 грудня 2014 р.

linux dynamic dns: оновлювати лише для мобільного пристрою wwan0

Приклад використання схеми: скажімо, пристрій на лінуксі крім мобільного пристрою використовує ще загальнодоступні wi-fi. На загальнодоступних wi-fi для пристрою будуть закриті потрібні порти, тому доцільно оновлювати запис динамічного dns, наприклад, лише для зв’язку через usb-модем, який отримує "білу" IP адресу.


Приклад оновлення динамічного dns лише для мобільного пристрою:

/etc/network/if-up.d/wwan0_is_up
#!/bin/sh

echo "wwan0 is up" >> /var/log/wwan0.log
wget -q --read-timeout=0.0 --waitretry=5 --tries=400 --background http://freedns.afraid.org/dynamic/update.php?[код вашого сервісу]
Створений скрипт потрібно зробити виконуваним

sudo chmod +x /etc/network/if-up.d/wwan0_is_up

і помістити в скрипт

/etc/network/interfaces

наприклад:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
allow-hotplug wwan0
iface wwan0 inet dhcp
post-up /etc/network/if-up.d/wwan0_is_up

Винятком може бути доступ через власну wi-fi точку, де налаштоване форвардування портів. Для таких винятків розглянемо скрипт пізніше, коли буде натхнення.

пʼятницю, 12 грудня 2014 р.

Excel + VBA - вибрати з комірки лише цифри

ALT+F11 -> Insert -> Module

Function DigitsOnly(S As String) As String
  Dim X As Long
  DigitsOnly = Replace(S, " ", "")
  If DigitsOnly Like "+91*" Then DigitsOnly = Mid(DigitsOnly, 4)
  For X = 1 To Len(DigitsOnly)
    If Mid(DigitsOnly, X, 1) Like "[!0-9]" Then Mid(DigitsOnly, X) = " "
  Next
  DigitsOnly = Replace(DigitsOnly, " ", "")
End Function 

=DigitsOnly(A1)

(протестовано в Office 2007)

пʼятницю, 5 грудня 2014 р.

linux - скрипт для сигналізування про завершення зарядки батареї

Раніше вже знайдено як виводити в консолі статус заряду батареї
http://marchelloua.blogspot.com/2014/11/linux-console.html

Але туди регулярно дивитися не зручно і не потрібно.

Для тих, хто використовує графічну оболонку, в трей біля годинника виводиться статус батареї. Але про завершення зарядки сигналізування відбувається лише один раз і можна про це забути.

Нижче наведено скрипт, який стартуємо після завантаження графічної оболонки, після чого скрипт резидентно сидить як процес і регулярно опитує стан батареї, після чого сигналізує діалоговим вікном і звуком.

#!/bin/sh

DELAY=180
while sleep $DELAY
do
valuea=`cat /sys/class/power_supply/BAT0/capacity`
echo "$valuea"
if [ $valuea -eq "104" ] || [ $valuea -eq "99" ] || [ $valuea -eq "100" ] || [ $valuea -eq "105" ] || [ $valuea -eq "101" ] || [ $valuea -eq "102" ] || [ $valuea -eq "103" ] || [ $valuea -eq "105" ]
then
  echo "please unplug charger"
  aplay /home/ymarkiv/Dropbox/music/wav/animals131.wav
  if ! xmessage -nearmouse -buttons continue:0,stop:1 "please unplug charger"
  then
       exit 0
  fi
else
  echo "still charging"
fi
done
/home/ymarkiv/bash_learn/power_100.sh (END)

Oracle - convert clob into varchar2

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:367980988799


create or replace procedure p ( p_str in varchar2 )
is
   l_str   long := p_str;
begin
   loop
      exit when l_str is null;
      dbms_output.put_line( substr( l_str, 1, 250 ) );
      l_str := substr( l_str, 251 );
   end loop;
end;
/

середу, 3 грудня 2014 р.

ubuntu - install toad for oracle

http://www.toadworld.com/products/toad-for-oracle/b/weblog/archive/2012/10/01/toad-11-6-runs-natively-on-linux.aspx

Here are the steps:
  1. Download Toad for Oracle 11.6 Commercial (32-bit) – choose the special, smaller MSI version (please note that the much larger downloads built on top of the “Quest Installer” not tested)
Поправка: використовую безкоштовну версію toad 
google: download toad for oracle free

 2. Download the Oracle 11.2.0.1.0 client zip file (Note that 10g clients are no longer available)

Поправка: з часу написання статті шлях змінився
актуальний шлях: 
wget -c http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_client.zip

а взагалі в гуглі: "install" Oracle 11.2.0.1.0 client
або в гуглі: Oracle Database 11g Release 2 for Microsoft Windows (32-bit)

3. Unzip the Oracle 11.2.0.1.0 client download into your user’s home directory (e.g. ~/client)
  1. Run command: wine --version and verify that you have at least version 1.4 (latest stable)
  2. If you need to update wine – here are the steps for Ubuntu (see Wine HQ for different Linux)
    1. Run command: sudo add-apt-repository ppa:ubuntu-wine/ppa
    2. Run command: sudo apt-get update
    3. Run command: sudo apt-get install wine
    4. Recheck your wine version – repeat steps a to c above until you see wine 1.4
  3. Run command ./winetricks gdiplus mdac28 msxml6 vb6run vcrun6sp6 tahoma msls31 riched20 riched30 richtx32 comctl32 comctl32.ocx
Поправка: tahoma не завантажується самостійно, тому 
використовую наступну інструкцію: 

http://makandracards.com/makandra/1258-install-the-verdana-and-tahoma-fonts-under-ubuntu-linux 

Tahoma:
wget http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/IELPKTH.CAB
cabextract -F 'tahoma*ttf' IELPKTH.CAB
mv -f tahoma*ttf /usr/share/fonts/truetype/msttcorefonts/
chmod 644 /usr/share/fonts/truetype/msttcorefonts/tahoma*
fc-cache -v
rm -f IELPKTH.CAB
 
 
  1. Run command: cd ~/client (or whatever directory you choseto unzip Oracle client to back in step #3)
  2. Run command: wine setup.exe (this will invoke the Oracle client installer program)
  3. Choose the third option: RUNTIME (754 MB) – see screen snapshot in Figure 2 below
  4. Select an Oracle home that you like and will remember – see screen snapshot in Figure 3 below
  5. Create a tnsnames.ora text file to point to your database(s) either manually or using Oracle netca
  6. Run command to copy your tnsnames.ora file to your Oracle client home selected in step 11 above: cp ~/tnsnames.ora ~/.wine/drive_c/oracle/product/10.2.0/client_1/NETWORK/ADMIN
  7. Run command: wine msiexec /i toad_for_oracle_11.6.msi (this runs the base Toad product installer)
  8. Run Toad either via desktop icon or menu Applications->wine->programs->Quest Software->Toad (Note – be patient first time Toad starts as it needs to copy some files from install to app directories)
Enjoy Toad on Linux!