Posts

Showing posts from June, 2012

sql server - Building where clause based on null/not null parameters in sql -

i trying create stored procedure return records based on input. if input parameters null, return entire table, else use parameters , return records: create procedure getrecords @parm1 varchar(10) = null, @parm2 varchar(10) = null, @parm3 varchar(10) = null declare @whereclause varchar(500) set @whereclause = ' 1 = 1 ' if (@parm1 null , @parm2 null , @parm3 null) select * dummytable else begin if (@parm1 not null) set @whereclause += 'and parm1 = ' + '' + @parm1 + '' if (@parm2 not null) set @whereclause += 'and parm2 = ' + '' + @parm2 + '' if (@parm3 not null) set @whereclause += 'and parm3 = ' + '' + @parm3 + '' select * dummytable @whereclause <-- error end error while creating procedure "an expression of non-boolean type specified in context condition" please comment if approach wrong in building clause? tha

php - magento getpath() extract value -

i request information of how extract particular value in getpath() function. currently placed following information: <?php $currentcat = mage::registry('current_category'); ?> <?php echo $currentcat->getpath()?> and system echo 1/2/5 , 1 root of root, 2 catalog root , 5 first simple category. i extract third value (number 5 in example) in serie of categories echo info in page tried different appraches no success. thank you. explode() , end() <?php echo end(explode("/", $currentcat->getpath())); ?> do know if can place value retrieve 3 level no matter if im placed in subcategory should looks this: <?php $exp = explode("/", $currentcat->getpath()); echo $exp[2]; ?> i recommend take @ explode() again :)

c# - Update Application via WCF -

i've application reads online database current version of application itself, when make changes application use create new msi setup , put on server, change version inside database , when application starts notices there newer version , asks user update. during update downloads msi file , launchs after download: problem.. when user tries install new version popup message appears saying version of software installed in , can't overwrite it! ideas? have looked using clickonce deployment? http://msdn.microsoft.com/en-us/library/t71a733d.aspx

postgresql - Is there a logically equivalent and efficient version of this query without using a CTE? -

i have query on postgresql 9.2 system takes 20s in it's normal form takes ~120ms when using cte. i simplified both queries brevity. here normal form (takes 20s): select * tablea (columna = 1 or columnb = 2) , atype = 35 , aid in (1, 2, 3) order modified_at desc limit 25; here explain query: http://explain.depesz.com/s/2v8 the cte form (about 120ms): with raw ( select * tablea (columna = 1 or columnb = 2) , atype = 35 , aid in (1, 2, 3) ) select * raw order modified_at desc limit 25; here explain cte: http://explain.depesz.com/s/uxy simply moving order by outer part of query reduces cost 99%. i have 2 questions: 1) there way construct first query without using cte in such way logically equivalent more performant , 2) difference in performance how planner determining how fetch data? regarding questions above, there additional statistics or other planner hints improve performance of first query? edit: taking away limit c

java - replicatorg eclipse building -

i need change parts in ui of replicatorg opensource project 3d printers (see http://replicat.org ). downloaded source codes github , opened new project on eclipse using build.xml in replicatorg. when try run on eclipse have message on console: java.lang.unsatisfiedlinkerror: no rxtxserial in java.library.path thrown while loading gnu.io.rxtxcommdriver exception in thread awt-eventqueue-0 java.lang.unsatisfiedlinkerror: no rxtxserial in java.library.path . looked on net seems related rxtx not figure out. can me? thank much...

android - Custom converter of Simple XML is not serializing from xml to java object -

i have simple xml annotated class want use serialization/deserialization. have byte[] array using custom converter fails @ read method.. here simple xml annotated object @root public class device implements serializable { @element @convert(bytearrayconverter.class) protected byte[] imageref; ... } here converter import org.simpleframework.xml.convert.converter; import org.simpleframework.xml.stream.inputnode; import org.simpleframework.xml.stream.outputnode; public class bytearrayconverter implements converter<byte[]> { @override public byte[] read(inputnode node) throws exception { string value = node.getvalue(); //return value.getbytes(); return new byte[]{1,2,3,4,5}; } @override public void write(outputnode node, byte[] bytearray) throws exception { node.setvalue("something"); } } here xml called device.xml <device> <imageref>a

python - Read a single byte from large file -

i have function want read single byte large file. problem after amount of file reads memory on pc jumps steady 1.5gb 4gb , higher depending on how many file reads. (i break @ 80 files because higher crash pc) all want 1 byte , not whole file. please. def mem_test(): count = 0 dirpath, dnames, fnames in scandir.walk(restorepaths[0]): f in fnames: if 'dir.edb' in f or 'priv.edb' in f: f = open(os.path.join(dirpath, f), 'rb') f.read(1) #problem line! f.close() if count > 80: print 'exit' sys.exit(1) count += 1 mem_test() to address memory issue, think you'd want use generator: def mem_test(): dirpath, dnames, fnames in scandir.walk(restorepaths[0]): f in fnames: if 'dir.edb' in f or '

sql - understanding group by statements in rails -

given invoices table this: invoice_date customer total 2012/01/01 780 2013/05/01 3800 2013/12/01 1500 2012/07/01 b 15 2013/03/01 b 21 say want both: the count of invoices of each customer of each year the sum of amounts of invoices of each customer of each year the max amount among invoices of each customer of each year that is, in sql, easily: select customer, year(invoice_date) invoice_year, max(total) max_total, sum(total) sum_amounts, count(*) invoices_num sum_total invoices group year(invoice_date), customer; (the function extract year of date may year(date) or else depending on database server, on sqllite strftime('%y', invoice_date)) ok, i've tryed translate in rails/activerecord: invoice.count(:group => 'customer') this works, how can both count , sum , max? the idea i'm familiar (in sql) group by

jquery mobile - Duplicate Ids on jquerymobile ajax page -

Image
when navigation around pages ajax (jquerymobile), see dom (page) duplicate the old page (/question/index/11?type=all) , new page(/question/index/4?type=all) have same structure , same ids, ids in div(data-role=page) duplicated -> events going wrong. there option ajax loading page in jquerymobile can remove dom in old page?

ruby on rails 3 - add a delay to the focusout jquery -

how can delay $('#header_user_list').html(''); line executing second? application.js: $(function() { $("#user_header_search_form input").focusout(function() { $('#header_user_list').html(''); }); }); just use 1 second timeout $(function() { $("#user_header_search_form input").focusout(function() { settimeout(function(){$('#header_user_list').html('');},1000); }); });

javascript - Uncaught TypeError: Object [object Object] has no method 'editable' -

i working try implement jquery datatables jeditable plugin @ http://www.appelsiini.net/projects/jeditable . have: <script language="javascript" type="text/javascript"> $(document).ready(function() { /* init datatables */ var otable = $('#mydatatable').datatable(); /* apply jeditable handlers table */ $('td', otable.fngetnodes()).editable( 'js/datatables/examples/examples_support/editable_ajax.php', { # line 25 "callback": function( svalue, y ) { var apos = otable.fngetposition( ); otable.fnupdate( svalue, apos[0], apos[1] ); }, "submitdata": function ( value, settings ) { return { "row_id": this.parentnode.getattribute('id'), "column": otable.fngetposition( )[2] }; }, "height": "14px" } ); } ); </script&

Run process with gdb and detach it -

is possible run process gdb , modify memory , detach process afterwards? i can't start process outside of gdb need modify memory, before first instruction executed. when detach process started gdb , gdb hang, killing gdb process makes debugged process still running. i use following script launch process: echo '# custom gdb function finds entry_point assigns $entry_point_address entry_point b *$entry_point_address run set *((char *)0x100004147) = 0xeb set *((char *)0x100004148) = 0xe2 detach # gdb hangs here quit # quit never gets executed ' | gdb -quiet "$file" this happens in both of gdb versions: gnu gdb 6.3.50-20050815 (apple version gdb-1824) gnu gdb 6.3.50-20050815 (apple version gdb-1822 + reverse.put.as patches v0.4) i'm pretty sure can't detach inferior processes started directly under gdb , however, following might work you, based on recent gdb , don't know how of work on version 6.3. create small shell script,

Spring MVC: Pass Object between Controllers Given URL -

i have controller passes list of song objects view. this list outputted list of urls object's id property in url: e.g. http: //.../song/23 obtained by: <a href="song/${song.id}"> <c:out value="${song.songname}"/> </a> further details: the question correct way forward correct song object song controller responsible in generating ...song/23 url ? example: looping through 4 song objects should produce view 4 links. link1 link2 link3 link4 each link corresponds song object , clicking on each link should forward unique url. e.g.: if song1's id 42 clicking on link1 should forward http: //../song/42 , pass song object corresponding link1 song controller. i hope understood question enough, in spring mvc (annotation based), can this: @requestmapping(value="/song/{songid}/", method=requestmethod.get) public string showsong(@pathvariable int songid) { // } now can retrieve song object id (i suppo

loopings GIFs with animation package in R -

Image
i'm trying create gif loops animation package in r. reason, if set option loop=true , images make play once , stop. gif keep playing indefinitely. tips? install.packages("animation") library(animation) savegif({ (i in 1:10) plot(runif(10), ylim = 0:1) },loop=true,interval=0.2) the following works me. loop=true default setting. sure problem not in gif viewer? library(animation) ani.options( convert = shquote('c:/program files (x86)/imagemagick-6.8.1-q16/convert.exe') ) savegif( { (i in 1:10) plot(runif(10), ylim = 0:1) }, movie.name = "test.gif", interval = 0.2, ani.width = 300, ani.height = 300, outdir = getwd() ) p.s. i'm guessing code works without addition of pointer convert.exe program since able produce .gif.

java - Objects not staying in ArrayList -

i writing program supposed allow user enter course school. however, couple problems. first, can't reason take more 1 word coursetitle. if 2 words entered, throws error. second, it's not "permanently" adding these classes arraylist? here's how it's supposed work: please select following options: add course add student course view available courses exit system this isn't being stored file, i'm not sure how keep courses in memory. anyway, here's i've got. if(userchoice==1) { system.out.println("enter course number: "); int coursenum=scan.nextint(); system.out.println("enter course title: "); string coursetitle=scan.next(); system.out.println("enter max number allowed students: "); int coursemaxsize = scan.nextint(); system.out.println("course number "+coursenum); system.out.println("course t

sockets - How DataOutput.writeByte()/DataInput.readByte() or other equivalent works in Java? -

byte[] message = ... socket socket = ... dataoutputstream dout = new dataoutputstream(socket.getoutputstream()); dout.write(message); //#1 ... //other code let assume machine 1 (with code above) trying send somethings machine 2 trying read byte machine 1. according tcp, can codes after line #1 not execute if machine 2 has not yet read data sent above? but @ point, can machine 2 read data , codes after line #1 execute? happens @ operating system level or application level? example, machine 2 os buffer message machine 1 right after machine 1 execute writebyte command/statement, machine 2 signal machine 1 proceed line #1? or machine 2 signal machine 1 proceed if java application execute readbyte command/statement @ application level? if whole receiving process happens @ os level, how can control buffer size used cache incoming data (in machine 2)? tcp has local buffers. java not handle comms, handled os. java accesses local buffers, reads empty bytes out of

angularjs - Using ng-click to call two different functions -

is there way can ng-click call 2 functions? i along lines of ng-click ="{search(),match()}" instead of how have now, is: ng-click = "search()" you can call multiple functions ';' ng-click="search(); match()"

python - Huge JSON lists without eating all the memory -

i have queue endpoint (celery) consumes batch of messages before working on them, writes them a temporary file process(spark clustering) consume. huge list of dicts, encoded in json. [{'id':1,'content'=...},{'id':2,'content'=...},{'id':3,'content'=...}.....] but keep messages in memory, json.dumps generates big string in memory. can better storing in memory? can dump messages file arrive, not consume memory? write own json encoder efficient json encoding. or use json.dump passing in file pointer object. also, don't read whole json file memory when consuming data. use json.load instead of json.loads , , use standard python iterator interface

.net - What is the Difference Between `new object()` and `new {}` in C#? -

first of searched on , found following links on stack overflow: is there difference between `new object()` , `new {}` in c#? difference between object = new dog() vs dog = new dog() but i'm not satisfied answer, it's not explained (i didn't well). basically, want know difference between new object() , new {} . how, treated @ compile time , runtime? secondaly, have following code have used webmethods in asp.net simple application [webmethod] [scriptmethod(usehttpget = false)] public static object savemenus(menumanager proparams) { object data = new { }; // here im creating instance of 'object' , have typed `new {}` not `new object(){}`. try { menumanager menu = new menumanager(); menu.name = proparams.name; menu.icon = proparams.icon; bool status = menu.menusave(menu); if (status) { // however, here i'm returning anonymous type data = new {

string - C++ memcpy to char* from c_str -

i've done bit of basic reading , i've gathered .c_str() has null terminator. i have simple c++ program: int main(int argc, char** argv) { std::string = "hello"; char to[20]; memcpy(to, from.c_str(), strlen(from.c_str())+1); std::cout<< << std::endl; return 0; } will memcpy ensure copy on null-terminated string variable (provided string shorter in length)? memcpy doesn't know string. give range copy. depends on strlen here provide termination point of range

c# - Linq compare 2 lists of arrays -

this question has answer here: compare 2 lists c# linq [duplicate] 4 answers i compare 2 lists of arrays. let's take instance example: snot duplicated don't wish compare regular lists. wish see each record in list1 how many items list2 contain how many common items. list<int[]> list1 = new list<int[]>() { new int[4] { 1, 2, 3, 4 }, new int[4] { 1, 2, 3, 5 } }; list<int[]> list2 = new list<int[]>() { new int[2] { 1, 2 }, new int[2] { 3, 4 }, new int[2] { 3, 5 } }; i know each element in list1 calculate every elemet in list 2 how many common elements have. ex. 1,2,3,4 compared 1,2 result 2 matching elements. 1,2,3,4 compared 3,5 result 1 matching element. any ideea? you'd this: var results = x in list1.select((array, index) => new { array, index }) y in list2.select((array, index) => new { array

php - Symfony2 and Doctrine - @ORM\PostPersist() does not work -

i have file upload function on symfony2 project. used http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html example. the problem @orm\postpersist() not trigered , file not stored in specific folder. here have: 1 entity "manuscript" manage file: /** * @orm\postpersist() * @orm\postupdate() */ public function upload() { if (null === $this->file) { return; } $this->file->move( $this->getuploadrootdir().date('ymdhis').'_'.$this->file->getclientoriginalname() ); } i tryed put var_dump() there var_dump() never actioned, never entering there. in form, have file: public function buildform(formbuilderinterface $builder, array $options) { $builder->add('file', 'file', array('label'=> 'htm file', 'required' => true)); } finally, in controller, have if ($request->ismethod('post')) { $form->bind($request); if (

excel vba - How to use SQL Select Query in VBA code? -

i have 1 query of sql , want put in vba code bring result in excel sheet. i tried code pasted below. sub connect2sqlxpress() dim ors object dim ocon object set ocon = createobject("adodb.connection") set ors = createobject("adodb.recordset") set ocon = new adodb.connection ocon.connectionstring = "provider=sqloledb.1;integrated security=sspi" ocon.open ors.source = "select keyinstn,longname,shortname,shortestname new_inst ......" ors.open range("a1").copyfromrecordset ors ors.close ocon.close if not ors nothing set ors = nothing if not ocon nothing set ocon = nothing can please me in figuring out going wrong ?? to create connection string try this: right-click on desktop (or folder) choose new > textfile right-click on file have created, , change it's name ( and extension ) connectioninfo.udl double-click on file connectioninfo.udl , should open in microsoft data - core services. set provid

html - How do I get non-ascii form data when using enctype multipart/form-data -

i have html form uses post enctype of multipart/form-data. user both able upload file , enter in additional information (in same html form). currently input values come correctly when input fields regular ascii characters. need able handle input in non-ascii format too. how force values of input fields utf-8?

How do i print a pdf document using javascript or jquery in Asp.net -

below code used doesn't print pdf file. <script type="text/javascript"> function callprint() { var pages = 'pdf url'; var owindow = window.open(pages, "print"); owindow.focus(); self.print(); owindow.close(); return false; } </script> you can try following code. since page(which linked callprint function) pdf format(i assume?), browser open built in print feature , able print out pdf doc $(document).ready(function() { function callprint(){ window.print(); }; }); you have bind callprint function click function on button link...eg. <a href="callprint()">print pdf</a>

asp.net - Connecting Android to web service -

this question has answer here: how fix android.os.networkonmainthreadexception? 45 answers i'm making android application supposed connect made localhost web service. things aren't going well. have following code: public void proben() { string soapmsg="<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:envelope xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<soap:body>"+ "<selectvezba xmlns=\"http://tempuri.org/\">"+ "<ime>" + "a" + "</ime>" + "</selectvezba>" + "</soap:body>" + "

algorithm - Ruby - modifying classes -

i wrote simple method checks if number armstrong number . want modify default number class putting method. so, have code: def is_an(number) (number.to_s.split(//).map(&:to_i).inject{|x,y|x+y**(number.size-1)}) == number ? true : false end p is_an(153) i want use method: 153.is_a? so, how this? class number def is_an ??? how use object data on here? ??? end end thx lot reading. incorporating @mikej's answer, plus replacing number self : class fixnum def is_an digits = self.to_s.split(//).map(&:to_i) digits.inject(0) { |x,y| x+y**digits.size } == self end end but suggest name change, make more ruby like. instead of #is_an , isn't descriptive, how #armstrong? can call: 153.armstrong?

Is an empty initializer list valid C code? -

it common use {0} initialize struct or array consider case when first field isn't scalar type. if first field of struct person struct or array, line result in error ( error: missing braces around initializer ). struct person person = {0}; at least gcc allows me use empty initializer list accomplish same thing struct person person = {}; but valid c code? also: line guaranteed give same behavior, i.e. zero-initialized struct ? struct person person; no, empty initializer list not allowed. can shown gcc when compiling -std=c99 -pedantic : a.c:4: warning: iso c forbids empty initializer braces the reason way grammar defined in §6.7.9 of 2011 iso c standard : initializer: assignment-expression { initializer-list } { initializer-list , } initializer-list: designation(opt) initializer initializer-list , designation(opt) initializer according definition, initializer-list must contain @ least 1 initializer.

xslt date format change (dd-mmm-yyyy) -

i using below code show current date in xslt program.it's working fine date format yyyy-mm-dd. need format dd-mmm-yyyy. please me this. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:cs="urn:cs" > <xsl:value-of select="cs:datenow()"></xsl:value-of> you have tagged question xslt 2.0 expect current date current-date function http://www.w3.org/tr/xpath-functions/#func-current-date , format xslt 2.0 function format-date http://www.w3.org/tr/xslt20/#format-date . format-date(current-date(), '[d01]-[mn,*-3]-[y0001]') gives format 11-jul-2013 . depending on needs (i not sure format mmm stands for, date formatting routines define own patterns) need adapt "picture string" argument of format-date , see documentation linked to.

Android Listview item selection in Xamarin using VS 2012 C# -

i'm using vs 2012 working on android app. actually, want achieve this: // lv = listview name. lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> myadapter, view myview, int myitemint, long mylng) { string selectedfromlist =(string) (lv.getitematposition(myitemint)); } }); but, i'm not getting setonitemclicklistener() event. reason is, i'm working in c# using xamarin . want select value or item of listview . how can this? have activity implement listview.ionitemclicklistener this: public class someactivity: activity, listview.ionitemclicklistener get refence listview this: lsitview lv = findviewbyid<listview>(resource.id.id_in_axml); then set onitemclicklistner activity since going implement interface listview.ionitemclicklistener lstitems.onitemclicklistener = this; finally add activity class: public void onitemclick(adapterview parent, view view, int position

html - JQuery show/hide items based on click -

i have page on site show parks within region default. show specific items based on clicked region , hide other parks. so far have 3 regions , id e.g. region-1, region-2 , region-3 show parks within regions if clicked on id of region-1 show parks class of region-1 , hide others, same other regions. my biggest problem getting work client able add more regions in future , more parks new regions. so need jquery pick every region id added in future , pair them relevant parks. <div id="side-bar" class="pull-left"> <h2>parks region</h2> <ul class="nav nav-pills nav-stacked"> <li> <a href="#region-1">south east england</a> </li> <li> <a href="#region-2">south west england</a> </li> <li> <a href="#region-3">north wales</a> </li> </u

Exclude some folders from module declaration suggestions in PhpStorm -

Image
when try click on function in phpstorm crtl button system tries bring me definition of function. there multiple definitions , annoying page shows telling chose definition want go. here: because using grunt , minifing / concatenating results, definitions in multiple places. know should ignore in node_modules , system not. there way me exclude of folders? if don't need completion/navigation/etc. local node_modules, can exclude folder project: right-click , mark directory as/excluded you still able run grunt, files in these folders won't indexed , suggested completion/navigation

asp.net mvc - Kendo UI Grid/Row Template -

i tried put image grid using kendo ui. had problem columns.bound(c => c.productphotoid) , when comment columns.bound(c => c.productphotoid) grid can edit, when uncomment grid cannot edit anymore. have no idea this. @model ienumerable<subcateviewmodel> @(html.kendo().grid(model) .name("grid") .columns(columns => { columns.bound(c => c.productsubcategoryid).width(140); columns.bound(c => c.productcategoryid).width(140); columns.bound(c => c.nameofbike).width(190); columns.bound(c => c.name).width(190); columns.bound(c => c.productphotoid).width(50).clienttemplate("<img alt='<#= pictureurl #>' src'" + url.content("~/getimage.ashx?id=@bike.productproductphotoes.firstordefault().productphotoid") + "#= pictureurl#.jpq'/>").title("picture"); columns.bound(c => c.isselected).width(120); }) could t

angularjs - Can protractor be used for Test Driven Developement? -

can protractor used test driven developement ? want know whether can use protractor tdd. if yes ,please share example. tdd refers unit testing, can achieved using karma . protractor wraps selenium intended functional testing - makes sure views on app working expected. wouldn't use these kind of tests drive development process can't test actual input/output of methods, want doing in tdd workflow.

how to save a file in android, ENOENT IOexception -

how save file in android? have following code: final file file = new file(cont.getexternalfilesdir(null), filename); if (!file.exists()) { file.createnewfile(); } and 03-21 11:31:29.903: w/system.err(31668): java.io.ioexception: open failed: enoent (no such file or directory) 03-21 11:31:29.903: w/system.err(31668): @ java.io.file.createnewfile(file.java:948) exception complete code saving of file following: final file file = new file(context.getexternalfilesdir(null), filename); if (!file.exists()) { // file.mkdirs(); file.createnewfile(); } final outputstream output = new fileoutputstream(file); try { try { final byte[] buffer = new byte[1024]; int read; while ((read = input.read(buffer)) != -1) output.write(buffer, 0, read);

mysql - c# entity framework throw exception but no roll back on database -

i have simple query updates 2 tables in database public void updatelogins(int userid) { using (var context = new storemanagerentities()) { user item = context.users.where(x => x.id == userid).firstofdefault(); item.logins += 1; context.savechanges(); account accountitem = context.accounts.where(x => x.userid == userid).firstofdefault(); accountitem.logins += 1; context.savechanges(); } } but if "throw new exception();" between them so context.savechanges(); throw new exception(); account accountitem = context.accounts.where(x => x.userid == userid).firstofdefault(); the user table not updated account table has not been updated, , database saves these changes. how can tell database rollback changes if exception thrown? thanks try : using (transactionscope txscope = new transactionscope()) { using (var context = new storemanagerentities()) {

android - Why does my app crash on calling a Service from a Broadcast Receiver on a Button click? -

i have developed app in service keeps running in background. service started broadcast receiver after every 3 minutes. broadcast receiver initiated button click. problem getting following errors when click button start broadcast receiver. can tell me going wrong? my broadcast receiver follows: public class k extends broadcastreceiver{ public static alarmmanager am; @suppresslint("newapi") @override public void onreceive(context context, intent arg1) { // todo auto-generated method stub intent broadcast = new intent(context, k.class); pendingintent pendingintent = pendingintent.getbroadcast(context, 0, broadcast, 0); alarmmanager alarmmanager = (alarmmanager) context.getsystemservice(context.alarm_service); alarmmanager.setrepeating(alarmmanager.rtc_wakeup,system.currenttimemillis()+1000, 300000, pendingintent); intent = new intent(context,ser.class); context.getapplicationcontext().startservice(i); } } and servi

java - Check if a collection contains an object, comparing by reference -

the collection.contains() method check if collection contains given object, using .equals() method perform comparison. from java7 javadoc: boolean contains(object o) returns true if collection contains specified element. more formally, returns true if , if collection contains @ least 1 element e such (o==null ? e==null : o.equals(e)). is there smart way check if collection contains object o , comparing reference instead (i.e. o==e )? of course can iterate through collection , make check, i'm looking existing function can that. clarifications: i want perform operation regardless equals() implementation of object in collection. i don't want change objects in collection nor collection itself. edit: even though question general solution collection implementations, specific cases collection sub-interfaces appreciated. for of using java 8, collection#stream() clean option: collection.stream().anymatch(x -> x == key)

mysql - Comparing substrings in Google BigQuery -

Image
i want query 2 table depending on condition , want generate tag can see in image yes/maybe for displaying above result using if(places.name contains poi.name 'yes','maybe') problem : in image on line no. 4 poi_name contain value surana.agen , respective column places_type have value [w1]surana.agency , hence want tag yes instead of maybe . poi_name column can have special character here dot(.) want split columns values whichever special character present , in case want search surana or agen present in places_name . any appreciable at high level, i'd suggest thinking problem follows: step 1: split poi_name substrings want match. step 2: check whether of substrings contained in places_name. for step 1, it's hard pull apart arbitrary number of substrings in sql. however, if have limit in mind (e.g., @ 3 substrings), pull them out using regexp_extract. example: regexp_extract(poi_name, r'([^.]*)') first, regexp_extract

Cannot login to wordpress admin once i change the admin url -

i have installed wordpress website, , working security measures wordpress admin not loading. gets redirected page not found. steps have done i have installed wordpress in following url icg.projects.com then have moved wp files sub-folder named "core-files" (as per url http://www.ampercent.com/move-core-wordpress-files-custom-directory/6211/ ). till frontend , wp admin works fine now tried change admin url icgadmin (ie. icg.projects.com/core-files/wp-admin/ icg.projects.com/core-files/icgadmin/). problem after giving username , password in wp-login page url becomes http://icg.projects.com/core-files/icgadmin/ . content of page "page not found". should wordpress admin. any appreciated. thanks in advance

Checking out a tag from SVN using chefs subversion ressource -

i have found subversion ressource in chef documentation check out subversion repository. how can use subversion ressource check out tag? a tag in subversion special location in repository (usually in /reponame/tags/name_of_your_tag) copy of main development (usually on /reponame/trunk) stored. check out tag in same way check out other part of project.

php - Can we post Unchecked Radio Button value? -

i have situation need unchecked radio button value. possible send unchecked radio button value through form in php? if yes, can please explain? <input type="hidden" name="myfield" value="false" /> <input type="checkbox" name="myfield" value="true" /> both fields have same name, if checkbox isn't checked, hidden field submitted, if checkbox checked, virtually override the hidden field. on side note, sure radio buttons wouldn't better suited needs, able see definite answer each questions, whereas checkboxes more submitted selected checkboxes. failing assume checkboxes not submitted checked, assumed unchecked.

angularjs - Select a value from typeahead shows Objec object -

Image
i working on single page application , using angular-typeahead when write in textbox shows me suggestions when select suggestion values of textbox become object object instead of name here html markup <div class="bs-example" style="padding-bottom: 24px;" append-source> <form class="form-inline" role="form"> <div class="form-group"> <label><i class="fa fa-globe"></i> state</label> <input type="text" class="form-control" ng-model="selectedstate" ng-options="state.firstname state in states" placeholder="enter state" bs-typeahead> </div> </form> </div> and here angularjs code var app = angular.module('mgcrea.ngstrapdocs', ['nganimate', 'ngsanitize', 'mgcrea.ngstrap']) .controller('typeaheaddemoctrl', function ($scope

batch file - How can I run my java program as different windows user? -

scenario: i have java program connect database. dbadmins , give security must access ip , db_user , osuser . these access. can connect toad db. problem: i cant connect java program use jdbc connection. java.sql.sqlexception: ora-00604: error occurred @ recursive sql level 1 ora-20099: my_db_user user'i osuseri ile myserver(10.210.yyy.xxx) host'undan db_host db'ye baglanamazsiniz. "thegroup" grubundan yetki talep ediniz... ora-06512: @ line 32 you can see osuser has empty value. mean should filled. mean java program cant osuser name think. tried: i open cmd test jar file , run cmd my_user(it allowed connect db can connect toad) , enter cmd. @ top of cmd screen says connect 'my_user' (it seems right) and write java-jar my_program.jar problem same, osuser empty. how can run jar file different user? or should need give grant user such can run batch file (i not know actually). extra info i have server c

How to add SEO plugin in Codeigniter -

i using codeigniter. want add seo plugin.i found code,but don't know how apply it.my code is, controllers/seo.php class seo extends ci_controller { function sitemap() { $data = "";//select urls db array header("content-type: text/xml;charset=iso-8859-1"); $this->load->view("sitemap",$data); } } views/sitemap.php <?= '<?xml version="1.0" encoding="utf-8" ?>' ?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc><?= base_url();?></loc> <priority>1.0</priority> </url> <!-- code looking quite different, principle similar --> <?php foreach($data $url) { ?> <url> <loc><?= base_url().$url ?></loc> <priority>0.5</priority> </url> <?php } ?> </urlset> config/routes

java - Use JScrollPane in JPanel and zoom a Graphics2D correctly -

i have problem zoom jpanel . have circle in middle of panel when click message say: you clicked in circle and if don't click on circle be: you're out of circle the problem tried zoom panel when click message says you're out of panel (but i'm clicking in zoomed circle) jscrollpane don't work tried hard don't working. please help. this code: import java.awt.dimension; import java.awt.graphics; import java.awt.graphics2d; import java.awt.geom.ellipse2d; /* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ public class zoomproject extends javax.swing.jframe { ellipse2d draggedcircle; ellipse2d circledrawinpanel; public zoomproject() { initcomponents(); circledrawinpanel=new ellipse2d.float(jpanel1.getwidth()/2,jpanel1.getheight()/2, 50, 50); } /** * method called within constructor initialize form.

delphi - adjusting width of columns in DBGrid -

this question has answer here: adjust column width dbgrid 3 answers i new delphi :). have made simple app able write , read sql server database. displaying query results in dbgrid. currently, have 3 columns in db (id, name, surname). dbgrid displays them in waz dont like. can see id (its width accurate) , name, stretched way right, have use horizontal scrollbar see surname, extremely wide. how can tell dbgrid adjust width of columns widest row? my app looks this: implementation {$r *.dfm} procedure tform1.button1click(sender: tobject); begin adoquery1.sql.text := 'insert [dbo].[client] ([meno],[priezvisko]) ' + 'values(:meno, :priezvisko)'; adoquery1.parameters.parambyname('meno').value := edit1.text; adoquery1.parameters.parambyname('priezvisko').value := edit2.text; adoquery1.execsql; end; pr