Posts

android - How to load a Custom Java View class to a RelativeLayout programmatically -

i want load custom views within relativelayout don't know how. code i've tried doesn't work hence know how correctly? xml <?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin"> <textview android:id="@+id/textview0" android:layout_widt...

c# - System.IndexOutOfRangeException when trying to copy data from list to 2d array -

i getting exception: system.indexoutofrangeexception: 'index outside bounds of array.' on col ++ when in second loop. trying put vales list> excel columns , rows. please let me know doing wrong. object[,] cellvaluestowrite = new string[excelrange.rows.count, excelrange.columns.count]; foreach (list<string> errorrecord in section.errorrecords) { int rows = 0; int col = 0; int length = errorrecord.count; foreach (var elem in errorrecord) { if (col < length) { cellvaluestowrite[rows, col] = elem; col++; } } rows++; } if create array excelrange.rows.count , excelrange.rows.count 5 cannot access cellvaluestowrite[5, col] because indexing starts @ 0 , try access 6-th element way. why not using old loop (especially if need indexing): for (int row = 0; row < cellvaluestowrite.getlength(0); row++) { (int col = 0; col < cellvaluestowrite.getlengt...

Encoding sys.argv in python 2.7 -

i'm writing script takes input software (maltego), , using sys.argv[1] variable. when information maltego in hebrew, question marks rather actual text. tried encoding text in different ways failed. i'm using python 2.7. any idea solution appreciated. the script being run within maltego: # -*- coding: utf-8 -*- import time selenium import webdriver selenium.webdriver.common.keys import keys bs4 import beautifulsoup maltegotransform import * import codecs import sys reload(sys) sys.setdefaultencoding('utf-8') me = maltegotransform() search_value = sys.argv[1].encode("utf-8") here fifty pence: import sys def win32_utf8_argv(): """uses shell32.getcommandlineargvw sys.argv list of utf-8 strings. versions 2.5 , older of python don't support unicode in sys.argv on windows, underlying windows api instead replacing multi-byte characters '?'. returns none on failure. ""...

Accessing members of collection during rails activerecord query with geocoder -

i'm using geocoder gem. model user has latitude , longitude , , radius attributes. have collection of users called liveusers in instance method in class user . want trim liveusers down users less radius away instance's location, using .near method geocoder . how construct kind of query? liveusers.near([self.latitude, self.longitude], liveuser.radius ) # realise won't work

How to Compress Image Size on Upload in Php -

i beginner , have been trying reduce image size on upload failing results. please me. here php code <?php if (isset($_post['update'])){ header('location:index2.php'); $upload_image = $_files["image"][ "name" ]; $folder = "images/"; move_uploaded_file($_files["image"]["tmp_name"], "$folder".$_files["image"]["name"]); $file = 'images/'.$_files["image"]["name"]; $uploadimage = $folder.$_files["image"]["name"]; $newname = $_files["image"]["name"]; $random = substr(number_format(time() * rand(),0,'',''),0,10); $resize_image = $folder.$newname.$random; $actual_image = $folder.$newname; list( $width,$height ) = getimagesize( $uploadimage ); $newwidth = 600; $newheight = 600; $thumb = imagecreatetruecolor( $newwidth, $newheight ); $source = imagecreatefromjpeg($actual_image); imagecopyresized($thum...

javascript - how could I map the divs to a two dimensional array tictactoe game -

i have tic-tac-toe game implement using 2 dimensional array. right i'm using simple array , works fine. think easier implement using 2 dimensional array, take advantage of loops when checking winners , other things. my problem can find way map div clicked index in 2 dim array. example if user clicks on 3rd div of second row on ui, how map 2darray[1][2] (the second subarray index 2)? thanks. hope explained well. interested in looking @ code here's codepen of tic-tac-toe: https://codepen.io/zentech/pen/xlrzgr var xplayer = "x"; var oplayer = "o"; var turn = "x"; var board = new array(9); var message = document.getelementbyid("message"); $(document).ready(function() { $(".square").click(function() { var sqrid = $(this).attr("id"); playermove(sqrid); if (checkwinners()) { message.innerhtml = "message: " + turn + " wins!"; return; } if (chec...

javascript - How to check if the user scrolled to 30% of an element, from the top or the bottom -

as specified in title, i'm listening scroll event in order fire function when 30% of video shows in window - regardless whether user scrolls or down. what have this: // on dom ready, set top , bottom offset of video, // +/- 30% of video height var $video = $('#js-b2b-video'); var videoheight = $video.outerheight(); var videoheight30 = parseint(videoheight/3, 10); // approx. 30% of video height var videoobj = {} videoobj.top = $video.offset().top + videoheight30; // approx. 30% top of video videoobj.bottom = videoobj.top + videoheight - videoheight30; // approx. 30% bottom of video then, scroll event: $(window).on('scroll', function() { if ($(window).scrolltop() >= videoobj.top) { alert('30% top of video reached'); } }); however, fires late, when video visible. need fire function when 30% of top or bottom of video visible. how do properly? fiddle you need take window height account. if ($(window).scrolltop()...