Scripts

Simulating Keypresses / keystrokes with Javascript using Greesemonkey in Google Docs

This is a quick post about creating dispatching events using javascript and specifically key press events (for use with greesemonkey or whatnot and firefox).

Note that this will not work for the latest versions of firefox in many instances. I believe this is due to security updates.

Personally I am using this dispatch keypresses to google docs from a greesemonkey script.

Below the code for typing “hello world” to google docs from a greesemonkey user script.

I suspect there may be a more efficient ways though I noticed not all browsers support the same API 🙁 .
Specifically, on http://help.dottoro.com/ljbwbehw.php  we see that initKeyEvent is only available in firefox. On the other hand, initTextEventis available in IE, chrome, and Safari.

Sample Greesemonkey Script:

More

Killing CouchDB on Ubuntu 10.04

I Wanted to do some maintenance and move my couchdb data files to another partition but couchdb would not stop when I called the usual stop commands:

1)sudo /etc/init.d/couchdb stop
2)sudo service couchdb stop

Found a lot of posts and out of all of them found this nice tidbit below:

ps -U couchdb -o pid= | xargs kill -9

 

Note: It’s not the best thing to viciously kill a process. I imagine databases usually have shutdown tasks to do, must end with current insertions, etc. I’ll post if I find a bug fix.

 

Data insertion to CouchDB using Lightcouch lib in Java (Sample)

Introduction

Hello, a small sample on how to insert JSON data to couchDB.

First off there are MANY java libraries for accessing couchdb. For information on which one to choose for you the 2 links below may help:
1) http://stackoverflow.com/questions/1105807/which-java-library-libraries-for-couchdb
2) http://wiki.apache.org/couchdb/Getting_started_with_Java

In this post we made use of LightCouch as we wanted something relatively simple without object mappings and other such features.

Aside: an also interesting tutorial utilizing couchdb4j with description of sessions is: http://www.drdobbs.com/jvm/223100116

More

Reading web data with VBA from excel using Microsoft HTML Object Library and Microsoft Internet Controls

Excel VBA

Excel VBA

Description:

This is a sample script showing how I pull web-banking balances off the internet when I want to have a total picture of how my finances are. For the boring reasoning go to the last page. Otherwise technical details follow.

Project References:

Add the following to the references for this to work:

-Microsoft HTML Object Library
-Microsoft Internet Controls

VBA references

VBA references

 

Code:

The code below is an example of how to do this missing error handling. As it uses IE, it saves the developer the task of implementing SSL in VBA. 

Navigating the Site

Public oBrowser As InternetExplorer
Sub Login_2_Website()

    Dim oHTML_Element As IHTMLElement
    Dim sURL As String
    Dim text As String
    Dim avarSplit As Variant

    sURL = "https://secure.alpha.gr/e-services"
    Set oBrowser = New InternetExplorer
    oBrowser.Silent = True
    oBrowser.navigate sURL
    oBrowser.Visible = True

    Do
    ' Wait till the Browser is loaded'
    Loop Until oBrowser.readyState = READYSTATE_COMPLETE

    oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_NewLayoutSignOn__userName").Value = "USER"
    oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_NewLayoutSignOn__Pswd").Value = "PASSWORD"
    oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_NewLayoutSignOn__login").Click

Do
    ' Wait till the Browser is loaded'
    Application.Wait DateAdd("s", 0.1, Now)
    Debug.Print (oBrowser.document.readyState)
    Debug.Print (oBrowser.LocationURL)
Loop Until oBrowser.document.readyState = "complete"

oBrowser.navigate "https://secure.alpha.gr/e-services/AWBPage.aspx?service=balancesStatements"

Do
    ' Wait till the Browser is loaded'
    Application.Wait DateAdd("s", 2, Now)
    Debug.Print (oBrowser.readyState)
    Debug.Print (oBrowser.LocationURL)
Loop Until oBrowser.document.readyState = "complete"

Application.Wait DateAdd("s", 2, Now)

oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_balancesStatements__productsPagedDropDownList__selectionList").selectedIndex = 1
oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_balancesStatements__productsPagedDropDownList__selectedIndexHiddenField").Value = "1"
oBrowser.document.all.Item("_contentPlaceHolder__loadedControl_balancesStatements__balancesButton").Click

Do
' Wait till the Browser is loaded'
    Application.Wait DateAdd("s", 0.1, Now)
    Debug.Print (oBrowser.document.readyState)
    Debug.Print (oBrowser.LocationURL)
Loop Until oBrowser.document.readyState = "complete"

getBalance

End Sub

 

 

Analysis follows on next page More

Backup on Bash Login from other server using SSHFS and RSYNC

Dear All,

Quick little post about a small script I made for backing up some files from a webserver (hosting apache+mysql).

I wanted a script which would remind me to backup whenever I would log onto the specific machine.

I would have preferred automated but I’m a little paranoid about security. Why?
I don’t want to automatically compromise the security of a public webserver if another computer is hacked…so even if the backup server is hijacked no certificate/password will be stored.

Hence running the backup script required an actual user to type in the password.

More

Programatically Access Statistics from 3G Mifi/Access Point!!

Specifically I’m going to talk about the Huawei MIFI (Mobile 3G Wifi) E585 though these could be applied to another access point/ mifi. You will need the web debugger FIDDLER (a http request sniffer).

So, probably your MIFI/access point is configured with IP address 192.168.1.1 .

If there are pages that display the statistics (such as those on the E858) there is a chance the information can be accessed through a .php or other dynamic page.

On the E858, accessing http://192.168.1.1/ displays the current total download/upload and flux for the current session. (pictures coming later).

However, if you want to check more analytical statistics such as total usage you have to log on. Fortunately, if the data screen uses a JQuery (or javascript ajax script)  fiddler can be used to sniff and discover the data source (post me a line for more instructions). More