Tuesday, 10 September 2013

How to Ensure Input from URL isn't from a Redirected Page

How to Ensure Input from URL isn't from a Redirected Page

I have the following lines of code that gathers the source code from a
given URL:
URL url = new URL(websiteAddress);
URLConnection connection = url.openConnection(); // throws an IOException
connection.setConnectTimeout(timeoutInMilliseconds);
bufferedReader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
outputString += line;
}
However, the problem that I'm having is that wi-fi hotspots often redirect
you to a page where you have to click "I Agree." If you run this code
before you have clicked that checkbox, then it gathers the source code
from the hotspot login page, rather than the intended page.
What I want to do is have some way of checking whether or not the intended
page was reached. I was hoping that calling connection.getURL() after
creating the InputStreamReader would show me the actual web page that was
arrived, but no such luck. How can I determine whether or not the intended
URL has been redirected?

In Dart how to get the ID of clicked SVG object?

In Dart how to get the ID of clicked SVG object?

For the Dart code below:
for(var SVG_Element in SVG_Element_list){
SVG_Element.onClick.listen((event){
//some code
});
}
How to determine the ID of the clicked object? I tried "event.target.id"
and would only get the type of the Element like "line" or "circle".
How to get the ID?
Thanks!

How to find index to the last touched place in JavaScript?

How to find index to the last touched place in JavaScript?

touchstart, touchmove and touchend give these informations:
event.touches.length - number of touches event.touches[0] - first touch in
the list data
my question is: if there are more then one touch, how can I know which one
moved when touchmove was dispached? how can I know which one dissapeard
from the list when tochend was dispached?
touches contains item which have these data: view - WindowProxy target -
EventTarget identifier - long pageX -long pageY -long screenX - long
screenY - long
should I use this 'identifier' to distinguish correct touch?

How to Convert hex code in text form in PHP

How to Convert hex code in text form in PHP

How can i will convert
"092E094809020020091C093E002009300939093E0020093909420901" Hex code into
Text string in php

addressing asset stylesheets with file extensions

addressing asset stylesheets with file extensions

I have some stylesheets in a subfolder /app/assets/stylesheets/themes of
my rails app. These assets have the file extension .css.scss extension.
In my development environment I've been addressing those files with:
asset_path 'themes/theme-name.css.scss'
However, when I go to production Rails won't find those files. When I use
just .css extension it seems to be working okay:
asset_path 'theme/theme-name.css'
My question is: what is the correct way to address asset files with
multiple extensions?
Thanks for help

Monday, 9 September 2013

Isuue with NSRegularExpression

Isuue with NSRegularExpression

I use objective-c on windows.When I try using NSRegularExpression, this
shoots up on my console.
" unknown type name 'NSRegularExpession'
'NSRegularExpression' undeclared.........."
Any clues?
TIA

Xev doesnt recognize the down key

Xev doesnt recognize the down key

I accidentally unbound my downkey. Now my system wont recognize it.
Xev prints out
FocusOut event, serial 36, synthetic NO, window 0x0,
mode NotifyGrab, detail NotifyAncestor

FocusIn event, serial 36, synthetic NO, window 0x0,
mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 36, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

showkey -a dumps nothing when i press down.
$ showkey -s
$ 0xe0 0x50 0xe0 0xd0
$ showkey
$ keycode 108
I know xev would tell me down's keycode is 116.
What I am to do with this information I dont know but this is possible to
fix I swear.
Also when I run dumpkeys "keycode 108 = Down" and thats it. while next says
keycode 109 = Next
shift keycode 109 = Scroll_Forward
Thanks for the help