Posts

Showing posts from January, 2010

arranging maps from greatest to least based on their stored values in C++ -

ok kindof have 2 questions think they're sortof easy experienced programmer , similar. if bothers you, me 1 question & not other. have map(char, int) associates number of times character appears in string int value. problem i'm having can't figure out how print out associated values occuring least occuring. example, if type aabbbcddddd. a:2 b:3 c:1 d:5. i'm trying d:5 b:3 a:2 c:1. hope i'm explaining okay... second question. wondering how 1 go making maps same thing above series of letters or numbers. example: string: 'aabbb001c1 ddd'... "aabbb", "c", , "ddd" seperate words. "001" , "1" numbers, not equal. tried using 2 seperate map(string, int) (one words 1 numbers), series cutting off when character that's not of "type" appeared, nothings working. technique or advice nice. here's code have far. #include <iostream> #include <string> #include <sstream> #incl

java - @RequestBody is not working when used along with params attribute in @RequestMapping annotation -

my code below works fine , reads xml content @requestbody parameter @requestmapping(method = requestmethod.post, value = "{clientcode}/paybycell.xml") public modelandview paybycell( httpservletrequest request, httpservletresponse response, @requestbody string xml, @pathvariable("clientcode") string clcode, @requestparam integer customerid) throws invalidrequestxmlexception, internalexception, exception { info("request body=="+xml); getservice().validatecitycodecid(clcode, customerid); paybycell(xml, clcode, customerid); response.setstatus(httpstatus.sc_ok); return null; } the log file shows content eg request body==<?xml version="1.0"encoding="utf-8" ?> <paybycell> but wanted use same url pattern on different method baesd on request parameter,hence added params attribute in @requestmapping element shown below @requestmapping(method = requestm

PHP confirmation email -

i have registration form on website, upon completion details stored on csv file want send confirmation email user. issue email arrives blank, have done created template.php file contains email structure want send out, within template structure have function other file determines registration date. template within template.php wrapped within function call in from_to_csv.php part of mail() atrebiutes: hopefully makes sense , guys understand me have @ code: template.php : <?php function getmailcontent(){ $subject = "opes academy- workshop confirmation"; $message = " <body style='background-color: #eeeeee; margin: 0 auto; font-family: 'lato',sans-serif'> <table style='background-color:#ffffff' width='600' heigth='auto' cellspacing='0' cellpadding='0' align='center'> <tr> <td> <table width='600' style='background-color: #5e8ab5;

CakePHP's CakeTime format for minutes -

i don't understand result of caketime::format when using %i. debug(caketime::format('2014-01-10 15:00:00', '%y-%m-%d %h:%i')); outputs false debug(caketime::format('2014-01-10 15:00:00', '%y-%m-%d %h:xx')); outputs 2014-01-10 15:xx what correct format minutes? from documentation the formatting uses option strftime . , "m" right parameter minute, @user2711870 said. however, cakephp documentation wrong: // called via timehelper echo $this->time->format('%f %js, %y %h:%i %a', '2011-08-22 11:53:00'); // august 22nd, 2011 11:53 this should be echo $this->time->format('2011-08-22 11:53:00', '%f %js, %y %h:%m %a');

Spring @Autowired working without context:annotation-config -

i've tested behavior of auto wiring in case context:annotation-config element missing in application context xml file. surprise worked same. so here question: how come autowiredannotationbeanpostprocessor registered in applicationcontext though context:annotation-config element missing application context configuration file, or else mechanism makes configuration work? i'm using spring version 3.0.6.release project pom file: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <modelversion>4.0.0</modelversion> <groupid>org.springframework.samples.spring</groupid> <artifactid>spring-utility</artifactid> <version>1.0.0.ci-snapshot</version> <p

adding geolocation in webform using drupal 7 -

im newbie in drupal maybe im asking irrelevant question, goal user fill via google map api location. watched in youtube video ( http://www.youtube.com/watch?v=hdzembwmgpc ) possible geolocation module dont know how add field in webform. the final goal store in table in db whole form results of users. hope guys understood me. use location module along gmap module . location adds many fields content type form . use coordinate chooser add location coordinates. coordinate chooser - consists of latitude , longitude fields. if using gmap module users can enter these coordinates clicking on map. here's screencast walk through using both modules.

c++ - Undefining min and max macros -

in source code, saw min , max being undefined. reason that? // remove stupid msvc min/max macro definitions #ifdef win32 #undef min #undef max #endif some msvc header has pre-processor macros define min , max . bad many reasons. first, not reserved names, second, there standard library functions same names. so msvc or whatever breaking rules , code defining min , max macros, , use of undef work-around fix problem. see this related question , shows how defines can break code.

Business/Domain logic in domain models and service objects -

i trying design domain layer both rich models(anemic models bad oo practices). learned ddd not exclude service objects, , domain layer design healthy balance of domain logic split both domain models , service objects. wonder though, if business logic should divided between domain models , service objects, should line drawn? in other words, how know if business logic belongs domain model or service object? there rule of thumb specifies behavior should go domain models while others belong service objects? please let me know if can give little bit of hint, thanks. since domain services part of domain model, assume mean domain services vs. domain objects. toran billups has give similar answer here , jimmy bogard nice blog-post here . as general rule of thumb: domain services stateless, while domain objects have state. thus, depends on internal state go domain object, concepts not depend on current state and/or not conceptually fit single domain object modeled domain ser

Batch Delete Videos From YouTube Favorites Playlist -

i trying batch delete videos user youtube favorites using youtube v2 api. (see https://developers.google.com/youtube/2.0/developers_guide_protocol_batch_processing ) posting videos favorites in batch works nicely; , can remove single videos favorites without problem (this rules out problem authentication). my request body follows, videoid1 , videoid2 <yt:favoriteid> ids found in corresponding video xml: <?xml version="1.0" encoding="utf-8"?> <feed xmlns='http://www.w3.org/2005/atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'> <batch:operation type="delete"/> <entry><id>videoid1</id></entry> <entry><id>videoid2</id></entry> </feed> this response however, userid ofcourse userid of user , batchid batchid given service:

ruby on rails - adding a feature that formats a code in a blog -

i creating own blog. i add feature enabling users format code (based on wanted langage) before posting. my blog being written ruby on rails. how can this? thanks there ckeditor can download gem: gem install ckeditor which can drop in rails - documentation since you're using rails, it's super easy make safe drop database without worrying xss scripting attacks. it's highly customizeable, if there things don't want users (easily) able style through gui, can customize menu items show up. in fact, you're pretty familiar ckeditor - years ago known fckeditor. functionality you'll similar text editing features see here on stackoveflow.

css - Using data uri scheme in IE 8 for fonts -

how can fonts defined in data uris appear in internet explorer 8? here's background: i'm using tinymce html editor in web application, being used several organisations, of using ie has been set not allow font downloads. icons in tinymce implemented font, , therefore people can't download fonts can't see icons. i'm trying fix issue using data uri scheme in skin.min.css, says src:url('fonts/icomoon.eot') i've changed say src:url("data:application/vnd.ms-fontobject;base64,tcaaak...dojnto") this works in ie 9, isn't working in ie 8. according this wiki page data uris should allowed in ie8 if they're less 32kb , appear url expected in css. font 9kb. update: i've since discovered data uris not adequate solution problem of ie being set not allow font downloads in version 9. setting, web fonts aren't used if embedded within stylesheet. make sense security point of view, because malicious code reside in embedded base6

Why does a CTE in SQL Server execute the INNER JOIN when no conditions are met? -

i have table mse have rows statusid = 1 . in query inner joined view executed regardless of value of column statusid . how prevent it? with cte201401291517 ( select 'quantityoutpershift' = sum([vsqo].[quantityoutpershift]) , [mse].[shiftgroup] , [mse].[station] , [vsqo].[shift] [dbo].[mse] mse inner join [dbo].[vmsqo] vsqo on [mse].[station] = [vsqo].[fromstation] , ( [mse].[shiftgroup] = [vsqo].[shiftgroup] or [mse].[shiftgroup] = 'all') -- order important! [mse].[statusid] = 3 group [mse].[shiftgroup] , [mse].[station] , [vsqo].[shift]) update [dbo].[mse] set [dbo].[mse].[quantityoutpershift] = [cte].[quantityoutpershift] , [dbo].[mse].[shiftcurrent] = [cte].[shift] --output inserted.* cte201401291517 cte [dbo].[mse].[station] = [cte].[station] , ( [dbo].[mse].[shiftgroup] = [cte].[shiftgroup] or

angularjs - Javascript history api - window.history.forward() availability -

i have back/next buttons set phonegap app built in angular.js. i'm using partials in angular pages , using window.history simple back/next buttons. working i'd add visual feedback when , next functionality becomes available. is there way check if history.forward available? next page wont known, dont think looking through pages in history viable solution this, shouldnt kneed know page on or pages app contains, (sudo) if(window.history.forward()){ // show buttons available }else{ // show buttons not available } sadly history returns undefined, there other way? any suggestions great thanks history doesn't allow this, still can history.length check if there history @ (if not - disable both buttons). or can "dirtyhack" wrapping whole site or app 100% width|height borderless iframe on "index" page , log iframe's hisory "manually" top window (not advised @ all; work same domain only; not work "x-frame-options:

linux - Script does not run under cron but runs manually again -

i sorry asking again, i've tried advices. have 2 scripts in /var/tpbackup_script/ . first one: mysqldump -u root -ppassword teampass > /var/tpbackups/tpbackup_$(date +"%y-%m-%d").sql corresponding cronjob in /etc/crontab 20 9 * * * root sudo sh /var/tpbackup_script/tpbackup_script this script works in crontab. good. second script not run: s3cmd sync /var/tpbackups s3://pwdmgmt corresponding cronjob in /etc/crontab : 25 9 * * * root sudo sh /var/tpbackup_script/tpsyncs3_script this 1 fails. if run manually in terminal: sudo sh /var/tpbackup_script/tpsyncs3_script then works perfectly. tried: 1) trying add shebang #!/bin/sh beginning of script 2) renaming script tpsyncs3_script.sh 3) have added script cron.daily , in list of daily cron tasks (i see command run-parts --test /etc/cron.daily ) no success. here /etc/crontab file: # /etc/crontab: system-wide crontab # unlike other crontab don't have run `crontab' # comman

c - waitpid returns pid=0 and WIFEXITED=1 how to get pid? -

steps: fork , start process in different program group stop process sigtstp restart process sigcont process ends problem: sigchld handler has: waitpid(-1, &status, wnohang | wuntraced); upon return pid=0 , wifexited=1 so, process exited, can't pid? need pid. man page: "if wnohang specified , 1 or more child(ren) specified pid exist, have not yet changed state, 0 returned" but seems status has changed exited. the status meaningless if pid returned 0. think it. return of 0 means have 1 or more children have yet change state. state of child has yet change state be? if there multiple children, child status code referencing? this analogous checking errno on successful call. previous call can in errno has nothing recent successful call because errno not set on success.

css - base chart slice color on series value? -

right i'm using custom palette display warning level counts in pie chart. however, alarm comes in unexpected severity messes colors. set css classes warningpie, criticalpie or minorpie orange, red , yellow respectively. then, i'd use series label text apply class. i don't see in dxchart documentation make possible. anyoe have ideas? here full chart code if curious. dxpiechart: { datasource: fieldvaluecount(['severity']), palette: ['#cc3300', '#ff9900', '#ffff00', '#33cc33', '#0066ff'], animation: true, legend: { backgroundcolor: '#fcfcfc', border: { color: 'black', width: .5, visible: true, cornerradius: 10 }, visible: false }, series: [{ type: 'doughnut', argumentfield: 'severity', valuefield: 'count', label: {

asp.net - How to display only date in GridView when pulling data from a DB? C# -

i pulling data access database show in gridview control on asp.net project. works fine want see if can format data being pulled. currency being truncated xx.xx dollar amounts. dates displaying mm/dd/yyyy hh/mm/ss am/pm i tried editing database right values (i set currency field "currency" , date field "short date" when pull date still shows them not formatted. edit: sorry, had take code down any ideas? thank you in grid view of yours add property called dataformatstring dataformatstring examples: {0:dd mmmm yyyy} - gives 24 february 2006 {0:mmm dd} - gives feb 24 (substitue mmm mmmm full month name instead of abbreviation) {0:dd/mm/yy} - gives 24/02/06 {0:dd/mm/yyyy} - gives 24/02/2006 sample code <asp:boundfield headertext="date" datafield="sampledate" dataformatstring="{0:mm/dd/yyyy}" > msdn boun

ios - Reachability Resolves Host Name But Host Name Cannot be Pinged -

i used network utility in mac ping host name like: ssads.ads.asd (unfortunately, cannot share exact address). not able ping , timed out. // make sure host reachable networkstatus status = [[reachability reachabilitywithhostname:@"somehostnamethaticannotping"] currentreachabilitystatus]; when used above code resolves reachableusingwifi. how can reachable if cannot ping it? the machine on other end might blocking or ignoring pings. not machines reachable respond pings.

c# - Populating Dropdown using Reflection -

i using mvc4 , want use dropdown connected search box search selected property. how stuck on text= prop.name. how go through , access of properties using this. my controller public actionresult searchindex(string searchstring) { var selectlistitems = new list<selectlistitem>(); var first = db.bloodstored.first(); foreach(var item in first.gettype().getproperties()) { selectlistitems.add(new selectlistitem(){ text = item.name, value = selectlistitems.count.tostring()}); } ienumerable<selectlistitem> enumselectlist = selectlistitems; viewbag.searchfields = enumselectlist; var bloodsearch = m in db.bloodstored select m; if (!string.isnullorempty(searchstring)) { bloodsearch = bloodsearch.where(s => string.compare(getvalue(s, propertyname), searchstring) == 0); } return view(bloodsearch); } the selectlist work

css - Moving text to be to the left of plots in knitr bootstrap -

Image
i using knitrbootstrap package within r produce reports. particular audience keep r code out of report echo=false , leaves pretty large amount of white space right of plots default layout. how go editing layout such plot images right aligned , text write appears left of plots rather above? you can use css property float: right make images float right, e.g. ```{r fig-a, out.extra='style="float: right"', echo=false} x <- rnorm(100) y <- 2*x + rnorm(100) par(mar = c(4, 4, .1, .1)) plot(x,y) ``` example output:

google chart prevent xaxis annotation overlap -

i'm looking make line graph more readable making 1 series annotation on top , other series on bottom. if close on same line can't hover on other , can't read it. know way this? would post image site not allow posting whats important var options = { title:'availibility comparison '+labela+' , '+labelb, width: 1150, height: 600, backgroundcolor:'white', annotation: {style: 'line'}, vaxis: { minvalue: 99.94, gridlines: {count: 20} }, series: { 0: { color: 'blue', pointsize: 2 }, 1: { color: 'purple', pointsize: 2 } }, chartarea: { width: 950 }, annotation: { 1: { style: 'none' } } };

mongodb - ReactiveMongo custom BSONDocument{ Reader, Writer } -

i'm new reactivemongo , want create custom document reader/writer 1 object i'm getting error type mismatch; found : reactivemongo.bson.bsondocumentreader[reactivemongo.bson.bsondocument] required: reactivemongo.bson.bsondocumentreader[db.database.estudiante] note: implicit object estudiantereader not applicable here because comes after application point , lacks explicit result type error occurred in application involving default arguments. this code , based in example found in reactivemongo's official webpage. package db import scala.concurrent.executioncontext.implicits.global import reactivemongo.api._ import reactivemongo.bson._ object database { //driver para la conexion val driver = new mongodriver //conexion con mongodb val connection = driver.connection(list("localhost")) //conexion con la base de datos amdb val db = connection("reactive") //colección domainnames que se encuentra en la base de datos amdb val c

php - Using a fallback value from a table with PDO bound parameters/values -

in particular method need fallback particular piece of data in table if variable isn't given. looks this: public function readdiscountsforcampaign(cd\campaign $ocampaign, $ipricelistid = 0) { // stuff } so if $ipricelistid === 0 want sql query retrieve pricelist channel.default_pricelist_id instead. with pdo prepared statements can't bind tables names parameters or values there 2 options. 1: interpolate value query string, like: public function readdiscountsforcampaign(cd\campaign $ocampaign, $ipricelistid = 0) { //ensure pricelist id integer $ipricelistid = (int) $ipricelistid; //create string insert sql query string $spricelistinsert = $ipricelistid ? $ipricelistid : "channel.default_pricelist_id"; //sql query string $squery = "select ... select stuff here " . "where pricelist.pricelist_id = {$spricelistinsert}"; // <-- either (int) or channel.default_pricelist_id // other stuff, run query , return

jquery - How can I vertically center a div without knowing the parent height? -

hello hope can me. i'm trying vertically center div keep failing. think problem div gallery composed of 2 elements - main images not scrollable because fit screen - thumbnails (that appear through jquery hide/show , hide main images clicking on specific icon). can't center child div (the gallery) because can't set height parent (page container) because need thumbnails scrollable. want main images centered in page... here's html code (i kept essential): <!--page --> <div id="gallery-container"> <!-- main images --> <div class="cycle-slideshow"> <img src="img.jpg"> </div> <!-- thumbnails --> <div class="thumbs"> <img src="img.jpg"> </div> <!-- jquery hide/show code --> <script type="text/javascript"> $('.thumbsicon').on('click', function() { $('.cycle-slideshow').hide(); $('.thumbs').f

Entity Framework 6 RTM - Custom Relationship Convention -

i using convention this in beta version of ef6: public class navigationpropertyconfigurationconvention : iconfigurationconvention<propertyinfo, navigationpropertyconfiguration> { public void apply(propertyinfo propertyinfo, func<navigationpropertyconfiguration> configuration) { var foreignkeyproperty = propertyinfo.declaringtype.getproperty("id" + propertyinfo.name); if (foreignkeyproperty != null && configuration().constraint == null) { var fkconstraint = new foreignkeyconstraintconfiguration(); fkconstraint.addcolumn(foreignkeyproperty); configuration().constraint = fkconstraint; } } } but iconfigurationconvention interface has been marked internal, can't upgrade ef's references. have searched many places, not found how reproduce functionality in rtm version. i have tried this , seems works independent associations (ias), not case cause have fk

Haskell List Comprehension - Ineffective Predicate -

i'm pretty brand new haskell (only written fizzbuzz program before current one) , trying write program takes unix wordlist ('/usr/share/dict/words') , prints out list of anagrams word, direct palindromes starred. have meat of summed 1 function: findanagrams :: [string] -> [(string, [string])] findanagrams d = [x | x <- map (\s -> (s, [if reverse s == t t ++ "*" else t | t <- d, s /= t && null (t \\ s)])) d, not (null (snd x))] however, when run program output: abase: babes, bases abased: debase abasement: basements abasements: abatements abases: basses and on, isn't working properly. intention list comprehension read follows: t in d such t not equal s , there no difference between t , s other order, if t reverse of s include t*, otherwise include t. problem seems "no difference between t , s other order" part, i'm trying accomplish using "null (t \ s)". seems should work. testing in ghci gives: prelud

java - JavaMail SSL with no Authentication trust certificate regardless -

i have local mail server (hmailserver) ssl (port 465) , self-signed certificate. domain "foobar.com" i have setup properties enable ssl, disable auth, , trust host props.put("mail.smtp.auth", "false"); props.put("mail.smtp.ssl.enable", "true"); props.put("mail.smtp.ssl.trust", "*"); if send message through static call transport.send() email gets delivered. if try transport instance session get javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target how static call avoids sslhandshakeexception? here's tester code: public static void main(string[] args) throws exception { properties props = new properties(); props.put("mail.smtp.host", "127.0.0.1"); props.put("mail.debug", &q

database - how to exclude certain columns being returned in hibernate -

i referred below 1 adding specific columns returned in hibernate. how return entity chosen columns using criteria however in mycase exclusion small see if can give list of columns excluded in result. is there optimal way in hibernate? note: there no way provide exclusions in hibernate criteria. several other ways of inclusions below. totally choice. one way of doing creating light weight hibernate mapping object columns required. use hql columns need ' select c.col1,c.col2 columns c' construct hql @ run time, have template prepared below 'select ' + userdefcolumns + ' columns c'; // pass userdefcolumns @ run time. as mentioned here

debugging - Twitter handler (sensu and ruby) troubleshooting -

i'm trying sensu twitter-handler working on environment. issue i'm not getting errors on screen or logs when cat .json event twitter-handler and, tweets not being shown on linked account. here're config files: https://gist.github.com/mariano-gon/8648427 https://gist.github.com/mariano-gon/8648455 https://gist.github.com/mariano-gon/8648489 this output get: https://gist.github.com/mariano-gon/8648480 one important note in sensu-api.log request being recieved: https://gist.github.com/mariano-gon/8673758 so, question is: there way troubleshoot issue? way debug handler.rb? thanks! finally got working! thing new 'twitter' gem (in case v5.6) won't work code written. needed follow great answer , thread too. matter of sintaxis (as usual). thanks!

python - When configuring Geodjango, gdal1.10 and python3.3 are incompatible on Windows7 -

i using windows7 develop geodjango app, python version 3.3. following steps django documentation, installed postgresql9.1 , postgis extension. when installing gdal library, there problem. install gdal http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal which says has required files. me, can not correctly set up. test from django.contrib.gis import gdal and following errors prompt out: >>> django.contrib.gis import gdal traceback (most recent call last): file "<stdin>", line 1, in <module> file "c:\program files\python33\lib\site-packages\django\contrib\gis\gdal\__in it__.py", line 41, in <module> django.contrib.gis.gdal.driver import driver file "c:\program files\python33\lib\site-packages\django\contrib\gis\gdal\driv er.py", line 5, in <module> django.contrib.gis.gdal.prototypes import ds capi file "c:\program files\python33\lib\site-packages\django\contrib\gis\gdal\prot otypes\ds.py",

node.js - Sailsjs: How to populate association after *update* to model? -

i have following controller code works index , show , create methods update fails when include populate - doing wrong? // user list index: function(req, res) { user.find() .populate('profile') .exec(function(err, users) { if (err) return res.json(err, 400); if (!users) return res.json(users, 404); res.json(users, 200); }); }, // single user show: function(req, res) { user.findone({ username: req.param('username') }) .populate('profile') .exec(function(err, user) { if (err) return res.json(err, 400); if (!user) return res.json(user, 404); res.json(user, 200); }); }, // create user create: function(req, res) { user.create(req.body, function(err, user) { if (err) return res.json(err, 400); person.create({user: user.id, slug: user.username}, function(err, profile) { if (err) return res.json(err, 400); user.update(user.id, {profile: profile.id}

php - codeigniter - form returning no data -

i'm trying create page form using ci. when submit form, controller says have no data that's been submitted. can't see error lies. here's view: <?php echo validation_errors(); ?> <?php echo form_open('widgets/search/'.$hardwaremodel.'/'.$objectid.'/'.$name.'/'.$fd); ?> <div class="form-group"> <label for="search">last 4 characters of address:</label> <input type="text" class="form-control" id="searchstring" placeholder="last 4 characters" size="4"> </div> <button type="submit" class="btn btn-default">search</button> <button type="cancel" class="btn btn-default">cancel</button> </form> once page renders, form tag ends looking this: <form action="http://myserver/myciapp/index.php/widgets/search/205406zl/5461/sw-1/sw1net&q

java - Jaxb marshalling strips out a required tag -

i'm trying produce following xml output snippet : <benefits> <notes>benefits note</notes> <detail xmlns:ns2="http://www.w3.org/1999/xhtml"> **<body>** <p style="font-family:'myriad pro';text-decoration:none">description 2</p> **</body>** </detail> </benefits> here xml annotated class @xmlaccessortype(xmlaccesstype.field) @xmltype(name = "descriptiontype", proporder = { "notes", "detail" }) public class descriptiontype { @xmlelement(required = true) protected string notes; @xmljavatypeadapter(value=cdataadapter.class) @xmlelement(required = true) protected object detail; public string getnotes() { return notes; } public void setnotes(string value) { this.notes = value; } public object getdetail() { return detail; } public void setdetail(object

arrays - Change variable to be used inside loop (Python) -

so programming checkers game, , problem having creating several pieces in loop. have class creation part of code, won't post here, , rest, i'm posting, don't know how change variable loop use. if can lend me hand , clear out, thankful. sorry posting code image, i'm new website ( , programming) , couldn't format website accept post. hope it's ok guys me! thanks help! further clarification: need use different "piece" creation everytime loop runs. means first loop has create piece1, piece2, piece3... , forward edit: posting whole code. know format wrong, can't it. so, hope can fix it. class piece: def __init__(self, kind, yposition, xposition): self.color = kind self.ypos = xposition self.xpos = yposition def getcolor(self): return self.getcolor def adjusty(self, change): self.ypos = self.ypos + change def adjustx(self, change): self.xpos = self.xpos + change def get

jsp - Issue with the single quote with passing a string to the javascript function -

i'm using custom tag title of field template. in case, there's field "customeremailtitle" has string "riot team's email". i'm passing within javascript function checkemailaddress (as seen below): <input onblur="checkemailaddress(this, 'the input invalid <getname:getfield fieldkey="customeremailtitle"/> address')" /> but single quote in riot team's email seems throwing page off , won't process javascript properly. tried escaping single quotes , double quotes in input tag nothing seems working. has better idea how handle this? it may helpful you. can set data/string on data attribute of input element. <html> <body> <input data-message="'the input invalid <getname:getfield fieldkey='customeremailtitle'/> address')" onblur="checkemailaddress(this)" type="text" /> </body> <script> function checkemailadd

Understanding of not() function in jQuery -

i not understand why still getting element <li class=".item-2"> red background. please take code , provide me tips. <ul class="level-1"> <li class="item-i">i</li> <li class="item-ii">ii <ul class="level-2"> <li class="item-a">a</li> <li class="item-b">b <ul class="level-3"> <li class="item-1">1</li> <li class="item-2">2 .item-2</li> <li class="item-3">3</li> </ul> </li> <li class="item-c">c</li> </ul> </li> <li class="item-iii">iii</li> </ul> $("li.item-ii").find('li').not($(".item-2")).css("background

rest - How to create Http Response with Dart -

i trying follow along 1 of dart httpserver examples github, and, while show how create , handle routes, i'm still @ loss on how produce , send httpresponce in response specific url being requested. for example, while working webapi, have api controller, in explicitly define action get, put, delete , post verbs, , return appropriate httpresponse resource each such method. does know how typical crud business done using dart http server? once receive httprequest need use response attribute answer. void sendok(httprequest request, [content]) { request.response ..statuscode = httpstatus.ok ..write(content) ..close() ; }

php - Scrambling an image? -

Image
i find myself reading comics in number of different ways. interests me how companies behind comic viewers reduce piracy. example comixology use flash. not uncrackable of course deters most. anyway bought comics on google play first time , intrigued find out how google protect comic images. it appears scramble images , reassemble them on fly in reader! cool ay? i hoping recreate , implement similar effect. understand basic principle behind , have drawn out how roughly. with tool imagemagick crop image in equal chunks ( like so ) , stitch them i'm unsure browser side. image there's sort of key or seed called when page loaded determines goes i'm unsure how i'd implement this. so question how go implementing this? each image having key or maybe locked master key. there particular name other image scrambling? or existing library/system sort of thing. i'd love read more or maybe see more examples of it update: i thought i'd give image magick go b

c++ putting objects into arrays -

i trying make city distance calculator using longitude , latitude of city. problem having putting cities array. array attempt commented out in main method. please let me know doing wrong. #include <iostream> #include <math.h> #define pi 3.14159265358979323846 using namespace std; double distance(double lat1, double lon1, double lat2, double lon2, char unit); double deg2rad(double deg); double rad2deg(double rad); class city { public: //declare variables string name; double latitude; double longitude; city(string, double, double); //constructor double distance(string, string); }; double citydistance(city a, city b); int main() { //construct cities city providence("providence", 41.8239890, -71.4128340); city cranston("cranston", 41.7798230, -71.4372800); city newyork("newyork", 40.7143530, -74.0059730); city boston("boston", 42.3584310, -71.0597730); city killington("kill

Multiple Similar Route not working in ASP.NET MVC 4 -

i have 2 routes, of them not working on same time. 1 on top working fine bottom 1 not works config.routes.maphttproute( name: "getkeywordsearch", routetemplate: "api/{controller}/{action}/{keyword}/{selection}" //defaults: new { selection = routeparameter.optional } ); config.routes.maphttproute( name: "getchapter", routetemplate: "api/{controller}/{action}/{bookname}/{chapternum}/" //defaults: new {} ); any suggestion? those 2 routes have same pattern. there's absolutely no difference between them , routing engine has no way of disambiguating them. , since routes evaluated in order in defined, first 1 picked. in order make work need constrain parameters using regular expressions or custom constraints. example: config.routes.maphttproute( name: "getkeywordsearch",

exception handling - How to stop a Vibe.D application? -

does vibe.d have build-in terminate function, when library run through static initializer? want terminate application when vibe.d throws exception when example opening file. i have server listening using listenhttp function. try geteventdriver().exiteventloop(); , here , here . edit: there's simpler version, standalone function vibe.core.core.exiteventloop .

xml - How to add an XSD to Eclipse catalog directly -

i developing plugin eclipse, 1 of features able edit xml. in order have add xsd in eclipse catalog. there easy way add xsd eclipse catalog directly (i mean directly through code) you can use org.eclipse.wst.xml.core.catalogcontributions extension point (this requires have web tools (wst) component of eclipse installed. the following contribution made org.eclipse.wst.xsd.core plugin: <extension point="org.eclipse.wst.xml.core.catalogcontributions"> <catalogcontribution id="default"> <uri name="http://www.w3.org/2001/xmlschema" uri="platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/xmlschema.xsd" /> <system systemid="http://www.w3.org/2001/xml.xsd" uri="platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/xml.xsd"/> </catalogcontribution> </extension>

c# - Exchange Web Services Autodiscover non default link -

i writing piece of software runs on utility device on customers network, not on domain. autodiscover service not available off domain same either on domain or on internet. none of ways service works default find according docs, customer's staff tells me, supposedly :/ , work if can access autodiscover @ link gave me. there way override default approach , pass url autodiscover from? hardcoding link /exchange.asmx not option nor adding device domain. i reusing, , tweaking, tried , true piece of software has been deployed many times, situation first. using ews managed api may able using autodiscoverservice class. has constructor takes uri of autodiscover service parameter. your code should this. note disable scp lookup not on domain. have not tried code give try: autodiscoverservice ads = new autodiscoverservice(new uri("...")); ads.enablescplookup = false; ads.credentials = new networkcredential(...); ads.redirectionurlvalidationcallback = delega

Access 2010 Macro on Server 2008 R2 Task Scheduler Unattended -

Image
i've seen many questions none of suggested solutions working me. i have access 2010 macro named "main" (on 32-bit office). database contains odbc linked tables against different database servers , complex join queries compare , analyze data produce csv files importing third-party system. macro designed automatically run these queries , save results csv files later use third-party import tool. my desire run macro "unattended" files created on set schedule regardless of whether user logged system or not. target system running server 2008 r2 (natively 64-bit windows). many of answers see online indicate office automation macros may require user logged in office program has valid user desktop session. there several people giving opposite answer - saying can run microsoft access macro unattended using windows task scheduler option "run whether user logged on or not" selected. the action set "start program", program/script set "

hibernate - Spring 3.2 disable @Cacheable during unit tests -

i'm facing problem unit tests. use ehcache whith spring 3.2 (@cacheable) works disable cache during unit tests. so in src/test/resources/ehcache.xml wrote : <cache name="mycache" maxelementsinmemory="1" eternal="false" timetoidleseconds="0" timetoliveseconds="0" overflowtodisk="true" maxelementsondisk="0" diskpersistent="false" diskexpirythreadintervalseconds="0" memorystoreevictionpolicy="lru"/> but cache still working ! has idea ? thanks in advance help! spring profile done purpose. see documentation here , here . define profile "test" in cache manager bean ( <bean profile="test" ... /> ) or upper , activate or not profile annotation @activeprofiles("test") . if problem persists, verify context defines cache root context.

shell - Exclude certain directories in find results in AIX -

i trying search directories have extended attributes (-ea) not have string in path name. trying: find / -ea -type d ! -name '*arcdst*' however still returns /arcdst , directories under it. have looked @ similar answers on site, per aix man page -not not available nor -path. aix 6.1 tl6. many thanks, larryd your command not looking complete paths without arcdst only directories other name arcdst . expect find find directories , files under directory arcdst, find should skip top directory in result. if not mind little overhead, can filter results. find / -ea -type d | grep -v 'arcdst' when don't want find in arcdst in first place, can tell find not in arcdst directory find $(ls / | grep -v arcdst) -ea -type d

r - Specific way of plotting matrix (picture included) -

Image
i plot rather small matrix (4 5) shown in picture - please, see (it short time-series of indicator, consists of components w+x+y+z. year 1, indicator value denoted "a" equals w_1 + x_1 + y_1 + z_1.) \ any thoughts how plot this? maybe it's not idea plot kind of data. on other, it's not bad imo. , it's better let 5 histograms or worse, 5 pie charts. \ ot: know sites or documents advanced r plots examples? google has found simple plots. edit: data example (vectors w/x/y/z expressed a percentage) w <- (0.1,0.15,0.1,0.1,0.3) x <- (0.15,0.15,0.1,0.1,0.25) y <- (0.15,0.10,0.2,0.2,0.05) z <- (0.6,0.6,0.6,0.6,0.4) abcd <- (222222,333333,444444,500000,555555) from picture , information provided, can't tell what's going on on righthand side of figure, relative abundance plot you've shown pretty easy make using geom_area ggplot2. here's how data provide: first, data should in single dataframe in long form, easy resha

html - Php contact form with validation not working -

hi i've created contact form send messages. i've read many times , haven't found wrong. tip? when press "enviar" (send) nothing happens. i've createad new form option field related "subject" ("assunto"). ps.:plz ignore "mail@mail.com.br", in tests i'm using real one. hope can help! this php code i've inserted before form tag. it's code i've seen here i've changed work site. <?php $page = 'contact'; $to = "mail@mail.com.br"; //$subject = "company - contato"; if (isset($_post['submit'])) { // error checking $errors = array(); // name check if (empty($_post['name'])) { $errors[] = 'preencha corretamente o campo nome.'; } // email check if (empty($_post['email'])) { $errors[] = 'preencha corretamente o campo email.';