Tuesday, December 8, 2015

Linux pc (arch) as slave to synology NAS that's connected to a UPS with USB

My synology NAS is connected to my UPS with USB. I want my linux pc to listen for UPS events and shut down when the power is low.

Step 1 - Set up UPS daemon the on the synology nas

192.168.1.148 is the IP of my PC.



Step 2  - Install network-ups-tools

https://aur4.archlinux.org/packages/network-ups-tools/

In my case it was
$aura -A network-ups-tools


Step 3 - Configure network ups tools client.

First I got the password from the synology ups daemon.
 $ ssh root@nas1
$ DS212J> cat /usr/syno/etc/ups/upsd.users

In my case it was:

[monuser]
password = secret
upsmon master

Second add the credentials to /etc/ups/upsmon.conf

For me it ended up being

MONITOR ups@192.168.1.69:3493 1 monuser secret slave
Step 4 - Enable the nut-monitor

sudo systemctl daemon-reload
sudo systemctl enable nut-monitor
sudo systemctl start nut-monitor

Step 5 - Test

$ sudo systemctl status nut-monitor

Dec 08 20:01:31 buggle upsmon[17335]: UPS ups@192.168.1.69:3493 on battery
Dec 08 20:02:01 buggle upsmon[17335]: UPS ups@192.168.1.69:3493 on line power
Dec 08 20:04:41 buggle upsmon[17335]: UPS ups@192.168.1.69:3493 battery is low

Step 6 - WalNUT

I installed https://github.com/zykh/walNUT to get some status in gnome shell.


1.) mkdir ~/.local/share/gnome-shell/extensions
2.) cd ~/.local/share/gnome-shell/extensions3.) git clone --depth 1 https://github.com/zykh/walNUT.git walnut@networkupstools

4.) glib-compile-schemas walnut@networkupstools/schemas/
5.) alt+f2 r (restart shell)
6.) Use gnome web browser to go to extensions.gnome.org
7.) Enable the extension.
8.) Click the magnifying glass and put in 192.168.1.69:3493 (ip of nas).

Saturday, October 10, 2015

Reverse proxy for sonarr

First, on my home PC which is hosting sonarr - I'll restrict access to PCs on my LAN and the VPS.
iptables -I INPUT -p tcp -s VPS_IP --dport 8989 -j ACCEPT
iptables -I INPUT -p tcp -s 192.168.1.0/24 --dport 8989 -j ACCEPT
iptables -I INPUT -p tcp -s 127.0.0.1 --dport 8989 -j ACCEPT
iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 8989 -j DROP
Forward 8989 to PC running sonarr in router.



On vps in apache default site:

ProxyPreserveHost Off
ProxyPass /sonarr http://HOME_PC:8989/sonarr
ProxyPassReverse /sonarr http://HOME_PC:8989/sonarr

Also had to set settings->general-> URL Base in sonarr.


Make sure to enable authentication, either via sonarr or apache. I used form login.

<Proxy z>
AuthFormProvider file
    AuthType form
    AuthName "Login Required"
    Session Off
    SessionCookieName session path=/
    require valid-user
  # This is the login page
   ErrorDocument 401 /auth.html
           # This is the file containing users login data
   AuthUserFile /etc/apache2/.htpasswd
</Proxy>



Friday, September 18, 2015

Configuring new VPS.

Login to the server (via ssh).

$ ssh root@*.*.*.*
root@ubuntu:~# w
I want to create another user.
root@ubuntu:~# adduser youri
Make sure I can login as youri. 
 $ ssh youri@*.*.*.*

Escalate to root:
youri@ubuntu:~$ su root
Password: 
I want to disable root ssh login.
#PermitRootLogin no in /etc/ssh/sshd_config and service ssh restart
Logging as root says: Permission denied, please try again
Now I want to transfer my keys.
 $ ssh-copy-id  youri@*.*.*.*
spits out

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
but after ssh-add ~/.ssh/id_rsa it worked and copied the key.

Ssh in again and passwordless login is working. 

Now I want to disable password logins altogether.
PasswordAuthentication no in /etc/ssh/sshd_config and service ssh restart
Add my user to sudoers:
root@ubuntu:/home/youri# usermod -a -G sudo youri
Set.

Wednesday, December 17, 2014

Diff for plex media server chromecast 5.1 audio issue

diff -aur src/usr/lib/plexmediaserver/Resources/Profiles/Chromecast.xml srcpatched/usr/lib/plexmediaserver/Resources/Profiles/Chromecast.xml
--- src/usr/lib/plexmediaserver/Resources/Profiles/Chromecast.xml 2014-12-17 03:45:38.000000000 -0500
+++ srcpatched/usr/lib/plexmediaserver/Resources/Profiles/Chromecast.xml 2014-12-17 20:48:48.500219267 -0500
@@ -51,7 +51,7 @@
     <VideoAudioCodec name="aac">
       <Limitations>
         <UpperBound name="audio.bitrate" value="768" isRequired="false"/>
-        <UpperBound name="audio.channels" value="6" />
+        <UpperBound name="audio.channels" value="2" />
       </Limitations>
     </VideoAudioCodec>
     <MusicCodec name="mp3">


prepare()
{
cd "${srcdir}"
echo "Applying chromecast 2 channel patch"
patch -p1 < chromecast_2channel.patch
}

Thursday, December 11, 2014

irssi/znc install

youri@buggle ~ $ sudo aura  -S irssi
youri@buggle ~ $ irssi

In Irssi:

/NETWORK add znc-freenode

/SERVER add -auto -network -ssl znc-freenode znserver.com +6617 youri/freenode:zncpass

/NETWORK add znc-synirc

/SERVER add -auto -network -ssl znc-synirc znserver.com +6617 youri/synirc:zncpass

wget http://dave.waxman.org/irssi/xchatnickcolor.pl

mv xchatnickcolor.pl ~/.irssi/scripts/autorun

Monday, November 24, 2014

arch sonarr auto update sonarr PKGBUILD script

sonarr-develop in aur now automatically installs the latest version. (pkgver) https://wiki.archlinux.org/index.php/VCS_package_guidelines#The_pkgver.28.29_function
 #!/bin/sh  
 # Where the release information is.  
 API_ENDPOINT="https://services.sonarr.tv/v1/update/develop?os=linux"  
 # Put the release info into a variable.  
 json=$(curl -s $API_ENDPOINT)  
 # Get version and hash using JSON parser for the shell.  
 VERSION=$(jshon -e updatePackage -e version -u <<< $json)  
 HASH=$(jshon -e updatePackage -e hash -u <<< $json)  
 echo "Found latest version:" $VERSION  
 echo "Changing PKGBUILD"  
 # Get the version inside the PKGBUILD.  
 PREV_VER=$(grep pkgver PKGBUILD | head -n1 | awk -F= '{print $2;}' | sed 's/\"//g')  
 # Replace old version with new.  
 sed -i "s/^pkgver=\"$PREV_VER\"$/pkgver=\"$VERSION\"/" PKGBUILD  
 echo "Downloading Release"  
 # Get the release.  
 if [ -f NzbDrone.master.$VERSION.mono.tar.gz ]; then  
   echo "Already have latest version"  
   return   
 fi  
 wget http://update.nzbdrone.com/v2/develop/mono/NzbDrone.develop.$VERSION.mono.tar.gz  
 echo $HASH "NzbDrone.develop."$VERSION".mono.tar.gz"| sha256sum -c - --status  
 if [ $? = 0 ]; then  
      updpkgsums  
      makepkg -f  
      sudo pacman -U "sonarr-develop-"$VERSION"-1-any.pkg.tar.xz"  
      sudo systemctl daemon-reload  
      sudo systemctl restart sonarr  
 else  
   echo "CHECKSUMS DID NOT MATCH"  
 fi  

Thursday, November 20, 2014

VirtualBox virtual serial port Windows Guest to linux host.


1.) Select "Enable Serial Port"
2.) Port mode: Host Pipe
3.) Create Pipe Checked.
4.) Port/File Path: /tmp/vboxCOM'

Now the port shows up windows.

My version of netcat allows connecting to sockets.

extra/gnu-netcat 0.7.1-5 [installed]



nc -U /tmp/vboxCOM
test
testback


To test sending data over the socket with bash:

function sendData()
{
    nc -U /tmp/vboxCOM <<< $(echo -en "\x1B$*\xD")
}
echo "Sending ST"
sendData "ST"

With python
#!/usr/bin/env python
import socket
import os, os.path
import time 
socketLocation = '/tmp/vboxCOM' 

print("Connecting...")
s = socket.socket(socket.AF_UNIX)
s.settimeout(1) # 1 second timeout, after all it should be instant because its local
s.connect(socketLocation)

def sendMessage(message):
    '''
    Sends a message to a socket.
    '''

    s.send(str.encode(message))
 
 
print("Sending a test message")
sendMessage("test\n")

Friday, October 3, 2014

VirtualBox/Windows 10 tech preview get okay resolution without guest additions.

I ran

VBoxManage setextradata tv-00002 CustomVideoMode1 1920x1080x32

rebooted - and was able to select the 1920x1080 resolution.

It added:

      <ExtraDataItem name="CustomVideoMode1" value="1920x1080x32"/>

to the vbox file for the virtual machine.

Thursday, July 17, 2014

Reverting libstagefright_httplive.so to 4.4.2 on nexus 7 4.4.4


  1. Downloaded nakasi-kot49h-factory-5e9db5e1.tgz
  2. Extracted nakasi-kot49h-factory-5e9db5e1.tgz
  3. Unzipped image-nakasi-kot49h.zip
  4. git clone https://github.com/YuLaw/ext4-utils.git
  5. cd ext4-utils and 'make'
  6. ext4-utils/simg2img system.img img.raw
  7. sudo raw.img system/
  8. adb push libstagefright_httplive.so /sdcard/
  9. adb shell
  10. su
  11. cp /sdcard/libstagefright_httplive.so /system/lib/
  12. chmod 744 /system/lib/libstagefright_httplive.so
  13. reboot

Friday, December 6, 2013

Find, xargs, split2flac split everything in a directory.

find ./ -maxdepth 1 -type d | xargs -I{} split2flac {}

Thursday, December 5, 2013

How I updated my rooted nexus 5 with a custom kernel to kitkat 4.4.1


  1. Download the 4.4.1 image (7ed504f678cea49ecf0974e8cd956e2974e3f943.signed-hammerhead-KOT49E-from-KRT16M.7ed504f6.zip)
  2. Download the stock image (hammerhead-krt16m-factory-bd9c39de.tgz).
  3. Copy the updated image to the phone

    $ adb push ~/Downloads/7ed504f678cea49ecf0974e8cd956e2974e3f943.signed-hammerhead-KOT49E-from-KRT16M.7ed504f6.zip  /mnt/sdcard/

  4. Reboot into fastboot (power and volume down when booting).
  5. Extract the stock image.

    $ tar zxvf hammerhead-krt16m-factory-bd9c39de.tgz

  6. Unzip the image

    $ unzip image-hammerhead-krt16m.zip

  7. Flash the boot img

    $ fastboot flash boot boot.img

  8. Reboot into bootloader

    $ fastboot reboot-bootloader

  9. Flash the system img.

    $ fastboot flash system system.img

  10. Go into recovery (TWRP for me) and flash the 4.4.1 update copied over earlier. 
  11. Flash custom kernel on sdcard.
  12. Let twrp install supersu and reboot.
  13. Not rooted - download the latest twrp (openrecovery-twrp-2.6.3.4-hammerhead.img)
  14. Reboot into fastboot mode again.
  15. Flash the twrp image

    $ openrecovery-twrp-2.6.3.4-hammerhead.img

  16. Boot into recovery mode.
  17. Download latest supersu (UPDATE-SuperSU-v1.80.zip)
  18. Copy supersu over to card.

    $ adb push UPDATE-SuperSU-v1.80.zip  /sdcard/update-supersu-v1.80.zip

  19. Install it from TWRP.
  20. Done.




Tuesday, December 3, 2013

Android 4.4 trying to resolve local domains with dhcp server on server 2003.

My android 4.4 device would not resolve local domains.

Ex:
sv00004 - could not resolve
sv00004.blah.com - resolved.

Solution:
* start->-run-> mmc
* Add/remove snap in-> DHCP
* Right click DHCP "Add server"
* Select the DHCP server.
* Expand to server options.
* Right click server options

I added my two DNS servers to "006 DNS Servers" and my domain blah.com to "015 DNS Domain Name".

Seems to resolve fine now - at least from chrome.

Saturday, June 15, 2013

Nexus 7 rooting on arch.

Following this tutorial: http://forum.xda-developers.com/showthread.php?t=1741395

1.) pak -S android-tools
2.) adb devices showed
List of devices attached 
????????????    no permissions
3.) fixed with pak -S android-udev
4.) DL CWM touch and superSU
5.) Allow computer connection on device.
6.) adb push path-to-zip/JB-SuperSU.zip /sdcard/0/Download/update.zip
7.) adb reboot bootloader
8.) fastboot oem unlock
9.) Yes, unlock bootloader.
10.) $ fastboot flash recovery ~/Downloads/recovery-clockwork-touch-6.0.3.1-grouper.img 
sending 'recovery' (6644 KB)...
OKAY [  8.759s]
writing 'recovery'...
OKAY [  0.512s]
finished. total time: 9.271s
11.) tablet - use volume buttons to boot into recovery.
12.) mounts and storage
13.) mount system
14.) adb shellcd /systemmv recovery-from-boot.p recovery-from-boot.bak
15.) Return back to recovery.
16.) Navigate to update.zip
17.) install update.zip




Wednesday, February 13, 2013

Exchange EMC

Running EMC would cause this:

Connecting to remote server failed with the following error message: The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help topic. 

Tried every single thing I could find on google, set winrm maqxrequests, reinstall exchange, reinstall winRM, spent 12 hours. 

My solution (issue was caused by wsus messing with dynamiccompression module)

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /-[name='xpress']

Tuesday, February 12, 2013

Exchange 2010 ECP event ID 4

New exchange2010 installation, ECP complained with


Test-ecpconnectivity -verbose | fl


PerformanceCounterName      : ECP Web Sevice Logon Latency
Result                      : Failure
Error                       : An exception was thrown by the Web service: The remote server returned an error: (500)

and event viewer had getlist failures on msexchagne control panel 4


failed with the following error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


reloading counters didn't help, removing and reinstall ECP did not help.


Solution in IIS set the application pool for msexchagneECPapppool to .net 2.0 instead of .net 4.0.


Friday, December 21, 2012

Exchange 2010 KB2756496 error 80070643


Update Rollup 7-v2 for Exchange Server 2010 Service Pack 1 (KB2756496)

Installation date: ‎12/‎21/‎2012 11:31 PM

Installation status: Failed

Error details: Code 80070643

Update type: Important

This update rollup resolves problems that were found in Exchange Server 2010 Service Pack 1 (SP1) since Exchange Server 2010 SP1 was released and replaces previously released update rollups for Exchange Server 2010 SP1.

More information: 
http://support.microsoft.com/?kbid=2756496
http://go.microsoft.com/fwlink/?LinkId=207096

Help and Support: 
http://technet.microsoft.com/en-US/exchange/dd203064

Fix:
http://www.expta.com/2012/08/exchange-2010-sp2-roll-up-4-does-not.html?showComment=1349847237817#c894835615165077581

Edited C:\Program Files\Microsoft\Exchange Server\V14\Scripts\ManageScheduledTask.ps1

and changed line 462 to write-output instead of return.

Exchange 2010 & Windows Server 2012 exchange management console crash.

Trying to gather data from the exchange console kept getting: error FX:{A5406CA3-6393-48a0-8827-CF06F0C94C55} Exception has been thrown by the target of an invocation.

Everything showed "Unavailable".

Fix is here:

http://social.technet.microsoft.com/forums/en-US/exchangesvrdeploylegacy/thread/02881780-9982-4a5a-a7fd-1cf609913779

Open mmc, add the exchange management console snap in and save it as emc.msc

create a bat file 


set __COMPAT_LAYER=RUNASINVOKER
set COMPLUS_Version=v2.0.50727
"C:\Users\youri\Desktop\emc.msc"

and the management console will work.

Friday, November 30, 2012

"Unable to find a version of the runtime to run this application."

Saw this trying to install software using ClickOne with a dependency on .NET framework full on windows XP.

"Unable to find a version of the runtime to run this application."

.NET framework 4 full was installed.

Solution was to download .NET framework 2.0

http://www.microsoft.com/en-us/download/details.aspx?id=20137

Let windows update install .NET framework 3.5 update.

Install .net Framework 4.


Thursday, September 20, 2012

xrdp_sec_incoming: error reading /etc/xrdp/rsakeys.ini file

xrdp_sec_incoming: error reading /etc/xrdp/rsakeys.ini file  

Fix : run xrdp as root

Tuesday, April 10, 2012

Visual Studio 2010 and "Cannot publish because a project failed to build".

Problem is with visualmicro addon.

Tools->add-in manager - > Visual Micro Arduino
Uncheck "start" and "command line" and everything works

Thursday, March 1, 2012

Apps on my Toshiba Thrive

Box.net
Stopwatch & Timer
PaintJoy
QuickPic
Whiteboard Pro
SSHDroid
Earth
Wifi Analyzer
Opera Mobile
Copilot Live USA
ColorNote
MyFitnessPal
Amazon AppStore
Parcels
Google Sky Map
MX VIdeo Player
ES File Explorer
Adsense Dashboard
Dolphin for PAD
Skype
TeamworkPM
Tapatalk
GetJar
Calculator
AdFree

Saturday, February 11, 2012

My steps for rooting a toshiba thrive hmj 37.31.5.011

Toshiba thrive version HMJ 37.31.5.0011.

I got all the information from thriveforums.org threads.

1. Downgrade to HMJ37.01.5.0032
http://www.thriveforums.org/forum/dalepl-development/4359-downgrade-official-toshiba-hmj37-31-5-0011-hmj37-01-5-0032-rollback.html

2.) Boot into recovery mode ( power off -> hold power + volume up)
3.) Select white package, select 'install update from external card'
4.) Reboot - thrive is downgraded
5.) Turn on usb debugging in settings -> applications -> development
6.) Download dalenet easy flash tool http://www.thriveforums.org/forum/dalepl-development/1974-root-tool-dalenet-thrive-10-1-easy-flash-tool.html
7.) Download a rooted ROM
8.) Extract easy flash tool
9.) Plug in thrive, install adb drivers (they were part of easy flash tool zip) (takes a while)
10.) PS C:\Users\youri\Downloads\DaleNet-Thrive_10-Easy_Flash_Tool-v1.5\tools> .\adb.exe devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
280400643406517 device
11.) shutdown, boot into recovery mode
12.) select fast boot (usb icon)
13.) Device looks like hangs at 'starting usb download protocol'
14.) PS C:\Users\youri\Downloads\DaleNet-Thrive_10-Easy_Flash_Tool-v1.5\tools> .\fastboot.exe devices
?       fastboot
15.) Reboot it
16.)PS C:\Users\youri\Downloads\DaleNet-Thrive_10-Easy_Flash_Tool-v1.5\tools> .\fastboot.exe reboot
rebooting...

finished. total time: -0.000s

17.) Steps 9-16 confirm that the usb connection is good
18.) Reboot into fastboot again
19.) Run  thrive_easy_flash_tool.bat
20.) Select #1
21.) extract update.zip from rom image onto the sd card
22.) go to applications -> super user and update it
23.) root has been obtained
24. safe boot again
25.) thrive easy flash tool
26.) 3 - install  flash recovery
27.) Install clockwork
28.) thrive will hang at installing mrb image
29.) reboot into recovery, select the package icon
30.) should be in CWM mode, install zip from sdcard
31.) reboot from the cwm menu
32.) Should be on the right image now & rooted

Wednesday, February 8, 2012

VB.net defeat simple padding obfuscation

There is an applicationthat obfuscates a serial number by padding each character. Here is a de-obfuscator I made.

First: define the array with all the characters the algorithm uses:






    Public charArray() As Char = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", _
                           "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", _
                           "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", _
                           "V", "W", "X", "Y", "Z"}

Function that will deobfuscate it.

    Private Function OffsetAChar(ByVal chartooffset As Char, ByVal offset As Integer)
        Dim posInArray As Integer = Array.IndexOf(charArray, chartooffset)
        Dim ArrayLength As Integer = charArray.Length

        If posInArray + offset = ArrayLength Then
            Return "0"
        End If

        If (posInArray + offset) <= ArrayLength And (posInArray + offset) > 0 Then
            Return charArray(posInArray + offset)
        End If

        If posInArray + offset = 0 Then
            Return 0
        End If

        If (posInArray + offset) < 0 Then
            Return charArray(ArrayLength + posInArray + offset)
        End If

        If (posInArray + offset) > ArrayLength Then
            Return charArray(Math.Abs(ArrayLength - (posInArray + offset)))
        End If

    End Function


Usage is simple:

        Dim charArray2() As Char

        Dim ArraySTring As String = txtDecode.Text
        ArraySTring = ArraySTring.Replace("-", "")
        charArray2 = ArraySTring


       txtCodeDecoded.Text += OffsetAChar(charArray2(0), -19).ToString.ToUpper


Figuring out the offset of two letters


    Public Function OffsetFinder(ByVal letter1 As Char, ByVal letter2 As Char)

        Dim CharPos1 = Array.IndexOf(charArray, letter1)
        Dim CharPos2 = Array.IndexOf(charArray, letter2)
        Return CharPos2 - CharPos1

    End Function

VB.net 2010 run an app, activate it, and send keys.

This isn't an elegant way to do it, but it works for me. It runs a program, sends alt+h, a, tab, then ctrl+c to copy text to a clipboard and puts the contents of the clipboard into a textbox.

In sendkeys:
 % = alt
vbTab = tab
^ = crl
{escape} = ESC

Imports System.Diagnostics.Process
Imports System.Threading

Public Class Form1


Public Sub GetSerials()
Dim pInfo As ProcessStartInfo = New ProcessStartInfo("C:\Program Files (x86)\CustomApp\Bin\customapp.exe")

      pInfo.WindowStyle = ProcessWindowStyle.Maximized
        Process.Start(pInfo)
        Thread.Sleep(3000)

AppActivate("CustomApp 1.1.5")


        System.Windows.Forms.SendKeys.SendWait("%")
        System.Windows.Forms.SendKeys.SendWait("h")
        System.Windows.Forms.SendKeys.SendWait("a")
        System.Windows.Forms.SendKeys.SendWait(vbTab)
        System.Windows.Forms.SendKeys.SendWait("^c")
        TextBox2.Text = (TextBox1.Text & " : " & Clipboard.GetText & vbCr)

        System.Windows.Forms.SendKeys.SendWait("{escape}")
        System.Windows.Forms.SendKeys.SendWait("%")
        System.Windows.Forms.SendKeys.SendWait("f")
        System.Windows.Forms.SendKeys.SendWait("q")



    End Sub


End Class

Monday, January 23, 2012

VB.net and oracle package that returns boolean

Public Function VALIDATE_NUMBER(ByVal num As String)
 
'connection string
 oraconnstring = "Data Source=" & OracleDataSource & ";User ID=" & OracleUserID & ";Password=" & OraclePassword & ";"

 'initialize command
        Dim oraclecmd As New OracleCommand
        oraConnection.Open()


        'Initiate the package command
        oraclecmd = oraConnection.CreateCommand
        oraclecmd.CommandType = CommandType.StoredProcedure
        oraclecmd.CommandText = "CUSTOM_PACKAGE.GET_NUM"

        'create parameters that will be passed with command
        Dim dbNum As OracleParameter
        Dim dbPartNum As OracleParameter
        Dim dbCode As OracleParameter
        'serialnumber is sent to package
        dbNum = oraclecmd.Parameters.Add("I_STR_NUMBER", OracleDbType.Varchar2)
        dbNum.Value = serialnum
        dbNum.Direction = ParameterDirection.Input
        dbNum.Size = 25
        'value is modified by oracle package
        dbPartNum = oraclecmd.Parameters.Add("O_STR_PART_NUMBER", OracleDbType.Varchar2)
        dbPartNum.Value = DBNull.Value
        dbPartNum.Direction = ParameterDirection.InputOutput
        dbPartNum.Size = 25
        'value is modified by oracle package
        dbCode = oraclecmd.Parameters.Add("O_STR_HEAT_CODE", OracleDbType.Varchar2)
        dbCode.Value = DBNull.Value
        dbCode.Value = "default"
        dbCode.Direction = ParameterDirection.InputOutput
        dbCode.Size = 25
        oraclecmd.ExecuteNonQuery()
'populate class
       numinfo.PartNumber = dbForgingPartNum.Value.ToString
       numinfo.Code = dbHeatCode.Value.ToString
 
 
        Return numinfo
 
        oraConnection.Dispose()
end function
-------------
if the package returns a boolean value, which vb.net/oracle adapter can't handle, then a solution is to create a wrapper around that package.
  oraclecmd = oraConnection.CreateCommand
 
        'initiate return value
        Dim ReturnValue As OracleParameter = oraclecmd.Parameters.Add(":ReturnValue", OracleDbType.Varchar2)
        ReturnValue.Direction = ParameterDirection.Output
        ReturnValue.Size = 1
 
        'Wrapper for the stored function (anonymous block)
        'boolean datatype is not available outside of pl/sql
 
        oraclecmd.CommandType = CommandType.Text
        oraclecmd.CommandText = "declare tmp boolean; ReturnValue varchar2(1) ;begin tmp := FS.GETSN('" & value & "');if tmp = true then :ReturnValue := 'T'; else ReturnValue := 'F'; end if; end;"
 
        'execute the anonymous block
        oraclecmd.ExecuteNonQuery()
 
        'convert returnvalue into a string
        Dim a As String = oraclecmd.Parameters(":ReturnValue").Value.ToString
A will be T or F.

Friday, November 4, 2011

pacman-key --init not enough random bytes available

Running pacman-key I get



[youri@slavluv ~]$ sudo pacman-key --init
gpg: Generating pacman keychain master key...


Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 284 more bytes)


a.)[youri@slavluv aur]$ wget http://aur.archlinux.org/packages/rn/rng-tools/rng-tools.tar.gz
b.)[youri@slavluv aur]$ tar zxvf rng-tools.tar.gz
c.)[youri@slavluv aur]$ cd rng-tools
d.)[youri@slavluv rng-tools]$ makepkg -s
e.)[youri@slavluv rng-tools]$ sudo pacman -U rng-tools-3-2-i686.pkg.tar.xz
f.) change timeout=0 to timeout=10 in /etc/conf.d/rngd

2.) [youri@slavluv rng-tools]$ sudo rngd -f -r /dev/urandom

3.) [youri@slavluv ~]$ sudo pacman-key --init
Password:
gpg: Generating pacman keychain master key...
....+++++
................+++++
gpg: key DBCCC88E marked as ultimately trusted
gpg: Done
==> Updating trust database...
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u



Tuesday, June 7, 2011

Trying to play GTA vice city under linux with wine.

First I need to install wine:

[youri@slavluv Downloads]$ sudo pacman -S wine

Now to configure wine and create all the folders, and it also installs gecko packages. In config I added drive D: as /tmp/CD

[youri@slavluv Downloads]$ winecfg

Make the folder in CD in tmp and mount the iso. "-o loop" (modprobe loop if it's not loaded)

[youri@slavluv tmp]$ mkdir CD
[youri@slavluv tmp]$ sudo mount -o loop /home/youri/Downloads/Grand\ Theft\ Auto\ Vice\ City\ -\ PC/GTA_Vice_City.iso CD/


Run the setup:

[youri@slavluv tmp]$ wine CD/setup.exe




Went through install (did not choose to use radio stations)

Using the no-cd crack (I have the cd but not cd-rom drive, so I have to download it, it's not illegal if you have the licensed CD)

[youri@slavluv Grand Theft Auto Vice City - PC]$ cp -f Crack/gta-vc.exe /home/youri/.wine/drive_c/Program\ Files/Rockstar\ Games/Grand\ Theft\ Auto\ Vice\ City/


Now I went to install directory ( /home/youri/.wine/drive_c/Program Files/Rockstar Games/Grand Theft Auto Vice City ) and ran wine gta-vc.exe


It messed up my screen/didn't work.

Mounting the play CD the same way I did the install CD loaded the game. All the textures are blocky though. Probably would work fine at this point for someone with a decent video card..


Errors:

fixme:d3d:CompareFunc Unrecognized WINED3DCMPFUNC value 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:swapchain_gl_present Render-to-fbo with WINED3DSWAPEFFECT_FLIP
fixme:d3d:CompareFunc Unrecognized WINED3DCMPFUNC value 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:swapchain_gl_present Render-to-fbo with WINED3DSWAPEFFECT_FLIP
fixme:d3d:CompareFunc Unrecognized WINED3DCMPFUNC value 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:StencilOp Unrecognized stencil op 0
fixme:d3d:swapchain_gl_present Render-to-fbo with WINED3DSWAPEFFECT_FLIP
fixme:d3d:CompareFunc Unrecognized WINED3DCMPFUNC value 0

Disabling "Allow pixel shader" in wine settings  fixes the blockiness. Game is still slow though.

Thursday, April 21, 2011

lighttpd fastcgi issues

Suddenly "mod_fastcgi" being enabled in "server.modules" for lighttpd is causing problems.

 2011-04-21 19:30:58: (log.c.166) server started
2011-04-21 19:30:58: (mod_fastcgi.c.978) bind failed for: unix:/var/run/lighttpd/php-fastcgi.socket-0 Permission denied
2011-04-21 19:30:58: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.
2011-04-21 19:30:58: (server.c.938) Configuration of plugins failed. Going down.

Fix:

[youri@nemesis run]$ sudo gpasswd -a youri http
Password:
Adding user youri to group http

Or I should maybe make lighttpd run as http user again.

Wednesday, April 20, 2011

Mapping the cell locations from an iphone db on google maps

IOs stores the GPS locations of towers it connects to in this file:

/var/root/Library/Cache/locationd/consolidated.db

It's an sqlite3 file... So here is a script to pull the longtitude and lattitudes and turn them into a simple KML file.
#/bin/bash

#this is the KML heading
echo '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>

  <name>youri</name>'
 
#pull the longitude and latitude from sqlite3
for i in $(sqlite3 consolidated.db 'select longitude,latitude from celllocation';)
do coordinate=$(echo $i | sed 's/|/,/g')



echo '<Placemark><name>'$coordinate'</name><Point><coordinates>'$coordinate',0</coordinates></Point></Placemark>'
done;

echo '</Document></kml>'


I added this to my lighttpd.conf and restarted it.

  ".kml"       =>      "application/vnd.google-earth.kml+xml",

Then it's just a matter of passing the kml file to google maps..

http://maps.google.com/maps?q=http://$yourserver/output.kml

I noticed a bunch of towers I never connected to  (far away places) so there are some problems with this.

Monday, April 11, 2011

Gnome-shell annoying bug.

Accidentally hitting the print screen button (which I do a lot because of this stupid keyboard) I get an annoying popup:

Text was empty (or contained only whitespace)

and in /.xsession-errors
Window manager warning: Error on command 33 "": Text was empty (or contained only whitespace)

Went to system settings - > keyboard -> shortcuts and disabled the printscreen shortcut for now.

Update: removing ~/.gconf and ~/.gnome* fixes this.