Posts

Showing posts from January, 2012

c++ - const-correctness of data-accessor types - better solution? -

i'm working on image-class makes possible work images different pixel layouts (rgb, rgba, gray, bayer, ...). access pixel it's possible call image.at<pixeltype>(x,y) returns "accessor". concrete accessor-implementation dependent on template argument. i've ran issues regarding const correctness. here dumbed down implementation makes apparent: template<bool constaccessor> class accessor { public: typedef typename boost::mpl::if_c<constaccessor, const int, int>::type datatype; accessor(datatype& data) :data(data) { } accessor(accessor<false>& other) : data(other.data) { } datatype& data; }; class image { public: accessor<false> at(unsigned int x, unsigned int y) { return accessor<false>(data); } accessor<true> at(unsigned int x, unsigned int y) const { return accessor<true>(data); } private: int data; }; int main() { im

plot - R ggplot, two scales together -

i want y-axis scaled: by log10, used: scale_y_log10(breaks = trans_breaks("log10",function(x) 10^x)) more ticks: scale_y_continuous(breaks=pretty_breaks(10)) but error message, there can 1 scale. there way have both of 2 scales? if understand question right, want have y axis on log scale more ticks 1, 10, 100, etc. here's reproducible example describing tried: library(ggplot2) library(scales) dat <- data.frame(x=1:3, y=c(2,50,10000)) ggplot(data=dat, aes(x=x, y=y)) + geom_point() + scale_y_log10(breaks=trans_breaks("log10",function(x) 10^x)) + scale_y_continuous(breaks=pretty_breaks(10)) ## error: scale 'y' present. adding scale 'y', replace existing scale. ok, error says we're allowed 1 call scale_y_something . since want log scale, let's keep scale_y_log10 . our approach here depends on want achieve - work have more evenly spaced ticks along axis, if aren't nice round numbers? if so, can let pret

How to use variable in JQuery select -

how modify jquery use var instead of '12'? var disableid = 12; if (e.currenttarget.checked) { $("input:checkbox[value=12]").attr("disabled", true); } else { $("input:checkbox[value=12]").attr("disabled", false); } you should use jquery's prop() method instead of attr() boolean values; there's no need if statements @ can set disabled state equal e.currenttarget.checked (which either true or false ): var disableid = 12, state = e.currenttarget.checked; $("input:checkbox[value='" + disableid + "']").prop("disabled", state);

Photo distorted in Html Need Help Rendering too 500x375 -

my photo in html not rendering long enough. photo less distorted pretty new html. original photo 500x375. hoping make render in html block exact dimensions. just set height , width attributes on img tag: <img src="myfile.jpg" width="500" height="375"/> that set dimensions 500x375 pixels. image should have these styles automatically though, it's image's styles being modified stylesheet. counteract this, can define inline style override other styles: <img src="myfile.jpg" style="width:500px;height:375"/> this override other styles applied image.

opencv: Manipulating edge-detected pixels -

i new opencv image processing. my task simple. have canny-edge detected image. have rid of edge-detected pixels. example, @ coordinates of (20,20), edge-detected pixel should eliminated. is there possibility solution? i thankful if of can guide me in solving this. thank much, karthik you can change parameters of canny edge detection , tune them needs. if want specific point or finite specific knows points want rid off access underlying pixel data , set 0. width = image.cols = y-position, j = x-position image.data[i*width + j] = 0.

c++ - boost::mpl::fold for double parameter abstraction -

i have class called carender, provides 1 carender::renderclientobject() method per given object type in clientobjecttypes. following code snipped shows running situation: #define unused(x) (void)(x) typedef boost::mpl::vector<model::clientmodel::cclientverticesobject, model::clientmodel::crawclientobject> clientobjecttypes; template <class t> struct methodforward{ virtual void renderclientobject(t* clientobject, controller::qtopengl::cqopenglcontext* glcontext) { unused(clientobject); unused(glcontext); }; }; struct base { template<class baseclass, class t> struct apply { struct deriverender: baseclass, methodforward<t> { virtual ~deriverender(){}; using baseclass::renderclientobject; using methodforward<t>::renderclientobject; }; typedef deriverender type; }; template<class t>

html5 - How to mark the copyright of an image in html? -

this semantic question. want put images copyrights on website. know figure , figcaption element, figcaption doesn't seem best tag that. it's rather caption need. if i've got image that: <figure> <img src="img/content/preview.jpg" alt="alttext für das bild" /> <figcaption>caption goes here</figcaption> </figure> where put copyright? edit: copyright text must visible. in general the copyright notice should contained in small element : […] typically features disclaimers, caveats, legal restrictions, or copyrights . if copyright notice applies content of sectioning content element (e.g., article ), include small element in footer element belongs sectioning element: a footer typically contains information about section such as wrote it, links related documents, copyright data , , like. if applies whole page, might include small element in footer belongs body (i.e. not nested in se

php - internet explorer image specifications -

i using wordpress , making statis page there. needed background image part of content, made new template php file code: <div style="background: url(/xxx.xxx) no-repeat; background-size: 100% auto; filter: progid:dximagetransform.microsoft.alphaimageloader (src='/xxx.xxx',sizingmethod='scale'); -ms-filter: "progid:dximagetransform.microsoft.alphaimageloader (src='/xxx.xxx',sizingmethod='scale');"> it works in other browsers in picture width spans , height proportional, in internet explorer (version 8) image distorted height spans everything, not want!! how can make image not distorted , width spans while height still in porportion?

Spring Security: Not able to configure method security with java config -

i struggling configure method security java configured spring security. configuration works without problem, until use @secured annotation within controller. spring security config: (java config) @configuration @enablewebsecurity @enableglobalmethodsecurity(securedenabled=true) public class securityconfig extends websecurityconfigureradapter { @autowired private datasource datasource; @override public void configure(websecurity web) throws exception { web .ignoring() .antmatchers("/webjars/**","/css/**", "/less/**","/img/**","/js/**"); } @autowired public void registerglobal(authenticationmanagerbuilder auth) throws exception { shapasswordencoder shapasswordencoder = new shapasswordencoder(256); auth .jdbcauthentication() .datasource(datasource) .usersbyusernamequery(getuserquery()) .authoritiesb

backbone.js - What is the best way to user authentication with Devise 3 and Backbone? -

i'm working stack: core api restful rails 4 , devise 3.2 another app/stance backbone i have read many articles, manuals, stackoverflow topics, google random results, blogs, etc, deprecated. using practical approach (tl;dr here) need real session between devise 3 , backbone in different server stances , holding it, 2 separate projects. remote login, know. i'm stuck appreciate suggestions. thank guys. personally have same situation in project angular instead of backbone front-end , rails 4 api devise. try sum things in assumption got question right. to work correctly sessions in scenario need sure that: browsers handle communication correctly (i.e. don't mess data because requests not comply cors policies) and, requests through rails csrf protection please, read this article cors . if not familiar cors article should provide necessary background answer. info csrf protection here here scenario step-by-step: backbone.js sends get req

ios - How to animate a UILabel after another -

i animate 2 uilabel such: [uiview beginanimations:nil context:null]; [uiview setanimationduration:2.0]; [_temperaturelabel setalpha:1]; [_tempdescriptionlabel setalpha:1]; [uiview commitanimations]; however, want show first label _temperaturelabel once done animating (or maybe halfway through) start animating second label _tempdescriptionlabel . as said i'll answer: [uiview animatewithduration:2 delay:0 options:uiviewanimationoptioncurveeasein animations:^{ //set alpha 1 first uilabel _temperaturelabel.alpha = 1; } completion:^(bool finished){ [uiview animatewithduration:2 delay:0 options:uiviewanimationoptioncurveeasein animations:^{ //when finished enter here //set alpha 1 second uilabel _tempdescriptionlabel.alpha = 1; } completion:^(bool finished){ }]; }]; remember add quartzcore framework, , add #import <quartzcore/quartzcore.h>

New project - JSF vs JSP -

hi i'm looking build new classified site using java. understanding jsf latest framework (ie newer jsp). appears developers versed jsf far , in between compared jsp. while understand existing setup built using jsp makes sense continue doing if brand new project, there reason avoid jsf? using jsf , automatic binding data visual components , including mapping, validation of input data , save state between requests. using jsp - have implement manually. jsf , supports ajax interaction server . if developing application requires standard behavior, such data entry, editing , display - jsf suit you. if need online application fast response, navigation within page on client side ,such gmail or twitter - can spend lot of time translating client-side logic components in jsf. in case, better use jsp , source of data , javascript library display data. therefore, jsf not suitable types of projects, use jsp, not moving "jsf" recommend use of intermediate option giv

min - XPath 1.0 - How can I get the minimum value in my selection of elements? -

example of file (exercise based on itunes xml file) : <plist version="1.0"> <dict> <key>major version</key><integer>1</integer> <key>minor version</key><integer>1</integer> ... <dict> <key>219</key> <dict> <key>track id</key><integer>219</integer> <key>name</key><string>ruby</string> ... <key>track number</key><integer>1</integer> <key>track count</key><integer>11</integer> <key>year</key><integer>2010</integer> <key>date modified</key><date>2010-08-28t10:16:04z</date> <key>date added</key><date>2010-08-30t19:40:27z</date> ... </dict> <key>243</key&

jquery how to include .js files -

when checking stackoverflow or flipkart.com website code view source in browser, saw <script type="text/javascript"> stackexchange.init({ "locale": "en", "stackauthurl": "https://stackauth.com", "servertime": 1391174565, "stylecode": true, "enableuserhovercards": true, "site": { "name": "stack <br/>overflow", "description": "q&a professional , enthusiast programmers", "isnoticestabenabled": true, "recaptchapublickey": "6ldchgiaaaaaajwgpizrqsofao0pu6s44xt8atwc", "recaptchaaudiolang": "en", "nonasciitags": true, "enablesocialmediainsharepopup": true }, "user": { "fkey": "64a9dd799b4d

android replace confirm on contextual action bar -

i want delete confirm button appears on left side of cab when app si in selection mode. or replace button. i have single selection mode, so, in contextual action bar need title, , button. i follow android tutorial , work fine, how can remove default confirm ? you can change icon on top left changing in theme. if styles.xml, create new theme if don't have 1 already. <style name="theme.custom.light" parent="holo.theme.light"> <item name="android:actionmodeclosedrawable">@drawable/ic_menu_checkmark</item> </style> you can put in drawable here. tried , worked.

objective c - How Do You Figure Out What the Date Format Is For a Given NSString? -

hey stackoverflow people, i have date timestamp nsstring following value backend server: nsstring *date = @"2014-01-27t21:06:59.000-05:00"; i can't life of me figure out date format string above , have been trying use nsdateformatter object 2 following date formats (that have both returned me nil ): format 1: @"yyyy-mm-ddthh:mm:ss.000-05:00"; format 2: @"yyyy-mm-ddthh:mm:ss.sss-ss:ss"; my question is: how heck use given string determine date format you're working with? try this, works: @"yyyy-mm-dd't'hh:mm:ss.ssszzzzz" the -05:00 timezone, need use zzzzz that. also, because t not part of date, need scape it, use 't' that. notice hh instead of hh . find formatters examples here: http://www.unicode.org/reports/tr35/tr35-25.html#date_format_patterns about question of how know format, have guess based on see, or ask person providing date.

How to submit checkbox values alongwith existing form data using PHP, jQuery and AJAX(i.e. avoid form reloading after checking any of the checkboxes)? -

Image
i've filter form in smarty template follows: <form id="view-questions-form" name="user_transactions" action="{$control_url}modules/transactions/view_transactions.php" method="post"> <div class="w50"> <ul> <li> <label>from date</label> <div class="form-element"> <input type="text" class="cal fl-left" id="frmdate" name="from_date" value="{if $from_date}{$from_date}{else}{$today_date}{/if}" maxlength="10"> </div> </li> <li> <label>transaction no.</label> <div class="form-element"> <input type="text" name="transaction_no" id="transaction_no" class="" value="{if $transaction_no}{$transaction_no

python dictionary from config parser if value and "%(" in value: argument of type 'int' is not iterable -

getting error in random, appear, not: for in range(1,32): sezione = "grp"+str(i) dizionariogrp = dict(config.items(sezione)) print int(dizionariogrp['r']) and error file "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap self.run() file "/home/pi/gigi.py", line 436, in run self.esegui() file "/home/pi/gigi.py", line 307, in esegui l.gruppo(idgruppo) file "/home/pi/gigi1.py", line 282, in gruppo dizionariogrp = dict(config.items(sezione)) file "/usr/lib/python2.7/configparser.py", line 655, in items option in options] file "/usr/lib/python2.7/configparser.py", line 663, in _interpolate if value , "%(" in value: typeerror: argument of type 'int' not iterable why referring int, if i've converted in string? somewhere in code you're doing this: config.set('something', 'something',

artificial intelligence - java:implement 8 queen using depth first search -

i try implement 8 queen using depth search initial state work fine empty board(no queen on board) ,but need work initial state if there solution,if there no solution initial state print there no solution here code: public class depth { public static void main(string[] args) { //we create board int[][] board = new int[8][8]; board [0][0]=1; board [1][1]=1; board [2][2]=1; board [3][3]=1; board [4][4]=1; board [5][5]=1; board [6][6]=1; board [7][7]=1; eightqueen(8, board, 0, 0, false); system.out.println("the solution pair"); for(int i=0;i<board.length;i++){ for(int j=0;j<board.length;j++) if(board[i][j]!=0) system.out.println(" ("+i+" ,"+j +")"); } system.out.println("the number of node stored in memory "+count1); } public static int count1=0; public static voi

javascript - Iframe resize on firefox, only extending not shrinking -

hello im working on iframe resize cross browser apps. ie, firefox, chrome ans safari specifically. resize works on ie not on others. on others work partially. happening when expand iframe cannot shrinked or reduce. code using in iframed page bringing last , highest value used. every time update size, brings thesame value. here code im using this: parent: main.asp <%@language="vbscript" codepage="65001"%> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>iframe  resize a</title> <script src="js/jquery-1.5.min.js" type="text/javascript"></script> </head> <body> <form id="form1" runat="server"> <div> <iframe frameborder="1" id="iframetest"

ms access - exception when using ipy64 with pypyodbc -

i'm trying create database msaccess using pypyodbc on ironpython. have working fine on old machine, must migrate new machine. on new machine exception trying run same script. using python can create database without errors. ipy import pypyodbc pypyodbc.win_create_mdb('c:\database.mdb') pypyodbc.connect('driver={microsoft access driver (*.mdb)};dbq=c:\database.mdb;') however, if try same using ipy64 exception "access driver not found" traceback (most recent call last): file "", line 1, in file "c:\ironpython27\pypyodbc.py", line 2564, in win_create_mdb exception: access driver not found. i installed accessdatabaseengine_x64 have 64-bit office products installed. thanks, john.

append - Appending lists in SML -

i'm trying add int list list int list list using append function, can't work way want. say want append [[1,2,3,4,5]] [6,7] [[1,2,3,4,5,6,7]] . here's attempt: [1,2,3,4,5]::[]@[6,7]::[] , gives me list want append list of own instead of 2 lists combined one, this: [[1,2,3,4,5],[6,7]] . how can re-write operation make return [[1,2,3,4,5,6,7]] ? your question unspecific. dealing nested lists. want append second list every inner list of nested list, or first one? example doesn't tell. for former: fun appendall xss ys = list.map (fn xs => xs @ ys) xss for latter: fun appendhd [] ys = raise empty | appendhd (xs::xss) ys = (xs @ ys)::xss however, both of these should needed, , somehow feel trying solve wrong problem if end there.

Android Dialogs and Activity -

i bit confused that, dialog activity or not? if yes can perform operation on activity , set custom layout can loaded xml.. dialog part of activity , yes can assign custom xml layout dialog. you can visit here more info: http://developer.android.com/guide/topics/ui/dialogs.html

Git marks my new pushed files as deleted in the remote repository (staging server) -

whenever push local code staging server (a remote repository) don't show instead appear in 'git status' deleted. how can set properly? i work in local repository ('development' branch). other non-git people putting files directly on server (and server period updates well). have set server 'staging' branch. when want push code server. add / commit changes made on server in 'staging' branch. pull them down local 'staging' branch. merge them 'development' branch. push 'staging' branch server. unfortunately no longer working - new files marked 'deleted' , changed files marked 'modified'. how can resolve condition? files don't appear in directory. i suspect has change made there resolve fact live staging server , wanted able push checked-out branch. git config receive.denycurrentbranch ignore any help, ideas, scorn, ridicule, resolutions, appreciated. are saying you're work

algorithm - Recurence related to master theorem T(n)=T(n^(1/2))+1 -

in masters theorem given "plug-in" formula find big o, given satisfies condition. however, if have problems following below? can show me how step step formula. , topics me know more these types of questions. assume person asking question knows nothing induction. t(n)=t(n^(1/2))+1 t(n)=t(n-1) + 1 t(n)=t(n-1) + n^c , c natural number >1 t(n)= t(n-1) c^n, c natural number >1 you'll need know little math of these. can figure out recursion looks when expand out way base case, e.g. t(n) = t(n-1) + n^c t(n) = 1^c + 2^c + ... + n^c, need know math in order know o(n^(c+1)). (the easiest way see bounding sum above , below in terms of integrals of x^c). t(n) = t(n-1) + c^n t(n) = c^1 + c^2 + ... + c^n again need use calculus or figure out t(n) = o(c^n). for t(n) = t(n^(1/2)) + 1 need count how many times apply recurrence before base case. again math helps here. when take square-root, logarithm gets cut in half. want know how many times can cut logarithm in h

java - Remove limited activity from stack not all -

i have 5 activity example a, b, c, d, e i going -> b -> c -> d -> e now when press button e i want go directly b , b should not create new actiivity i know intent intent = new intent(this, activityb.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); by can don't want create activity b doing startactivity in button's onclick can have following: intent intent = new intent(this, activityb.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent);

asp.net - XPath only works if I add an extra node -

i'm pretty new using xml , new xpath. i'm trying select field in xml document , display in label on webpage. sound nice , simple. here code on webpage: <body> <form id="form1" runat="server"> <div> <asp:listview id="newslistview" runat="server" datasourceid="newsdatasource"> <itemtemplate> <asp:label id="label1" runat="server" ><%#xpath("temp1")%></asp:label> </itemtemplate> </asp:listview> <asp:xmldatasource id="newsdatasource" runat="server" datafile="~/news.xml"></asp:xmldatasource> </div> </form> </body> this works 100% fine when using xml document 1 below. <test> <response> <temp1>23.7</temp1> </response> </test> but xml document trying a

ruby on rails - Simple Form collection, but exclude a specific record -

here code use generate select list of companies. <%= f.association :company, :collection => company.order('name asc'), :label => "company: ", :include_blank => false %> now table pre-populated special record "id:1, name:none", want exclude record selectable option in select list that's generated. how can go accomplishing this? thanks! try <%= f.association :company, :collection => company.where("id != 1").order('name asc'), :label => "company: ", :include_blank => false %> or in controller @companies = company.where("id != 1").order('name asc') in view <%= f.association :company, :collection => @companies, :label => "company: ", :include_blank => false %>

c# - Unable to serialize model with Highcharts property -

firstly apology english, i'm not best @ explaining things, here goes using mvc have following model [datacontract] public class myclass { . . . [datamember] public dictionary<string, highcharts> myproperty{ get; set; } } when come serialize model using var serializer = new datacontractserializer(typeof(myclass)); string xmlstring; using (var sw = new stringwriter()) { using (var writer = new xmltextwriter(sw)) { writer.formatting = formatting.indented; serializer.writeobject(writer, model); writer.flush(); xmlstring = sw.tostring(); } } i'm getting following error: additional information: type 'dotnet.highcharts.highcharts' cannot serialized. consider marking datacontractattribute attribute, , marking

android - ORMlite database version not incrementing after onUpgrade -

i've been working on android project , i've been using ormlite. far i've been able need , i'm using quite complex data model now. now seems i'm having problems onupgrade method of helper. here essentials of onupgrade method: public void onupgrade(final sqlitedatabase db, final connectionsource connectionsource, int oldversion, final int newversion) { try { // loop round until newest version has been reached , add appropriate migration while (++oldversion <= newversion) { // available update sql statements , execute them final string[] availableupdates = sqlstaticcontenthelper.getmigrationstatements(oldversion); executestatements(db, availableupdates, true); } } catch (exception e) { log.e(log_tag, "onupgrade() - can't migrate databases, bootstrap database, data lost", e); oncreate(db, connectionsource); } here oncreate method: public void oncreate(sqlitedatabase database ,connectio

lxc - How do I move a docker container's image to a persistent disk? -

we have noticed our containers taking lot of space, 1 of reasons images. we move images. i know right stored in /var/lib/docker/graph/<id>/layer is there way move these location/persistent disk? to move images drive or server.. docker save image_name > image_name.tar mv image_name.tar /somewhere/else/ load docker docker load < image_name.tar

python - use ipython to get REAL code-completion in pycharm -

many python ide's boasts of providing code-completion (code insight), pycharm 1 of ide's. however, seems me provided code-completion extremely limited. let me give example make clear: import numpy np m = np.random.random((3,5)) m. hitting ctrl-space after 'm.' not give me code-completion, -no matter how hard hit ;).. guess because ide have type inference know type of variable 'm', , isn't trivial in domain of dynamic programming languages. now, pycharm comes setting called "collect run-time types information code insight", indeed sounds promising. however, doesn't seem fix problem mentioned above.. still not able code-completion on variable 'm'. thus far, have found 1 way code-completion on variables in pycharm: import numpy np m = np.random.random((3,5)) ''':type : np.matrix''' m. in example able code-completion when pressing ctrl-space after 'm.', , because helping ide specifying type of

replace - replacing values from two columns in R -

i have data frame 24 columns , second , third column like 1 2230 1 2300 1 2330 1 2400 2 30 2 100 this part of columns. column 2 has 48 ones 48 twos 48 threes , on way 365. column 3 half hour time , starts 30 100 130 200 , on way 2400. patterns of each column end above example, last 1 corresponds 2400. need go though each column , replace 2400 0 , last value associated 2400 value plus 1 end with 1 2230 1 2300 1 2330 2 0 2 30 2 100 i can replace values single column don't know how 2 columns 1 column depends on another. tried use loop , if statement coulnd't make work. it should simple - if data.frame ( df ) has columns day , time : df[df$time==2400,]$day <- df[df$time==2400,]$day + 1 df[df$time==2400,]$time <- 0 if you're willing learn use data.table package, easier: df[time==2400, c("day", "time"):= list(day + 1, 0)]

Intercept all events that update data of some kind with angularjs -

before can use angularjs have solve following problem maintaining application state across single page view flips , multi-page flips i have started view state service , trying integrate application. if call stuff manually, works great. problem want have viewstate object update automatically developer doesn't have anything, include few things , works. im trying follow angulars source code, functional programs hard debug being pain. there document (other 1 http://docs.angularjs.org/api/ng .$rootscope.scope , pretty useless), explains event system within angular? want able pull list of events registered in system. here's design im trying pull off. any time field typed in, button clicked, column sorted, want event fired triggers viewstate service. view state service records event in sorta delta v type layout. when directive initialized, want event fire again triggers view state service, service looks @ internal delta storage , if directive exists, plays delta

java - Selenium won't read the current input value -

i'm running selenium on site changes value of disabled input text box using jquery. looking @ html, value of input box continues "not available" though value changed. i can current value using firebug $("#inputid").val() but value "not available when i've used selenium code: driver.findelement(by.id("inputid")).getattribute("value"); any suggestions on how value in selenium? want avoid trying use javascriptexecutor if that's best solution know. i don't have access jquery code can't there. sorry :-/ if value changed jquery due dom events, chances selenium test going check new value fast. can value after changes away "not available" this: webdriverwait wait = new webdriverwait(driver,10); string value = wait.until(new expectedcondition<string>() { public string apply(webdriver driver) { string value = driver.findelement(by.id("inputid")).getattribute("v