Posts

Showing posts from February, 2010

How do I hide .java files from the Open Resource dialog in Eclipse? -

in ideal world should able filter pattern or @ least file extension. never want open .java files in open resource, there's separate window called open type that. i saw this, it's not general solution: how hide .class files open resource dialog in eclipse? cannot mark .java files derived, because they're not! go project -> properties -> resource -> resource filters -> add there select: exclude all, folders, children (recursive) name matches: .java that should trick. regards, kayz

c# - Using an SQL View from an Entity Framework Code First version 5 -

i developing contact log in website using vs 2010, mvc3 , ef 5 - entities created using code first. data stored in sql server 2008 r2 set of databases. want display summary of contact log , have created view. create view dbo.contactlogsummaries select cle.contactlogentryid, cle.caseid, 'test' contactname, eu.username officeuser, cle.dateandtimeofcontact, clc.category, cle.contactdetails contactlogentries cle join contactlogcategories clc on cle.contactlogcategoryid = clc.contactlogcategoryid join control.dbo.endusers eu on cle.userid = eu.enduserid there 2 entities in contact log database ( contactlogentries , contactlogcategories ) , database first entity control.dbo.endusers in database. contact log contain large number of records. want able display records specific case. my question in 2 parts: can use sql view directly display summary on web page (perhaps reading class) can create code first object e

ios - UIView emanate rings matching shape of border -

i have been trying create custom view in ios emanates rings border. have drawn ellipse using core graphics , want periodically emanate. i have been looking use both caemitterlayer , core animation achieve have no idea how achieve effect want. ideally ellipse emanate ring 10 pixels in thickness edge of shape , gently fade grows , moves further away. for initial attempt had ellipse grow , fade every 3 seconds using core animation want if ellipse stay stationary , have layer animates. any suggestions great. my code has moved on initial attempt. have atm is: #import "thumbview.h" #import <quartzcore/quartzcore.h> @implementation thumbview - (void)drawlayer:(calayer *)layer incontext:(cgcontextref)ctx { [super drawlayer:layer incontext:ctx]; // create emitter layer , make same size view. caemitterlayer *emitterlayer = [caemitterlayer layer]; emitterlayer.frame = self.frame; // apply attributes emitter. emitterlayer.emittershape = k

reporting - Cognos: How to round an average of a data item result -

i'm using cognos report studio. i'm pretty new software. anyway, i've created query meant count number of days between 2 dates. there multiple records , need average of days. i'm able of this. result 6.57254211... want number rounded. can't seem figure out how this. achieved average applying aggregate function. though round applied same way. there no round in rollup aggregate function option. tried use _round() in data item code, returned error. plus, i'm pretty sure rounds each individual number get, not average of of them. know how this? i able round average creating query calculation , doing _round([weekdays]) code. [weekdays] being average need rounded.

javascript - How do I pass a view to another Backbone view? -

i trying create base table class in backbone. each subclass row have different look. want pass in view of row. trying add attribute set in child class, keep getting , error typeerror: cannot read property '_listenerid' of undefined . here parent class: var basetableview = baseview.extend({ template: null, rowview: null, initialize: function() { ... } }); here child class set row view up: var peoplecollectionview = basetableview.extend({ initialize: function() { this.collection = new peoplecollection(); this.template = peopletemplate; this.itemview = personview; basetableview.prototype.initialize.apply(this, arguments); } }); when go use personview in super class, use this: var view = new this.rowview({ model: item }); that when above stated error typeerror: cannot read property '_listenerid' of undefined . how can fix this, or if should set hierarchy different, how should done? help

javascript - how to pass ruby instance variable as params to js function in a rjs page -

i have instance variable @foo in create controller action , rendering create.rjs template. in rjs template need call js function (with page.call) , pass @foo params. how possible.. it's been years since i've used rjs, might work: page.call "your_function(#{ escape_javascript(@some_instance_var) })"

python - Data Abstraction Layer between tastypie and Django ORM -

i have been entrusted creating api large existing codebase , have decided use tasypie. problem app structure. we have database on top of djnago orm runs. app doesn't work directly orm though through set of methods (the data abstraction layer) handle things creating orm objects, validating them etc. i hook tastypie said methods benefits of throttling, authentication etc. have no idea how that. i've attempted write custom data source tastypie (like riak example have in docs) i'm thoroughly confused need override , each method does. so, sum up: how go adding data abstraction layer between tastypie , orm? is using custom data source right way? how go creating such custom data source? thanks. yup, tasypie that. simple hook api calls directly django orm functionality. you'd use classes related django models subclasses of tasypie's modelresource, , ithandles things work fast out of box. people want more customized interface data abstarction lay

ip address - Wifi subnet for IP addresses -

i have around 500 ip addresses. 172.45.67.1 - 172.45.67.200. how find wifi subnet these ip addresses? if use java api, great. if not, other technique determine subnet? your ip range appears part of class b ipv4 subnet based on starting octet value 172. http://en.wikipedia.org/wiki/ip_address#ipv4_subnetting as such subnet mask 255.255.0.0. http://www.subnet-calculator.com/subnet.php?net_class=b a class b subnet allows maximum of 65,536 addresses. your building may allocated slice of subnet people administering subnet. however, there no way of knowing how of subnet allocated building without further information (if there 500 addresses, cannot allocated 172.45.67.* there 255 addresses in range).

c# - Converting a Winform application to a service (Best way) -

i have (or company) simple watchdog application monitors memory, diskspace , connections , other stuff realated realtime database server. using application detect errors , notify system administrators email faults. send daily report on som kpi , other stuff. the problem there need logged inn server @ time solution (it created simple monitoring problems had has become application futher develop) , convert service avoid needs logged on @ time. the application written in c# framework 3.5. know there wcf , other stuff now. looked in vs (version 2012) , see removed service project used there, , there wcf. i dont have experice in field (.net technology) since i've done legacy c++ programming last 5 years @ work. does have som recommandation doing best way ? if move of logic class library, can create new service project, , use library within service that's generated. msdn has walkthrough on creating services walks through process, step step.

php - Count visitors of each day -

i've got array being generated mysql contains visitors of current week: array ( [0] => array ( [iid] => 2 [mid] => 123456 [name] => username [date] => 2013-09-03 18:19:23 ) [1] => array ( [iid] => 2 [mid] => 123456 [name] => username [date] => 2013-09-03 18:19:20 ) [2] => array ( [iid] => 2 [mid] => 123456 [name] => username [date] => 2013-09-03 18:10:42 ) ) each key visitor, need count each day how many visitors there in array. this array should return: mon: 0 tue: 3 wed: 0 etc as learned googling , finding count grouping multidimensional arrays in php have modified code , seems solve problem: $inputarray = ar

javascript - Knockout.js custom binding design -

i not understand logic behind following , hoping can me understand. cleaning web app , have found following lines of code. app mvc app using knockout.js. there several custom bindings setup following structure: var originalbindinginit = ko.bindinghandlers.binding.init; var originalbindingupdate = ko.bindinghandlers.binding.update; ko.bindinghandlers.binding = { init: function (element, valueaccessor, allbindingsaccessor, viewmodel, bindingcontext) { originalbindinginit(element, valueaccessor, allbindingsaccessor, viewmodel, bindingcontext); // init code here... }, update: function (element, valueaccessor, allbindingsaccessor, viewmodel, bindingcontext) { originalbindingupdate(element, valueaccessor, allbindingsaccessor, viewmodel, bindingcontext); // update code here... } }; i not understand why init & update being set variables outside of binding , fired on first line of each section of binding? seem me creating loop doi

tomcat7 - getting "Servlet.init() for servlet PhpCGIServlet threw exception" when trying to configure php for tomcat 7 -

i'm trying configure php on tomcat 7 , every time try open php page, following error in browser: javax.servlet.servletexception: servlet.init() servlet phpcgiservlet threw exception org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:953) org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1023) org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) org.apache.tomcat.util.net.aprendpoint$socketprocessor.run(aprendpoint.java:1852) java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1110) java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:603) java.lang.thread.run(thr

excel - VBA script when dividing by zero -

i trying formula in vba, coming across errors because of 0 in denominator. if have 0 in denominator, i'd active cell set zero. whatever doing incorrect, , not programmer. have no idea i'm doing. appreciated. here range("h" & row).activate if range("f" & row) = 0 activecell.formula = 0 activecell.formula = range("g" & row) / range("f" & row) try using else something like range("h" & row).activate if range("f" & row) = 0 activecell.formula = 0 else activecell.formula = range("g" & row) / range("f" & row) end if

oop - Sending Multiple Mails In PHP Mailer -

i have been writing trigger mails email using php mailer. problem code is sending multiple mails single recipient. tried using function singleto didn't seem work. $mail = new phpmailer(); for($i = 0; $i <= sizeof($emailid); $i++) { $mail->wordwrap = 50; $mail->ishtml(true); $mail->singleto = true; $mail->addaddress($emailid[$i],$name[$i]); $mail->subject = 'some subject'; $mail->body = "some body"; $mail->altbody = "some body"; $errornumber[$i] = 1; if(!$mail->send()) { $errorinfo[$i] = $mail->errorinfo; $errornumber[$i] = 0; } } i using same script, set this: while(...) { $mail = new phpmailer(); //reset class instance new 1 ..... $mail->from = $fromaddress; $mail->fromname = $fromaddress; $mail->addaddress($toadress); .... } .... - same code have

java - What is the correct way to add this field to this entity? -

i have entity public class location{ private string name; private final set<string> sublocations = new hashset<string>(); public string getname(){ return name; } // corresponding setter public void addsublocations(string sublocation){ sublocations.add(sublocation); } public set<string> getsublocations(){ return sublocations; } } this class populated , stored mongo db collection. we have requirement of adding new field called "organization_group". logically, belongs under sublocation, add there. what pasted class right now. best way of adding 'group' child sublocations? create sublocation class? just need input on this, thanks! before answer question, whats difference between location , sub location ? single field name, me both class definitions same. are aware of composite pattern ? if location class needs represent tree data, should consider using composite pattern. now an

php - Use function but run it again if it has the same result as function before -

so i've made function random colour. problem im gonna print same function 8 times , dont want 2 of prints return same variable. want run function again if has printed colour before. function random_color(){ $color_numb = "8"; $color = rand(1, $color_numb); if($color == "1"){ $type = "blue"; } if($color == "2"){ $type = "red"; } if($color == "3"){ $type = "orange"; } if($color == "4"){ $type = "green"; } if($color == "5"){ $type = "yellow"; } if($color == "6"){ $type = "black"; } if($color == "7"){ $type = "purple"; } if($color == "8"){ $type = "white"; } return $type; } print random_color(); print random_color(); print random_color(); print random_color(); print random_color(); print random_color(); print random_color(); print random_color(); so idea how can manage this? instead

wpf - How to add Page to Navigation queue without displaying -

i pre-populate wpf navigation queue pages, in code need call .goforward() , .goback() (in case have 2 pages deal with) on frame , not worry .navigate() calling logic in middle of code. possible?

java - My response.sendRedirect isn't working -

i have smartgwt app , in filter in i'm trying figure out (on login) if request should forwarded (e.g. desktop mobile). code executes , browser makes request doesn't response , doesn't redirect. i've tried http://google.com , didn't work must else. public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws servletexception, ioexception { httpservletrequest request = (httpservletrequest) req; httpservletresponse response = (httpservletresponse) res; httpsession session = request.getsession(); wurflholder wurfl = (wurflholder) getfilterconfig().getservletcontext().getattribute(wurflholder.class.getname()); wurflmanager manager = wurfl.getwurflmanager(); device device = manager.getdeviceforrequest(request); boolean webbrowser = iswebbrowser(device); string path = ((httpservletrequest) request).getrequesturi(); boolean isbrowseronmobile = true; // webbrowser && path.contains(mo

powershell - Suffix to a variable -

i trying append suffix variable in order create path in powershell. let me clarify. $workingdirectory variable contains path c:\temp. however, use new-item command create item in path. item has called temp.csv. full path c:\temp\temp.csv. new-item $workingdirectory\temp.csv -type file would not work. overseeing basic syntax rule? does know how fix problem? in advance! you need put path in quotes work. new-item "$workingdirectory\temp.csv" -type file you can find out more escaping characters typing command in powershell console window ps c:\> about_escaping_characters

vb.net - How to encrypt in VB and PHP? -

i trying create php code encrypts text , in vb decrypt. php code: <?php if (isset($_post['text'])) { $buffer = $_post['text']; $extra = 8 - (strlen($buffer) % 8); // add 0 padding if($extra > 0) { for($i = 0; $i < $extra; $i++) { $buffer .= "\0"; } } $key = "phpandvb"; $iv = "password"; $fopen = fopen("merda.enc", "w"); $fwrite = fwrite($fopen, mcrypt_cbc(mcrypt_3des, $key, $buffer, mcrypt_encrypt, $iv)); fclose($fopen); } else { echo " <form action='index.php' method='post'> <table> <tr> <td>seu texto:</td> <td><textarea name='text'></textarea></td> </tr><tr>

javascript - Resize ArrayBuffer -

if want create arraybuffer, write: var buff = new arraybuffer(size) but how possible resize existing buffer? mean, adding more bytes @ end of buffer. var buf = new arraybuffer(32); buf[31] = 43; var buff = new arraybuffer(buf.bytelength*2); (var i=0;i<buf.bytelength;i++){ buff[i] = buf[i]; } buf = buff; i've done in c++ this. made bigger array , copy contents on , return larger array , set original.

android - How to do a custom sort of SQL data using Cursor & Loader? -

i have data in sqlite database , want provide basic search capabilities in listview. here example of search query want able solve : 1) example of sqlite data : ad bc cd d da ec 2) input & wanted output : a -> [ ad , da ] d -> [ d , da , ad , cd ] c -> [ cd, bc , ec ] i thought of few things nothing ok : full text search : cannot modify input db file think cannot use it one sqlite query ( name ?% or name %?% ) : not sorted. perhaps query not aware can figured out two differents queries ( name ?% , name %?% ) : how implement content provider ? cursorwrapper ? mergecursor ? custom loader ? i have seen lot of examples nothing useful custom search. thanks help. edit : query on d should give [ d , da , ad , cd ]. the custom sort order want is : pattern% , %pattern% (for example socks should come before a pair of socks ) here hack requirements: select distinct t.name (select *, 1 sec items name

oop - How to make property overrides of C# classes during runtime -

consider c# classes representing application data. instance class a properties: public class { public bool p1 { set; get; } public string p2 { set; get; } public int p3 { set; get; } } further have different time ranges in application. lets time range 1 , 2. @ first application set time range 1. instances of a exist in time ranges alike. switch time range 2 , set new value p2 of instance of a . new value should effect time range 2. upon switching time range 1, p2 should have old value. switching time range 2 , p2 new value again. whenever set value in data model should specific current time range , not effect others. on other hand values not changed should shared on time ranges. there no requirements whatsoever on how these time ranges should represented. might timerange class, might else. how design such scenario in c#? i think must replace property method, because realted time range. or include time range class if possible.

Installation of OS in android emulator -

i working on android emulator. upgraded kernel of emulator. want change os of emulator. know can select appropriate apis android sdk manager. want install jelly beans manually or can want upgrade ics jelly beans in emulator. is there way manually install source code of android 4.3 on emulator?? you can change api emulator uses , you'll have restart it. can't imagine change operating systems. create different avd each api use , run them when need them (with api 18 emulator running).

Basic input filename parsing in R -

i have log files in directory , want generate graphs each of them. have written r functions plot graphs , save in jpg files. csv files named "_par1_par2_par3_date.log" there way can par1, par2 , par3 values inside r code use calculations? integers, if helps. take files , generate graphs in single command vs giving single commands each of 100 or files. once read in of files want, can use str_extract() or str_extract_all pattern matching stringr package pull out items file name: > teststring <- "_2342_2773_23452_date.log" > library(stringr) > str_extract_all(teststring, "([0-9]+)") [[1]] [1] "2342" "2773" "23452" > str_extract_all(teststring, "([0-9]+)")[[1]][1] [1] "2342" then read values data frame , charts there.

c# - Moving Object with Paint Event -

i have test tomorrow, , must use paint event redraw our objects, may not use timer. as msdn says: "the paint event raised when control redrawn." , that,occurs known, when form minimized, or got invisible , visible. my code: public partial class form1 : form { public graphics drawarea; public int xpos, ypos; public form1() { initializecomponent(); } private void form1_paint(object sender, painteventargs e) { drawarea = e.graphics; drawuser(); } private void form1_keydown(object sender, keyeventargs e) { switch (e.keycode) { case keys.down: ypos++; break; case keys.up: ypos--; break; case keys.left: xpos--; break; case keys.right: xpos++; break; } } private void drawuser() { drawarea

Type of a function with Implicit parameters in Scala -

i have higher order function takes in parameter function accepts specific implicit parameter. to more precise, trying make function takes future creation method depends on implicit context , returns method doesn't depend on context. to more concrete, let's have this: def foo(a: int)(implicit ctx: executioncontext): future[float] = future { somelongbar... } i have method this: def providectx[a](func: executioncontext => a): = { val ctx = setupctx func(ctx) } but if call providectx(foo) , compiler complains implicit execution context missing. the fact dealing executioncontext not important. find how write parameter type accept function implicit argument of specific type. understand implicit part curryed argument, in fact have function so: executioncontext => int => future[float] , , pretty sure @ runtime, jvm doesn't know that executioncontext implicit, can't make compiler understand that. the problem foo method, not functio

meteorite - What options are there for creating universally accessible javascript functions (on the client side) in Meteor? -

i'm starting out meteor @ moment. js based project, helps have little algorithm library somewhere contains handy basic functions invoke throughout project code. i'm still getting head around app infrastructure, wondering 2 things making functions universally accessible across client side: 1) should functions go? 2) framework functionality should use (or used automatically) make them available throughout project? you should have "client" folder in meteor root application directory. inside it, create "js" directory, , put javascripts files in it. declare global vars , functions way : myvar=value; myfunction=function(arguments){...}; using classic syntax (var myvar=value;) cause symbols local source file. in "js" folder, can play order in scripts loaded (read docs futher details), basically, inside "lib" folder gets loaded first, , inside folders, files loaded using filename alphabetical order.

How to delete a message in PHP and MySQL? -

how can user delete message sends or other user sends? message should shown in conversation of 1 hasn't deleted message. if($action == 'delete_mess') { $hash=$_get['hash']; $mess_id=$_get['mess_id']; $mess_query=mysql_query("select * messages hash = '$hash'"); while($check_mess = mysql_fetch_assoc($mess_query)) { $from = $check_mess['from_id']; $to = $check_mess['to_id']; } if ($from == $session_user_id) { mysql_query("update messages set from_del = 1 `id` = '$mess_id' "); } else { mysql_query("update messages set to_del = 1 `id` = '$mess_id' "); } header('location: messages.php?hash='.$hash); } hash conversation id started.

c# - Add a custom namespace to visual studio generated service references -

i have project in vs (say myproject) , using namespace doesn't start name of project itself. example: class 'myclass', using namespace looks mycompany.myfeature.myproject.models. added service reference project , visual studio generated code me. however, classes generated vs use namespace starting 'myproject'. now, want change default namespace provided vs (i.e. myproject) namespace (i.e. mycompany.myfeature.myproject). i tried : http://www.thorarin.net/blog/post/2010/05/31/customizing-visual-studio-generated-service-reference-namespaces.aspx didn't work.

ios - How can I get individual numbers from a 4 digit number? -

i have 4 digit number ex. 1234 how can break down it's component numbers int = 1; int o = 2; int p = 3; int = 4; any thoughts appreciated. some basic math: int num = 1234; int = num / 1000 % 10; int o = num / 100 % 10; int p = num / 10 % 10; int = num % 10;

performance - Raytracer - What are the standard approaches for finding the the next ray intersection point and what are their pros and cons -

i not asking how compute intersection point of ray specific primitive, asking current approaches determining possible of millions of primitives in scene next 1 ray intersects. i have heard octtrees , kd-trees commmonly used. don't know whether there other methods current contenders. if octrees used, 1 allow each cube keep track of whether of 8 subcubes intersects goemetry? don't no corresponding branch , each subcube gets branch. 1 descends down tree until 1 finds final node gives limited number of primitives intersects? if 1 builds such octree 1 can trace rays moving one's ray starting point through cubes descending in each point 1 can either verify ray meets no geometry in cube or descend point 1 can check against small number of primitives (which ray might miss, requiring 1 move on next cube)? anyway, question of how 1 finds next intersection looks huge performance factor top approaches , pros , cons? this large topic. can find information on tis websi

Build errors while cross compile C source project with android standalone toolchain -

i m trying build old c code android standalone tool chain , keeps failing on following error : fatal error: ftw.h: no such file or directory not sure how include these headers android. thanks, ftw.h included in android-21 platform (ndk 10c): mba-anton:android-ndk-r10c asmirnov$ find /softdev/android-ndk-r10c -name "ftw.h" /softdev/android-ndk-r10c/platforms/android-21/arch-arm/usr/include/ftw.h /softdev/android-ndk-r10c/platforms/android-21/arch-arm64/usr/include/ftw.h /softdev/android-ndk-r10c/platforms/android-21/arch-mips/usr/include/ftw.h /softdev/android-ndk-r10c/platforms/android-21/arch-mips64/usr/include/ftw.h /softdev/android-ndk-r10c/platforms/android-21/arch-x86/usr/include/ftw.h /softdev/android-ndk-r10c/platforms/android-21/arch-x86_64/usr/include/ftw.h

recursion - Recursively search for a file name and copy in MS DOS -

i have text file containing names of files separated newline , folder many sub folders contain files matching names in text file. i want pick file names text file can done using for loop; , recursively search file name in folder , if file found copy different location. can please shed light on it? thanks, @echo off /f "usebackq delims=" %%a in ("file names.txt") ( /f "delims=" %%b in (' dir "c:\folder\%%a" /b /s /a-d ') ( copy "%%b" "c:\new folder" ) )

ruby - Rails 4: Own engine "No route matches" -

i write.. rails new testapp cd testapp/ rails plugin new blog --mountable cd blog/ rails g scaffold post name description:text rake db:migrate cd ../ rails s go localhost:3000/blog/posts/index , error "no route matches [get] "/blog/posts/index"" what i'm doing wrong? putting engine @ random directory inside application won't make magically work. don't know learned technique from, wrong. you should put engine outside application , require application's gemfile, this: gem 'blog', :path => '../blog' then engine automatically loaded rails. the engines guide goes more detail. highly recommend reading that.

Generic collection of MenuItems in C#? -

i working on displaying list of audio input devices in menu, , i'm new c#. number of input devices not varies machine machine, possible might add or subtract usb device while program running. wrote code checks whenever menu activated, have limit number of possible input devices. it's not there more 10 input devices, but, in order understand c# better, i'd see if it's possible use generic don't have limit list. here's have going code now: mainmenu sgfilemenu = new mainmenu(); list<menuitem> inputdevice = new list<menuitem>(); menuitem mymenuiteminput = new menuitem("&input devices"); sgfilemenu.menuitems.add(mymenuiteminput); (int = 0; < devicecount; i++) { mymenuiteminput.menuitems.add(inputdevice[i]); } that compiles gives argumentoutofrange exception when run it. i'm missing how generics set up- can clue me in? added after reading of comments- devicecount integer , not 0- that's checked someplace else

c# - LINQ Sum all properties -

is there elegant way this? assume working objects have excusively numeric properties (ints , doubles), this: foo -bar1 int -bar2 int -bar3 int -foobar1 double -foobar2 double and have collection of list...is there way have sum numeric properties in list , return single object foo totals? thanks so it can done using one-liner :-) item sum = (from p in typeof(item).getfields() type.gettypecode(p.fieldtype) == typecode.int32 || type.gettypecode(p.fieldtype) == typecode.double group p p g select new { prop=g.key, sum=items.sum(s => (decimal)convert.changetype(g.key.getvalue(s), typecode.decimal)) }) .aggregate(new item(), (state, next) => { next.prop.setvalue(state, convert.changetype(next.sum, next.prop.fieldtype)); return state; }); complete sample: using system; using system.linq; using system.collections.generic; class program { class item {

c - This declaration has no storage or type specifier -

i have function: void bs_gmm(img in_img,struct bs_gmm_var *gmm_ctxt,img *bg_msk,img *bg_img) in declaring variables like: int num_models,num_features; float lr,update_factor; float deviation_thresh; int std_dev_int; the thing when trying define or use these variables — example: num_models=gmm_ctxt->num_models; i getting 2 errors: regarding num_models : this declaration has no storage class or type specifier and gmm_ctxt : gmm_ctxt undefined i know local variables default auto storage class , had specified type of variable; why type of error? the function call main() in source file. i know overseeing something. forgive me ignorance. i had declared above mentioned function in header file , had included in both source files concerned. the structure bs_gmm_var declared in header , had included in both source files concerned.the declaration goes follows typedef struct bs_gmm_var { mean mean; std_dev std_dev; weight weight; classification_state class

subtraction - Hex Twos Complement Arithmetic -

i'm trying following problem: e8b2035d -fb60528d ---------- in which, integers represented hex representations of 32-bit two's compliment binary numbers. best approach solve problem, , detect overflow? subtraction becomes addition when use two's complement. take complement of second number, add them: as know, two's complement of number starts out turning every 1 0 , vice versa (handy rule of thumb: 15 - number, f -> 0, e -> 1, d -> 2, etc): fb60528d --> 049fad72 then add 1 number (in case, 2 + 1 = 3 , , there no carry): 049fad73 -- two's complement of fb60528d now add numbers, using conventional rules of addition: e8b2035d 049fad73 + ---------- d + 3 = 10 : write 0, carry 1 1 + 5 + 7 : write d, carry 0 3 + d = 10 : write 0, carry 1 1 + 0 + : write b, carry 0 2 + f : write 1, carry 1 1 + b + 9 : write 5, carry 1 1 + 8 + 4 : write d, carry 0 e + 0 : write e the final result (still in two's complement) is

objective c - Creating Custom NSString from NSDate -

i need nsstring format "yyyy-mm-dd - 11:00:00" year, month, , date should current date, while hour, minute, , second should 11,00,00. not figure how that. i think mean yyyy-mm-dd - hh:mm:ss (because mm minutes , mm month). need nsdateformatter *formatter = [[nsdateformatter alloc] init]; formatter.dateformat = @"yyyy-mm-dd - hh:mm:ss"; nsstring *string = [formatter stringfromdate:[nsdate date]]; or if want 11:00:00 , either pass nsdate , or could: nsdateformatter *formatter = [[nsdateformatter alloc] init]; formatter.dateformat = @"yyyy-mm-dd' - 11:00:00'"; nsstring *string = [formatter stringfromdate:[nsdate date]];

python - push notification using Django -

i new django , looking research , development project push availability , rates given resort list of subscribed clients based on resort ids have chosen subscribe to. know possible sql server , windows services how (if possible) done in django? can cms handle configuration this? saw this: tastypie but not sure in here after. anybody have experience push notifications via django? grateful pointers i see alot of questions pushing android system , iphone want simple push given url. have signals topic on documentation . @receiver(post_save, sender=mymodel) def my_handler(sender, **kwargs): ...

c# - Value does not fall within the expected range exception winrt -

i trying read xml: <player> <id>10101</id> <name>ricardo ferreira rodrigues</name> <shirtnumber>1</shirtnumber> <position>guarda redes</position> <realteam>5</realteam> </player> and have code : private async void loadxml() { try { storagefolder storagefolder = package.current.installedlocation; storagefile storagefile = await storagefolder.getfileasync("/users/1101046102/xml/players.xml"); string xml = await fileio.readtextasync(storagefile, windows.storage.streams.unicodeencoding.utf8); var doc = xdocument.parse(xml); txtnome.text = (string)doc.root.element("name"); txtshirtnumber.text = (string)doc.root.element("shirtnumber"); txtposition.text = (string)doc.root.element("position"); } catch (except

Android facebook send a message -

Image
i have send message facebook friend via android app.i have done functions , tried code send message facebook friend. but showing error dialog not available device. here code send message facebook friend: facebook facebook = new facebook(app_id); bundle params = new bundle(); params.putstring("to", constant.facebookidbuffer.tostring()); params.putstring("name", "goal machine");//title params.putstring("link", constant.shortappurlforandroid+"\n"+constant.shortappurlforiphone);//message facebook.dialog(_activity, "send", params, new dialoglistener() {//apprequests @override public void oncomplete(bundle values) { constant.facebookidbuffer=null; //posttowall("@"+constant.facebookidbuffer.tostring()+sendinvite); } @override public void onfacebookerror(facebookerror error) {

using variables in DBUnit load file -

is there way can use variables in load file in dbunit can populate dynamic data @ runtime e.g. <employee id="var" , name="emp1" /> and want var can supply. sorry if basic questions have started looking @ dbunit on someone's recommendation i found solution couple of days before, use replacementdataset. here example(i use replace fields null) public static idataset flatxml(file file) throws malformedurlexception, datasetexception { replacementdataset dataset = new replacementdataset( new flatxmldatasetbuilder().build(file)); dataset.addreplacementobject("[null]", null); return dataset; } <dataset> <t_f2g_pending_order tracking_id="2" delivery_time="2013-04-01 13:44:00" delivery_address_street1="north che zhan road" delivery_address_street2="kui zhao road" restaurant_id="[null]" /> </d

How to convert UTF-8 to unicode in Java? -

for example, in emoji char set, u+1f601 unicode value "grinning face smiling eyes", , \xf0\x9f\x98\x81 utf-8 bytes value character. \xe2\x9d\xa4 heavy black heart, , unicode u+2764 . so question is, if have byte array value (0xf0, 0x9f, 0x98, 0x81, 0xe2, 0x9d, 0xa4) , how can convert unicode value? for above result, want string array value "1f601" , "2764" . i know can write complex method work, hope there library work. so question is, if have byte array value (0xf0, 0x9f, 0x98, 0x81), how can convert unicode value? simply call string constructor specifying data , encoding: string text = new string(bytes, "utf-8"); you can specify charset instead of name of encoding - guava 's simple charsets class, allows write: string text = new string(bytes, charsets.utf_8); or java 7, use standardcharsets without needing guava: string text = new string(bytes, standardcharsets.utf_8);

sql - Get last 12 months data from Db with year in Postgres -

i want fetch last 12 months data db, have written query giving me count , month not year means month related year. my sql : select count(b.id),date_part('month',revision_timestamp) package inner join package_revision b on a.revision_id=b.revision_id revision_timestamp > (current_date - interval '12 months') group date_part('month',revision_timestamp) it gives me output month | count -------+------- 7 | 21 8 | 4 9 | 10 but want year month 7 - 2012, or year in other col, doesn't matter i believe wanted this: select to_char(revision_timestamp, 'yyyy-mm'), count(b.id) package join package_revision b on a.revision_id = b.revision_id revision_timestamp > date_trunc('month', current_date) - interval '1 year' group 1

c++ - Memory allocation and copy construcors -

https://stackoverflow.com/a/3278636/462608 class::class( const char* str ) { stored = new char[srtlen( str ) + 1 ]; strcpy( stored, str ); } in case member-wise copying of stored member not duplicate buffer (only pointer copied) but here memory being allocated new . why still said pointer copied not whole buffer? in class class have pointer named stored . when instance of class copied, e.g. class a("hello"); class b = a; // copying then pointer stored copied, have 2 objects same pointer. if delete pointer in 1 object other object still have pointer point unallocated memory. that's why need create copy constructor : class(const class& other) { stored = new char[strlen(other.stored) + 1]; strcpy(stored, other.stored); } now if have above copy constructor, when copying happening in first code snippet, new string allocated, , contents other instance copied. of course, need copy-assignment operator used when assigning

How can I improve JAXB performance? -

here conversion code. taking long time when dealing large data... calling method million times... see holding threads while. please suggest me ways improve performance! public class genericobjectxmlconverter<t> { private t t = null; private static jaxbcontext jaxbcontext =null; public genericobjectxmlconverter() { } public genericobjectxmlconverter(t obj){ t = obj; } protected final logger log = logger.getlogger(getclass()); /** * converts java object , xml string message type. * @param object object convert * @return string converted xml message string */ public string objecttoxmlmessage(t object) { stringwriter stringwriter = new stringwriter(); //jaxbcontext jaxbcontext=null; try { jaxbcontext = jaxbcontext.newinstance(object.getclass()); marshaller jaxbmarshaller = jaxbcontext.createmarshaller(); jaxbmarshaller.marshal(object, stringwriter); } catch (jaxbexception e) { log.warn("jaxbex

asp.net - Parse input and export to Excel file using specified format -

i asked produce excel file of specific format, using text input. user input text textbox in asp.net, parse/process , export excel. since excel file format specified, thinking of using reporting services 2005 , vb.net. open other suggestion though, provided vb.net used. thanks in advance :) why want use reporting tools this? if understand problem correctly, can using link using vb.net write excel

r - How to create a data.table with one row filled with NA based on another data.table -

say have following data.table (but think of table lot of columns dynamically changing names) dt <- data.table(a=rep(1l,3),b=rep(1.32,3),d=rep("qwe",3)) dt b d 1: 1 1.32 qwe 2: 1 1.32 qwe 3: 1 1.32 qwe say want create row nas rbindlist dt. first try (it not working) dt1 <- dt[1][,colnames(dt):=na] dt1 b d 1: na na na rbindlist(list(dt1,dt)) b d 1: na na na 2: true true na 3: true true na 4: true true na this not working because dt1 casted when :=na called (something called plonking seems, because if provide full column when := rhs type overwrite lhs...) the question then, how can extract row of data.table , fill na or create data.table , filled na have same column names , column type another there many ways of doing it, here's one: rbind(dt[na], dt) # b d #1: na na na #2: 1 1.32 qwe #3: 1 1.32 qwe #4: 1 1.32 qwe

python - Problems in importing self-defined packages and modules? -

Image
i using spyder. i have started building project. architecture shown. as shown, have 2 packages, 1 of has module called trajectorygeneration now. both __init__.py files automatically generated. trying import module main.py , ended such error messages: >>> generation import trajectorygeneration traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named generation how may fix problem? ( spyder dev here ) bug in spyder. not adding project's path pythonpath , that's why can't import project in console after open it. created issue , we'll fix in our next major release (i.e 2.3). a workaround (as mentioned @jblasco) use our pythonpath manager add project's path yourself. after doing it, need open new console changes can take effect.

java - How do I add buttons over an image using the netbeans IDE? -

i using netbeans ide make desktop application. i have add 3 buttons on image. how do that? have been unable using drag , drop features of netbeans. put buttons in custom panel image background ( example here ). in ide use regular jpanel , drag jbutton s on it, change code jpanel imagepanel (or whatever name used it).

How does the NewRelic agent work on Heroku? -

how newrelic agent know how many instances running or how ram app using? i'm wondering how can glean without running agent on system thought run application code on heroku, , not process? i'll assume you're referring ruby, agent not different on heroku except accounting integrations due new relic/heroku partnerships. if you're using new relic add-on heroku, memory usage displayed in "instances" tab average per process. new relic track instances being used app in time window select.

ember.js - routing error after updating emberjs -

i try update app emberjs version 1.0.0 rc8 1.0.0 route error . in application route have these code : olapapp.applicationroute = ember.route.extend({ setupcontroller: function (controller, model) { this.controllerfor('column').set('model', olapapp.axismodel.find()); this.controllerfor('row').set('model', olapapp.axismodel.find()); }, rendertemplate: function (controller, context) { this._super(controller, context); this.render('application'); this.render('column', { into: 'application', outlet: 'column', controller: 'column' }); this.render('row', { into: 'application', outlet: 'row', controller: 'row' }); }, dimenssiontree: function () { return olapapp.memodel.find(); } }); and error : deprecation: action handlers contained in `events` object deprecated in favor of

save - VHDL: The following files are missing: .stx, .ncd, .xrpt -

before start synthesis(as press "save"), warnings: warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter.stx missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter_map.ncd missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter_xst.xrpt missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/test.stx missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter.stx missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter_map.ncd missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/counter_xst.xrpt missing. warning:projectmgmt - file c:/users/bojanm/desktop/enkoder-digital output/test/test.stx missing. anyone knows what's problem? it's simple go to: project tab go cleanup project files , click

jquery form creation and submit multiple parameters aren't arriving at controller -

i have checkboxes , i'm getting values them with: var itemids = []; $('input:checkbox.itemcheckbox:checked').each(function () { itemids.push($(this).val()); }); then i'm taking these values , create form: var form = $('<form/>', { action: '@url.action("process", "items")', method: 'get', css: { display: 'none' }, html: $('<input type="hidden" name="itemids" value="' + itemids + '"/>') }); $('body').append(form); form.submit(); on submitting form method on controller is: [httpget] public filestreamresult movetofinanceprocessing(ilist<int> itemids) { ... } so reason i've implemented things way because i'm tryi

sql server - while taking count of two column result is not showing proper -

i have stored procedure this: alter procedure [dbo].[driverperformance] @ecode nvarchar(50), @startdate datetime, @enddate datetime begin declare @date1 datetime = convert(datetime, @startdate + ' 00:01:00.000', 120); declare @date2 datetime = convert(datetime, @enddate + ' 23:23:59.000', 120); select e.ecode,cast(q.dtime date) date, e.ename, count(q.ecode) cntecode , count(delecode) cntdelecode employeemaster_tbl e inner join transaction_tbl q on e.ecode = q.ecode q.ecode=@ecode , dtime between '' + @date1 +'' , ''+@date2+'' group e.ecode, e.ename, cast(q.dtime date) order cast(q.dtime date)--e.ecode desc end but not getting count of delecode proper ,what wrong stored procedure while checking count of delecode this:select * transaction_tbl dtime >='2013-09-03 00:00:00.000' , dtime <='20

php - Cakephp pagination ajax messes up the view -

so after long time , alot of hassle ive made ajax pagination work (sort of) now html looks this: <?php $this->paginator->options(array( 'update' => '#content', 'evalscripts' => true, )); ?> <div class="portlet box green report index" id="content"> <div class="portlet-title"> <div class="caption"><i class="icon-globe"></i>report summary</div> <div class="tools"> <a href="javascript:;" class="collapse"></a> </div> </div> <div class="portlet-body"> <table class="table table-striped table-bordered table-hover table-full-width" <thead> <tr> <th><?php echo $this->paginator->sort('offer.name','offer'); ?></th>

python - Was there a change in NumPy's asserts dealing with NaN -

i having troubles running code wrote year ago on older system (python 2.7 , belive numpy 1.6.1). built in lot of "assert_array_almost_equal" check running of program. far checked code comparing like >>> np.testing.assert_array_almost_equal([1.0,1.0,np.nan], np.ones(3)) which wasn't aware of. clealy raises assertion error. however, since code worked fine on previous system, wondered whether changed in "assert_array_almost_equal" , ignored nans before. i don't believe there have been changes lead behavior describing. documentation numpy 1.6.0 , 1.7.0 show same behavior: >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33333, 5], decimal=5) <type 'exceptions.valueerror'>: valueerror: arrays not equal x: array([ 1. , 2.33333, nan]) y: array([ 1. , 2.33333, 5. ]) numpy 1.7.0 assert_array_almo

php - Unexpected '{', expecting T_STRING or T_VARIABLE or '$' -

i have laravel 4 web app using third party package. worked fine on localhost i've uploaded appfog , it's throwing following error in thirdparty plugin: syntax error, unexpected '{', expecting t_string or t_variable or '$' somewhere on line: mail::{$mailmethod}(config::get('saasframe::email.view'), (array)$subscription, function($message) use ($user) you can view full error details here: chris-till-staging-app.eu01.aws.af.cm mail::{$mailmethod} perhaps this? are calling static variable? if so, try mail::$mailmethod

ios - AVAssetExportSession merge videos with stereo -

i merging multiple videos using avassetexportsession videos in stereo , resulting video in dual mono. possible use avassetexportsession merge videos , maintain stereo channels? see possible merge in stereo using avassetwriter , audiochannellayout stereochannellayout = {.mchannellayouttag = kaudiochannellayouttag_stereo, .mchannelbitmap = 0, .mnumberchanneldescriptions = 0 }; to make stereo using avmutablevideocompositionlayerinstruction avassetexportsession handle video positioning within merge ideal if there way avassetexportsession . i found can replace avassetexportsession sdavassetexportsession . can specify audio settings avassetwriter while leveraging benefits of avassetexportsession . i had change __weak typeof(self) wself = self; __weak sdavassetexportsession * wself = self; on line 172 of sdavassetexportsession.m .

How do I create a zip file with AES 256 encryption in iOS? -

i know there open source library able zip file aes 256 password on ios ? i google around. there aes 256 encryption (but not zipped). , there zipping library (but not aes256 encrypted). m curious why there not have aes encryption + zip while there has both free libraries so. i hope give me more ideas on zip + aes 256 encryption stuff. thank much.

cordova - How to customize Android ChildBrowser screen and integrate it to my Phonegap app's screen -

i using childbrowser in android phonegap app. , app has title bar. want place childbrowser below title bar. there js file named childbrowser.js inside android plugin. used "childbrowser.prototype.showwebpage" method, calls "showwebpage" method in childbrowser.java. , child browser created using dialog window , takes whole screen of device. adjusted size of dialog window , can see app in background see app well, should close browser window. how can integrate dialog window app child browser displayed below title bar (not on top of app). , creating screens of app using javascript. is possible modifying plugin source(like childbrowser.java)? if can, please tell me how modify source this? thanks in advance..!!

sql server - Import Oracle Database into Database Project -

Image
i'd able use visual studio database project against oracle server. i can connect against instance of sql server no problems, when attempt connect oracle datasource button greyed out: i sincerely hope it's possible use against oracle. if not there alternatives / workarounds. you need install following: oracle data provider .net oracle developer tools visual studio

Puppet - setting variables -

i have in puppet fle solr: define solr::core( $solr_home = "/opt/solr", $schema_xml = "searchapi_schema.xml", $solrconfig_xml = "searchapi_solrconfig.xml", $user = 'jetty' ) { .. i in node override variables $schema_xml , $solrconfig_xml, how do in nice way? i tried this: node web02 inherits webbasenode { $schema_xml = "apachesolr_schema.xml" $solrconfig_xml = "apachesolr_solrconfig.xml" ... but did not work out. it looks like, need definition accept parameters. example define solr::core ($schema_xml = "searchapi_schema.xml", $solrconfig_xml = "searchapi_solrconfig.xml"){ .... } in node, call definition updated parameters. example node web02 inherits webbasenode { solr::core { schema_xml => "apachesolr_schema.xml", solrconfig_xml => "apachesolr_solrconfig.xml" } }

PHP undefined offset array -

i'm trying use , array print out first 3 letters of months name (i know can date(), i'm learning arrays in php , seemed easiest). every time run code @ bottom receive error code below. notice: undefined offset: 8 in c:\documents , settings\garry\my documents\dropbox\htdocs\web-apps\locander2\alpha\step2.php on line 17 i issue if type 8 or 9 index part of $montharray[] . <?php $montharray = array(01 => "jan", 02 => "feb", 03 => "mar", 04 => "apr", 05 => "may", 06 => "jun", 07 => "jul", 08 => "aug", 09 => "sep", 10 => "oct", 11 => "nov", 12 => "dec" ); echo $montharray[8];

javascript - weird thing. working fiddle doesn't work on html -

weird thing. my http://jsfiddle.net/48hpa/19/ doesn't work when write html http://jsbin.com/ayeqeje/1/edit checked . have dom ready things , so, too. from jsbin, seems you're missing add jquery ui css file. <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/> once added working. see corrected jsbin link

c# - Rabbit MQ unack message not back to queue for consumer to process again -

i use rabbitmq queue message server, use .net c# client. when there error in processing message queue, message not ackknowleage , still stuck in queue not processed again document understand. i don't know if miss configurations or block of codes. my idea auto manual ack message if error , manual push message queue again. i hope have better solution. thank much. my code public void subscribe(string queuename) { while (!cancelled) { try { if (subscription == null) { try { //try open connection connection = connectionfactory.createconnection(); } catch (brokerunreachableexception ex) { //you want log error , cancel after n tries, //otherwise start loop on try connect again after second or so.