Posts

Showing posts from February, 2010

eclipse - Access debug variables from within the code -

Image
it's debugging in eclipse, while debugging, can see variables window containing variable names , values, how can access variables , values within code or (expression) window? for example can write this: print cash.dbname or x=cr.in_max or s = _pool._serialized (see picture) there's complex tree of variables, can access variable tree reaching branches , leaves? open display view; there can enter code snippets execute within current stack frame selected in debug view. code completion works, too. you can select part or of contents of display view, right-click, , choose display, inspect, or execute it. powerful exploring application state when debugging. see eclipse page display view .

jquery - Change color of li class with javascript when keyboard key is pressed -

i've created keyboard html , css, , i'm trying make keys "glow" different background-color when same key pressed on keyboard (the real-life keyboard is). it looks this: <div id="keyboard"> <ul class="row"> <li class="letter">q</li> <li class="letter">w</li> . . . </ul> </div> and have following javascript code: $('#keyboard .letter').keydown(function() { $(this).addclass('red'); }).keyup(function() { $(this).removeclass('red'); }); this worked me: html <div id="keyboard"> <ul class="row"> <li class="letter" id="q">q</li> <li class="letter" id="w">w</li>. . .</ul> </div> jquery $(document).keypress(function(e){ var which_letter = string.fromcharcode(e.which); $('#'+which_letter+''

php - Current URL to variable and variable to regular exp -

sorry bad english... need code seo clean circuit urls, need regexp current url , swap < a , href , a> < i , title , i> (that searchengines - not see links , not flow page rank on it) in links coincide current url, jquery code swap in browser href links work exemple: current url - http: //exemple.com/pizza/ (sorry space ) thу сode: <div> <a title="some text" href="http://exemple.com/pizza/">pizza</a><br> <a title="text 2" href="http://exemple.com/salads/">salad</a> </div> i need code looks like: <div> <i class="asd" title="http://exemple.com/pizza/">pizza</i><br> <a class="asd" href="http://exemple.com/salads/">salad</a> </div> when i'm on http:// exemple.com/pizza/ page, and <div> <a class="asd" href="http://exemple.com/pizza

android - Compare dates using comparator in Java -

i compare date times in such way end result values have been sorted in date ascending , time descending order. how achieve in java using joda-time library? data: 01/31 5:50 01/31 5:40 01/30 2:20 result 01/31 5:40 01/31 5:50 01/30 2:20 a simple treeset (assuming have distinct dates) using comparator comparing datetime.getmillis() of each date instance trick. and better, why not use directly "out-of-the-box" comparator ;) implement exact logic want. (ascendant, descendant, whatever)

Android - How to add images onto slices with ExpandablePieChart library? -

i'm trying create rotating pie chart using expandablepiechart library ( https://github.com/saulpower/expandablepiechart/blob/master/readme.md ). i'd insert image in front of each slice, don't know how! i'm able set color each 1 in adapter, not image. can create custom method (get/set) in slices class ( https://github.com/saulpower/expandablepiechart/blob/master/src/com/saulpower/piechart/views/pieslicedrawable.java )? could me? thanks in advance (and excuse bad english).

oop - check if setter is set PHP -

hi there way check if setter in class set? i've tried is_object , isset without proper result. example: class fruitsmodel{ public $fruitid; public function setfruitid($fruitid){ $this->fruitid = $fruitid; } public function displayfruit() { if(setter_fruit not set){throw new exception("fruitid missing!");} echo $this->fruitid; } } a developer should know methods need implemented in class. assuming not, how force him implement them without checking existance of methods in other methods programatically? that's interfaces come in handy , for. see interface contract defines methods class must implement. so cleanest way tackle task implement interface. fruitsmodelinterface.php <?php interface fruitsmodelinterface{ public function setfruitid($fruitid); } fruitsmodel.php <?php class fruitsmodel implements fruitsmodelinterface{ protected $fruitid; public function

windows - QMake: Referencing a library using relative paths -

i have qt project using sqlite, have following directory structure: c:\workspace\myproject\myproject.pro c:\workspace\myproject\sqlite3\sqlite3.lib adding sqlite3.lib absolute paths works fine: libs += -l"c:/workspace/myproject/sqlite3" -lsqlite3 but can't make work relative paths. try with: libs += -l"sqlite3" -lsqlite3 but fails with: :-1: error: lnk1104: cannot open file 'sqlite3\sqlite3.lib' i tried libs += -l"../sqlite3" or libs += -l"../../sqlite3" , didn't work either. i'm using msvc 2008 compiler toolchain. since it's possible build different directory project directory, relative path pointing project directory should prefixed $$pwd/ ( pwd qmake variable contains absolute path directory processed *.pro file). your line like: libs += -l"$$pwd/sqlite3" -lsqlite3

Android: java.lang.NoClassDefFoundError after importing jar. Wrong jar? -

after i've imported jar file android project , ran it, java.lang.noclassdeffounderror @ first thought i'm doing wrong while importing it, tryed import jar i've online class , worked! here question: is there specific way of creating jar files android project? i've point out first jar created java class wrote time ago. jar works without problems in java app. jar created using eclipse kepler. thanks help. the solution shoved pretty simple. i'm using java 1.7 create jar files, android accepts jars created java 1.6 . problem caused incompatibility in bytecode , therefore need force compiler use java 1.6. if you're using eclipse, go project properties > java compiler , select compiler compliance level: 1.6 save changes , rebuild project. you're ready export "working" jar :)

Limiting number of disqus comments displaying on WordPress post? -

i have disqus comment system plugin installed on self-hosted wordpress website. there no option set limit on number of comments displaying on page/post. as number of comments increases slows down page. older comments not required on site. can tell me way limit disqus comments 10 or 15 on page , there can option load more. disqus not support disqus_per_page parametres , pagination version. default value 50 comments. sended mail, hope fixed :)

ios - Not sure where the core data code should go in the MVC -

in app i'm working on, use core data store content. populate database in appdelegate 's didfinishlaunchingwithoptions method. , in view controller, i'm extracting required data using nsfetchrequest . my question is, code related extracting data should in view controller? or should create separate methods in nsmanagedobject subclasses generated entities , call them view controller? can please shed light on this? thank you. you should create model class, means like: @interface dataimporter : nsobject @property(nonatomic, readonly) coredatamanager *coredatamanager; - (id)initwithcoredatamanager:(coredatamanager *)coredatamanager; - (void)importdatawithcompletioncallback:(void (^)())completionblock; @end it's not nsmanagedobject subclass, it's object responsible importing data coredata store. importdatawithcompletioncallback can e.g. create necessary nsmanagendobject objects (depending on json) , save them, in background, call callback blo

executorservice - java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException -

i getting concurrent modification exception when executing following code: mymap global variable , hashmap callable<string> task = new callable<string>() { @override public string call() { mymap.put("myid", "id2"); mymap.put("myname", "joe"); string id = mymap.get("myid"); system.out.println("id is: "+ id+ ", mymap before: "+mymap.tostring()); mymap.remove("myid"); system.out.println("id is: "+ id+ ", mymap after: "+mymap.tostring()); return id; } }; list<callable<string>> tasks = collections.ncopies(7, task); executorservice executorservice = executors.newfixedthreadpool(7); list<future<string>> futures = executorservice.invokeall(tasks); list<string> resultlist = new arraylist<string>(futures.size()); (future<string> future: futures){ resultlist.add(f

c# - Using ExifLib on remote images -

i have application displays images stored remotely on twitter, instagram , flickr's servers. use exiflib extract exif information (mainly gps data) , display them image details. here have far: string metadata = string.empty; string tagvalue = string.empty; try { using (var wc = new webclient()) { byte[] imagebytes = wc.downloaddata(imgurl); using (var ms = new memorystream(imagebytes, 0, imagebytes.length)) { using (exifreader reader = new exifreader(ms)) { if (reader.gettagvalue<string>(exiftags.gpsaltitude, out tagvalue)) log.debug("gpsaltitude: " + tagvalue); if (reader.gettagvalue<string>(exiftags.datetimedigitized, out tagvalue)) log.debug("datetimedigitized: " + tagvalue); if (reader.gettagvalue<string>(exiftags.datetimeoriginal, out tagvalue)) log.debug("date

javascript - storing html(response) in var -

im using ajax send form without reloading. use following method this: my mail sender: if (filter_var($email, filter_validate_email)) { mailto($to, $subject, $message, $headers); echo "0"; }else{ echo "1"; } the script sends info php file above $(document).ready(function(){ $('#submitbtn').click(function(){ $.post("send.php", $("#mycontactform").serialize(), function(response) { $('#success').html(response); }); return false; }); }); whenever give valid email , send returns 0 . when fails returns 1 . instead of displaying value in div #success want store value in var can see if mail send or not. , if send can hide contact form. i came this: $(document).ready(function(){ $('#submitbtn').click(function(){ $.post("send.php", $("#mycontactform").serialize(), function(response) { var x = html(response);

How to navigate to the last cursor position in Eclipse if it is in the same file and was not edited? -

i had used eclipse earlier, afterwards switched intellij while , eclipse. there 1 thing intellij can't find in eclipse: navigating real last cursor position - in same file , if cursor moved between lines using arrow keys on keyboard or mouse. intellij able , found useful. for example: move cursor using keyboard's down arrow key successively on lines 10, 20, 30. on line 30 , when press alt + left cursor go line 20. after pressing alt + left again cursor go line 10. after pressing alt + right afterwards cursor go line 20 again. the following shortcuts available in eclipse: alt + left - navigates last cursor position in different file, not last cursor position in current file if moved cursor in same file alt + right - navigates forward next cursor position in different file, not next cursor position in current file if moved cursor in same file ctrl + q - moves cursor last edit location the latest version of eclipse in tested above-mentioned shortcuts: ecli

regex - UK bank sort code javascript reg. expression -

i looking validate 1 of 2 sort codes. have created below expression match 1 of sort codes unsure how match second sort code part of same expression. below regex should match sort code beginning 72 how add expression should match either of 72 plus 04 ? appreciated. ^[7]{1}[2]{1}[0-9]{4}$ thanks, paul you rewrite current regex as: ^72[0-9]{4}$ and make match 6 digit numbers beginning 04 , can use or operator | , non-capture group: ^(?:72|04)[0-9]{4}$ (?: ... ) non-capture group, limit scope of or 72 , 04 . some sample numbers matches: 721234 041234

localization - Tool in the gettext suite to unify source strings with fuzzy match? -

is there way leverage tools in gettext suite fuzzy match source strings within 1 po file find strings identical? seem useful quality check improve sources. example: #: my_file msgid "sorry, went wrong" msgstr "" #: some_other_file msgid "sorry, went wrong." msgstr "" #: yet_another_file msgid "sorry, wrong" msgstr "" these strings virtually identical , source code possibly changed use same message in each instance. reduce l10n work , make ui more coherent. seem me fuzzy match algorithm in msgmerge should pretty suited identify these instances. yet not find obvious way this. you don't want kind of folding without human supervision. translation tools have feature, human should validate such folding. can't identical strings because of context. why: buttons ("commands") translated differently labels , titles ("descriptions)") example: "print" translated french "im

Pascal Delphi - Undeclared Identifier -

i'm using synapse library in delphi project networking. when try , use 1 of types defined in external units, i.e: 'ttcpblocksocket', has red underline , says "undeclared identifier 'ttcpblocksocket'". the files in correct folders , 'uses' statement can find them , shows no errors. the strange thing i've had identical setup in project , there have been no errors in project. as note: can't install/edit software/settings, can't add fixes. this well-known bug in error insight . has existed since error insight first introduced in delphi 2005 or 2006, , still exists today in delphi xe5. it's caused different compiler being used error insight, apparently, doesn't have access same symbol set used code insight compiler (the 1 helps find symbols in code editor) or command-line compiler (the 1 used compile code application or package). therefore uses files referenced in project (.dpr) file locate symbols, , since maj

module - 404 Error in Magento extension when deployed in production -

this 1 puzzling me 2 days now. i've found solution 404 in admin, not same happening here. have same version of magento in local copy , production server: 1.7.0.2. extension works great in local. packaged using magento connect , installed in production same way. files there. shows in menu , in configuration section, when click menu go report, beloved 404. loged out , in, flushed cache zillion times (including deleting files manually) nothing changed.this urls in both envs: (dev)http://localhost/magentos/index.php/salestaxes/adminhtml_salestaxes/index/key/c4b8ecb58fa2062f696cacfd340/ (prod)https://www.myserver.com/index.php/salestaxes/adminhtml_salestaxes/index/key/332e617e74a92a39a40cf5d3/ as can see same. don't know wahy i'm getting error. can point can solve this? need check setting? can cause this? this var_dump in router _validatecontrollerclassname() method: string(115) "/home_path/public_html/app/code/community/surpassweb/salestaxes/controllers/admin

Java VisualVM heap space dump into output path -

i need know if possible declare output path heap space dump in java visualvm. there parameter can use java visual vm? i have trace specific service on server , need dump of heap space. thanks. update thanks lot. found solution problem. connected service jmx remote. there possible save heapdump on other drive of server. you can use following visualvm.tmpdir system property change directory, visualvm stores snapshots, thread dumps , heap dumps. see this visualvm issue more details.

ajax - add access control allow origin in nginx discourse.conf -

so have application on forums.awake-gaming.com , have page on awake-gaming.com post form forums.awake-gaming.com via ajax . as expected xmlhttprequest cannot load http://forums.awake-gaming.com/posts. no 'access-control-allow-origin' header present on requested resource. origin 'http://awake-gaming.com' therefore not allowed access. so, have access server, added in discourse.conf file under nginx/conf.d directory. add_header access-control-allow-origin "http://awake-gaming.com/join-us.html"; add_header access-control-allow-methods: "get, put, post, delete, options"; add_header access-control-allow-headers: "content-type, authorization, x-requested-with"; i restarted nginx , tried submit form again, in theory, should work still same error in console : and ajax call didn't return success either. weird enough, data posted forums.awake-gaming.com , posted(via discourse api). so went wrong?, tried ask @ meta.discou

Callback for rails 4 delete_all -

i have unreadentry model , using after_commit callback send notification pusher service. problem event fires fine when adding records when delete_all sent on model, neither: after_commit , after_destroy fired. how can add catch delete_all , add callback it? class unreadentry < activerecord::base belongs_to :user belongs_to :feed belongs_to :entry after_commit :send_pusher_notification, if: pusher_enabled validates_uniqueness_of :user_id, scope: :entry_id def self.create_from_owners(user, entry) create(user_id: user.id, feed_id: entry.feed_id, entry_id: entry.id, published: entry.published, entry_created_at: entry.created_at) end def self.sort_preference(sort) if sort == 'asc' order("published asc") else order("published desc") end end def send_pusher_notification(user = nil, = 'unreadentry#callback') if user.nil? unread_count = unreadentry.where(user_id: self.user_id).count

sql - Oracle trim whitespace on the inside of a string -

i storing phone numbers varchar2 in system allow users input '+' characters infront of phone number if choose. my regexp allows perfectly, when storing number in database want strip out whitespace user may enter. my regexp allows following formats +4470123456789 +447 0123456789 +447 01234 56789 01234567890 01234 567890 01234 567 890 i know resolve issue not letting users put whitespace in numbers, know personal experience how frustrating have validation error due silly formatting on client side. have tried using trim function on insert/update trigger have realised limited front , trailing whitespace, there other function in oracle use remove internal whitespace? or need write own function this? any pointers appreciated. you want try replace (telno, ' ', '') .

c# - Entityframework Code First and Generic Repository , lazy loading not working after insert -

i have defined (poco?) class in domain project : public class employee { public int id { get; set; } public string name { get; set; } public virtual icollection<contactofemployee> contactofemployees { get; set; } } public class personel { public int id { get; set; } public string name { get; set; } public virtual icollection<contactofpersonel> contactofpersonels { get; set; } } public class contact { public int id { get; set; } public string name { get; set; } public string tel { get; set; } } public class contactofemployee : contact { public int employeeid { get; set; } public virtual personel employeecontact { get; set; } } public class contactofpersonel : contact { public int personelid { get; set; } public virtual personel personelcontact { get; set; } } public class databasecontext : dbcontext { public dbset<employee> employees { get; set; } public dbset<personel> personels { ge

wordpress - Disable order comments in Woocommerce? -

i have integrated website woocommerce. however, woocommerce updates status displayed in wordpress comments, makes hassle view. idea how create in functions.php make stop displaying them there? you add 'woocommerce' comments' black list won't show in list.

cordova - Prevent debugging of PhoneGap app -

i've created ios app using phonegap, , learned it's easy hook iphone mac, enable safari debugging on iphone, , use safari on mac view html , javascript that's part of app. this great debugging purposes, stinks in terms of security when i'm ready deploy app masses. means can instantly see internals of app. is there way in phonegap disable type of debugging? thanks! this works because get-task-allow entitlement enabled development builds. distribution profiles not include entitlement, it's not possible attach debugger app downloaded store. don't have worry this. of course doesn't mean code hidden. javascript still stored on device , determined users can find way access it. example users on jailbroken device have full access file system , can peek inside app's container.

cuda - Why can't I use a single thread to initialize shared memory? -

this seems should simple, can't find references, i'm asking here. i have following cuda kernel, launching in grid of 2-d thread blocks: __global__ void kernel(){ if (threadidx.x == 0 && threadidx.y == 0) { __shared__ int test = 100; } __syncthreads(); // more stuff } when try compile, error "initializer not allowed shared variable" what doing wrong? seems me have 1 thread doing initializing... thanks! do instead: __global__ void kernel(){ __shared__ int test; if (threadidx.x == 0 && threadidx.y == 0) { test = 100; } __syncthreads(); // more stuff } the declaration of __shared___ variable must separate code manipulates it.

java - How to set print orientation to landscape -

i using ireport 5.1.0 , jasperreports server 5 . able set report page size orientation landscape , able preview report in landscape . problem when exporting docx or rtf , when printing report, print preview , printing of report in portrait, making actual report cut. how set print orientation of jrxml file or how make printing landscape ?

javascript - Make browserify modules external with Gulp -

i have library lib.js want create lib/a.js , lib/b.js , able use script client.js using var = require('lib/a.js'); , works when include compiled lib.js library before client.js (therefore, lib.js has declare require function knows lib/a.js ) i guess have use external , alias not sure proper way it also, possible have gulp file creates alias automatically folders in library? eg. creates alias files in lib/ dir? here couple of gulp tasks build common lib.js , client.js bundles separately. note have tell browserify b.require() lib/*.js when bundling lib.js, , have tell b.external() libraries loaded separately when bundling client.js var path = require('path'); var gulp = require('gulp'); var browserify = require('browserify'); var concat = require('gulp-concat'); var transform = require('vinyl-transform'); gulp.task('build-lib', function () { // use `vinyl-transform` wrap around regular readablest

java - Maven not running Test -

i created new maven project in eclipse runs simple test using both htmlunitdriver , firefoxdriver pull web page , check title on page. when run maven command mvn test get: [info] scanning projects... [info] [info] ------------------------------------------------------------------------ [info] building my-app 1.0-snapshot [info] ------------------------------------------------------------------------ [info] [info] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app --- [warning] using platform encoding (macroman actually) copy filtered resources, i.e. build platform dependent! [info] skip non existing resourcedirectory /users/andrew/development/code/my-app/src/main/resources [info] [info] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ my-app --- [info] nothing compile - classes date [info] [info] --- maven-resources-plugin:2.6:testresources (default-testresources) @ my-app --

c# - Why isn't this very simple JQuery working? -

this question has answer here: register on-click event jquery - not firing 2 answers i trying pass width of page variable c# code behind asp.net, , receiving empty strings. narrowed down problem jquery function not firing. changed simplest code test if function doing anything: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> $(document).ready(function() { alert("hello"); }); </script> and yet, still nothing. i've included jquery i've triple checked syntax no errors reported in console i looked through other similar 'facepalm' questions, none of solutions work (see above) what incredibly obvious thing missing? you can't simultaneously set [src] attribute , include contents <script> element. if need 2 scr

Get Embed html code for bing map based on dynamic address -

how bing maps embed html code based on dynamic address. in page have city , state based on need show embed map in page. in order this, have several options including embedded maps, using interactive controls or static imagery service. embedded maps: based on feedback, simplest way achieve want use embedded maps, find options on msdn: http://msdn.microsoft.com/en-us/library/ee692180.aspx you can think @ using bing maps website , configure behavior of portal using parameters: http://msdn.microsoft.com/en-us/library/dn217138.aspx static imagery map if want display static map (image) pushpin @ specific location, see rest imagery service here: http://msdn.microsoft.com/en-us/library/ff701724.aspx sample url: http://dev.virtualearth.net/rest/v1/imagery/map/road/bellevue%20washington?maplayer=trafficflow&key=bingmapskey interactive map using ajax v7 you can find need implement own interactive map using javascript on page: http://msdn.microsoft.com/en-u

c# - LINQ issue with Equals statement -

i'm getting error following: var answerlist = (from answer in db.questionanswers answer.tloginid.equals(tid) && answer.ploginid.equals(pid) && answer.submitted.equals(submittedval) select answer).tolist(); the error is: unable create constant value of type 'system.object'. primitive types or enumeration types supported in context. however, when change to: var answerlist = (from answer in db.questionanswers answer.tloginid.equals(tid) && answer.ploginid.equals(pid) select answer).tolist(); then this: answerlist.where(x => x.submitted.equals(submittedval)); it works... missing? me these statements doing same thing. i'm not sure why working this. update: i figured out after looking @ link @sergeylitvinov provided .equals column checking submitted boolean instead of integer once made types same statements worked.

ios - Methods/Functions/ .h and .m files -

i want create .h , .m files @property latitude , longitude , return these values - how best done ? can create method sends variables , returns variables don't want send variables - recieving lat/long. hows best done ? best create .m , .h file or best create method ? if can provide me sample code. thanks lot jason use cllocationcoordinate2d wrap lat/long values in 1 property. you'll need #import <corelocation/corelocation.h>

access vba - How to stop recursive search once the file is found in VBA -

i have below script , modify http://www.vbforums.com/showthread.php?613400-loop-through-folders-subfolders private sub command1_click() dim fld folder dim searchstring string dim resultfilepath string set fso = new filesystemobject set fld = fso.getfolder("c:\users\janedoe\desktop\jane") searchstring = "claimsheet.xlsx" resultfilepath = recursivesearch(fld, searchstring) set fld = nothing set fso = nothing if resultfilepath = "" msgbox ("we not find file " & searchstring) else msgbox ("we found it, @ " & resultfilepath) end if end sub function recursivesearch(fld folder, search string) string dim tfold folder dim tfil file each tfold in fld.subfolders debug.print "looking in " & tfold & " folder" recursivesearch tfold, search if recursivesearch = search exit function end if next debug.assert instr(tfil, search) = 0 if

c# - Open PDF file in a specific page using pdfbox -

i have program makes search, example sentence, in pdf files of folder. it's working perfect... but add feature open in exact page of sentence. , through documentation of pdfbox , not find specific this. i don't know if let pass by, if enlighten me in grateful thank i read question earlier week. @ time, didn't have answer you. stumbled on methods setstartpage() , setendpage() on pdfbox documentation pdftextstripper class , made me think of question , answer. it's been 4 months since asked question, maybe someone. know learned thing or 2 while writing it. when search pdf file, can search range of pages. functions setstartpage() , setendpage() set range of pages searching. if set start , end page same page number, know page search term found on. in code below, using windows forms application can adapt code fit application. using system; using system.windows.forms; using org.apache.pdfbox.pdmodel; using org.apache.pdfbox.util; //the diagnostics name

php - Laravel Eager Loading Polymorphic Relationships -

trying eager load model , it's related model related model returns null though has related data. group model polymorphic 1:1 either game or gamer. group model relationship: public function groupable() { return $this->morphto(); } game model relationship: public function group() { return $this->morphone('group', 'groupable'); } gamer model relationship: public function group() { return $this->morphone('group', 'groupable'); } query load group game: $group = group::wheresubdomain($id)->first(); $game = $group->game; group returns group game returns null. here sample database entry groups table: id subdomain groupable_id groupable_type 5 starmade 10 game here sample database entry games table: id genre rating 10 7 4.5 not sure going wrong have no game returned. try this. might help. public function groupable() { return $this->

jquery - Javascript amelioration for option changer -

i guys, made script shows different div box each different radio button option check, starting 1 default option selected + right div shown in beginning. heres jsfiddle it: demo i use jquery on website. idea on how make js code cleaner, easier , simpler, in case have more possible options (up 10) ? $("input[name='radio-269']").change(function() { if ($(this).val() == "1") { $('#1').removeclass("hidden"); $('#2').addclass("hidden"); $('#3').addclass("hidden"); } if ($(this).val() == "2") { $('#1').addclass("hidden"); $('#2').removeclass("hidden"); $('#3').addclass("hidden"); } if ($(this).val() == "3") { $('#1').addclass("hidden"); $('#2').addclass("hidden"); $('#3').removeclass("hidden"); } })

java - How to return different array values according to condition? -

i'm trying return different array values according condition. here code made error. please me find out what's problem. private static string subject[] = {"mathematics", "english"}; private static string studentnum[] = {"1", "2"}; private static int marks[][] = {{56,51}, // student 1 mark mathermatics {69,85}}; // student 2 mark english public static double averagemarks(string acode) { double sum[] = new double[subject.length]; double average[] = new double[subject.length]; for(int j=0;j<subject.length;j++) { for(int i=0;i<studentnum.length;i++) { sum[j] += marks[j][i]; average[j] = (sum[j] / studentnum.length); // average[0] average mark of mathermatics , average[1] average mark of english } if (acode.equals(subject[j])) { return average[j]; } else { return 0; } } }

c++ - Inserting a vector of unique_ptr into another vector -

i have vector of unique_ptr's , want append them vector of unique_ptrs. simple insert: std::vector<std::unique_ptr<foo>> bar; bar.push_back(std::unique_ptr<foo>(new foo(1))); std::vector<std::unique_ptr<foo>> baz; baz.push_back(std::unique_ptr<foo>(new foo(2))); bar.insert(bar.end(), baz.begin(), baz.end()); however gives me compile errors similar this: /usr/include/c++/4.8/bits/stl_algobase.h:335: error: use of deleted function 'std::unique_ptr<_tp, _dp>& std::unique_ptr<_tp, _dp>::operator=(const std::unique_ptr<_tp, _dp>&) [with _tp = foo; _dp = std::default_delete<foo>]' *__result = *__first; ^ is there convenient way insert or have iterate on baz , push_back on bar? i'm using gcc 4.8.1. thanks unique_ptr not assignable normal assignment operator (the error says it's deleted). can move them: bar.insert(bar.end(), std::make_move_iterator(baz.begi

javascript - dc.js Bubble Chart, plotting bubbles along the x-axis timeline -

i building bubble chart in dc.js having problems plotting along x-axis. the link graphs is: http://junklogic.com/dcjs/creatures/creatures.html the design of chart follows, using dataset of "mythical creature sightings" fun. each line of json this: { "creature_name": "dragon", "seenby": "ann", "date": "2014-01-25t22:10:58", "danger": 3, "location": "fl" }, each bubble grouped based on date , time of creature sightings. the bubble radius count of sightings individual @ particular time. the bubble color average of danger levels, summed , divided count reveal number 1-3 the y-axis calculation of danger levels multiplied count (i call "impact") the x-axis should plot bubbles based on timeline, same time range bar chart below it. stuck. all bubbles pinned @ pixel 0 , dont plot across. these reflect point across timeline. ideally, i'd group the

Backgrid sorting with undefined values -

i using backgrid. found 1 of columns has 'undefined' value. backgrid sorting doesn't work correctly when there undefined in column. looked source code. onclick: function (e) { e.preventdefault(); var columnname = this.column.get("name"); if (this.column.get("sortable")) { if (this.direction() === "ascending") { this.sort(columnname, "descending", function (left, right) { var leftval = left.get(columnname); var rightval = right.get(columnname); if (leftval === rightval) { return 0; } else if (leftval > rightval) { return -1; } return 1; }); } else if (this.direction() === "descending") { this.sort(columnname, null); } else { this.sort(columnname, "ascending", function (left, right) { var leftval = left.get(columnname); var rightval = right.get(columnname); if (leftval === rightval) { return 0; }

c++ - Closing process from service without killing the processes -

i searching way close process running under user windows service running under system account. i've tried not find solution except killing process. why can't kill process? can't kill process uses tray icon. if kill process, tray icon won't disappear. what i've tried far i've tried use global eventhandles (did not work because child process got extremely laggy). i tried use postmessage/sendmessage communicate process. solution did not work because windows service can not interact user interfaces,... i found question (here on stackoverflow) describes problem: close child process windows service . question not contain nice solution. first of don't use c++ instead of c#. next problem is, child process uses mouse hook. has run fast without many overhead. otherwise laggy mean, mouse lag on whole system. so there no simple solution close process windows service? a service can use setprocesswindowstation() , setthreaddesktop() attach

Can you retrieve a redirect URL from a page using Robot automation via python or javascript? -

i'm trying validate page redirect in iframe working correctly. ideally request gets sent server our gateway server, , redirected external page. because of way page handles permissions, best way validate succeeding confirming redirect has occurred , correct url. using robot / selenium automation, there way grab redirect urls , status codes in order compare them expected value? i've seen mixed answers on whether or not possible. the javascript navigator object seems might solve problem, i'm not sure how use in context of automation retrieve redirect urls. any advice appreciated. as tagged selenium , python, selenium python bindings allow current url with: driver.current_url you use validate url you're looking verify whether redirect resolves right page/url. depending on complexity of you're testing involving iframes , not, selenium might overkill. if you're looking more general answers far approaching problem of testing redirects in genera

api - Ruby Net::Http never times out -

i've got code parse web api, def parse(uri) http = net::http.new(uri.host, uri.port) http.use_ssl = true http.open_timeout = 3 http.ssl_timeout = 3 http.read_timeout = 3 http.verify_mode = openssl::ssl::verify_none request = net::http::get.new(uri.request_uri) request.basic_auth("viewer", "viewer") response = http.request(request) end but either i'm missing timeout or ruby ignoring timeouts. when hits network issue script never finishes , hangs forever. ideas?

Android: Send a touch event -

in android possible send touch events screen? want programmatically toggle button third party app sending touch event. this possible using 1 of these 2 approaches: root device direct injection /dev/input/eventx using inputmanager.injecttouchevent() using windowmanager.injectpointerevent() create accessibilityservice . notice not guaranteed work third-party apps.

java - Does POI XSSF still have crazy bad memory issues? -

a couple years ago, ran issues creating large excel files using jxls , poi xssf . if memory correct, think xssf create 1gb+ temp files on disk create 10mb excel files. stopped using jxls , instead used sxssf create excel files, today have new reasons use jxls or jett . both jxls , jett websites seem allude performance better, poi 's xssf website still says generically xssf requires higher memory footprint. wondering if higher memory footprint reasonable 10% overhead these days, or if still 10,000% overhead couple years ago. are crazy bad memory issues fixed poi 3.9 xssf ? should not worry using jxls or jett ? or there gotchas avoid? careful reusing cell styles. to answer question, yes, poi use large amount of memory when working on large xlsx files, larger size of xlsx files. don't think change anytime soon, , there pretty obvious reasons that: xlsx bunch of zipped xml files, , xml compressed (around 10x). getting xml sit in memory uncompressed i

regex - How do I convert my ivy code to maven if I use a regular expression? -

my ivy declaration is: <dependency org="pmd" name="pmd" rec="4.2.5" conf="static-analysis->default"> <exclude module="xom|xml-apis|jdom|dom4j|xercesimpl|ant|junit" matcher="regexp" /> </dependency> right have in maven as: <dependency> <groupid>pmd</groupid> <artifactid>pmd</artifactid> <version>4.2.5</version> <exclusions> <exclusion></exclusion> </exclusions> </dependency> i not sure how exclusion right. not sure how convert conf attribute ivy either. if 1 concentrates on dependency management, maven , ivy tools similar mission, quite different implementations. i don't believe regular expression exclusions supported maven, although appears form of wildcard support added in version 3, see mng-3832 my advice adopt simplest solution possible, explicitly list dependencies don&#

java - JScrollPane doesn't work properly -

mr. hovercraft full of eels i did said. apology still not showing :( private void initialize() { frame = new jframe(); frame.setbounds(100, 100, 760, 666); frame.setdefaultcloseoperation(jframe.exit_on_close); //frame.getcontentpane().setlayout(null); //frame.getcontentpane().setlayout(); textarea = new jtextarea(20,20); textarea.setpreferredsize(new dimension(100, 100)); textarea.setlinewrap(true); jscrollpane sp = new jscrollpane(textarea, jscrollpane.vertical_scrollbar_always, jscrollpane.horizontal_scrollbar_always); frame.getcontentpane().add(sp); frame.setvisible(true); } i'm following tutorial on youtube using windowbuilderpro in eclipse. want create (scrollable) jtextarea using jscollpane. though followed principles, didn't work! little thing consumes time decided ask guys :( kindly, can tell me why jtextarea isn't showing in jframe . public class projectgui { private jframe frame; private jtextfield url

c# - What does an integer look like when converted to a byte? -

Image
i want create byte array in c# , first , second bytes have 70 , 75 respectively: so did following: list<byte> retval = new list<byte>(); retval.add(convert.tobyte(75)); retval.add(convert.tobyte(70)); i thought function convert numbers byte , if put watch on arraylist @ runtime, little different, did not change. expecting see values in format of 0x00 still looks raw integers. am missing something? right-click watch window or immediate window , check hexadecimal display option. default set "unchecked" bytes, because visual studio ide assumes prefer read int values instead of bytes:

ruby on rails - bundle install fails on rugged but 'gem install rugged' works -

i trying install gitorious on redhat 5. following these instructions: https://gitorious.org/gitorious/pages/rhel_installation one of steps is: rake db:create rails_env=production that command fails foll error message: [ gitorious ] sudo rake db:create rails_env=production not find libdolt-0.33.14 in of sources run `bundle install` install missing gems. when ran 'bundle install' fails with: 0: makeup (0.4.4) /usr/local/lib/ruby/gems/2.0.0/specifications/makeup-0.4.4.gemspec gem::ext::builderror: error: failed build gem native extension. /usr/local/bin/ruby extconf.rb checking gmake... yes checking cmake... yes -- cmake .. -dbuild_clar=off -dthreadsafe=on -dbuild_shared_libs=off -dcmake_c_flags=-fpic package zlib not found in pkg-config search path. perhaps should add directory containing `zlib.pc' pkg_config_path environment variable package 'zlib', required 'libgit2', not found -- /usr/bin/gmake *** extconf.rb failed *** not create m

sql server - MS-Sql Selecting from Horizontally Partitioned Tables -

Image
i have horizontally partitioned table system, using check-constraints on date_key reference date yyyymmdd integer version of date (so check-constraints between yyyy0101 , yyyy1231). i have view uses union all tables. if execute select * mydatedtable dt inner join mydates m on dt.date_key = md.date_key , md.date_key = 20120115 the optimizer "knows" scan , read correct 2012 table (or index), , ignores other tables unioned. however if use lookup-value in mydates table (for example year ) not use check-constraint on key-relationship , ie: select * mydatedtable dt inner join mydates md on dt.date_key = md.date_key , md.year = 2012 , md.month = 1 , md.day = 15 (the optimizer "knows" 0 rows come tables outside range, show needs check index...) is there way ms-sql (2012) optimize correctly? assuming existence of following objects (two tables , 1 view): create table dbo.mydates2013 ( date_key int primary key, check (date_key

c - why a pointer can be assigned value? -

i have puzzle here: int *a=*b; a[1]=3; a[2]=5 a pointer array , assigned value b. in understanding, a[]should address, why in practice can assign value place pointer (in case a[]) to? explain? i'm assuming c, or c subset of objective c/c++, since c+, java, php, , other c-like languages don't use pointers. use code tags , single statement per line. the statement int *a = *b; creates pointer int. not pointer pointer int, pointer int. it sets current address in a dereference of b, whatever b is. did not show declaration of b. unless b of type int ** , should getting compiler warning. a not pointer array. pointer int. point single int, or made point array of ints. compiler can't tell difference.. if b of type int ** , or pointer pointer int, statement dereferences 1 of pointers , makes point first sub-array inside b. the code a[1] = 3; assumes pointer array of integers, , since compiler can't range checking, tries index array , save valu