Posts

Showing posts from July, 2011

ios - How to get the Entity property from which an average is taken in CoreData -

i've fetched values coredata entity , averaged , groupedby date results. query works great. now... i've want know dates results come from. output shown raw result. how make query spit out date / groupby value (given groupby criteria date) averages taken from the output ( { averageweight = 36; }, { averageweight = 22; } ) the code: nsfetchrequest *request = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"exercisedata" inmanagedobjectcontext:context]; [request setentity:entity]; // specify request should return dictionaries. [request setresulttype:nsdictionaryresulttype]; // create expression key path. nsexpression *keypathexpression = [nsexpression expressionforkeypath:@"weight"]; // create expression represent function want apply nsexpression *expression = [nsexpression expressionforfunction:@"average:"

c# - Set default text in textBox on button click -

i'm wondering how set default text in textbox on button click. when users closes form , open again text in textboxes stay. if closes entire app. tried code below, think solution way far working one. thank time. private void btn_savetext_click(object sender, eventargs e) { this.textbox1.text = textbox1.text; this.textbox2.text = textbox2.text; this.textbox3.text = textbox3.text; this.textbox4.text = textbox4.text; } it depends default text is? if going same value each time can set text property in design view, value in textbox each time. if want textbox save value user has put in, need way store information. possible ways be: set sql data insert/update procedure, set textbox load saved value sql table each time form loaded. set xaml, see question guide through that. (this option preferred setting sql data table store 1 value may bit extreme you). if want sessions advise looking here from nikita's comment save value .txt document also, ag

php - I have define a class and instantiate it and after that I am calling methods of this class but it is not giving any output? -

code here: $obj instance of class user.i calling methods not showing output <?php class user{ public $name; public $age; public function _ _construct($name, $age){ $this->name=$name; $this->age=$age; } public function sayhello(){ echo("hiiiii".$this->name."!!!"); } public function sayage(){ $a=time()-strtotime($this->age); echo " hello age is".floor($a/(365*30*60*60)); } } $obj = new user('xyz','16 july 1980'); $obj->sayhello(); $obj->sayage(); ?> just remove $var $obj. call $obj <?php class user{ public $name; public $age; public function __construct($name, $age){ $this->name=$name; $this->age=$age; } public function sayhello(){ echo("hiiiii".$this->name."!!!"); } public function sayage(){ $a=time()-strtotime($this->age); echo " hello age is".floor($a/(365*30*60*60)); } } $obj = new user('xyz','16

android - Libgdx - Actions; adding one action to multiple actors -

i have defined set of actions , trying add multiple actors. here's code: parallelaction actions = new parallelaction(); rotatebyaction rotateaction = new rotatebyaction(); rotateaction.setamount(rotationamount); scalebyaction scaleaction = new scalebyaction(); scaleaction.setamount(-0.01f); delayaction delayaction = new delayaction(); delayaction.setduration(0.05f); repeataction raction = new repeataction(); raction.setcount(100); actions.addaction(rotateaction); actions.addaction(scaleaction); actions.addaction(delayaction); raction.setaction(actions); for(monster mon : mons) // mons arraylist of type monster (which extends image) mon.addaction(raction); but above logic adds action last actor in arraylist. why can't use same action multiple actors? need define many actions actors, or there other way it? i looked upon pool here https://

arrays - How to check that is list of objects or list of strings in javascript? -

does know how check list contain objects or strings? in javascript arrays untyped, meaning: nothing take care of in it, if don't yourself. since array composite structure addressed integer value, can check every address exact type stored inside. if array created else. however, array type if find objects, strings , int's in it? other options: create own structure specify type on creation , throw error in add(item) method if items type violated create own structure in add(item) take care of type , write in property of structure

Git Command to know current repository -

any command know remote repository connected to? if browse directory contains .git folder. can run command know remote repository .git folder mapped ? there no 1:1 local:remote mapping git repos. every repo can have several remotes, or none @ all. you can use git remote -v list of remotes in local repo's config. note these aliases convenience, , can directly fetch , push remote repos using urls.

Deleting global references in JNI -

i not sure means: virtual ~optimizer() { jnienv *env = getjnienv(); env->deleteglobalref(mjavaoptimizer); mjavaoptimizer = 0; } what confuses me delete global reference , set 0. isn't deleting enough? why assignment 0 part? thanks in code, being in c++ destructor, has no practical use. it's programming pattern. in many contexts, variable accessible (visible) before or after holds valid value. during times, preferable hold known value chosen value can tested (a sentinel value) and/or misuse reliably caught in defined way (e.g., null pointer vs bad pointer). setting variable standard invalid value serves comment operation has invalidated previous value, might not obvious reading of immediate code.

java - Single-signon in android using Active Directory -

i'm trying implement single signon windows active directory can suggest me best approach. i've looked kerberos , accountmanger in android or sample implementation useful. thanks in advance note:i've searched google before posting question. check azure active directory authentication library android (adal) https://github.com/azuread/azure-activedirectory-library-for-android

php - How to use Elastic Search on top of a pre-existing SQL Database? -

i've been reading through lot of documentation how implement elastic search on website javascript or php. very introduction es . very complete documentation here , here . a whole crud . elastic search php: here , here , , here . so reason why i'm giving urls understand how use 1 or many of great documentations when having pre-existing sql db. i'm missing point somewhere: said elasticsearch create own indexes , db mongodb, don't understand how can use (gigantic) database using sql? let have mysql db, , use elasticsearch make research faster , propose user pre-made queries, how do that? how es works over/along mysql? how transfer gigantic set of datas (over 8gb) es db in order efficient @ beginning? many i using jdbc-river w/ mysql. fast. can configure them continually poll data, or use one-time (one-shot strategy) imports. e.g. curl -xput http://es-server:9200/_river/my_river/_meta -d ' { "type" : "jdbc",

javascript - jQuery: pasting contents as plain text -

using information on internet, got far: http://codepen.io/anon/pen/eeofw $('textarea').bind('paste', function () { var element = this; settimeout(function () { var text = $(element).val(); console.log("paste") }, 100); }); it seems work fine, wondering event can trigger put "clean" version of pasted text text area instead of copied contents. includes if text pasted html, word or other sources. there way strip out tags , such without hassle? i'm guessing i'm looking kind of regex solution haven't been able find one. put styled content hidden div, , retrieve innertext . if styled content in text : a=document.createelement('div'); a.innerhtml=text; b=a.innertext;

Creating an game menu in OpenGL tutorials -

i'm creating 3d game in opengl. main thing @ moment want know how can create menu? e.g. main menu, in game pause menu, options , gamer hud display hp etc. can point me in right direction can tutorials on this? also if can give hint on loading 3d models texture , animation opengl appreciated. of models , animation done in autodesk 3ds max, textures in ps cs6. try following link show complete walkthrough designing tetris game in opengl. read till end , go own way:- http://www.codeproject.com/articles/30775/tetrogl-an-opengl-game-tutorial-in-c-for-win32-pla

python - django: get model instance with dynamic variable name and value -

i have following error: cannot resolve keyword 'attrname1' field. choices are: codesectrepmodel, configcons, id . code: modelname1="configconsmodel" model1 = get_model('actsinformationretrieval', modelname1) print "model attr", model1._meta.get_all_field_names() #displays ['codesectrepmodel', 'configcons', 'id'] print "attrname1", attrname1 #displays configcons print "attr1", attr1 #displays ecofin attr1instance=model1.objects.get(attrname1=attr1) what's wrong? think problem get_model returns model class, not object. right? when doing .get(attrname1=attr1) the attrname1 keyword argument not variable. if want name fields dynamically can try .get(**{attrname1: attr1})

javascript - capture network resource requests on casper.click() -

with casper.on("resource.requested") , can capture resource requests , perform checks evaluation. on page load, pushing network requests url in array , traverse array find number of calls google analytics (i.e. _utm.gif). // google analytics calls testing casper.test.begin('test container tags', function suite(test) { casper.start("http://www.viget.com/", function() { }); var urls = [], links = []; casper.on('resource.requested', function(requestdata, resource) { urls.push(decodeuri(requestdata.url)); }); casper.then(function() { var index = -1; var found = 0; (var = 0; < urls.length; i++) { index = urls[i].indexof('__utm.gif'); if (index > -1) found = found+1; } casper.echo('found' + found); test.assert(found > 0, 'page load test complete'); }); //emit "re

mysql - SQL not connecting via php -

i have activated iis7 on windows 7 pc. have installed php , mysql i running following php code via localhost create d'base namely 'my_files.' <?php error_reporting(e_all); ini_set('display_errors', true); $con=mysqli_connect("127.0.0.1", "root", "pass"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } // create database $sql="create database my_files"; if (mysqli_query($con,$sql)) { echo "database my_db created successfully"; } else { echo "error creating database: " . mysqli_error($con); } ?> this error: "fatal error: call undefined function mysqli_connect() in c:\inetpub\wwwroot\db.php on line 4". (other php codes running fine.) may problem , solution? given error (undefined function) mysqli interface either not enabled in php.ini file or can't loaded ready. look in

actionscript 3 - Flash - Text changing after chaning frame -

i have custom button made using movieclip. have text filed inside display text. show different effect when user over,out , click on button added 3 frames different effects , change frame using mc.gotoandstop(x) when user performs action. it working fine till yesterday. since ever added effect textfield (with different font color , style) text value of text field reverting default/initial value set in design time. is expected? there work around other removing effects on text filed? i have code(listeners) written out side component (inside main class, not in timeline) flash timelines kind of static state machine; moving frame-to-frame runs of document code @ frame (every time). resets value of content state in during design time (so, frame = design + code). because of headaches model can cause, highly recommend of design & code in single frame. changing appearance programmatically easy enough, though. use textformat , apply textfield settextformat . // cre

File Locking in C++ For simultaneous Read and Write Lock -

how can lock file read , write operation. if "abc" file name in write lock, provide read lock on same locked file. in normal case want wait till write operation completion.so if there ways acquire kind of locking many programs use lock file signify file in use writing. the lock file later removed when done writing. for example, when process #1 start writing file example , creates file example.lock . later when done writing, removes example.lock . when process #2 want read file example first checks if file example.lock exists. if file locked write operations , process #2 have wait.

c# - Linq CSV Import with line-numers (index) -

i have import csv file. since line-order important data, need part of import (index). (workaround) following: string[] alllines = file.readalllines(sourefilepath, encoding.default); //add line-index (int = 0; < alllines.length; i++) { alllines[i] = + ";" + alllines[i]; } _sourcelist = (from line in alllines.skip(1) let data = line.split(new[] {';'}, stringsplitoptions.none) select new mappingsource { index = convert.toint32(data[0]), targetentity = data[1].trim(), targetfolder = data[2].trim(), targetlevel = data[3].replace(',', '.').trim(), folderdefinition = data[4].trim(),

Twitter Bootstrap and jQuery Validation Plugin - use class="control-group error" -

i've created form using twitter bootstrap framework , have integrated jquery validation plugin. have 1 form series of yes/no questions radio buttons validate ensure each question not empty - working well. i leverage bootstrap class="control-group error" make error text appear in red stands out user - "this field required" text in black , it's hard locate. there's example of how error text appear here: http://twitter.github.io/bootstrap/base-css.html#forms at end of section under "validation states". here's specific example shows red message after input field (i want error appear after have clicked submit button): <div class="control-group error"> <label class="control-label" for="inputerror">input error</label> <div class="controls"> <input type="text" id="inputerror"> <span class="help-inline">please correct

ios - how to pass data when button is clicked -

lets have 10 buttons. each button want pass text... e.g. button 1, new button 2, etc.... what want print text in nslog. hence created 1 method , passed button. not getting how can pass data it... [mybutton addtarget:self action:@selector(btnselected:) forcontrolevents:uicontroleventtouchupinside]; -(ibaction)btnselected:(id)sender { nslog(@"btnselected data %@", sender); // want print text respective button here... } but not getting... idea how done? try this, [mybutton setaccessibilityvalue:@"some text"]; [mybutton addtarget:self action:@selector(btnselected:) forcontrolevents:uicontroleventtouchupinside]; -(ibaction)btnselected:(id)sender { nslog(@"btnselected data %@", [sender accessibilityvalue];); // want print text respective button here... }

latitude longitude - How to increase the Zoom Level of Google Maps in wordpress -

here code have written add marker google map providing latitude , longitude. problem not getting zoomed google map. have tried setting zoom level 12 has no effect closed map. <script type="text/javascript"> var lat = 49.892231; var lng = -97.132530; var zoomlevel = 12; var allmarkers = []; var curmarkerinder = 0; var site_url = "<?php echo bloginfo('stylesheet_directory') ?>"; var map_left = 270; var map_top = 234; var bounds ; function open_window(markerid){ gevent.trigger(allmarkers[markerid-1],"click"); } if (latlangs.length > 0){ var mapoptions = { center: new google.maps.latlng(lat, lng), zoom: zoomlevel, scrollwheel: false, draggable: false, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map"), mapoptions); bounds = new google.maps.latlngbounds(); }else{ $("#map").remove(); }

javascript - PhpStorm how I debug php file when request is initiated from JS? -

i have no issue debugging php files independently when want see request server side(php) client side locally, can't. try putting breaking point inside php file, debugger stop on break point when debugging project using chrome. my php looks that: <?php $response = "super" <--this line has breaking point echo $response client side sending request server side looks that: function ajaxrequest(url, data, requestmethod) { $.ajax({ type: requestmethod, url: url, data: { json: data }, success: responsehandler }); } when run project in debug window in chrome url: http://localhost/jason/index.html?xdebug_session_start=19067 and in phpstorm debugger see waiting connection ide key 19067 chrome displaying code if request been sent , response has been received without stopping in php break point. after start php debugging, try right click in

java - Android:does current android SDK support developing an unlock app? -

i want make unlock app android, read 2 years ago has not been supported android sdk of time (mentioned here: https://stackoverflow.com/a/3840732/1986618 ). possible now? if not, way can see lots of these unlock apps on market? i've found answer on compareable question on stackoverflow link , may helps. there new feature named daydream in api 4.2 interesting you. it's feature. in addtion when @ section lockscreen widget may find hint access lockscreen itself. hope helps greetings

Asp.Net MVC Dynamic Model Binding Prefix -

is there way of changing binding prefix value comes request parameters? i have many nested search popups, , of them shares same viewmodel. i can add binding prefix fields when requesting search filters, don't know how can make [bind(prefix = "")] work values coming request parameters. // search filters bindingprefix need public actionresult search(string bindingprefix) { viewdata.templateinfo.htmlfieldprefix = bindingprefix; searchviewmodel model = new searchviewmodel { bindingprefix = bindingprefix }; return partialview("_searchfilters", model); } // post search filters values [httppost] public actionresult search([bind(prefix = model.bindingprefix)]searchviewmodel model) { } i don't know why want this, should work. in form on view, have hidden value @html.hidden("bindingprefix", model.bindingprefix) modify action following [httppost] public actionresult search(searchviewmodel model) {

make a PHP script executable from CLI and include-able? -

consider this: #!/usr/bin/php <?php class foo { static function bar () { echo "foo->bar\n"; } } if (php_sapi === 'cli') { foo::bar(); } ?> i can execute cli, when include in, say, cgi-run php script, shebang ends in output. i simple scripts compact : guess put class part in separate "lib"-file , have simple wrapper cli use. i'd keep in 1 place without having worry include paths etc. is possible without ob_* -wrapping include capture shebang (if possible), or dumb cram of 1 file anyway? alternatives/thoughts/best practices welcome! edit: i'd put script in path , calling i'd rather not call php file.php . see comment @misplacedme's answer it's easy. remove shebang , when run script, run as php scriptname.php or /path/to/php scriptname.php instead of ./scriptname.php running php script.php in current directory, or directory within path. if absolutely

linux - Tomcat6 -> how to put a project into the root folder? -

i have tomcat6 server on linux server. structure of webapps directory is: examples host-manager manager root sample i have web application running on localhost on tomcat. created war file myproject.war , put webapps directory. restarting tomcat server, war extracted , have structure: examples host-manager manager myproject root sample calling url http://mysubdomain.mysite.com:8080/ tomcat start page with if you're seeing page web browser, means you've setup tomcat successfully. congratulations!. calling http://mysubdomain.mysite.com:8080/myproject/ page of project. what want, can access project url http://mysubdomain.mysite.com:8080/ , not http://mysubdomain.mysite.com:8080/myproject/ how can this? best regards. update have in server.xml: <host name="localhost" appbase="webapps" unpackwars="true" autodeploy="true" xmlvalidation="false" xmlnamespaceaware="false">

hadoop - Unable to find large files in Linux using "du -h" -

i have hadoop cluster running out of space recently. try clean logs disk space. run command df -h , shows: /dev/sda1 22g 20g 1.9g 92% / /dev/sda3 1.8t 747g 960g 44% /data/1 /dev/sdb1 1.8t 755g 986g 44% /data/2 /dev/sdc1 1.8t 754g 987g 44% /data/3 /dev/sdd1 1.8t 745g 996g 43% /data/4 the hdfs under dir /data fine. root dir / has little space left. used tool ncdu can calculate rapidly disk usage of dir, shows: 2.9tib [##########] /data 1.5gib [ ] /home 800.9mib [ ] /usr 716.3mib [ ] /var 349.1mib [ ] /lib 293.8mib [ ] /opt there no large directory. tried command such du -a | sort -n -r | head , still unable find invisible dir or file. know other way find out problem is? thanks i find answer. cause have deleted large log file didn't reclaim space in filesystem , it's still taking disk space. that's why result of commands du -h , df -h not match. solu

python - How can I create an EU quiz without 28 "if" statements -

i creating eu quiz. have gotten to: import random r import timeit tr import time t print "how many questions like?" q = int(raw_input()) count = 0 while q > count: aus_country = r.randrange(1,29) random import choice if aus_country == 28: country = "austria" country_1 = ['belgium', 'bulgaria', 'croatia', 'cyprus', 'czech republic', 'denmark', 'estonia', 'finland', 'france', 'germany', 'greece', 'hungary', 'ireland', 'italy', 'latvia', 'lithuania', 'luxembourg', 'malta', 'netherlands', 'poland', 'portugal', 'romania', 'slovakia', 'slovenia', 'spain', 'sweden', 'united kingdom'] country = choice(country_1) print "what capital of", country ans = raw_input() &

c++ - Well defined narrowing cast -

i'm trying come narrowing cast (a general solution) gracefully ignores lost data. in visual studio, narrowing cast loses data triggers "run-time check failure #1". not want turn off, instead i'm trying implement narrow_cast gracefully narrowing casts , wouldn't trigger run time check. visual studio suggests: char c = (i & 0xff); so started this, , came ugly solution: template< typename t > struct narrow_mask { static const t value = t(0xffffffffffffffff); }; template <typename t, typename u> t narrow_cast(const u& a) { return static_cast<t>(a & narrow_mask<t>::value ); } while works (vs seems fine losing data on constants), it's neither complete (no support non integral data), nor correct (i think not work correctly signed values). any suggestions better solution, or better narrow_mask implementation? edit: in face of comments question vs specific, checked standard document, , seems result of narrowi

multithreading - Get Process threads relationships in C# -

i have tried below mentioned code running process thread details. process proc=process.getcurrentprocess(); var threads=proc.threads; foreach (processthread pt in threads) { // code } from above code can able list of threads , corresponding thread state, etc. now requirement relationship between these threads ( 1 parent thread , child thread , relationship between them). please me , send me sample codes achieve requirement. thank you.

Add link to R Shiny Application so link opens in a new browser tab -

i creating first shiny application in r. using shiny display bivariate results survey conducted. pair of input boxes users can choose variables survey, , various statistics generated (tables, plots, etc.) allowing them explore attributes of survey data. i want include link actual pdf survey. right have written code pdf survey can linked to, clicking on text "click here download survey" appears helptext , embedded in wellpanel , within pagewithsidebar . used following commands (in ui.r file): wellpanel( helptext( a("click here download survey", href="http://www.dfcm.utoronto.ca/assets/dfcm2+digital+assets/family+and+community+medicine/dfcm+digital+assets/faculty+$!26+staff/dfcm+faculty+work+$!26+leadership+survey+poster.pdf") ) ) is there way automatically open file in new tab (of ie, firefox, etc.)? currently, functionality open link in same tab shiny app. have use forward , backwards buttons go app survey , again. right n

javascript - How to change text on a page? (Find and replace using jQuery?) -

i have block of hardcoded, uneditable html: <td id="v65-onepage-ordercomments-value" width="61%" valign="top" colspan="2"> order comments:&nbsp;(optional)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> <textarea name="order_comments" id="v65-onepage-ordercomments-input" rows="3" cols="55"></textarea> </td> i want replace "order comments (optional)", non-breaking spaces. preferably replace other html, header , paragraph tag. best way this? assumption find & replace using jquery? it it's textnode first child of parent div, can : var node = document.getelementbyid('v65-onepage-ordercomments-value').firstchild; node.nodevalue = 'new content'; fiddle or in jquery: $('#v65-onepage-ordercomments-value').contents().each(function() { if (th

r - matrix with row and column constraints -

i need solve n x n (n <12) matrix subject few constraints: 1.predetermined row , column sums satisfied. 2.each element in matrix having row number greater column number must 0 (so nonzero elements must in top right portion). 3.for given row, every element more 3 columns right first nonzero element must zero. so, 4x4 matrix might (the row , column constraints larger in practice, around 1-3 million): |3 2 1 0| = 6 |0 2 1 1| = 4 |0 0 2 1| = 3 |0 0 0 4| = 4 3 4 4 6 i have been trying use solver approaches in excel , have tried r based optimization packages have been unsuccessful far. any suggestions on how else might approach appreciated. thanks! test data: x <- c(2,2,2,1,1,1,1) rowvals <- c(6,4,3,4) colvals <- c(3,4,4,6) function construct appropriate test matrix (3n-5) parameters: makemat <- function(x,n) { ## first , last element of diag constrained row/col sums diagvals <- c(colvals[1],x[1:(n-2)],rowvals[n]) ## set off-d

jquery - KendoUI DropDownList to populate textboxes with data results using JavaScript -

thanks in advance... i'm new kendoui controls , trying resolve issue i'm having updating textbox fields upon changing item in kendo dropdownlist control. i'm populating dropdownlist using viewdata method when view loaded , calling json result method returns specific row use populate textbox fields. i'm able hit json event, reason error in jquery.min.js (jquery v1.9.1) file , function(data) never fires off , skips altogether. here's error jquery.min.js file... get http://localhost:52078/settings/getetilizelocale/7 500 (internal server error) jquery.min.js:19 b.ajaxtransport.send jquery.min.js:19 b.extend.ajax jquery.min.js:19 b.each.b.(anonymous function) jquery.min.js:19 ddlchange viewlocales:192 i.extend.trigger kendo.all.min.js:9 o.extend._change kendo.all.min.js:14 o.extend._blur kendo.all.min.js:14 o.extend._focus kendo.all.min.js:14 o.extend._accept kendo.all.min.js:15 o.extend._click kendo.all.min.js:14 b.extend.proxy.b.isfunction.i jquer

c++ - Where should non-member operator overloads be placed? -

i want overload operator<< class. should add overloaded definition std namespace? (since ostream operator<< part of std namespace) or should leave in global namespace? in short: class myclass { }; namespace std { ostream& operator<< ( ostream& ostr, const myclass& mytype ) {} } or class myclass { }; std::ostream& operator<< ( std::ostream& ostr, const myclass& mytype ) {} which more appropriate , why? in advance responses. you should put operator overload in same namespace class. this allow operator found during overload resolution using argument-dependent lookup (well, actually, since ostream in namespace std , overload overload found if put in namespace std , there no reason that). from point of view of design practices, operator overload more part of class's interface interface of ostream , belongs in same namespace class (see herb sutter's namespaces , interface principle ). from poin

AWS Web Application and Emails -

i have web app running through aws on 1 of ec2 servers, , i'd able send emails when users register. i'm wondering best way able send emails web app? googled around, , think options are: set own mail server (never done before) use amazon's simple email service somehow connect email server web hosting provided, , send emails there. (not sure if possible) has ever tried either of these methods, , comment on pros/cons? or perhaps there method? i should mention i'm running on windows server, , not linux. aws provides simple email service enables developers send emails using either api or smtp. dont have take pain of setting email server self. let me know platform using or into, can suggest something. php ruby , java, guess of platforms email sending libraries or gems, can plug , and use required credentials api ket or smtp user name , password. quite easy achieve this.if bound marketing stuffs generate reports, can integrate email sending module mail c

dlopen a dynamic library from a static library linux C++ -

i've linux application links against static library (.a) , library uses dlopen function load dynamic libraries (.so) if compile static library dynamic , link application, dlopen work expected, if use described above won't. can't static library uses dlopen function load shared libraries? thanks. there should no problem you're trying do: app.c: #include "staticlib.h" #include "stdio.h" int main() { printf("and magic number is: %d\n",dosomethingdynamicish()); return 0; } staticlib.h: #ifndef __staticlib_h__ #define __staticlib_h__ int dosomethingdynamicish(); #endif staticlib.c: #include "staticlib.h" #include "dlfcn.h" #include "stdio.h" int dosomethingdynamicish() { void* handle = dlopen("./libdynlib.so",rtld_now); if(!handle) { printf("could not dlopen: %s\n",dlerror()); return 0; } typedef int(*dynamicfnc)(); dynamicfnc func = (dynamic

c# - Split a string by a character -

i have string here: string filenameorginal = "lighthouse-126.jpg"; and trying split string 2, seperating "-" i have tried following, syntax error on spilt: string filenameorginal = drproduct["producthtml"].tostring(); string[] strdataarray = filenameorginal.split("-"); please help, not understand doing wrong. you need character instead of string: string[] strdataarray = filenameorginal.split('-');

c# - Error displaying DICOM image with ClearCanvas -

i have been working in displaying dicom image in c# clearcanvas, developer steve aided me in reading in tags image. however, have been stuck 2 weeks working on project of , on trying display image. have tried , added code steve helped , yet unable display dicom image. maybe i'm doing incorrect, can take @ code , tell me wrong or alternative way display it. have been trying project work in c# being able convert visual basic. obtaining same error on again. code posted below. enter string filename = @"c:\users\don jar\pictures\xray pics\fluro.dcm"; dicomfile dicomfile = new dicomfile(filename); dicomfile.load(dicomreadoptions.default); foreach (dicomattribute attribute in dicomfile.dataset) { console.writeline("tag: {0}, value: {1}", attribute.tag.name, attribute.tostring()); } int bitsperpixel = dicomfile.dataset.getattribute(dicomtags.bitsstored).getint32(0, 0); int width = dicomfi

Google Play Game Services with multiple user accounts -

i've released new version of game integration of google play game services leaderboards , achievements. better understanding of issue, here example: when user connects, popup window ask account use. let's i'm using account a. however, in g+ app, it's account b connected. when user go leaderboards, can share message friends but, that's not a's friends! that's friends of g+ connected account: b. it looks bug me that's not all. now, have disconnected b g+ app , connected instead. it's showing have no contact in circle playing game. that's not true. can see in public scores friend of mine. am misunderstanding something? or bug? last issue, problem of refresh? (i've tried refresh button no luck)

Grab Value from Javascript popup - use as php post value -

first off, if there better way of doing this? let me know... way seems kind of "hackish". here trying do: see in below input , have text field simple want appear <a> link. if user clicks it, want javascript pop box appear user entering email. want them hit ok, , send email value form , form submits via php post. i not know how grab value box , insert in form (if possible) can submit php . here code: <form id="frm1" action="login.php" method = "post"> <input onclick="resetpassword()" type="text" name="email" value="reset password" style="cursor: pointer; background:none; text-decoration: underline; border: none;" /> </form> <script> function resetpassword() { var x; var email=prompt("enter email reset password.", "example@email.com"); if (email!=null) { do

colors - Actionscript: ColorMatrixFilter for Photoshop's brightness adjust? -

i have b/w picture , need make adjustments - need increase it's 'visibility' (it gray, need make darker). know how reproduce photoshop's brightness adjust in as3? please note not same adjusting brightness in flash. difference is: in ps: brightness adjusts pixels have color different white. not white pixels, white pixels stay white in ps: lightness adjusts pixels, affects white pixels well. bringing lightness down makes image darker; unusable me , flash (although called 'brightness' there) i reproduce flash's brightness matrix: var m:array = new array(); m = m.concat([1, 0, 0, 0, value]); // red m = m.concat([0, 1, 0, 0, value]); // green m = m.concat([0, 0, 1, 0, value]); // blue m = m.concat([0, 0, 0, 1, 0]); // alpha new colormatrixfilter(m); ...however doesn't work sets image darker, including white parts. any ideas how reproduce ps's brigthness setting? or other matrix keeps white/light pixels light while darkening darke

javascript - How does Myspace refresh page without stopping music playback? -

i have been using new myspace quite time now, , astonished on design. elegant , have taken advantage of many html5 features. there 1 thing that, me, outshines other functionality , how navigate through myspace without having stop music playback. noticed few days ago while listening music, changed page , music player not reload. stay on fixed position , music still play, while page refreshing. , if log out, when log in music player play last song listening @ time left on. now long story short, question is: how achieve this? guessing saving current track position in cookie variable or in local storage playing, music player? how come not stop playing song when navigating through myspace? using html5 feature this? *note: inspecting code because thought using jquery.load() function, did not find trace of that thanks insight given @putvande, myspace feature achieved using html5 history api change browser url without refreshing page. combining jquery $.ajax can produce effects

java - How do I make JTree stop cell editing, when either Focus Lost or Left Click occurs outside JTree Location? -

what want happen while editing jtree, want commit edit if click outside of edit box. tree.setinvokesstopcellediting(true); helped, if click somewhere in jtree, edit gets committed. if click outside of jtree, jtextpane edit won't commit. question: question: how make jtree stop cell editing, when focus lost? or when left click outside jtree location? there prefered way this? note: in code below tried solve using focus listener annoymous inner class, , tried pseudocode whentreelosesfocus() { if( tree.isediting() ) tree.stopediting(); } that doesn't work because on edit focus changes celleditor component within tree, , see edit box flash on , flash off quickly. the solution doesn't have focus based, can left click outside jtree area. ssce follows (btw if run code convienence both spacebar , f2 rename nodes.) import java.awt.event.focusevent; import java.awt.event.focuslistener; import javax.swing.jframe; import javax.swing.jscrollpane; import javax.swing.jsplit

Using XMPP Framework for iOS: Receiving presence when a subscriber becomes available/unavailable -

i'm trying implement of delegate methods of xmppstream class, 1 of xmppstream:(xmppstream *)sender didreceivepresence:(xmpppresence *)presence . have 2 users registered, , both subscribed each other's presence notifications. thing noticed is, didreceivepresence method called when user authorizes. disconnecting and/or connecting user doesn't notify subscriber it. can receive notifications when i'm subscribed goes offline/online? code use send presence xmppstream is: - (void) goonline { xmpppresence *presence = [xmpppresence presence]; [_stream sendelement:presence]; } - (void) gooffline { xmpppresence *presence = [xmpppresence presencewithtype:@"unavailable"]; [_stream sendelement:presence]; } actually setup correct, wasn't subscribed user's presence notifications, thought if in roster i'd notifications automatically. don't forget have accept presence subscription request using acceptpresencesubscriptionrequestfr

BASH: Pattern match not working -

i using bash 3.2. can execute following command line: $ build_number=23332 $ if [[ $build_number != +([0-9]) ]] > > echo "bad build number ($build_number). no cpu time you!" > else > echo "build number ($build_number) numeric" > fi build number (2332) numeric" if change build_number to 23332a`, returns: bad build number (23332a). no cpu time you! now, i'll try put shell script: #! /bin/bash ... # # set options # while getopts :hu:j:b:p: option case $option in p) promotion_name="$optarg";; u) jenkins_url="$optarg";; j) job_name="$optarg";; b) build_number="$optarg" if [[ $build_number != +([0-9]) ]] error "build number must numeric" fi ;; h) printf "\n$usage\n" exit 0;; *) error "invalid argument";; esac done shift $(( $optind -

c++ - Removing a CCNode from std::list causes error in XCode -

i'm having trouble deleting items std::list containing ccnode object. xcode gives me following error when trying erase() element: error: address doesn't contain section points section in object file . or error: exc_bad_access code=2 @ assembly file. and crashes at: ccglbindtexture2d( m_pobtexture->getname() ); giving me exc_bad_access. each time run application 1 of errors. the remove() method correctly removes ccnode cclayer, disappears , node count goes down one. problem testobject still remains in testlist list, eating memory, cpu, , messing game. i wrote test case reproduce problem. here is: testlist = *new list<testobject>; testlist.push_back(*new testobject()); addchild(&testlist.back()); testlist.back().spawn(); testlist.back().remove(); std::list<testobject>::iterator test = testlist.begin(); while (test != testlist.end()) { if(test->isremoved){ testlist.erase(test++); } } the testobject class ccnode fo

c# - Ninject, using two way property injection to resolve cyclic dependency -

based on answers in question: cyclic dependency ninject , questions: ninject: give parent instance child being resolved both of these can use 2 way property injection resolve cyclic dependencies long change scope not default transient scope. tried doing that, i've got userservice , groupservice require each other (and please don't change classes or use third class, etc.!). i've got generic entityservicefactory uses ninject so: public static class entityservicefactory { public static tserviceclass getservice<tserviceclass>() tserviceclass : class { ikernel kernel = new standardkernel(); return kernel.get<tserviceclass>(); } } and services: public class groupservice : entityservice<grouprepository, group, dbcontext> { public userservice _userservice { private get; set; } public groupservice(grouprepository repository, userservice userservice) : base(repository) { userservice._groupservice = thi

Turtle in python- Trying to get the turtle to move to the mouse click position and print its coordinates -

i'm trying mouse position through python turtle. works except cannot turtle jump position of mouse click. import turtle def startmap(): #the next methods pertain drawing map screen.bgcolor("#101010") screen.title("welcome, commadore.") screen.setup(1000,600,1,-1) screen.setworldcoordinates(0,600,1000,0) drawcontinents() #draws bunch of stuff, works should not important question turtle.pu() turtle.onclick(turtle.goto) print(turtle.xcor(),turtle.ycor()) screen.listen() as understand, line says 'turtle.onclick(turtle.goto)' should send turtle wherever click mouse, not. print line test, ever returns position sent turtle last, nominally (0, 650) although not have major significance. i tried looking tutorials , in pydoc, far have not been able write successfully. i appreciate help. thank you. edit: need turtle go click position(done) need print coordinates. you looking onscreenclick() . method of turtlescre

c# - Why is this NHibernate code performing a chain of explicit casts? -

i looking through source of nhibernate project (version 3.3.1.4000) , noticed strange in anywherematchmode class: public override string tomatchstring(string pattern) { return (string) (object) '%' + (object) pattern + (string) (object) '%'; } why on earth cast char object , re-cast string? why cast string object before adding other strings? there performance bonus here, or edge case avoid? i'm looking idea behind code, because there must reason it. note: realized, got here resharper's "navigate to" feature , may decompiled code i'm looking at. if is, i'd know what's going on here. looks may artifact of resharper's "navigate to", looking @ source code nhibernate method looks this: public override string tomatchstring(string pattern) { return '%' + pattern + '%'; } nhibernate source code update: here's msil method: .method public hidebysig virtual instance string

c# - Create a lambda expression from a List of objects -

i'm trying implement multi-select filter pass generic repository. the repository filter method takes expression<func<t, bool>> parameter. generally apply filter filter(i => i.id == myid && i.name.contains(myname)) in case have set of values provided in list , want iterate through list , dynamically create part of lambda expression pass filter method. so call filter method filter(mygeneratedlambdaexpression && i.name.contains(myname)) where mygeneratedlambdaexpression resolve (i => i.id == myid1 || i.id == myid2 || i.id == myid3) , myid1, myid2 , myid3 values contained in list how go doing that? you need dynamiclinq . see this blog.

vb.net - How to check if Masked textbox is empty? -

i have several textboxes , masked texboxes in winform need check if empty, null or nothing before proceeding. the code have part working intended, if there empty texbox message telling user textbox empty , exits sub, reason not checking masked textboxes. maybe i'm wrong , checking them, since have mask they're not considered empty or null. your checking if masked texboxes empty appreciated. this code: private sub btncargarinformacion_click(sender system.object, e system.eventargs) handles btncargar.click each mycontrol control in me.groupbox1.controls if typeof (mycontrol) textbox if mycontrol.text.equals(string.empty) messagebox.show(string.format("please fill following textboxes: {0}", string.join(",", mycontrol.name))) end if if mycontrol.text.equals(string.empty) exit sub end if end if next dim partepersonaltableapt new personalobrada

How to disable a specific javascript file in Web Browser control in C# -

i'm using web browser control in c# project , want disable specific javascript file. there way that? script loading external website , want disable it. tx there's great article on @ javascriptkit.com dynamically removing external javascript or css file: to remove external javascript or css file page, key hunt them down first traversing dom, call dom's removechild() method hit job. generic approach identify external file remove based on file name, though there other approaches, such css class name. in mind, below function removes external javascript or css file based on file name entered: function removejscssfile(filename, filetype){ var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type create nodelist var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding

c++ - Cmake external library .a -

i have external library here: ${project_source_dir}/thirdparty/yaml-cpp/ it made makefile: thirdparty/makefile . executing makefile so: add_custom_target( yaml-cpp command make working_directory ${cmake_source_dir}/thirdparty ) i attempting link library, builds thirdparty/yaml-cpp/build/libyaml-cpp.a . this part not working : target_link_libraries(load_balancer_node ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a) i error: target "yaml-cpp" of type utility may not linked target. 1 may link static or shared libraries, or executables enable_exports property set. how execute makefile , link .a file? so makes sense cmake can't figure out dependencies here: have parse makefile , find output. have tell output someone. nearest can figure, best way use custom_command rather custom target: add_custom_command( output ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a command make working_directory ${cma

Need a basic submenu for my CSS navigation -

so disregarding styling , else, sub menu appear of navigation selections. right have basic list made on own using online tutorial. afterwards though, after searching through web, still have not found submenu navigation close code or understanding. this html code: <div class="navigation"> <li> <h2>services</h2> </li> <li> <h2>store</h2> </l <li><a href="#">photoshop</a></li> <li><a href="#">illustrator</a></li> <li><a href="#">web design</a></li> </li> </nav> </div> <div class="navigation blue"> <li> <a href="https://www.facebook.com/pages/argano-computer-services/268377233227887?fref=ts"> <h2>facebook</h2> </a></li></div><a h