Posts

Showing posts from August, 2014

Trying to send parameters from a simple Python function to C++ -

i'm trying link python script c++ script. found , works. foo.cpp #include <iostream> class foo{ public: void bar(){ std::cout << "test!" << std::endl; } }; extern "c" { foo* foo_new(){ return new foo(); } void foo_bar(foo* foo){ foo->bar(); } } foowrapper.py from ctypes import cdll lib = cdll.loadlibrary('./libfoo.so') class foo(object): def __init__(self): self.obj = lib.foo_new() def bar(self): lib.foo_bar(self.obj) f = foo() f.bar() to compile use: g++ -c -fpic foo.cpp -o foo.o g++ -shared -wl,-soname,libfoo.so -o libfoo.so foo.o if -soname doesn't work, use -install_name : g++ -c -fpic foo.cpp -o foo.o g++ -shared -wl,-install_name,libfoo.so -o libfoo.so foo.o and execute just: python foowrapper.py this works, prints me 'test!' of bar() function. the thing want send parameters python function c++ function i've trie...

Django EmailMessage with attachment issue -

i using emailmessage send mail attachment. attachment .html file. successful in attaching file in email. html not display properly. html file showing tag in attachment content. code return follows, attach_file_name file path want display i.e. "/path/of/html/file.html" msg = emailmessage(subject, content, from_email, to_list, cc=cc_list, bcc=bcc_list) if attach_file_name: msg.attach_file(attach_file_name) msg.content_subtype = "html" msg.send() please me you need use emailmultialternatives from django.core.mail import emailmultialternatives msg = emailmultialternatives(subject, content, from_email, to_list, cc=cc_list, bcc=bcc_list) if attach_file_name: msg.attach_file(attach_file_name, mimetype="text/html") msg.send()

iphone - Auto-renewal Subscription Refund Policy -

i have queries regarding ios in-app purchase refund policy: what happens if user have purchased auto-renewal subscription app , asks apple refund? if apple refunds user, auto-renewal subscription remain active till duration have purchased for? or cancels out immediately. how application people know guy has asked refund subscriptions? please help i recommend see wwdc 2012 video 308 "managing subscriptions in-app purchase". talk starting @ 13:30. anyway, if talk customer's money - don't know. , know too. after refunding, if send receipt apple server verifying, you'll 21006 status, if expire_date still in future. if subscription refunded, you'll additional cancellation_date entry in received json, stands time , date, when subscription refunded (cancelled). you don't receive special signal refunding. can periodically verify receipt , check received json object: if there value cancellation_date key, subscription cancelled.

mysql - how to retrieve non matching records from non-unique keys? -

i have table this: physician_key product month score 1 8 1 1 8 2 1 8 3 2 b 8 2 2 b 8 1 i trying retrieve count of keys having score<=2 , dont want count key if occurs have single time score>2. in output want this: count =2, product b in month 8. i trying self join null constraint on key records <=2 , >2. still returning me first 2 rows, don't want. a not exists clause may help: select * table t not exists ( select 1 table tx tx.physician_key = t.physician_key , tx.product = t.product , score > 2 ); this says "give me rows in table exclude rows there exists row physician , product score > 2"

entity framework - Automapper maps source to destination but dest values are always null -

i'm new automapper , i'm having problem it. in case automapper used map models(entityframework generated) own viewmodels. happens, sourcemodel it's values mapped destinationmodel dest values null. what's going on values? now did do: referenced automapper project , bootstrapped mappings. public static void registerautomappermappings() { mapper.initialize(x => { // add mappingprofiles configured below x.addprofile(new registrationviewmodelprofile()); }); } public static imappingexpression<tsource, tdest> ignoreallunmapped<tsource, tdest>(this imappingexpression<tsource, tdest> expression) { expression.forallmembers(opt => opt.ignore()); return expression; } public class registrationviewmodelprofile : profile { protected override void configure() { createmap<registrationviewmodel, contact...

Find using PHP how usefull a document to me using search keywords i have -

(please read patiently) i developing application searches html documents based on keywords passed : i want buy watch or a watch sale or etc. have large list of html documents contain these keywords problem facing want fetch docs match best keywords. suppose trying find post selling watch , tried keyword : sell watch should bring relevant post selling watch not contains selling word , watch word you ask have done far : have done searching documents simple php string search , doing don't want to. have natural search, third party api or idea lot. note : don't have documents saved in db pulling them internet code , finding keyword if relevant. thanks zend_search_lucene might you. http://framework.zend.com/manual/1.12/en/zend.search.lucene.html if have possibility install search engine on server recommend sphinx or elasticsearch . you coul use 3rd party search saas (in no particular order): http://www.indexden.com/ http://www.searchify.com/ http:...

jump table - Function array in Java? -

maybe think in c, don't see solution how solve in java. response server sends string this: command params <xml...> the client receives string , extracts command. call function knows how handle command. on c side solution obvious. implemented array command name , associated function pointes, can loop through array , call function. is there way on java well? don't know call function based on name. see following options: do series of if(command.euqals(command) for each command create separate object can store in array (very messy). use reflection, can have map function names vs. command names. are there other options? the if statements not best imo, @ least allows compiler errors , typechecking. using reflection @ least more elegant because can loop , extend more easily, of course, means can see runtime errors if misstype names. your second idea idiomatic. use map<string, runnable> store command names , corresponding code, commands.get(com...

symfony - Remove field in update form Entity (Symfony2) -

i'm working symfony2, , have form number of fields, 1 of them called video. possible remove field in update form not in insert form? (form) youtubeposttype.php: $builder->add('titulovideo') ->add('descripcionvideo') ->add('tagsvideo') ->add('video', 'file', array('required' => false)); thank in advanced. if controller defining form fields directly, can add if statement after define main fields, check if it's not update before adding video field, e.g. $builder->add('titulovideo') ->add('descripcionvideo') ->add('tagsvideo'); if($mymethod != 'update') { $builder->add('video', 'file', array('required' => false)); } but assuming have defined custom form collection of fields field defined in form builder object , loading collection in controller, in case remove it: $form = $this-...

sql - Update query with INNER Join -

i have 2 tables manual_transactions , manual_list_temp. wanted achieve update manual_transactions information manual_list_temp. here records present in manual_list_temp table should updated manual_transactions. i have done below problem following statement updates every records manual_transactions table. update manual_transactions set ( "age", "assigned_to", "attachments", "comments", "completed_date_time" , "content_type", "created", "created_by","cycle_time (crt complete)" , "cycle_time (first reply)", "distribution_channel")= (select manual_list_temp."age", manual_list_temp."assigned_to", manual_list_temp."attachments", manual_list_temp."comments", manual_list_temp."completed_date_time", manual_list_temp."content_type", manual_list_temp."created", manual_list_temp...

ruby on rails - How to invoke flash messages defined in locales -

i have message called my_message in config/locales/post.en.yml follow: en: post: show: my_message: "post saved. , boom!" how call :my_message flash in controller's method? class postscontroller < applicationcontroller def show flash[:error] = my_message end end in application controller rails 4 send locale in parameters in contoller params[:locale] before_action :set_locale def set_locale i18n.locale = params[:locale] || i18n.default_locale end then flash[:error] = t('post.show.my_message')

return difference of two dates in PHP -

i need compare past/future date current date in php , present difference in "4 hours until", or "2 days 3 hours until" or "5 hours ago" format. optionally in "-4h" (which bad) or "4h" (which good) format. so in example: x = $expiry_date - $todays_date if result positive, eg. $expiry_date 4 hours in future, x = "4 hours go", or "4 hrs". if result negative, example "4 hours ago" or "-4hrs". any other, sounding result formats fine. any please? refer dates diff in php $date1 = "2013-08-11"; $date2 = "2012-07-12"; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); printf("%d years, %d months, %d days\n", $years, $months, $days); or $date1 = new datetime(...

c# - Is there any premade function to help resize controls based on their parent control? -

i have been looking using generic resizing , repositioning feature game, creating, based on window size. problem haven't found proper function regulate controls size , position based on it's parents original size, new size , set of directions (such allow resize y , or x, disallow resize w , or y, allow reposition x , or y, disallow reposition x , or y). considering making own generic function , when tested @ first came problematic results controls resized not properly. don't expect create code curious if there function out there rather reinventing wheel. using control.dock property yourcontrol.dock = dockstyle.fill so it'll resize according it's parent.

calendar - Can iCal schedule an event for the first weekday after BYMONTHDAY if BYMONTHDAY is a weekend? -

if have recurring event on given day of month (i.e. 15th) , day falls on saturday or sunday, possible ical instead schedule event occur on next available week day? you cannot set exception can use combination of byday , bymonthday: give monday after week-end had either on saturday or sunday 15th. rrule:freq=monthly;byday=mo;bymonthday=16,17 by combining event: rrule:freq=monthly;byday=mo,tu,we,th,fr;bymonthday=15 you'll there

paging - set GridView virtualItmCount property -

i working on simple paging project gridview in asp.net 4.5 i receive (gridview not contain definition virtualitmcount error ?? have set allowpaging=true allowcustompaging=true . set property virtualitemcount of desired gridview total number of rows. used calculate pagecount pager rendering. just noticed typo? in virtualitmcount vs. right 1 virtualitemcount

Cassandra Frequent Read Write Timeouts -

i had changed whole codebase thrift cql using datastax java driver 1.0.1 , cassandra 1.2.6.. with thrift getting frequent timeouts start, not able proceed...adopting cql, tables designed per got success , less timeouts.... with able insert huge data not working thrift...but after stage, data folder around 3.5gb. getting frequent write timeout exceptions. same earlier working use case again throws timeout exception now. random once worked not working again after fresh setup. cassadnra server log this cassandra server partial log debug mode @ time got error : http://pastebin.com/rw0b4md0 client exception : caused by: com.datastax.driver.core.exceptions.writetimeoutexception: cassandra timeout during write query @ consistency 1 (1 replica required 0 acknowledged write) @ com.datastax.driver.core.exceptions.writetimeoutexception.copy(writetimeoutexception.java:54) @ com.datastax.driver.core.resultsetfuture.extractcausefromexecutionexception(resultsetfuture.java...

java - how to store value of checkboxes when creating a custom listView android -

public class applesupportlist extends baseadapter { private layoutinflater minflater; private final string[] values; public applesupportlist(context context, string[] values) { minflater = layoutinflater.from(context); this.values = values; } @override public int getcount() { // todo auto-generated method stub return values.length; } @override public object getitem(int position) { // todo auto-generated method stub return position; } @override public long getitemid(int position) { // todo auto-generated method stub return position; } @override public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub final viewholder holder; if (convertview == null) { convertview = minflater.inflate(r.layout.customlist1, null); holder = new viewholder(); holder.te...

Database web frontend php, ajax, js -

my skills in java/ajax relatively poor. looking method or example link, enable creation of postgresql front end, displays record, user clicks submit edit record changes. , next view next one. record shown within text boxes within page when first created.

php - PHPUnit and Selenium exampe 17.1 -

i'm trying run example phpunit selenium 17.1 ( link ) i have done installation keeps failing. i get: 1) webtest::testtitle badmethodcallexception: command http://localhost:4444/wd/hub/session/url not recognized server. i havent changed example. selenium server running. i can't figure out wrong. help? answer: please see @rutter's comment: do know version of phpunit_selenium you're running? reported fixed of 1.3.2 (changelog, pull request). – rutter in addition after 2 weeks project startet working again. think simple reinstall needed. :) answer: please see @rutter's comment: *do know version of phpunit_selenium you're running? reported fixed of 1.3.2 (changelog, pull request). – rutter* in addition after 2 weeks project startet working again. think simple reinstall needed. :)

unity3d - Eraser effect in plane using shader -

i trying produce eraser material on plane. the way thinking of doing passing array shader telling shader material should transparent; if value array 0, return no color material (i.e. tranparent). have 2 problems: how declare , pass array in cg? does way work , if so, best way this? thinking might demanding. just use texture2d "array". can modify @ run-time (using setpixel or setpixels ) , pass shader would. and in shader appropriately manipulate base texture using "erased" texture. manipulate alpha or so. given you're dealing simple plane, seem straightforward option.

linux - Set timeout to a PHP function -

i have script <?php function get_reverse_dns($ip) { $result = exec("nslookup -n ".escapeshellarg($ip)." | grep 'name = '"); if(strpos($result,"name =") === false) { return "no reverse"; } else { $result = trim($result); $explodedresult = explode("name =",$result); $explodedresult[1] = trim($explodedresult[1]); $reversedns = trim($explodedresult[1],"."); return $reversedns; } } ?> that gives me reverse dns, problem sometimes, ip can have long delay, , want script check ip can "looked up", , if 5 seconds passed , not happening, return false how can make that? i have tried in linux nslookup --timeout 5 1.1.1.1 | grep 'name = ' timeout 5 nslookup 1.1.1.1 | grep 'name = ' thanks. i use dig: dig -x ${ip} +time=5 +tries=1 +retry=0 +short this command return ip address simplify parsing bit. ...

php - How to make sure AJAX is called by JavaScript? -

i asked similar question before, , answer simply: if javascript can it, client can it. but still want find out way restrict ajax calls javascript. the reason : i'm building web application, when user clicks on image, tagged this: <img src='src.jpg' data-id='42'/> javascript calls php page this: $.ajax("action.php?action=click&id=42"); then action.php inserts rows in database. but i'm afraid users can automate entries "clicks" id's , such, calling necessary url's, since visible in source code. how can prevent such thing, , make sure works on click, , not calling url browser tab? p.s. i think possible solution using encryption, generate key on user visit, , call action page key, or hash/md5sum/whatever of it. think can done without transforming security problem. right ? moreover, i'm not sure method solution, since don't know kind of security, or it's implementation. i'm...

How to auto adjust the components for Sencha Touch 2 application -

am new sencha touch 2 framework. creating project using sencha architect in have option select device display views. devices include ipad, iphone 4 , 5, blackberry etc etc. creating project per view in iphone (320 * 480 ). question when view project in ipad simulator components of view screen not adjust automatically. want run project on iphone,ipad,blackberry or android phone or tab. how can achieve independence components on screen adjust length, height etc etc properties @ own. there way using sencha architect ? depending on app architecture, use fit layout . however, best implement profiles , take at: http://docs.sencha.com/touch/2.2.1/#!/guide/profiles

windows phone 7 - Deserialise XML response from server -

i want deserialise object. saw following code in msdn.com: private void deserializeobject(string filename) { debug.writeline("reading xmlreader"); // create instance of xmlserializer specifying type , namespace. xmlserializer serializer = new xmlserializer(typeof(user)); // filestream needed read xml document. filestream fs = new filestream(filename, filemode.open); xmlreader reader = xmlreader.create(filename); // declare object variable of type deserialized. user i; // use deserialize method restore object's state. = (user)serializer.deserialize(reader); fs.close(); // write out properties of object. debug.writeline( i.field1+ "\t" + i.field2+ "\t" + i.field3+ "\t" + i.field4); } however, don't want deserialise file, rather xml stream server response, corresponding code shown here: httpwebrequest webrequest = (httpwebrequest)asynchronousresult.asy...

Can I evaluate two groups of items with a foreach loop in C# winforms? -

i have winforms tabcontrol , trying cycle through controls contained in each tab. there way add and in foreach loop or isn't possible evaluate more 1 group of items? example i'd do: foreach (control c in tb_invoices.controls , tb_statements.controls) { //do } or foreach (control c in tb_invoices.controls, tb_statements.controls) { //do } is possible, , if not, next best thing? need use for loop? foreach(tabpage page in yourtabcontrol.tabpages){ foreach(control c in page.controls){ loopthroughcontrols(c); } } private void loopthroughcontrols(control parent){ foreach(control c in parent.controls) loopthroughcontrols(c); }

How do I resolve a formula error in Homebrew for imagemagick? -

i'm running os x , trying homebrew, ruby , git work together. got installed , trying resolve gem errors. i came across issue imagemagick , rmagick not working together, tried solution described in " installing rmagick in mac os x mountain lion homebrew ". now getting following error when try anything. how can resolve this? $ brew doctor error: /usr/local/library/formula/imagemagick.rb:99: syntax error, unexpected $end, expecting kend please report bug: https://github.com/mxcl/homebrew/wiki/troubleshooting /usr/local/library/homebrew/formulary.rb:40:in `require' /usr/local/library/homebrew/formulary.rb:40:in `klass' /usr/local/library/homebrew/formulary.rb:90:in `get_formula' /usr/local/library/homebrew/formulary.rb:175:in `factory' /usr/local/library/homebrew/formula.rb:404:in `factory' /usr/local/library/homebrew/formula.rb:340:in `each' /usr/local/library/homebrew/formula.rb:338:in `each' /usr/local/library/homebrew/c...

ios - Am I correctly creating and passing this C array to Objective-C method and referencing it with a property? -

i created c array this: unsigned char colorcomps[] = {2, 3, 22, 55, 9, 1}; which want pass initializer of objective-c object. so think have put array on heap: size_t arraybytesize = numcolorcompvals * sizeof(unsigned char); unsigned char *colorcompsheap = (unsigned char*)malloc(arraybytesize); then have write first "stack memory array" heap array in loop: for (int = 0; < numcolorcompvals; i++) { colorcompsheap[i] = colorcomps[i]; } side question: there more elegant solution avoid for-loop step? and pass method: defined as - (id)initwithcolorcompsc:(unsigned char *)colorcompsheap; theobject *obj = [[theobject alloc] initwithcolorcompsc:colorcompsheap]; theobject has property hold c-array: @property (nonatomic, assign) unsigned char *colorcomps; and in -dealloc free it: free(_colorcomps); this in theory. use arc objective-c. am doing correct or there better way? if theobject going free array, init method should 1 make copy,...

windows 8 - How can I save a zip file to local storage in a win8 app using JSZip? -

i'm able create jszip object in code, i'm having trouble saving local storage in windows 8 app. examples i'm able find set browser's location.href trigger download, isn't option me. i've included code below. zip file end invalid , can't opened. appreciated. for reference: jszip function _ziptest() { var dbfile = null; var zipdata = null; windows.storage.storagefile.getfilefrompathasync(config.db.path) .then(function (file) { dbfile = file; return windows.storage.fileio.readbufferasync(file); }) .then(function (buffer) { //read database file byte array , create new zip file zipdata = new uint8array(buffer.length); var datareader = windows.storage.streams.datareader.frombuffer(buffer); datareader.readbytes(zipdata); datareader.close(); var localfolder = win...

Magento how do I override/alter template/payment/form/purchaseorder.phtml file -

Image
i need add text file [ template/payment/form/purchaseorder.phtml ], particular store within clients' magento site. when make change purchaseorder.phtml file, changes text on stores. need somehow customize 1 store in particular. i have read comments on several sites, mention changing local.xml, change config.xml, make changes in admin panel, such small change, don't want disrupt going overboard. i need extend functionality on backend change can made particular store or stores. sites has 5 stores built 1 install , need make above change 1 store. i think need somehow add po field heading , "additional text" option purchase order section in image two. correct, if how do this? could point me in right direction making type of change please. note : can't create directory structure, copy files, change needed files option this magento 1.7 copy purchaseorder.phtml file base/default directory paste in current template. can alter content of p...

r - Trouble with horizontal and vertical lines accepting class "Date" in ggplot? -

Image
i'm trying make gantt chart in ggplot based on generous code offered user didzis elferts. i'm trying add vertical line showing today's date, geom_vline layer in ggplot2 package returns error: discrete value supplied continuous scale . here code: today <- as.date(sys.date(), "%m/%d/%y") library(scales) ggplot(mdfr, aes(time,name, colour = is.critical)) + geom_line(size = 6) + xlab("") + ylab("")+ labs(title="sample project progress")+ theme_bw()+ scale_x_datetime(breaks=date_breaks("1 year"))+ geom_vline(aes(xintercept=today)) the plot without geom_vline command looks : any reason why geom_vline wouldn't work "date" character? edit: reproducible code used generate plot: ### gantt chart 1 ###############3 tasks <- c("meetings", "client calls", "design", "bidding", "construction") ...

angularjs - Setting $scope.$watch on each element in an array -

i trying figure out how set $scope.$watch on each element in array. care attributes of each element. in example, each rental_date object has 3 attributes: date , start_time , , stop_time . whenever start_time changed, want stop_time set 2 hours after start_time . the $ngresource call (using angular 1.1.5 ): agreement.show( id: 5 ).$then ((success) -> $scope.agreement = success.data.agreement # returns array of rental dates $scope.rental_dates = success.data.rental_dates # $watch goes here here 4 variations of $watch function tried: 1: angular.foreach $scope.rental_dates, (date, pos) -> $scope.$watch date.start_time, ((newval, oldval) -> $log.info 'watch changed' $log.info newval $log.info oldval ), true 2: angular.foreach $scope.rental_dates, (date, pos) -> $scope.$watch $scope.rental_dates[pos].start_time, ((newval, oldval) -> $log.info 'watch changed' $log.info newval $log.info oldval...

c# - No errors or results when executing simple query on SQL Server database -

this first approach sql server. have exported access db sql server , want use in application. have added new sql db c# project , replaced oledb sql . unable execute queries working local db in access. query: string query = @"select sessionid, semestera, semesterb, roomid, sessiondate, sessiontimestart, sessiontimeend" + " [session] " + " roomid = @roomid " + " , sessiondate = getdate() "; i have replaced date() getdate() instructed vs error, query not produce result (should return 1 record, access db does) my roomselect form code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.data.sqlclient; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace autoreg { public partial class roomselect : form { datatable queryresult = new datatable()...

java - Synchronizaton Object Lock Confusion -

i studying k&b threads chapter. reading synchronization. here example k&b. public class accountdanger implements runnable { private account account = new account(); public void run() { for(int x =0 ; x < 5 ; x++){ makewithdrawl(10); if(account.getbalance() < 0 ){ system.out.println("account overdrawn"); } } } public static void main(string[] args){ accountdanger accountdanger = new accountdanger(); thread 1 = new thread(accountdanger); thread 2 = new thread(accountdanger); one.setname("fred"); two.setname("lucy"); one.start(); two.start(); } private synchronized void makewithdrawl(int amt){ if(account.getbalance() >= amt){ system.out.println(thread.currentthread().getname() + " going withdraw"); try{ thread.sleep(500); } catch(interruptedexception e) { e.printstacktrace(); } account.withdraw(amt); system...

Convert Java Object to Json and Vice versa? -

i know json object nothing string . my question have map of object , want convert json format. example : java class -> class person{ private string name; private string password; private int number; } java list -> map<list<long>,list<person>> map=new hashmap<list<long>,list<person>>(); ..and map has data filled in it. i want convert list json format? how can achieve it? because want send on httpclient... if not other alternative way? as per knowledge there gson api available, dont know how use , or in other efficient way. thank you not sure problem gson is. the doc : bagofprimitives obj = new bagofprimitives(); gson gson = new gson(); string json = gson.tojson(obj); and bagofprimitives obj2 = gson.fromjson(json, bagofprimitives.class); that object (as name suggests) made of primitives. gson trivially handle objects, collections of objects etc. life gets little more complex when using generics etc...

css - Strange behaviour when using text-align justify/text-justify and right -

Image
i ran 1 ie-specific problem can't wrap head around. the following html , css can seen live in pen . :: html <div id="container"> <div class="dummy">dummy</div> <nav> <div id="right"> <ul> <li>lorem ipsum <img src="http://placehold.it/80x40"> dolor sit amet.</li> <li>anal natrach, ut vas petat, <img src="http://placehold.it/80x40"> doriel dienve.</li> </ul> <div class="dummy">dummy</div> <div class="dummy">dummy</div> </div> </nav> </div> :: css /* reset */ * { margin: 0; padding: 0; vertical-align: top; } ul { list-style: none; } /* markup */ #container { line-height: 0; font-size: 0rem; text-align: justify; text-justify: distribute-all-lines; } #container:...

callback - Ajax: Append data in input value instead of div -

this ajax function works fine, change place result needs shown <script type="text/javascript"> function submitform1() { var form1 = document.myform1; var datastring1 = $(form1).serialize(); $.ajax({ type:'get', url:'file.php', cache: false, data: datastring1, success: function(data){ $('#results').html(data); } }); </script> html <input type="hidden" name="place" id="place" value="//append data here"> <div id="result"><div> i need have result in value=" " after ajax call back. way this? try use $('#result').html(data); instead $('#results').html(data); , forget close function function submitform1() { var form1 = document.myform1; var datastring1 = $(form1).serialize(); $.ajax({ type: 'get', url: 'file.php', cache: false, data: datastring1, success: function(...

android - Attempted to access a cursor after it has been closed -

i'm using following code delete image. works first time, when try capture image , delete staledataexception : 08-07 14:57:24.156: e/androidruntime(789): java.lang.runtimeexception: unable resume activity {com.example.cap_im/com.example.cap_im.mainactivity}: android.database.staledataexception: attempted access cursor after has been closed. public void deleteimagefromgallery(string captureimageid) { uri u = mediastore.images.media.external_content_uri; getcontentresolver().delete( mediastore.images.media.external_content_uri, basecolumns._id + "=?", new string[] { captureimageid }); string[] projection = { mediastore.images.imagecolumns.size, mediastore.images.imagecolumns.display_name, mediastore.images.imagecolumns.data, basecolumns._id, }; log.i("infolog", "on activityresult uri u " + u.tostring()); try { if (u != null) ...

java - Methods for an interface with a variable number of parameters -

i'd ask if it's possible in java have declaration of method in interface but, want methods defined have variable number of input parameters (for example, of same type). thinking in this: public interface equalscriteria { public boolean isequal(string... paramstocheck); // not equals(object obj) !!! } and 1 class implements equal criteria like, example: public class commonequals implements equalscriteria { private string name; private string surname; .... @override public boolean isequal(string othername, string othersurname) { return name.equals(othername) && surname.equals(othersurname); } } but maybe, want other criteria in part of code, this public class specialequals implements equalscriteria { .... @override public boolean isequal(string othername, string othersurname, string passport) { return name.equals(othername) && surname.equals(othersurname) && passport.equals(pass...

android - Change color of background drawable of a button from widgetprovider -

in normal android code in activity, can control color of background drawable drawable d = findviewbyid(r.id.button_highlight).getbackground(); porterduffcolorfilter filter = new porterduffcolorfilter(color.red, porterduff.mode.src_atop); d.setcolorfilter(filter); i know how can utilize within widgetprovider dynamically change background color of background drawable of elements from instance of appwidgetprovider call like: int color2 = settings.getint("secondary_color", r.color.main_alt); // following won't work because <button> has no method "setcolorfilter" remoteviews.setint(r.id.button_highlight,"setcolorfilter",color2); the button_bg.xml drawable button id r.id.highlight looks this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> ...

asp.net error form cannot be nested within element form? -

i have content page in asp.net application uses form tag. there's 1 on page i'm confused why give me error: validation (html5): element 'form' must not nested within element 'form' heres code: <%@ page language="c#" autoeventwireup="true" masterpagefile="~/site.master" codebehind="default.aspx.cs" inherits="webapplication6._default" %> <asp:content id="content1" runat="server" contentplaceholderid="maincontent"> <div> <form id="form1"> <asp:gridview id="gridview1" runat="server" allowsorting="true" autogeneratecolumns="false" datakeynames="id" datasourceid="sqldatasource1" allowpaging="true" onselectedindexchanged="gridview1_selectedindexchanged"> <columns> <asp:boundfield datafield="id" headert...

java - Difference between thread's context class loader and normal classloader -

what difference between thread's context class loader , normal classloader? that is, if thread.currentthread().getcontextclassloader() , getclass().getclassloader() return different class loader objects, 1 used? each class use own classloader load other classes. if classa.class references classb.class classb needs on classpath of classloader of classa , or parents. the thread context classloader current classloader current thread. object can created class in classloaderc , passed thread owned classloaderd . in case object needs use thread.currentthread().getcontextclassloader() directly if wants load resources not available on own classloader.

Embedding Javascript in PDF to force links to open in new window -

we generating pdfs displayed on pages of our web app. pdfs displayed in iframes within page. if user clicks link inside 1 of pdfs on internet explorer acrobat installed, loads link in iframe, breaks user experience. what accomplish embed javascript in pdf links clicked in pdf opened in new window. tried embedding following code in pdf: /type /action /s /javascript /js (app.openinplace = false;) the resulting pdfs continue open links in place. using utility functions pypdf2 embed javascript inside pdfs. it occurred me might not possible open link pdf in new window within iframe.

Will RCpp speed up the evaluation of basic R functions? -

pardon me, not know rcpp, trying figure out if learn in order improve package writing. i have written r package (is supposed to) efficiently , randomly samples uniformly high-dimensional, constrained space mcmc algorithm. (unfinished and) located @ https://github.com/davidkane9/kmatching . the problem when run statistical test called gelman-rubin diagnostic see whether mcmc algorithm has converged stationary distribution, should r = 1 statistic, high numbers, tells me sampling bad , no 1 should use it. solution take more samples , skip more (taking 1 out of ever 1000 instead of every 100). takes lot of time. if want code run, here example: ##install package first data(lalonde) matchvars = c("age", "educ", "black") k = kmatch(x = lalonde, weight.var = "treat", match.var = matchvars, n = 1000, skiplength = 1000, chains = 2, verbose = true) looking @ rprof output of rnorm , %*% taking of time: total.time total....

networking - AR9485 Wireless Network Adapter with linux mint -

lately change vivobook 500ca linux. i installed latest mint cinnamon. have been having problems wireless card : description: wireless interface product: ar9485 wireless network adapter vendor: atheros communications inc. physical id: 0 when start pc works 10 minutes , disconnected wireless network. i tried install drivers ndiswrapper , inf files no way make works! : module not loaded. error was: fatal: module ndiswrapper not found. ndiswrapper module installed? any ideas why keep getting disconnected? sudo apt-get install ndiswrapper-dkms

plugins - JQuery Timepicker interfering with Datepicker -

i trying find way remove jquery plugin specific class/id. i have web form has several fields use date picker, form has fields use timepicker. timepicker input field ids targeted .timepicker() , works, because have same class datepicker fields, datepicker showing when click on time field inputs. is there way can remove plugin timepicker divs , not affect of other fields?

asp.net - redirect .aspx with query string to html page using htaccess -

we have migrated windows server linux server. trying redirect .aspx urls html urls. the static pages works fine if used redirect 301 /contact.aspx http://mysite.com/contact.html but when try add redirect like redirect 301 /products.aspx?cid=30&bid=5 http://mysite.com/category/books.html the redirect not working. any advice highly appreciated

android - DrawerLayout populating menus from other activity -

i'am creating menu 2 navigation drawers 1 in each side: left/right navigation drawers everything working should want separate populating tasks main activity left activity , right activity, on had separeted layouts (just better struture) this main layout: <!-- main content view --> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" tools:context=".mainactivity" > <listview android:id="@+id/main_list_viewer" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:divider="@android:color/darker_gray" android:dividerheight="1dp" android:footerdividersenabled=...

html - Why is this div dropping down to the next line on window zoom out? -

jsfiddle i have wrapper 4 divs inside floated left , in 1 line. when zoom out, 4th div drops bottom. possible problem can think of width of wrapper decreasing, causing not able contain 4th one, wrapper has fixed width i'm sure thats not problem. here's html: <div id="wrapper"> <div id="panel"> <div id="panel1" class="panelcell"></div> <div id="panel2" class="panelcell"></div> <div id="panel3" class="panelcell"></div> <div id="panel4" class="panelcell"></div> <div class="spacer" style="clear: both;"></div> </div> </div> and here's css: #wrapper{ width: 1280px; } #panel{ width:100%; } #panel .panelcell{ width: 318.75px; height: 213px; float: left; border-right: 1px solid white; } .pane...