Posts

Showing posts from June, 2011

computer science - What is the benefit of minimizing a finite automata? -

minimizing discrete finite automata standard problem in computer science. benefits of minimizing finite automata? academic problem? the principal reason minimize finite automaton save implementation cost. when finite automata being studied, respect machines implemented function being studied. when inverter or gate or memory component consisted of 1 or more vacuum tubes, http://en.wikipedia.org/wiki/vacuum_tube - devices cost money, consumed power , took considerable space, really, wanted reduce number of tubes , connections between them. even move solid state implementations, real estate concern. if particular finite automaton reused in system, optimizing fa paid big dividends in chip yields.

android - How am I getting a "Cannot draw recycled bitmaps" exception without ever calling recycle in code? -

my imageview defined in activity layout , there's no listview or gridview, there's no automatic view recycling here. whenever activity loads crash "java.lang.illegalargumentexception: cannot draw recycled bitmaps" in logcat. here's style imageview. can see there's nothing special here. thing notable image it's pretty large (full screen size nexus 10). know view culprit since commenting out resolves error. <style name="tabletbackground"> <item name="android:scaletype">centercrop</item> <item name="android:src">@drawable/loading_background</item> <item name="android:contentdescription">background image</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> </style> nowhere in code activity call recycle bitmaps made. idea what's going on he

c# 4.0 - Populate iTextSharp pdf with database values -

i have code below , trying populate pdf values database. pdfpcell points = new pdfpcell(new phrase("and therefore entitled ", arialcertify)); points.colspan = 2; points.border = 0; points.paddingtop = 40f; points.horizontalalignment = 1;//0=left, 1=centre, 2=right // code below needs attention var cid = "alfki"; var xw = customers.first(p => p.customerid ==cid); table.addcell(xw.companyname.tostring()); i can not figure out going wrong. when remove code under 'code below needs attention' works need database values. i using webmatrix itextsharp. if answer need further code please let me know. pdfpcell cell=new pdfpcell(new phrase(xw.companyname.tostring())); cell.setcolspan(numcolumns); table.addcell(cell); document.add(table);

How to generate database LocalDB with NHibernate -

'm having trouble creating test generates database read several articles using instance pipe name. not know how use! project it follows structure of app creditoimobiliariobb.repository.integration.test for testings nhibernate , localdb file app.config <configsections> <section name="hibernate-configuration" type="nhibernate.cfg.configurationsectionhandler, nhibernate" /> </configsections> <appsettings> <add key="fluentassertions.testframework" value="mstest"/> </appsettings> <connectionstrings> <clear/> <add name="datanp" connectionstring="np:\\.\pipe\localdb#53edc7c5\tsql\query" providername="system.data.sqlclient"/> <add name="data" connectionstring="data source=(localdb)\projects;initial catalog=sistema.creditodobrasil.test;integrated security=true;connect timeo

codeigniter form validation for dynamic form input names -

i have codeigniter app. view uses database row id append input name unique id. allows me use inputs in form action, update. my view syntax: <?php if(isset($records)) {?> <table id="hor-minimalist-a"> <tr> <th>&nbsp;</th><th>&nbsp;</th><th>customer name</th><th>postalcode</th> <tr> <?php if(isset($records)) : foreach ($records $row) : ?> <tr> <td> <?php echo anchor('masterdata/confirm_delete_customer/'.$row->id, img(array('src'=>'images/delete_icon.png','border'=>'0','alt'=>'delete'))); ?> </td> <td> <input type=checkbox name="editcustomer[]" id="editcustomer[]" value="<?php echo $row->id ?>"> </td> <td> <input class="inputwide" type=&q

arrays - Odd Java String[] error -

i have line of code: string[] projection = {mediastore.audio.media._id, mediastore.audio.media.artist, mediastore.audio.media.title, mediastore.audio.media.data, mediastore.audio.media.display_name,mediastore.audio.media.duration}; which should work, eclipse giving me error: "syntax error on token ";", , expected" here top half of code: public class main extends activity implements onclicklistener { listview lv; static final int check = 1111; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lv = (listview) findviewbyid(r.id.listview1); button b = (button) findviewbyid(r.id.button1); b.setonclicklistener(this); } cursor cursor; string selection = mediastore.audio.media.is_music + " != 0"; string[] projection = {mediastore.audio.media._id, mediastore.audio.media.artist, medi

objective c - How can I color a particular part of a view, as if you were using the fill tool gimp or paint? -

how can color particular part of view, if using fill tool gimp or paint? let me explain. if have color square divided in half black line, how select part e 'delimited blacks edges? know how catch , paint part, if want paint portion enclosed edges of different color? it's called floodfill, , standard osx , ios apis dont have it. it's not unless writing graphics editor yourself. ordinary filled graphics created using example nspath define edges of shape, giving fill color potentially stroke (line) color. if writing graphics editor, or have unusual case need floodfill, there people who've written them cocoa already. google "cocoa floodfill". won't link 1 here haven't tried them, , anyway best might vary depending on you're trying do.

endianness - c++ missing endianconvert method -

i have partial source code i'm trying reconstruct (don't ask rest is, not available) , i'm stuck @ missing method 'endianconvert' i don't have experience c++ i'm hoping here can me out. heres function call endianconvert (reinterpret_cast<dword *>(pdata+dwclassoffset), sizeof (pagetable) >> 2); pdata byte array filled contents of file byte * pdata = new byte[l]; dwclassoffset current location in file dword dwclassoffset = 0; and pagetable class containing several dword variables. it looks need swap endianess of several dwords in byte array don't know how start implementing this, appreciated. the >> 2 expression divides size of object in bytes 4, gives number of 4-byte words convert, start function something many times: void endianconvert(dword* data, size_t count) { (size_t n = 0; n < count; ++n) /* convert data[n] */; } now need able swap endianness of single dword, quite simple: dword&

java - Long overflows : Fibonacci series -

i'm trying solve second euler problem (calculate sum of fibonacci numbers < 4 million) , far i've come this: public class cctrial1 { public static void fib(){ long = 0, b = 1; long c = 0, sum = 0; int = 1; long = 0; while(i < 400000){ c = + b; sum = c; = b; b = c; if(sum %2 == 0){ += sum; } i++; } system.out.println("count " +i); system.out.println("last fib no " +sum); system.out.println("sum " +even); } public static void main (string[] args){ fib(); } } i have changed long , still overflow. can please tell me i'm going wrong? the problem involves fibonacci terms less 4 million, not first 4 million fibonacci terms. for example, 35th, 36th , 37th fibonacci numbers 5702887, 9227465 , 14930352; problem statement excludes them consideration, because greater 4000000.

packaging and deploying a java application with java DB in netbeans -

i have developed java application not java desktop application java db interact it, in netbeans. want package , deploy distribution. guess java db must in embedded mode in order communicate application. how do this? maybe this article can you. check if using latest version of sql connector, connector/j 5.1.25 latest.

css position - CSS drop down menu positioning in IE7 -

i have css drop down menu works fine in firefox , chrome. sub menus line directly underneath parents. however, in ie7, positioned off side. css: /* menu level 1 */ #nav-img { padding-top: 4px; } #main-nav { height: 30px; /* set height want menu */ margin: 0 0 10px; /* give spacing */ width: 600px; display: inline-block; font-family: tahoma, geneva, sans-serif; font-size: 10pt; text-transform: uppercase; } #main-nav ul { margin: 0; padding: 0; /* needed if have not done css reset */ } #main-nav li { display: block; border: 1px solid #000; float: left; line-height: 30px; /* should same #main-nav height */ height: 30px; /* should same #main-nav height */ margin: 0; padding: 0; /* needed if don't have reset */ position: relative; /* needed in order position sub menus */ } #main-nav li { display: block; height: 30px; line-height: 30px; padding: 0 15px; } #main-nav .current-menu-item a, #main-nav .current_page_item a, #main-nav a:hover { color: #000; } /* menu level 2

python - invalid literal for int() when spliting value with comma -

i looking answers on this, every error did not mean same problem... driver = webdriver.firefox() driver.get('http://example.com') def repeat(): import wx while 1 == 1: botloc = driver.find_element_by_id('botloc').text botx,boty = map(int,botloc.split(',')) print botloc print botx print boty wx.yield() def checker(): while 1 == 1: if driver.current_url == 'http://logged.example.com/': repeat() checker() so after when login myself, div value should automatically printed in shell comming: valueerror: invalid literal int() base 10: '' that div split makes crash, typing manually in shell repeat() printing infinite loop correctly time: >>> repeat() 27,86 27 86 27,85 27 85 ... if remove botx,boty = map(int,botloc.split(',')) ok, need split div using comma, because want x , y. how can fix bug simplest way? edit: website still load

jquery - delay the hover function until after the animation has ceased? -

edit: realize color change happens if user has hovered on text during delay time. how can delay hover function until after animation has ceased? i not javascript coder, im having trouble figuring out missing here. have 2 divs - sidebar , biotext , behaviour client wants: both fadein onload, sidebar after bio. after 40 seconds, bio fades 20%, sidebar fades in 80%. then after bio fades in on hover. right now, of working except after 40 seconds, bio text flashes dark again 1 second light. im sure simple. thoughts? divs not nested @ all. using jquery/1.9.1/jquery.min.js http://www.halamufleh.com/about thanks! $(document).ready(function () { // fade in content. $('#biotext').fadein(2000).delay(40000).fadeto(5000, 0.20); $('#sidebar').fadeto(4000, .6).delay(40000).fadeto(2000, .8); $("#biotext").hover(function () { $("#biotext").fadeto(1000, 1.0); // sets opacity 100% on hover }, function () { $("

python - concatenate several file remove header lines -

what'd way concatenate several files, removing header lines (number of header lines not known in advance), , keeping first file header line header in new concatenated file? i'd in python, awk or other languages work long can use subprocess call unix command. note: header lines start #. something using python: files = ["file1","file2","file3"] open("output_file","w") outfile: open(files[0]) f1: line in f1: #keep header file1 outfile.write(line) x in files[1:]: open(x) f1: line in f1: if not line.startswith("#"): outfile.write(line) you can use fileinput module here: this module implements helper class , functions write loop on standard input or list of files. import fileinput header_over = false open("out_file","w") outfile: line in fileinput.input(): if line.start

c# - Exception while loading xml document -

i'm developing windows phone application. while accessing bing maps, exception occurred while loading xml document "xmlexception - name cannot begin '.' character" @ line xdocument result = xdocument.load(r); please. this code private void locationtoaddress() { string url = "http://dev.virtualearth.net/rest/v1/locations/" + latitude + "," + longitude + "?o=xml&key=" + bingkey; webclient wc = new webclient(); wc.downloadstringasync(new uri(url)); wc.downloadstringcompleted += wc_downloadstringcompleted; } void wc_downloadstringcompleted(object sender, downloadstringcompletedeventargs e) { string s = e.result; xmlreader r = xmlreader.create(new memorystream(unicodeencoding.unicode.getbytes(s))); xdocument result = xdocument.load(r); var abc= result.root.getdefaultnamespace(); var address1 = query in result.descendants(abc + "locati

google app engine - Unable to get saved entity using objectify -

i unable saved entity reliably using objectify. it looks cache getting corrupted. strange thing - can see saved entity correctly though admin console datastore viewer. wrote small program view entity using remoteapi , can see saved value correctly. when query entity successively using servlet or cloud endpoint rest api - successive queries giving different results, , looks in datastore/cache getting corrupted. my entity looks this. class contententity { @id long id; string html; @index string tag; boolean publish; } i save this. contententity entity = ofy().load.type(contententity.class) .filter("tag", "my tag").first().get(); if (null == entity) entity = new contententity(); entity.html = "my html"; entity.tag = "my tag"; entity.publish = true; ofy().save.entity(entity).now(); i retreive this. contententity entity = ofy().load().type(contententity.class). filter("tag", "my tag&quo

java - Get year format from a given Date format -

i have localized date format. want retrieve year format in java. so if given mmddyyyy extract yyyy. if given mmddyy, extract yy. i cannot find way info using simpledateformat, date, calendar etc. classes. it's important note concept of "year format" applies simpledateformat . (in default jdk, anyway.) more specifically, simpledateformat dateformat implementation provided jdk uses concept of "format string" can pull out year format from; other implementations use more opaque mappings date string . reason, you're asking well-defined on simpledateformat class (again, among dateformat implementations available in stock jdk). if you're working simpledateformat , though, can pull year format out regular expressions: simpledateformat df=(something); final pattern year_pattern=pattern.compile("^(?:[^y']+|'(?:[^']|'')*')*(y+)"); matcher m=year_pattern.matcher(df.topattern()); string yearformat=m.find() ?

javascript - Alter array using $.grep() -

currently, use $.grep filter , remove elements array pass. believe $.grep intended used filtering only, since it's iterating on entire array, figured might alter array inside well. do have other approaches can suggest? had thought $.map , afaik should used translating elements, , not removing them. is separate $.each alternative? the relevant part of code: $.each(filter, function (k, v) { if (v.codekeys) { $.each(v.codekeys, function (i, codekey) { rows = $.grep(rows, function (v2, i2) { if ($.isarray(v2[v.dbcolumn]) && $.inarray(codekey, v2[v.dbcolumn]) === -1) { var index = $.inarray(codekey ,v2[v.dbcolumn]); if (v2[v.dbcolumn][index]) v2[v.dbcolumn].remove(index); return true; } else { return v2[v.dbcolumn] !== codekey; } });

Scala: Abstract types vs generics -

i reading a tour of scala: abstract types . when better use abstract types? for example, abstract class buffer { type t val element: t } rather generics, example, abstract class buffer[t] { val element: t } you have point of view on issue here: the purpose of scala's type system conversation martin odersky, part iii bill venners , frank sommers (may 18, 2009) update (october2009): follows below has been illustrated in new article bill venners: abstract type members versus generic type parameters in scala (see summary @ end) (here relevant extract of first interview, may 2009, emphasis mine) general principle there have been 2 notions of abstraction: parameterization , abstract members. in java have both, depends on abstracting over. in java have abstract methods, can't pass method parameter. don't have abstract fields, can pass value parameter. , don't have abstract type members, can specify type parameter. in java

MySQL order by with count and group by issues -

my tables like: # table user user_id pk ... # table buy buy_id pk user_id fk ... # table offert offert_id user_id ... well need know last 'buy' of 1 'user' , count of 'offert' 'user' has, tried like: select b.buy_id,count(distinct c.offert_id) cv user inner join buy b using(user_id) left join offert c using(user_id) a.user_id=4 group a.user_id order b.buy_id desc but returns first 'buy' not last, order doesn't make effect i know can sub queries know if there way whout use sub queries, maybe using max functions idk how it. thanks. your approach not guaranteed work. 1 big reason group by processed before order by . assuming mean biggest buy_id each user, can as: select u.user_id, u.last_buy_id, count(distinct o.offert_id) (select u.*, (select buy_id buy b u.user_id = u.user_id order buy_id desc limit 1 ) last_buy_id user u ) left outer join offert o on o.user_id

windows - Get name Drive Hardware -

hello me how name of drive / hardware / / 'c: \' 'd: \' ....... example namedrive function (const sdrive: string): string; begin   result: = getdrivename (sdrive); end; showmessage (namedrive ('c: \')) / / = st500dm0 .... thank attention. it's possible vendor info calling deviceiocontrol ioctl_storage_query_property code (storage_property_query propertyid set storagedeviceproperty), or smart_ control codes, or reading wmi data. in case should work physical drives having names \.\physicaldrivex rather logical ones. these 3 alternatives can see @ once. example of method 1 (type definitions taken ddk): type storage_property_id = ( storagedeviceproperty, storageadapterproperty, storagedeviceidproperty, storagedeviceuniqueidproperty, // see storduid.h details storagedevicewritecacheproperty,

java - Creating a Windows installer for application -

this question has answer here: create windows installer java programs 8 answers i want create windows installer package can .exe or msi. want following : check if java 7 runtime available in system & system has enough space installation if jre not available install same installer package once jre installation completes unzip contents of installer specific location in system (c:\tools). create shortcut on desktop. exit installer . any issues alert user this first time thinking how can accomplished ? you can achieve nsis here post explaining process in more detail: nsis script java installation in case project can use ant, maybe antinstaller might right choice.

angularjs - using mongolab with angular for update(put) but record is not getting updated correctly -

i have following angular code below. i'm noticing when call ng-click="update($index, list.name)" update name field, creating new key/value pair in json list id not necessary. other fields such type, cdn etc. getting wiped out. want update name field. thanks! var tools = angular.module("tools", ['ngresource']) tools.config(function($routeprovider) { $routeprovider.when('/home', { templateurl: 'home.html', controller: 'homecontroller' }); $routeprovider.when('/about', { templateurl: 'about.html', controller: 'aboutcontroller' }); $routeprovider.otherwise({ redirectto: '/home' }) }); tools.con

c# - Images don't show up after VS 2012 Publish -

i have created asp.net web project. have included files in project. following css standards required. background-image: url('~/images/sideheader.png') i can see pictures when debug site. when publish site, don't see picture in site. please me resolve problem. you should use : background-image: url('/images/sideheader.png') in way relative paths resolves correct place .

c++ - What does the double colon stand for in the Qt documentation? -

i'm newbie on qt, , in documentation, don't understand syntax prototype shown below: here syntax prototype of function addtab() qtabwidget class . int qtabwidget::addtab(qwidget * page, const qstring & label) i don't understand why two colons after qtabwidget. think said addtab() comes qtabwidget class, if want use function, have include qtabwidget (or class wrap whole , include @ same time qtabwidget). right ? but write syntax qtabwidget::addtab(.....) in practical/in code or notation documentation signify class comes from? i don't understand why 2 colons after qtabwidget. think said addtab() comes qtabwidget class, if want use function, have include qtabwidget (or class wrap whole , include @ same time qtabwidget). right ? have ever programmed in c++? it's scope resolution operator . means addtab name found in qtabwidget scope; documentation borrows how you're going define method (curious? have look ). the scope resolution

java - Cancel anonymous SwingWorker -

i have run weird dependency when trying cancel anonymous swingworker. current code: private static void init() { if (connected) { return; } //final swingworker<void, void> initworker; final timer noconnectiontimer = new timer(5000, new actionlistener() { @override public void actionperformed(actionevent e) { //initworker.cancel(true); waitobject.settimedout(true); connected = false; waitobject.process(); } }); new swingworker<void, void>() { @override public void doinbackground() { noconnectiontimer.setrepeats(false); noconnectiontimer.start(); cachedinstance = new network(config.host_name, config.host_port); if (connected) { noconnectiontimer.stop(); new thread(cachedinstance).start(); waitobject.settimedout(false); waitobject.process();

ipad - Manual segue not transitioning properly -

i new ios i've been able muddle though... until now. have application login page. first thing did create few empty view controllers , stuck them on storyboard. have loginviewcontroller text fields userid , password plus login button. plan if log in brought tabviewcontroller. right out of box. deleted 2 view controllers got created , replaced them 2 navigationcontrollers. just test made segue login button tabviewcontroller. worked fine. views came up. out of box stuff worked. next step tried simulate actual login. since have through web service call figured needed asynchronous. deleted initial segue added login button , added ibaction button loginviewcontroller. added manual segue loginviewcontroller tabviewcontroller , named "loginsegue" here code have far: - (ibaction)login:(id)sender { [decorator showviewbusyin:self.aview scale:1.5 makewhite:no]; self.clientidtext.enabled = no; self.useridtext.enabled = no; self.passwordtext.enabled = no

deployment - How to deploy a Glassfish application on CloudBees -

i'm trying deploy web application running on glassfish on cloudbees . unfortunately didn't find documentation or tutorial. i'll thankful if can explain me best way this. i'm lost... thank you! (ps: i'm working on netbeans ) to deploy, need right-click on project in netbeans project list , click "deploy". need ensure properties project pointing correct deployment location , directory.

android - Error by starting FragmentActivity -

i want change project activity fragmentactivity. first step create fragment: public class frag1 extends fragment { public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater .inflate(r.layout.detail_fragment, container, false); return view; } } the detail_fragment simple linearlayout textview the second step (after splashscreen) make parent class fragmentactivity: public class testfrag extends fragmentactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.frag_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_main, menu); return true; } } the r.layout.frag_main: <fragment xmlns:android="http://sch

java class and static method -

i have question regarding how use variables have used in method method , how set limit on user can input, example, 1 of java homework assignments need write program takes 3 6 names , need create new static method called geneatenewname() , has use 3 6 names display names take each of names' second letter , produce new name, how can this, thank you. also, here code have far: public class testing{ public static void main(string args[]){ console c = system.console(); string str1; string str2; string str3; string str4; string str5; string str6; str1 = c.readline("please enter family member's name: "); str2 = c.readline("please enter family member's name: "); str3 = c.readline("please enter family member's name: "); str4 = c.readline("please enter family member's name: "); str5 = c.readline("please enter family member's

Android: http login request being redirected in php? -

so follow this post . attempting log in using code in post linked. works, believe there going on in login.php file i'm unaware of. here of login.php file, apologize in advance wall of code. <?php session_start(); error_reporting(e_all^ e_notice); //include connection , variable defination page include("include/server.php"); include("include/function.php"); //checking form has been submit user or not if(isset($_post['cmdsubmit']) , $_post['cmdsubmit']="login") { //$reflink = $_server['http_referer']; $reflink = "index.php?err_msg=1"; $user = addslashes($_post['username']); $pass = addslashes($_post['password']); $remember = $_post['remember']; $strerrormessage = ""; if($user==""){ $strerrormessage = "user name can not blank"; } if($pass==""){ $strerrormessage = "password can not blank"; } if($user=="" , $pass==&q

google maps - GoogleMaps API V3 Polygon dblclick auto-complete -

i have created plotting system using googlemaps javascript api v3, allows users draw out , save polygons. i have received number of complaints concerning autocompletion of plots result of accidentally doubleclicking while manually drawing out points using polygon drawing tool. therefore looking disable dblclick auto-complete function, plots complete once user clicks on first point again. i have tried unbinding dblclick event map, , attempted stop propagation of dblclick event throwing error on double click, below (just test event call). google.maps.event.addlistener(map, 'dblclick', function(){ throw("stop"); }); this succeeds in stopping zoom function on doubleclick, autocomplete still occurs when dblclicking while plotting points (this listener not triggered). have tried stopping propagation of doubleclick event on whole page, no avail. can suggest either way of unbinding dblclick event, or alternative solution prevent dblclick autocomplete? i hav

r - Write csv or table variables to file -

lets have file this: a b c d 2 3 4 5 9 8 7 4 5 7 8 4 i export column a , c nothing else. can version of write.csv or write.table e.g. write.csv(myobject$a && myobject$b, file="outfile.csv") this should work write.csv(myobject[,c("a","b")], file="outfile.csv",row.names=false) the brackets in myobject[rows,cols] select rows , columns of data frame or matrix. if rows argument left empty, rows returned; , "cols". vector can used select multiple rows or columns. in case, we're selecting rows (because part blank) , columns "a" , "b". the row.names=false option prevents rownames being printed. in cases, might want keep them, of course.

URL reversing not working in django when using arguments -

i'm stuck one. i have following in urlpatterns: url(r'^user/$', userview.as_view(), name='farmauth-user'), url(r'^user/(?p<id>\d+)/confirm/(?p<token>\w+)/$', userconfirmationview.as_view(), name='farmauth-confirm'), i have other urls too. in html get reverse 'farmauth-confirm' arguments '([u'28'], [u'n48dssasbkhabwxzz6xv'])' , keyword arguments '{}' not found. when this: {% url 'farmauth-confirm' id token %} i tried using positional arguments. in case wondering, urls visible i'm attempting because works: {% url 'farmauth-user' %} i tried other urls , without arguments. never works when using arguments. doing wrong?? please advise. just try order: url(r'^user/(?p\d+)/confirm/(?p\w+)/$', userconfirmationview.as_view(), name='farmauth-confirm'), url(r'^user/$', userview.as_view(), name='farmauth-user'),

javascript - referring script stuck in a loop -

what trying redirect user based on referring url promo page. in script below if comes referring url “mydomainsite.com” sent “mydomainsite.com/promo.html” when have script below in page “mydomainsite.com/promo.html” , comes refer of “mydomainsite.com” seems loop or continue load page , never loads page “mydomainsite.com/promo.html” script has in “mydomainsite.com/promo.html,” page being promo page , can’t have access page. assume due indexof , checks “mydomainsite.com” executes. there away fix this? <script language="javascript"> if (document.referrer.indexof('mydomainsite.com') > -1) location.href='http://mydomainsite.com/promo.html'; else location.href='http://notfrommydomainsite.com'; </script> as has been mentioned in comments referrer data not reliable, if want pursue this... the mqost cause of issue have when arriving @ redirected promo.html finds referrer mydomainsite.com goes creating infinite loop. you need

java - How to safely convert from a Collection of generic types to an array? -

this question has answer here: how create generic array in java? 27 answers array of generic list 5 answers for various reasons want convert list array, collection contains objects generics. i have tried following 4 options compile without needing @supresswarnings('unchecked') annotation, none of them work. there solution make work correctly, or forced use annotation? iterator<t>[] iterators; final collection<iterator<t>> inititerators = new arraylist<iterator<t>>(); // type safety: unchecked cast iterator[] iterator<t>[] iterators = inititerators.<iterator<t>>toarray( (iterator<t>[])new iterator[inititerators.size()]); // type safety: unchecked invocation toarray(iterator[]) of generic // method toar