Posts

Showing posts from August, 2013

How do I store HTML/XHTML in an XML file and then use XSLT to retrieve it? -

i have xml file containing documentation project of mine. i'm using xslt transform xml file html output in browser. now thing have entities contain html code. nothing complicated, <br/> tags. don't seem able make work. have tried "disable-output-escape" works in internet explorer. now i'm trying namespaces. have wrote in root tag. xmlns:h="http://www.w3.org/1999/xhtml" and changed tags <h:br/>, tags don't appear , still don't have line break. i assume i'm missing something. it's first time i'm working xslt. found mistake. had use copy-of instead of value-of.

visual studio 2008 - How to close tab in CMFCTabCtrl -

i have used cmfctabctrl in mfc application , have enabled active tab close button. m_tabcontrol.enableactivetabclosebutton(); but when click close button, tab not closed. how close tab properly??.. thanks. when click close button, wm_close message sent window used in addtab during initialisation. so, in child window, add wm_close message handler , this: void cmytabwindow::onclose() { // nb - must created tab ctrl parent cmfctabctrl *ptab = static_cast<cmfctabctrl*>(getparent()); ptab->removetab(ptab->getactivetab()); }

sql server - Nested Case statement in sql query -

my query declare @from datetime='01 feb 2013' declare @to datetime='28 feb 2013 23:59:59' select case when ( select top 1 f1.updatedon tickettypefollowup f1 with(nolock) f1.updatedon<t.updatedon , f1.ticket=t.ticket order f1.updatedon desc )is null ticket.ticketraisedon else ( select top 1 f1.updatedon tickettypefollowup f1 with(nolock) f1.updatedon<t.updatedon , f1.ticket=t.ticket order f1.updatedon desc ) end [start date] dbo.tickettypefollowup t with(nolock) --some tables omitted cast(ticketraisedon date)between ''+convert(varchar(19), @from, 100)+'' , '...

android - How to stop setOnItemSelectedListener from running in onCreate -

this question has answer here: load data setonitemselectedlistener 1 answer i set values in setonitemselectedlistener depending on selected in spinner. how can stop method being called oncreate? thanks in advance set setonitemselectedlistener spinner not onitemclicklistener take boolean field this boolean onload=false; and in oncreate set onload=true; and in onitemselectedlistener, this spinner.setonitemselectedlistener(new adapterview.onitemselectedlistener() { public void onitemselected(adapterview<?> parent, view view, int position, long id) { if(!onload) { } onload=false; } public void onnothingselected(adapterview<?> parent) { } });

Abort file upload with Javascript/Jquery -

how possible cancel pending post request using javascript/jquery? i have upload form large files , want offer possibility abort upload after submit button triggered without reloading whole page. var xhr = $.ajax({ //stuff}); //to canel call abort(). xhr.abort(); however, think requires further investigation. looked if jquery calls onaboort dom's event "stop waiting"/abort response.

java - JDBC Template - One-To-Many -

i have class looks this. need populate 2 database tables, shown below. there preferred way this? my thought have service class select list<> via resultsetextractor dao. foreach on list, , select list<> of emails individual person via resultsetextractor , , attach foreach loop. is there better way, or gets? public class person { private string personid; private string name; private arraylist<string> emails; } create table person ( person_id varchar2(10), name varchar2(30) ); create table email ( person_id varchar2(10), email varchar2(30) ); this best solved orm. jdbc, have hand orm you. executing n + 1 queries inefficient. should execute single query, , build objects manually. cumbersome, not hard: select person.id, person.name, email.email person person left join email on person.id = email.person_id ... map<long, person> personsbyid = new hashmap<>(); while (rs.next()) { long id =...

java - How to do Custom Serialization using GSON? -

i have case use gson custom serialization feature. class student{ public string name; public int rollnumber; public student(string name, int rollnumber){ this.name = name; this.rollnumber = rollnumber; } public int getrollnumber(){ return this.rollnumber; } public string getname(){ return this.name; } } class school{ public student[] students; public school(student[] students){ this.students = students; } public students[] getstudents(){ return this.students; } } now when do private static final gson gson = new gsonbuilder().disablehtmlescaping().create(); student[] students = new student[2]; students[0] = new student("sam", 1); students[1] = new student("tom", 2); school school = new school(students); gson.tojson(school); i output this: [{"name":"sam","rollnumer":1},{"name":"tom","rollnumer...

c - Chained macro invocations. Argument in parentheses treated differently? -

#define a(p1, p2, p3, p4) foo(p1, p2, p3, p4) #define b(s) a(p1, p2, (s), p4) here, a() macros binding, aimed increase portability should ever need call bar(p1, p2, p3, p4) , not want rewrite whole code base. now trying define b() make writing easier on me, p1, p2 , p4 have same values. this, however, not work, unless remove parentheses around s. what going on? passing a? turns out that: #define foo(p1, p2, p3, p4) p1 ## p2 ## p3 ## p4() i not sure p4 defined, though, have valid value. so, when pass (s) instead of s, p1p2 instead of p1p2sp4 . so passing "(" + + ")"? right! , (which concatinates it's inputs simple p1 ## p2 ## p3 ## p4 ) stops before third argument yes, foo produces p1 ## p2 ## ( s ) ## p4 and pasting parentheses p4 resp. p1 ## p2 produces invalid tokens whole thing refused. for token-pasting, parentheses big no-no.

http - How to upload file using vba with Access 2010 -

i trying use vba/xmlhttp in access 2010 database upload file. while going through process , i'm not receiving errors, nothing ends on web site. here's code called using: response = http_fileupload(showname, "www.website_name","post") public function http_fileupload(filename string, byval purl string, _ optional byval pmethod string = "get") string dim strresponse string on error goto errorhandler dim xmlstream object set xmlstream = createobject("adodb.stream") xmlstream.mode = 3 ' //read write xmlstream.type = adtypebinary xmlstream.open xmlstream.loadfromfile filename dim objhttp object set objhttp = createobject("msxml2.xmlhttp") objhttp.open pmethod, purl, false debug.print "file name " & filename & " size of file " & xmlstream.size objhttp.setrequestheader "content-type", "text/generic" objhttp.setrequestheader "content-length", xmlstream....

java - Spring data mongodb Find by nested attribute in document -

im using spring data mongodb, , wondering how can make find using nested attribute documents, using repositories. let´s imagine have document: { a:"val", b:{a:1, b:"test"}, b:{a:1, b:"test"} } and make find findbyaa(int a); but not works, can me please! ps:i willing not use mongotemplate repository. thanks

javascript - Why is SP.js not loading? -

i have researched pretty thoroughly , says code have below should load sp.js, cannot load. debugging get: newform.aspx, line 1667 character 5 script5009: 'peoplepicker' undefined and not see sp.js under view sources. <sharepoint:scriptlink name="sp.js" runat="server" ondemand="true" localizable="false" /> <script type="text/javascript"> executeordelayuntilscriptloaded(setwebuserdata(), "sp.js"); function setwebuserdata() { var pplpicker = new peoplepicker(); // set parent tag id of people picker. pplpicker.setparenttagid('main_x0020_contact'); pplpicker.setloggedinuser(); }; </script> any assistance appreciated. you using executeordelayuntilscriptloaded wrong. should pass function name, should this: executeordelayuntilscriptloaded(setwebuserdata, "sp.js"); without ()

iTextSharp generating corrupted PDF in WPF -

i new programming itextsharp. have application writes in pdf file. file written in word , saved in pdf (there 2 pages). problem is, when want write on pdf see data written on output pdf corrupted. don't understand why pdf gets corrupted? public sub writeform(templatefilepath string, newfilepath string, data formdata) 'input output files dim oldfile string = templatefilepath dim newfile string = newfilepath 'if file exists delete if system.io.file.exists(newfile) system.io.file.delete(newfile) end if ' open reader dim reader new pdfreader(oldfile) dim size rectangle = reader.getpagesizewithrotation(1) dim document new document(size) ' open writer dim fs new filestream(newfile, filemode.create, fileaccess.write) dim writer pdfwriter = pdfwriter.getinstance(document, fs) document.open() 'write data first page me.writedata(reader, writer, data) 'write second page me.ap...

php - SUM all points for each team player in different category -

i need sum of points (hiscore) each player. for i'm able sum either player1 or player 2. example in category 7, player 1 tom, , in category 5 player 2 tom. result should tom = 2+10 = 12 points. select sum(subpoints) hiscore, player1_id, player2_id, ( select count(current_record)*2 subpoints, player1_id, player2_id db category_id in (7,8) group player1_id union select count(current_record)*10 subpoints, player1_id, player2_id db category_id in (1,2,3,4,5,6) group player1_id ) hi group player1_id sample table: category_id | player1 | player2 | subpoints | -------------+---------+---------+-----------+ 7 | tom | mike | 2 | 5 | peter | tom | 10 | ---------------------------------------------- final result should be: player | hiscore | -------+---------+ tom | 12 | mike | 2 | peter | 10 | you can unpivot columns first , aggregate it: select player, sum(subpoints)...

express - App.get() in Node.JS -

using express can call function get() : var app = express(); app.get('/',function(req,res){ // stuff }) what equivalent in node.js ? how can same thing without express ? i guess way that var http = require('http'); http.createserver(function (req, res) { if(req.method === 'get' && req.path === '/'){ // stuff } }).listen(8080, "127.0.0.1");

linq - When aggregating C# datasets, how do I convert a DataSet into an DataTable Array for .Load()? -

i using .net 4.0. i'm trying aggregate many datasets identical schemas single dataset. each source dataset should contain same 3 tablenames other datasets. now, may assume data unique, across tables , datasets. i'm trying use .load() function stuck on third parameter. may misunderstanding .load() intended for, , if isn't best way accomplish task, means let me know. here's have far: private accessfilecollection accessfilecollection; private dataset allaccessdata; public void aggregatecollection() { foreach (accessfile accessfile in accessfilecollection.files.values) { foreach (datatable dt in accessfile.dataset.tables) { if (allaccessdata.tables[dt.tablename] == null) { allaccessdata.tables.add(new datatable(dt.tablename)); } } allaccessdata.load(accessfile.dataset.createdatareader(), loadoption.preservechanges, accessfile.dataset.tables); } } //accessfilecollection custo...

php - recursive array_diff()? -

i'm looking tool give me recursive diff of 2 arrays. envision web page 2 color-coded tree-structures. on each tree, green parts of array match in both arrays, , red parts of each don't match other. output of dbug i have code gives me nested array populate report. i'm developing new method should faster, need test values , structure, make sure gives output identical old method. is there out there can use? or need write this? or there way accomplish goals? there 1 such function implemented in comments of array_diff . function arrayrecursivediff($aarray1, $aarray2) { $areturn = array(); foreach ($aarray1 $mkey => $mvalue) { if (array_key_exists($mkey, $aarray2)) { if (is_array($mvalue)) { $arecursivediff = arrayrecursivediff($mvalue, $aarray2[$mkey]); if (count($arecursivediff)) { $areturn[$mkey] = $arecursivediff; } } else { if ($mvalue != $aarray2[$mkey]) { $areturn[$mkey] = $mvalue; } ...

Convert array of numbers into single Hex value in c -

using 'c' program i want convert array of numbers single hex value , array mentioned below. input: `unsigned char no_a[12] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x01,0x02,0x03}; the single number formed above array 123456789123. it's hex equivalent is 0x1cbe991a83`. expecting output : unsigned char no_b[5] = {0x1c,0xbe,0x99,0x1a,0x83}; i have implemented logic creating single number(123456789123) in long long 64bit(8byte) variable. have restriction without 64bit variable. have idea implement this........? thanks.... you can solve using 'long arithmetic': represent integers arrays of digits. converting base-16 require implementing division operation.

memory leaks - Why Spring Context not gracefully closed? -

on stop or undeploy/redeploy of spring framework 3.0.5 based web application following error logged in tomcat7's catalina.out : severe: web application [/nomination##1.0-qa] created threadlocal key of type [java.lang.threadlocal] (value [java.lang.threadlocal@4f43af8f]) , value of type [org.springframework.security.core.context.securitycontextimpl] (value [org.springframework.security.core.context.securitycontextimpl@ffffffff: null authentication]) failed remove when web application stopped. threads going renewed on time try , avoid probable memory leak. i thought of implementing servletcontextlistener , close() context there. however, found contextloaderlistener implements servletcontextlistener set in web.xml : <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> from javadocs: **contextdestroyed** public void contextdestroyed(servletcontextevent event) close root web applicatio...

sql server - recursive UDF inaccurate in SSRS with embedded SQL -

i creating report in report designer. dataset uses query looks like: select le.amount, dbo.fnmoneytoenglish(le.amount) tblxxx le le.id = @id the udf fnmoneytoenglish should return words like: thirty , 00/100 dollars but instead returns thirty i suspect because udf uses recursion, calling itself. when execute embedded sql in sql query window udf returns full "thirty , 00/100 dollars". it's report designer has trouble, returning "thirty". find odd because expect ssrs make 1 call database, udf execute , recurse. does report designer somehow decompose query , limited 1 call database? fyi, here udf: alter function [dbo].[fnmoneytoenglish](@money money) returns varchar(1024) begin declare @number bigint declare @minusflag bit if @money < 0 begin set @money = -1 * @money set @minusflag = 1 end set @number = floor(@money) declare @below20 table (id int identity(0,1), word varchar(32)) declare @below100 table (id int ide...

javascript - Simple js add for 3d -

im not sure why not working, i've tried many different ways doesnt want work, doing wrong? im trying add 3d inset parallax effect my html <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>title</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="3d.js" type="text/javascript" /> </head> <body> <div class="inset" style="margin:0 auto"> text here </div> <h1>3d inset parallax effect</h1> <p class="inset">the following example of how can create illusion of 3d inset block-level element (with parallax on scroll position) using basic css , jquery. see effect in action, scroll page.</p> <h2>example form:</h2> <form> <label> first name: <input class="inset" type="text" placeholder=...

typo3 - Extension Builder Frontend plugin showing Extbase object error -

i created extension using extension builder called "events". created frontend plugin. model created has attributes eventdate , eventtitle . controller has actions : show, list, , new. i added plugin page. not seem working. its showing me error @ : $events = $this->eventrepository->findall(); in eventcontroller . the php logs show me following error : fatal error: call member function findall() on non-object in ../typo3conf/ext/event/classes/controller/eventcontroller.php on line 44 the appache logs show me follwoing error : thu may 09 19:19:26 2013] [error] [client ::1] php 30. typo3\\event\\controller\\eventcontroller->listaction() /home/public/project/typo3/typo3_src-6.1.0/typo3/sysext/extbase/classes/mvc/controller/actioncontroller.php:277, referer: http://localhost/project/typo3/typo3/mod.php?m=web_viewpageview&id=74 how resolve issue ? please check if eventrepository correctly injected. check option "is aggregate root...

c# - Upload created xml file to Google Drive at certain intervals -

i upload specific xml file google drive account @ intervals. application creates xml file every 30 seconds. xml file name static. develop desktop application in .net platform , using c#. examined this url's instruction. when applied codes sample application, web based auth need upload file. my question is, can upload xml file without web based auth. thanks in advance. if there no user accounts needs involved -- if you're not uploading user's account -- can use "service accounts". there introduction service accounts on https://developers.google.com/events/8400075-3001/ if user account involved, it'd suggest ask permissions offline access. so, can retrieve new access tokens current expires. read more offline access on https://developers.google.com/accounts/docs/oauth2webserver#offline of our client libraries supporting it. can manually retrieve access , refresh token exchanging oauth2 endpoints. persist these tokens inject them client librar...

php - Replace tabs or multiple spaces -

i wanted check code valid trying (replaces tab(s) or multiple spaces 1 space. preg_replace('/\t+|\s{2,}/', ' ', $street); however if found tab , space together, wouldn't end 2 spaces then? original space & new 1 tab got replaced with. how can change spaces in string end being 1 space? as \s match both tabs , spaces (as other forms of white-space), should trick replace amount of consecutive white-space single space: preg_replace('/\s+/', ' ', $street);

sorting - Can't sort dates with PHP -

this question has answer here: how sort date array in php 4 answers i have php array looks this: $dates = array(); $dates['01-07-2013'] = 'dummy data'; $dates['01-21-2013'] = 'dummy data'; $dates['01-28-2013'] = 'dummy data'; $dates['01-20-2012'] = 'dummy data'; when using ksort($dates) it's not sorting them correctly. there way sort keys this? i expect sort return: '01-30-2012', '01-07-2013', '01-21-2013', '01-28-2013', those aren't dates, far php concerned. they're strings, it's applying standard string sorting rules it. you'll need define custom sort function use usort() , or convert dates format sortable string, e.g. yyyy-mm-dd

Grouping umbraco pages in folders without affecting URL -

one of our umbraco sites getting bit messy , wondering if there way of grouping pages in folders without affecting url. example if under homepage have top level sections, footer links , various other system pages. i'd group footer pages in footer folder, system pages in system folder don't want urls become /footer/page1, system/contact etc. is there nice way of doing this, maybe umbracourlname? there 2 answers, first turn on 'hide root folder' option in web.config - can have many folders in root - without them forming part of url. umbracohidetoplevelnodefrompath causes top level content items excluded url paths. example, pre-set true, so: [content]home = /home.aspx or /home/ [content]home\projects = /projects.aspx or /projects/ [content]footer\page1 = /page1.aspx or /page1/ [content]home\projects\about = /projects/about.aspx or /projects/about/ http://our.umbraco.org/wiki/reference/webconfig secondly there 4 'h...

Magento resource model not working -

i have following code: $recipients = mage::getresourcemodel('crm/crm_collection'); $recipients->getselect() ->joininner(array( 'link' => $recipients->gettable('crm/bulkmaillink'), ), "link.crm_id = e.entity_id", array( 'link_id' => 'link.id', )) ->where("link.queue_id = ? , link.sent_at null", $queue->getid()); $recipients->addattributetoselect('title'); $recipients->addattributetoselect('first_name'); $recipients->addattributetoselect('chinese_name'); $recipients->addattributetoselect('last_name'); $recipients->addattributetoselect('email1'); $recipients->addattributetofilter('email1', array('neq'=>'...

arrays - Why does this refactored ruby method return nil? -

i wrote method in class float takes float (seconds) , converts countdown timer. code works fine when write this: class float def to_countdown (self % 60) == 1 ? cd_sec = "#{(self % 60).to_i} second" : ( (self % 60).to_i == 0 ? cd_sec = "" : cd_sec = "#{(self % 60).to_i} seconds" ) ((self/60) % 60) == 1 ? cd_min = "#{((self/60) % 60).to_i} minute" : ( ((self/60) % 60).to_i == 0 ? cd_min = "" : cd_min = "#{((self/60) % 60).to_i} minutes" ) (self/3600) == 1 ? cd_hour = "#{(self/3600).to_i} hour" : ( (self/3600).to_i == 0 ? cd_hour = "" : cd_hour = "#{(self/3600).to_i} hours" ) (self/(60*60*24)) == 1 ? cd_day = "#{(self/(60*60*24)).to_i} day" : ( (self/(60*60*24)).to_i == 0 ? cd_day = "" : cd_day = "#{(self/(60*60*24)).to_i} days" ) countdown = [cd_day, cd_hour, cd_min, cd_sec].reject! {|c| c == nil} return countdown.to_sentence end end ...

mysql - Can someone explain this model.save() behavior in Django, test server vs. Apache? -

i have django model contains, among other things, product field restricted 128 characters: class sku(models.model): ... product = models.charfield(max_length=128, null=true, blank=false) ... at 1 point in app, read in user data , make sku out of it, , save it. turns out, data goes product field exceeds specified size of 128 characters. when app being served apache through wsgi, sku.save() command emits warning: /library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py:114: warning: data truncated column 'product' @ row 1 … that's is, warning. sku saved, , contents of product field truncated 128 chars. however, when i'm testing django's built-in test server, sku.save() command results in crash, , following (abbreviated) stack trace: file "/library/webserver/documents/acdc_cmd/trunk/promotions/promo_parsers.py", line 467, in createkitsandcontents thesku.save() file ...

jquery - How to send a form using javascript without being redirected? -

i use work submit(callback) jquery method, in callback serialize form , ajax post call. but time, need upload file, , method desn't seems work, try directly submit form submit() jquery method, not able avoid redirection, calling e.preventdefault(); before: $('form.input.upload').change(function(e) { e.preventdefault(); $('form.example').submit(); }); you have preventdefault in onsubmit event of <form> , not in onchange event of <input> : $("form.example").on("submit", function (e) { // preventing browser's native form submit e.preventdefault(); }); $("form.example input.upload").on("change", function (e) { // auto-submit if input.upload changed $("form.example").submit(); }); update: before edit wasn't correct. onsubmit event fired clicking on <input type="submit"> or pressing enter in focused <input> . but: event not triggered if cal...

sftp - WinSCP timestamp retrieval from command line/scripting -

how last time stamp of .txt file winscp when using .txt , .bat scripting? well, should better state, want timestamp. might better answer then. anyway: winscp has stat command : stat /home/martin/index.html outputs like: -rwxr--r-- 0 20480 jan 5 14:09:33 2009 index.html you can redirect output of winscp script file , parse. or better use xml logging , parse xml log. easier solution may make use of winscp .net assembly method session.getfileinfo . an additional example (to linked in method documentation) here: https://winscp.net/eng/docs/scriptcommand_stat#net

JPA CascadeType priority? -

using jpa have question relating cascadetypes. for example: @manytomany(fetch=fetchtype.lazy, cascade={cascadetype.persist, cascadetype.merge, cascadetype.refresh}) is different this: @manytomany(fetch=fetchtype.lazy, cascade={cascadetype.merge, cascadetype.persist, cascadetype.refresh}) why? need cascadetype persist automatically insert referenced objects in entityclass. , need merge because dont want have double entries in tables. when define persist first, merging doesnt work, when define merge first, persist doesnt work. why? the jpa specification readable document , can downloaded here: https://jcp.org/aboutjava/communityprocess/final/jsr317/index.html inside on page 384 covers cascade attribute of manytomany annotation: the cascade element specifies set of cascadable operations propagated associated entity. operations cascadable defined cascadetype enum: public enum cascadetype { all, persist, merge, remove, refresh, detach}; value cas...

Google maps Jquery in Wordpress doesn't show anything -

new site , new-ish jquery. look @ temp site: www.bluelime.be/jibjib, there should googll-e map showing in header, doesn't. can check working template here: http://pentea.cap-tic.com/ the template i'm using one: http://preview.ait-themes.com/index.php?bartype=desktop&theme=directory i submitted question support theme, still no answer. i have feeling script not running... thanks in advance it appears these errors related $.browser this property has been removed in jquery 1.9 , guess using jquery 1.9 or newer not compatible used plugin-versions. check plugin-homepages compatible updates(recommended) or try use jquery-migrate

tomcat - problems deploying project in Worklight 5.0.6 -

running worklight 5.0.6 on tomcat 7 mysql 5.6 i dropped previous databases , let install manager recreate them. console runs fine , able upload wlapp , adapetrs. however, after deploying myproject.war following error every 5 seconds: severe: persistency data access problem com.worklight.core.exceptions.persistentdataaccessexception: persistency data access problem @ com.worklight.core.exceptions.defaultexceptionhandler.handleexception(defaultexceptionhandler.java:50) @ com.worklight.core.tasks.taskthread.run(taskthread.java:100) caused by: org.springframework.dao.invaliddataaccessapiusageexception: can perform operation while transaction active.; nested exception <openjpa-1.2.2-r422266:898935 nonfatal user error> org.apache.openjpa.persistence.transactionrequiredexception: can perform operation while transaction active. os: windows server 2008 r2 standard databases: appcntr, wlreport, wrklght content of context.xml <context> <resource name="jdbc/work...

c# - Compare folders using LINQ -

edit: editing question more details: i'm working on comparing 2 huge folders , figuring out files common in both folders. msdn has program using linq solve : article msdn however there problem i'm trying fix. let's have 2 folders. foldera , folderb. foldera , folder b has 2 subfolders 1 , 2. c:\foldera\1\a.aspx c:\foldera\2\b.aspx c:\folderb\1\a.aspx c:\folderb\1\b.aspx a.aspx , b.aspx identical in both foldera , folderb. note b.aspx exist in different subfolders though. current result: c:\foldera\1\a.aspx c:\foldera\2\b.aspx i expect result matches c:\foldera\1\a.aspx because match folder structure , file identical. would able modify filecompare class perform comparison of files lies in same directory structure? or what changes should make make sure comparison done correctly. thanks! sanjeev to make work, need adjust how equals() function operates. suggestion follows: step 1 - make path variables available equals() method: cl...

c# - ContentLoadException in MonoGame -

i've been trying load texture in monogame using xamarin studio. code set below : #region using statements using system; using microsoft.xna.framework; using microsoft.xna.framework.graphics; using microsoft.xna.framework.storage; using microsoft.xna.framework.input; #endregion namespace testgame { /// <summary> /// main type game /// </summary> public class game1 : game { graphicsdevicemanager graphics; spritebatch spritebatch; //game world texture2d texture; vector2 position = new vector2(0,0); public game1 () { graphics = new graphicsdevicemanager (this); content.rootdirectory = "content"; graphics.isfullscreen = false; } /// <summary> /// allows game perform initialization needs before starting run. /// can query required services , load non-graphic /// related content. ...

MySQL Query: Filtering search results by tags -

suppose have database table works link between 2 others. in case, link between book , tag, such "fiction" or "gardening". if have following dataset: book_id | tag_id ---------------- 1 | 13 1 | 43 1 | 15 2 | 13 2 | 25 what kind of query run "find books have links tags 13, 43, , 15"? is, more tags add, smaller number of books shown. i hope makes sense. in advance time , help!! try this select book_id book_tags group book_id having sum( case when tag_id in (13, 43, 15) 1 end ) >= 3 you need books have tags 13, 43, 15 (all of them), returns book_id = 1 result. sum() >= 3 specifies total number of tags searching, in case 3 , i.e 13, 43, 15 sqlfiddle

objective c - iOS hide default keyboard and open custom keyboard -

i have uitextview , when user taps on uitextview need hide default keyboard. have done, [mytextview seteditable: no]; so keyboard not shown, here have created custom view uibutton , need show uiview when user taps on uitextview , have done, textviewdidbeginediting{ //here have added uiview subview } but method not working because of, [mytextview seteditable: no]; and need close uiview when user clicks close button inside uiview you should using resignfirstresponder instead of setting uitextview not editable. hide system keyboard. [mytextview resignfirstresponder]; if want use different view keyboard system provided 1 set inputview on uitextview custom view want used in place of system keyboard. mytextview.inputview = mycustomview;

jquery - Jcrop IE8 not work -

i have problem jcrop. funcuina in other browsers not working in ie8. can not find problem. if problem of image data or image size not allow crop. can help?? <script type="text/javascript"> jquery(document).ready(function () { // create variables (in scope) hold api , image size var jcrop_api, boundx, boundy; var $targetimage = jquery('.targetimage'), targetimagedom = $targetimage[0]; var carregarjcrop = function () { $targetimage.jcrop({ onchange: updatepreview, onselect: updatepreview, aspectratio: 1 }, function () { // use api real image size var bounds = this.getbounds(); boundx = bounds[0]; boundy = bounds[1]; // store api in jcrop_api variable jcrop_api = this; }); function updatepreview(c) { if (parseint(c.w) > 0) { var rx = 231 / c.w; var...

sql - C# SMO Select from Database -

i have been racking brain trying figure out how execute select table using smo in c# , returning value string item. i have seen multiple posts of how can run sql script within c# not want do. here code have far public static void getdealerinfo() { server databaseserver = new server(dbserver); try { databaseserver.connectioncontext.loginsecure = dbsecure; databaseserver.connectioncontext.login = dbuser; databaseserver.connectioncontext.password = dbpass; databaseserver.connectioncontext.connect(); sdealername = databaseserver.connectioncontext.executewithresults("use database select datavalue table keyfield = 'dealershipname'").tostring(); } catch (exception ex) { console.writeline(ex); } { if (databaseserver.connectioncontext.isopen) { databaseserver.connectioncontext.dis...

c# - Returning the SqlDataReader -

i trying either pass reader reference or have 1 returned. , having issues on return. public static sqldatareader getsql(string businessunit, string taskid) { const string connstring = "connection string"; sqlconnection conn = new sqlconnection(connstring); sqlcommand command = new sqlcommand(); sqldatareader reader; try { conn.open(); command.connection = conn; command.commandtype = commandtype.text; command.commandtext = "select * audits businessunit = @bu , taskid = @tid"; command.parameters.addwithvalue("@bu", businessunit); command.parameters.addwithvalue("@tid", taskid); return reader = command.executereader(commandbehavior.closeconnection); } catch (exception ex) { return null; ...

c++ - Pass pointer array address to function and update data in the address -

i pretty weak in understanding , working pointers. so, please me here. my objective pass array pointer's address function ,(i.e.) address pointer pointing to, , update values directly in address using '*' operator, in function, avoid return values. moreover, length of array has changed dynamically in function passed. attempt. if there's better method update value of variable, without having returned function, please mention me. but getting errors, know doing wrong, still wanted try know, since thought best way learn , make many mistakes possible. please me here this main function int main() { double *trans; int *rots; readctrls(rots,trans); for(int i=0;i<trans.size();i++) { cout<<trans[i]<<endl<<rots[i]; } } here, trying pass address of pointer arrays function readctrls. later, print values. haven't mentioned size, cuz determined later in function. the...

oracle - PL/SQL function returning no value -

i getting ora-06503 error "function returned without value". wanted know whether error occurs when query inside function finds null value , function trying return null value retrieved ? here function outline - function getemailaddress (user in varchar2) return varchar2 v_email xxxxtable.email%type; begin select email v_email xxxxtable user_id = user; return v_email; exception when others return constantvalue; end getemailaddress; any clarification here helpful thanks returning null still counts returning value. selecting no rows raises error. possibly trapping exception when others clause, bad habit into.

Is the a mechanism in Spring MVC to rename bean for JSON -

is there way rename bean properties in spring mvc response, i'm using content negotiation , response returned json. for example, if have class field called 'title' public class entity { @xmlattribute private string title; } in json created displayed so: "entity":{ "mycompany:title": "this title" } @xmlattribute annotation has name attribute, suggest try it:- public class entity { @xmlattribute(name = "mycompany:title") private string title; } updated: answer looks wrong. try following: @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class entity { @xmlelement(name = "mycompany:title") private string title; }

java - How to reflect a field that implements map interface? -

i'm trying value of following field via reflection: map<string,classloader> loaders0 = new linkedhashmap<string,classloader>(); but when try value using field.get(new linkedhashmap()) , following: java.lang.illegalargumentexception: can not set java.util.map field loaders0 java.util.linkedhashmap and seeing map interface not make new map interface set too. know how around this? field loadersfield = this.getpluginloader().getclass().getdeclaredfield("loaders0"); togglefinal(loadersfield); map<string, pluginclassloader> loaders0 = (map<string, pluginclassloader>) loadersfield.get(new linkedhashmap<string, pluginclassloader>()); loaders0.put(description.getname(), bcl); loadersfield.set(map.class,loaders0); this statement loadersfield.set(map.class,loaders0); means trying set field loader of object map.class value loaders0 . what want call on instance of class has field loader . loadersfield.s...

c# - Building a custom predicate to act as a filter using a foreach loop -

i need filter list of documents passing them custom filter i'm struggling build dynamically using foreach loop : var mainpredicate = predicatebuilder.true<document>(); // mainpredicate combined other filters here ... var innerpredicate = predicatebuilder.false<document>(); foreach (var period in periods) { var p = period; expression<func<document, bool>> inperiod = d => d.date >= p.datefrom && d.date <= p.dateto; innerpredicate = innerpredicate.or(d => inperiod.invoke(d)); } mainpredicate = mainpredicate.and(innerpredicate); this last line : documents = this.objectset.asexpandable().where(mainpredicate).tolist(); throws exception : the parameter 'd' not bound in specified linq entities query expression. anyone knows why i'm getting exception ? don't understand 'd' parameter passing inperiod method gets lost. don't know missing work. code same many other examples w...

Javascript: Printing floating point values with decimals and not with e- notation -

when print floating point 0.0000001 in javascript gives me 1e-7 how can avoid , instead print "normally" ? you can use this: var x = 0.00000001; var toprint = x.tofixed(7); this sets toprint string representation of x 7 digits right of decimal point. use this, need know how many digits of precision need. need trim off trailing 0 digits if don't want them (say, if x 0.04).

python - Application-scope variables in Flask? -

is there such thing application-scope python variables in flask? i'd implement primitive messaging between users, , shared data cache. of course, possible implement via database, wanted know maybe there db-free , perhaps faster approach. ideally, if shared variable live python object, needs satisfied strings , ints, too. edit: complemented (non-working) example from flask import g @app.route('/store/<name>') def view_hello(name=none): g.name = name return "storing " + g.name @app.route("/retrieve") def view_listen(): n = g.name return "retrieved: " + n at trying retrieve g.name, triggers error: attributeerror: '_requestglobals' object has no attribute 'name' i'm unsure whether idea or not, i've been using share data between requests: class myserver(flask): def __init__(self, *args, **kwargs): super(myserver, self).__init__(*args, **kwargs) #instan...

c# - replace texts between specified tag in given string -

what best way replace text between tag [[ text ]] example "x" using regex | for example: this [[is]] text [[new text]] and result have: this x text x i have triend that: string pattern = @"\[\[(.*)\]\]"; regex rgx = new regex(pattern); string input = "this [[is]] text [[new text]]"; string pattern = @"\[\[.+?\]\]"; var output = regex.replace(input, pattern, "x"); edit what if want iterate through each matches string pattern = @"\[\[(.+?)\]\]"; var matches = regex.matches(input, pattern) .cast<match>() .select(m => m.groups[1].value) .tolist(); or looking that string pattern = @"\[\[(.+?)\]\]"; var output = regex.replace(input, pattern, m=>string.join("",m.groups[1].value.reverse())); which return: this si text txet wen

How to ensure my self executing block is executed and ready for use in javascript -

i have 2 script files file1.js var module = com.utils.createnamespace('com.pdp.ordermysampletemplate'); (function(ordermysampletemplate) { ..... })(module); file2.js var module = com.utils.createnamespace('com.pdp.ordermysample'); (function($,m,ordermysample,ordermysampletemplate) { ...... })(jquery,mustache,module,com.pdp.ordermysampletemplate); and in jsp make call init method defined in file2 <script> $(document).ready( function() { com.pdp.ordermysample.init(); } ); </script> i js error saying variables com.pdp.ordermysample not defined. both file1,file2 , jsp invokes them downloaded ajax response question here how can ensure js files downloaded , self executing blocks executed can make use of variables invoke function inside it

python - Custom Syntax Highlighting with Sphinx -

good afternoon, i interested in creating custom syntax highlighter can used in sphinx environment. possible? if how go doing it? any appreciated! -sean background sphinx ( http://sphinx-doc.org/ ) internally uses pygments ( http://pygments.org/ ) syntax highligher. pygments supports adding custom syntax highlighter (lexer) described here http://pygments.org/docs/lexerdevelopment/ . example usage i try define new custom lexer in pygments , initialize new custom lexer in conf.py sphinx configuration file. small example should started: from pygments.lexer import regexlexer pygments import token sphinx.highlighting import lexers class bcllexer(regexlexer): name = 'mylang' tokens = { 'root': [ (r'mykeyword', token.keyword), (r'[a-za-z]', token.name), (r'\s', token.text) ] } lexers['mylang'] = bcllexer(startinline=true)

powershell - Shortcut that points to folder named the current date. YYYY_MM_DD Format -

so part of daily project. each day, create new folder store of our files day. named according current date, counter added front representing 'episode'. format wxyz_yyyy_mm_dd. ex: 0001_2013-05-09 0002_2013-05-10 0003_2013-05-13 0004_2013-05-14 the folders being created, need make shortcut take 'current' folder day. after working out options, seems powershell straightforward. know need use scheduler here, torn between deleting existing shortcuts create new one, or editing existing shortcut path values. not sure how increment episode , append date value. want appending strings here? i'm more versed in c++, , java shells. haven't worked them in long while here appreciated. you can create shortcuts in powershell using following. $sh = new-object -comobject wscript.shell $shortcut = $sh.createshortcut("c:\latest_folder.lnk") $shortcut.targetpath = "c:\foo\bar.txt" $shortcut.save() you don't need remove old 1 ea...

delphi - painting background from TSeStyleFont -

Image
i'm trying paint vcl style background tsestylefont in bitmap style designer .. there way draw background ? i have make try : - draw object first in bitmap using drawelement . - copy current bitmap nother clean bitmap using 'bitmap.canvas.copyrect' problem : methode not work correctly objects has glyph such checkbox ... var bmp, bmp2: tbitmap; details: tthemedelementdetails; r, rn: trect; begin bmp := tbitmap.create; bmp2 := tbitmap.create; r := rect(0, 0, 120, 20); rn := rect(0 + 4, 0 + 4, 120 - 4, 20 - 4); bmp.setsize(120, 20); bmp2.setsize(120, 20); details := styleservices.getelementdetails(tthemedbutton.tbpushbuttonhot); styleservices.drawelement(bmp.canvas.handle, details, r); bmp2.canvas.copyrect(r, bmp.canvas, rn); canvas.draw(10, 10, bmp2); bmp.free; bmp2.free; end; if want draw background of buttons must use styleservices.drawelement method passing proper tthemedbutton part. try sample uses vcl.styles,...