Posts

Showing posts from September, 2013

Resharper intellisense : how to show method return type -

Image
i've formatted pc, , can't seem find option show method return type in intellisense... using vs 2015 rc resharper 9.1.1 thanks, screenshot below. here can find corresponding setting:

linked list - C++ Is it possible to create a private link between objects? -

as far can understand, linked list can implemented outsider class. because class can't have member varable of it's own type , node list need type. problem is, if link intented used specific class. if, link class created outside, available created standalone object. it's okay if link class/struct pure link object because can used linking object type. but, in case need link has functionallity related object, public availability of pointless. , think it's better created private. let's take @ this declaration: #include <unordered_map> using namespace std; template<class t> class node { public: node(); node(const t& item, node<t>* ptrnext = null); t data; // access next node node<t>* nextnode(); // list modification methods void insertafter(node<t>* p); node<t>* deleteafter(); node<t> * getnode(const t& item, node<t>* nextptr =...

mysql - Displaying users in query result if they have no posts? -

i have bot collects activity users , logs posts make on 1 of websites. have list of moderators on website , use mysql return information activity. @ moment, following: select count( num ) posts, username `logs` username in ( 'username1', 'username2', 'username3', 'username4', 'username5', ) , from_unixtime( epoch ) between "2015-05-26" , "2015-05-29" group username order posts desc limit 0 , 30 some sample output above query: username1 100 username2 50 username3 25 what want output: how do this? username1 100 username2 50 username3 25 username4 0 username5 0 table structure: num (int, key) username (varchar) epoch (varchar) msg (varchar) there's ifnull function think applies in case select ifnull(count( num ),0) posts, username `logs` ... if value of count null posts return 0 mysql has limitations make queries particularly hard. what's hard creating temporary list of usernames ...

r - Split the title onto multiple lines? -

in r markdown document (html , presentations), possible manually split title onto multiple lines? tried playing pipes produces orrendous output. --- title: 'a title want split on 2 lines' author: date: output: ioslides_presentation --- for html output <br> tag while if output pdf or pdf presentation standard latex code break line given \\ should work. example --- title: 'a title want <br> split on 2 lines' author: date: output: ioslides_presentation --- for pdf just rule out possibilities, i've tried put \\ or \newline , both not split, pdf seems little bit tricky. \linebreak stop knitr parsing. maybe user can solve question knitr pdfs.

bigcommerce - Is it possible to show the number of pre-orders on the product page? -

my primary business pre-orders, , how works: i list item sale. my customers order item. credit card authorized not charged. once minimum number of orders placed, customers charged, , buy live. if, after specified amount of time, minimum not reached, orders cancelled. what this: specify minimum number of orders needed particular item in backend. (not 100% needed, nice). display total number of pre-orders on product page, customers know how many left before buy live (it great show in following format: 23/50 ordered). does know if possible? if so, can please explain me need in order make happen? thanks! p.s. - in case doesn't show up, i'm using bigcommerce store minimum needed custom field & set initial inventory same number. you'll need allow inventory displayed pre-orders, though can hide display if you'd (we want present in dom). as products pre-ordered, inventory decrement. use javascript subtract number left in inventory origin...

matlab - Putting sampled values into a matrix- simulink -

how can put values matrix in simulink? example, if sampled sine wave every 0.5s, , put value fixed size matrix of size n. after matrix full, overwrite oldest values. assuming talking using matrix if it's buffer, if have dsp blockset can use buffer block. otherwise pretty straight forward using matlab function block (see code below). if matrix constructed part of model, can passed second input matlab function block , (new element) insertion code modified appropriately. function y = custom_buffer(u) %#codegen persistent buffer next_index buf_size = 1000; % define initial values if isempty(buffer) buffer = zeros(buf_size,1); next_index = 1; end % populate buffer buffer(next_index) = u; % increment location write @ next time if next_index < buf_size next_index = next_index + 1; else next_index = 1; end % populate output y = buffer;

c# - OutOfMemory exception thrown while writing large text file -

i want generate string , write in .txt file. problem outofmemory exceptions when attempt so. the file large (about 10000 lines). i use string.format , loops create string. how can write .txt file? string text= @"..."; const string channelscalar = @"..."; text= string.format(...); foreach (channel channel in ...) { switch (channel.type) { case "...": text= string.format(text, channelframes(channel, string.format(...); break; } } file.writealltext(textbox9.text,text); use streamwriter directly write each line generate textfile. avoids storing whole long file in memory first. using (system.io.streamwriter sw = new system.io.streamwriter("c:\\somewhere\\whatever.txt")) { //generate single lines , write them directly file (int = 0; i<=1...

ruby on rails - Assign one of values in controller -

post model has 2 fields: title , category_id. in simple_form i'd assign name , it's ok, category i'd assign in controller (value different dependends on action). have problem, because every time category_id null. do: def fun @post=post.new @post.category_id=1 end it doesn't work and @post=post.new(category_id: 1) too. <%= simple_form_for @post |f| %> <%= f.error_notification %> <%= f.input :title %> <%= f.button :submit %> <% end %> class post < activerecord::base belongs_to :category end class category < activerecord::base has_many :posts end you can @oscillatingmonkey suggested, suggest use hidden field tag in new form: <%= f.hidden_field :category_id, value: @post.category_id %> in case controller new be: @post = post.new(category_id: 1) calling save in new action terrible thing, afaik. every time new action called, new object created irrespective user con...

java - Integration tests with spring security -

i need send request api, despite having placed administrator annotation error @withmockuser(roles="administrador") . how send request? api @requestmapping(value = "/{id}", method = requestmethod.get) @postauthorize("returnobject.instancia == principal.instancia.instancia") public validacao retrieve(@pathvariable("id") string id) { return validacaoservice.retrieve(id); } test @test @withmockuser(roles = "administrador") public void testcretrieve() throws exception { this.mockmvc .perform(get("/api/validacao/" + id).with(user("daniela.morais@sofist.com.br"))) .andexpect(status().isok()) .andreturn(); } log org.springframework.web.util.nestedservletexception: request processing failed; nested exception org.springframework.security.authentication.authenticationcredentialsnotfoundexception: authentication object not found in securitycontext tes...

c++ - Use a function's return type as for another template function call -

i'd call templated function typename being determined function's return type: template<typename t> void dosomething(t& value, int x) { if(getresult(x)) // continue normal if result true. { object.call<t>(value, x); } else { //i'd have function templated on //return type of transformvalue function. //transformvalue functions takes in value of type //and transforms value of other type. object.call<return_type_of_transform_value>(transformvalue(value), x); } } // condition bool getresult(int x) { if(x == 42) { return true; } else { return false; } } edit: cannot use c++11 :( in specific case you'd better rely on template type deduction instead of specifying explicitly class object { // sample object public: template<typename t> void call(t whatever, int x) { // sample templated function (you didn't provid...

function - How do I reference a clicked point on a ggvis plot in Shiny -

i wish use values of clicked point further processing unclear how reference data library(shiny) library(ggvis) library(dplyr) df <- data.frame(a=c(1,2),b=c(5,3)) runapp(list( ui = bootstrappage( ggvisoutput("plot") ), server = function(..., session) { # function handle click getdata = function(data,location,session){ if(is.null(data)) return(null) # returns values console print(glimpse(data)) # observations: 1 # variables: # $ (int) 2 # $ b (int) 3 } # create plot df %>% ggvis(~a, ~b) %>% layer_points() %>% handle_click(getdata) %>% bind_shiny("plot") # further processing clickeddata <- reactive({ # how reference value 'a' e.g. 2 of clicked point' }) } )) tia here's working solution prints out data.frame. you're close. df <- data.frame(a = 1:5, b = 101:105) runapp(shinyapp( ui = fluidpage( ggvisoutput("ggvis") ), server = function(input, output, session) {...

Jquery find text in a td after current td -

i'm using jquery (coffeescript) in rails 3.2 app. in form, want add checks using jquery. if user changes value of containing class 'numeric', want check input has typed next of class 'text'. i'm debugging right now. can't content of next text field. this html: <tr> <td class="strongnowrap">construction costs</td> <td class="typical"></td> <td class="typical_dollars"></td> <td class="calculated"></td> <td class="amount"><div class="control-group integer optional costproject_costestimates_amount"><div class="controls"><input class="numeric integer optional" id="costproject_costestimates_attributes_0_amount" name="costproject[costestimates_attributes][0][amount]" style="width:100px" type="text" value="120000"></div></div>...

java - ExceptionConverter com.itextpdf.text.pdf.parser.InlineImageUtils$InlineImageParseException: Could not find image data or EI 420 -

i using itext extract text pdf, however, had following exception, , cannot caught try/catch(exception e), have attached file here, don't care whether can extract text it, want know how catch exception. exception: exceptionconverter: com.itextpdf.text.pdf.parser.inlineimageutils$inlineimageparseexception: not find image data or ei 420 @ com.itextpdf.text.pdf.parser.inlineimageutils.parseinlineimagesamples(inlineimageutils.java:386) @ com.itextpdf.text.pdf.parser.inlineimageutils.parseinlineimage(inlineimageutils.java:156) @ com.itextpdf.text.pdf.parser.pdfcontentstreamprocessor.processcontent(pdfcontentstreamprocessor.java:427) @ com.itextpdf.text.pdf.parser.pdfreadercontentparser.processcontent(pdfreadercontentparser.java:80) @ com.itextpdf.text.pdf.parser.pdftextextractor.gettextfrompage(pdftextextractor.java:74) file: https://www.dropbox.com/s/4l4ioqzpcca05vc/understanding%20the%20high%20photocatalytic%20activity%20of%20%28b%2c%20ag%29-codopeda31220...

machine learning - Finding similarity between two user profiles -

i have user profiles following attributes. u={age,sex,country,race} best way find similarity between 2 users? example have following 2 users. u1={25,m,usa,white} u2={30,m,uk,black} i have searched , found cosine similarity mentioned lot. problem or other suggestions. similarity measures between object in clustering analysis broad subject. what suggest consider approach of 'divide , conquer'. treat similarity between 2 user profiles weighted average attributes similarity. remember user normalized values attributes similarity before doing avg. weights average should decided on data , use case. if consider 1 of dimension more important when match between 2 profiles should have more weight in overall result. for attributes distance can try: age -> simple euclidian; sex, race, country -> 0/1. if have time, distance between 2 countries can better defined based on geoloc. or cultural similarity (on e.g.language, religion, political system, gdp,...). experimen...

c - Error message "dereferencing pointer to incomplete type" when I use udphdr -

i write programme udphdr.h . , here header file list: #include <linux/module.h> #include <linux/kernel.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> #include <linux/ip.h> #include <linux/tcp.h> #include <linux/udp.h> #include <linux/skbuff.h> #include <linux/init.h> #include <linux/types.h> #include <linux/sched.h> #include <net/sock.h> #include <linux/netlink.h> and here code: void dealudph(struct updhr* udph){ if(udph==null){ printk("udph null!!\n"); }else{ printk("updh %u\n",udph); printk("udp sport %u\n",udph->source); } } static unsigned int hookfunc(unsigned int hooknum, struct sk_buff **skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)){ struct iphdr *iph=ip_hdr(skb); struct ethhdr * ethh = eth_hdr(skb); s...

ember.js - How to call components inside a components with pods structure in ember cli -

i have 2 components x-foo , y-foo in pods structure. app/pods/components/x-foo/template.hbs app/pods/components/y-foo/template.hbs i want call y-foo component inside x-foo component's template.hbs this: <section> {{y-foo}} </section> but errors out saying y-foo helper doesn't exist. can show me right way in pods structure? i've managed fix creating parent component path , calling child component via {{component y-foo}}. ember generate component x-foo --pod --path x will generate x-foo component in app/pods/x/x-foo/component.js app/pods/x/x-foo/template.hbs in x-foo component template, call y-foo component this: <section> {{component y-foo}} </section> the reason question because i'm trying future-proof ember 1.x ember 2.0. i'm not sure though if i'm doing right thing, looks okay in opinion.

java - LWJGL Texture Unbinding -

i'm working on simple textured rectangle class using lwjgl (gl11). have far in draw method. glenable(gl_texture_2d); color.bind(); glbegin(gl_quads); t.bind(); if (centered) { gltexcoord2d(0, 0); glvertex2d(x - (width / 2), y - (height / 2)); gltexcoord2d(t.getwidth(), 0); glvertex2d(x + (width / 2), y - (height / 2)); gltexcoord2d(t.getwidth(), t.getheight()); glvertex2d(x + (width / 2), y + (height / 2)); gltexcoord2d(0, t.getheight()); glvertex2d(x - (width / 2), y + (height / 2)); } else { gltexcoord2d(0, 0); glvertex2d(x, y); gltexcoord2d(t.getwidth(), 0); glvertex2d(x + width, y); gltexcoord2d(t.getwidth(), t.getheight()); glvertex2d(x + width, y + height); gltexcoord2d(0, t.getheight()); glvertex2d(x, y + height); } glend(); glbindtexture(gl_texture_2d, 0); gldisable(gl_texture_2d); the problem second last line ( glbindtexture(gl_texture_2d, 0) ). if leave on, image display split second (probably 1...

performance - Should neo4j be very slow on a lot of merge reqests? -

i'm experiencing slow neo4j , htop shows it's lucene ate cpus on server. i'm writing data, attempting 50-500 cypher requests per second, each foreach (id in {ids} | merge (:community {id: id})) all 3 request generators here https://github.com/publicradio/vk_graph_reflector/tree/master/lib/reflectors (yes, javascript es2015) i've started suspect lucene slow down because of merge requests, right? can reason? how can optimise stuff if i'm right? can share visual query plan? just take query , prefix profile in browser. i think it's number of things: use cypher parameters not string substitution try merge on single properties have constraint (or index) if don't need merge use match, i.e. if data exists ! if don't need unique relationships use create, i.e. when know need connect new nodes existing nodes. something this: match (group:vk_group {id: {group_id} }) merge (post:vk_wall_post { id: {post_id}}) on create set pos...

What do these Maven Liquibase errors mean? -

when try running "mvn compile" in command prompt, these errors. warning: liquibase skipped due maven configuration warning: using platform encoding copy filtered resources, i.e. build platform dependent! you don't version of liquibase you're using. if it's 3.3.3, see this question , this issue on liquibase site (helpfully found me @tome ).

ruby on rails - How to create input fields for a hash storing multiple values in a database column? -

i'm trying store multiple values using hash in database column "text" in object called overlays. so calling looks overlay.text there multiple values want store in text column, such as.. • preheadline • bullet1 • bullet2 • bullet3 i'm serializing text column in model class overlay < activerecord::base belongs_to :user has_many :contacts, as: :contactable serialize :text then, in form creating model, i've tried creating input field "bullet1", it's not storing value. <div class="form-group"> <h4 class="col-xs-12 field-title">bullet 1</h4> <div class="col-md-12"> <input type="text" name="overlay[text][bullet1]" placeholder="bullet point text here" class="form-control input-lg" value="<%= @overlay.text[:bullet1] if defined? @overylay.text , @overlay.text[:bullet1].present? %>" /> ...

java - Store constructor that accepts parameter in reference -

i have class public class person { private int age; } and using supplier in java 8 , can store constructor reference supplier<person> personsupplier = person::new but if constructor accepts parameter age like public class person { private int age; public person(int age) {this.age = age;} } now supplier<person> personsupplier = person::new doesn't works, should correct signature personsupplier ? can like. supplier<person> personsupplier = () -> new person(10); but age must different each person, doesn't solve problem. may should use else instead of supplier ? you can use java.util.function.function in java , supply age when calling apply . e.g. function<integer, person> personsupplier = person::new; person p1 = personsupplier.apply(10); person p2 = personsupplier.apply(20); which equivalent to function<integer, person> personsupplier = (age) -> new person(age); person p1 = personsu...

c - "initialization makes integer from pointer without a cast" waning in array initialization -

i starting learn c. know why warning. declared bidimensional char array, why character "d" not allowed? char array[3][3] = {{1,"d",3},{3,2,1},{2,1,3}}; replace "d" 'd' 'd' character "d" string

MySQL Select with alpha wildcards not working -

i have simple table of single column rows of char(12) like: drf4482 drf4497 drf451 drf4515 ehf452 fjf453 gkf4573 i want select of rows between d , f , , have 4 numbers @ end. drf4482 , drf4497 , drf4515 , etc. i've tried number of different wildcard combinations no rows. i'm using: select * `expired` id '%[d-f][a-z][a-z]____'; i've tried broaden to: select * `expired` id '%[d-f]%'; and returns nothing well. i've tried collate latin1_bin based on other posts didn't work either. table utf8 , i've created second table latin1 , tried few different collations same results - no rows. where error? you need use regexp instead of like . notice syntax little different; doesn't sqlish % wildcard characters. so, want id regexp '[d-f][a-z][a-z][0-9]{4}' for app. don't have multibyte characters in these strings, because mysql's regexp doesn't work correctly in circumstances. ...

detection - Why is so difficult to detect polymorphic malware? -

why difficult detect polymorphic malware? is not enough build signature after decompress encrypted part of malware? and match signature possible version of malware doing similar process? with similar process mean decompress on real time encrypted part of malware using software peid, , test against signatures generated. with signature, doing reference classic signature used in antivirus software, sintactic signature (regular expresion of hexadecimals example). edit: why don't consider malware software can't correctly unpacked? benign software use custom pack methods? edit: ¿how know if software packed? ¿if software packed can aware of that? ¿can know beginning of obfuscated part of malware? ¿what mimimorphism? is there book or handbook specific polymorphic malware? or obfuscated malware? appreciate reference. well, no it's not simple. first of all, peid detects packer used pack sample signature. assuming packer has constant signature, not ...

perl - Running script and defining object value in terminal window -

when run perl scripts, open terminal window on mac , write "perl test1.pl" after moving folder containing perl script. often find myself wanting run same perl many times, @ same time, minor changes. for example perl script "test1.pl" looks this: $year = 2001; <rest of code uses $year> i want execute "test1.pl" $year = 2001, $year = 2002, etc. run script $year = 2001, adjust script $year = 2002, save, open new terminal window, run again, repeat. is there way submit perl script designate in terminal window value $year? i'm thinking like: "perl test1.pl, $year = 2001" thanks! one way (of many ways) is: my $year = (@argv) ? shift : 2001; then run as: perl test1.pl 2002 2001 defualt if don't specify year on command line. see also: perldoc -v @argv

scala - Is there more compact way to convert Map[Any,Any] to Map[String,String]? -

consider code: def convertmape(map:map[any,any]): map[string,string] = { map.foldleft(map.newbuilder[string,string]) {(builder,kv)=> builder += ((kv._1.tostring, kv._2.tostring)) }.result() } is there more compact way convert map[any,any] map[string,string] without using map builder? what about map.map{case (k,v) => k.tostring -> v.tostring}

r - New x-axis does not show up -

i have dataset values depend on days. there on 6000 days in dataset.i see of days on x-axis of graph. dates <- as.date(yen[,1], "%d.%m.%y") yen <- as.xts(yen[,2], dates) plot(yen, xaxt= 'n', ylab="exchange rate", xlab= "time") with have created graph no values on x-axis. i want 1st, 1000th , 3000th day shown on x-axis. axis(side=1, at=1:3, labels= dates(c[1,2000,3000]) r gives no error warning not drawing new axis requested values. thanks in advance!

hadoop - Element is not clickable at point (339, 85). Other element would receive the click -

below current html dom. &lt;div class="addr notchooseopera right" click="switchpanel" un="contact"&gt;&lt;a class="addrbutton " href="javascript:;" title="通讯录"&gt;&lt;span class="bag"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; i'm using python+selenium+webdriver execute method self.browser.find_element_by_class_name("addrbutton").click() but error: selenium.common.exceptions.webdriverexception: message: unknown error: element not clickable @ point (339, 85). other element receive click: <div class="addr notchooseopera right" click="switchpanel" un="contact">...</div> (session info: chrome=36.0.1985.143)

php - PHPMailer using gmail -

i'm trying send emails using phpmailer , gmail. worked fine on php 5.5 when updated php 5.6 error (tls on port 587): stream_socket_enable_crypto(): ssl operation failed code 1. openssl error messages: error:14090086:ssl routines:ssl3_get_server_certificate:certificate verify failed if try using ssl on port 465 instead: 2015-05-29 15:11:58 smtp error: failed connect server: (0) 2015-05-29 15:11:58 smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting i googled around , thing found out should set oauth2 don't know how. googled around , found this: https://github.com/phpmailer/phpmailer/wiki/using-gmail-with-xoauth2 i followed , got stuck when said should update get_auth_token.php. can't find file anywhere. how installed phpmailer using composer: "phpmailer/phpmailer": "~5.2" do know how working or without oauth2? i'm using php 5.6.8 thanks in advance, busarna4 php 5.6 introduces ssl certificate v...

javascript - Jquery UI droppable action when snapped in -

hi wan event starts wenn droppable element snapps in? is there possibility realise this? js looks @ moment: function matchingtask(questions, answers) { // elemente drag n drop faehig machen $(".match_task_draggable").draggable({ cursor: 'move', containment: $('.match_task_draggable').parent('div').parent('div'), scroll: false, snap: ".match_task_drop", snapmode: "inner", stop: setdroppableanswer }); } // set answer function setdroppableanswer(){ alert("ba"); } but stop reacts every time drop element, should react when dropped snap area solution: $(".match_task_drop").droppable({ drop: function( event, ui ) { setdroppableanswer( ui.draggable ); } });

css - Chrome: mouse hover on some elements causes vertical scrollbar to jump to the top -

i have application contains vertical scrollbar on page because 1 of 2 lists on page can long , want user scroll or down. found user hovers mouse on other elements on page , if scroll bar @ bottom, chrome causes scrollbar jump top. has seen behavior in chrome? works fine other browsers. tried changing bottom padding on 1 of header div elements: padding: 0.75em 2em 1.75em 2em; and seems have reduced problem, problem still occurs occasionally. 1 thing notice occurs when 1 of lists long. it turned out css problem. whenever, element hovered, css added box-shadow on element using :hover selector. caused border increase , caused list change size. when removed box-shadow, problem went away. not chrome problem.

github - Are the remote and centralized repository the same thing in git? -

they seem synonyms, can't tell quite yet. basing off subversion vs. dvcs debate here . maybe. remote repositories fundamental feature of git (though can use git without remote). "central" repositories matter of project organization. a remote git repository repository other local one; can push, pull, , fetch local repo. if have number of developers working on project, each 1 have or own local repository, , might have single "central" repository each developer can push , pull. can give advantages of non-distributed dcvs while still letting each developer make local changes. "central" repository remote repository each of developers. (it needs "bare" repo, since can't push non-bare repo.) with central repository, can have single definitive location defines current state of project. other organizations possible; example, developers can share changes sending each other pull requests.

JQuery accordion - targeting only header anchors -

i’ve created jquery accordion using generator - http://code.anotherwebstorm.com/apps/awsaccordion/ however, there links within content areas of accordion tabs, , when these links clicked, tab automatically closes. need tab remain open when these content links clicked. when tab header clicked should tab close. creator of script no longer supports it, gave me idea of needs done, here: “i think need core , change in order listen anchor tabs when clicking , not ones inside. i think key here  https://github.com/anotherwebstorm/awsaccordion/blob/master/jquery.accordion.js#l55 in line. all click events bound headlis if couple of conditionals , / or target header anchors should fix it. “ unfortunately, don’t know how implement has described. appreciated! thank you headlis = elem.children().children() this elements getting initialized; before click event binding happens on elements of array can remove elements array doing custom check headlis = elem.children().child...

wordpress - Prevent theme styles from loading in custom page template -

i have wordpress website theme. implement changes created child theme. works fine. now want add page template allows me enqueue styles via wp_enqueue_style . work need add wp_head() page template if understand correctly. i want use custom page template front end app creating (plugin). design of app separate rest of website. right theme styles when use wp_head() . prevent default theme styles loading. what easy way achieve this? preferably theme independent solution. you can include different header. https://codex.wordpress.org/function_reference/get_header multiple headers different header different pages. <?php if ( is_home() ) : get_header( 'home' ); elseif ( is_404() ) : get_header( '404' ); else : get_header(); endif; ?>

php - Get file extension after file is uploaded and moved in Symfony2 -

i'm uploading file through symfony2 , trying rename original in order avoid override same file. doing: $uploadedfile = $request->files; $uploadpath = $this->container->getparameter('kernel.root_dir') . '/../web/uploads/'; try { $uploadedfile->get('avatar')->move($uploadpath, $uploadedfile->get('avatar')->getclientoriginalname()); } catch (\ exception $e) { // set error 'can not upload avatar file' } // right filename $avatarname = $uploadedfile->get('avatar')->getclientoriginalname(); // wrong extension meaning empty, why? $avatarext = $uploadedfile->get('avatar')->getextension(); $resource = fopen($uploadpath . $uploadedfile->get('avatar')->getclientoriginalname(), 'r'); unlink($uploadpath . $uploadedfile->get('avatar')->getclientoriginalname()); i renaming file follow: $avatarname = sptrinf("%s.%s", uniqid(), $uploadedfile-...

wpf - TabItem style based on ViewModel type -

i able achieve binding of tabitems collection of viewmodels , use datatemplates style contents of each type. cannot find way styling tabitem (header etc.) based on selected viewmodel. edit: may ask why want have different styles tabitems, well, 1 of reasons instance have 1 tabitem open should not have close button.

c# - Access a Model class from a View without direct access to Model Layer -

Image
i need create property in 1 of user controls of model type think must prevent direct access model layer view layer . i have view model of model provide set of model objects ... setofa_usercontrol setofa_viewmodel a_model i need property in user control: public a_model selecteda { get; set; } one way create new view model following codes , use in user control : // ------------ view model layer ------------ public class singlea_viewmodel: modela { } // --------------- view layer --------------- public singlea_viewmodel selecteda { get; set; } but i'm trying prevent new empty view model class inherit model above. correct? what suggestions prevent direct access model layer , create property in user control ??? edit 1: i have 3 project: view project view model project model project i want know can prevent reference model project in view project or not.... i have selecteda property in view model , put logic in view model class , wor...

Structural correctness while refactoring in Clojure -

if project using "person" maps shape {:firstname :lastname :address} , , want change shape {:name {:firstname :lastname} :address} , can ensure i've made corresponding changes everywhere these objects used? in java, it's straightforward anywhere still have person.firstname issue compile error. in clojure might not runtime error, bad data saved server. assume it's not possible guarantee correctness, there other fine-toothed-combs? clojure has libraries provide data definition , validation. example, use https://github.com/prismatic/schema regarding difficulty of compile-time vs. runtime errors...well, issue not unique clojure. quote john carmack: "the challenge of lisp getting program run, challenge of haskell getting compile."

jquery - XSS prevention - jqencoder - canonicalize more than once? -

i'm using jquery plugin prevent xss attacks. called jquery-encoder https://github.com/chrisisbeef/jquery-encoder there series of functions canonicalize - ation used multiple times. is safe canonicalize data more once? read somewhere on owasp not preferred , can lead risks. thanks, appreciated! -dkavathe

javascript - Bootstrap navbar-toggle alway open -

i button (navbar-toggle ) visible @ time tested: http://jsfiddle.net/kylemit/m49bb/ , works 50/50. button time. if click button menu pops @ moments , disappears. maybe more understandable: 1. click on button. 2. see menu 2s. 3. again, don't see menu. i used bootstrap v3.3.4 <nav class="navbar navbar-default navbar-static-top always-open" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar" aria-controls="navbar"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar...

function - Javascript Callback Scoping Issue -

i reading douglas crockford's book on javascript , having issues function scoping section. under impression callback function's value bound value of function calling callback (in case dosomethingasync). however, when run code, foo printed, far dosomethingasync concerned, foo undefined. shouldn't mean callback doesn't have access var well? function dosomething() { var foo = "foo"; dosomethingasync(function callback() { console.log(foo); //prints foo }); } this , variables different 1 another. this set how function called , not it's defined, although bound functions , es6's arrow functions change (more below). callback isn't bound , isn't arrow function, value of this within callback you're giving dosomethingasync determined how dosomethingasync calls function. if calls standalone function: callback(); ...then this undefined (in strict mode) or reference global object (in loose mode). but if calls speci...

Plain MEAN Stack or a MEAN Framework like mean.io? -

i have decent html , css skills , basic understanding of javascript. i'm designing system different users can store inventory list (a separate list each user). i started plain mongo, express, angular , node stack. when researching user authentication in mean-stack stumbled across mean.io seems have build-in user auth/management. is usefull beginner start such mean framework or better stay @ basics first try? mean frameworks mean.io or mean.js great structuring app still have understand how works. may better go tutorials scratch learn use framework once want build app. start node/express server using simple html/js page understand api creation add angular learn frontend stuff. understand mean.xx doing regards frontend vs backend. mean.js example puts backend (e , n) stuff in server/ folders , frontend (a) stuff in client/ folders.

javascript - How to move an object to the other stable object in THREE.JS? -

i new , have created scene,renderer,camera,and 2 objects , want move 1 object other object how can achieve in three.js ? heres stuff have tried kindly me in thanks <script src="js/three.min.js"></script> <script src="js/tween.min.js"></script> <script src="js/orbitcontrols.js"></script> <script> var scene = new three.scene(), camera = new three.perspectivecamera(75, window.innerwidth/window.innerheight, 0.1, 1000), renderer = new three.webglrenderer(), controls = new three.orbitcontrols(camera), tween = new tween.tween({cube.position}) .to({cube1.position},3000) .delay(2000) .start(); renderer.setsize(window.innerwidth, window.innerheight); document.body.appendchild(renderer.domelement); var cube = new three.mesh( new three.cubegeometry(2,2,2), new three.meshbasicmaterial({wireframe: true, color: 0...

powershell - Task Scheduler Run Whether User Logged Or Not Issue -

i'm running powershell script task scheduler , runs fine when option 'run when user logged on' selected. this isn't efficient obvious reasons. there specific reason why when choose 'run whether user logged on or not' script doesn't run? i've tried local admin , account. have full administrator rights don't see permissions issue. clues? thank much this task scheduler export xml. fyi, script opens excel, refreshes connections, , saves. (the file in 1 drive) regardless of being in 1 drive or not, doesn't refresh file on desktop. i have tried passing unc path in script opposed c:/users/-- <?xml version="1.0" encoding="utf-16"?> <task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <registrationinfo> <date>2015-05-28t09:34:25.8180083</date> <author>-----</author> </registrationinfo> <triggers> ...

encryption - why does my python code not encrypt or decrypt my message -

for reason when run code @ end displays message without encrypting or decrypting im confused please not hate on me if obvious new python , barely know basics #declare variables newword ="" newletter = "" secretmessage = 0 mode = input("please enter mode: ").lower() #makes lowercase message = input("please enter message: ").lower() # lowercase tackle capitals while true: try: offset = int(input("please enter number: ")) #if no exception occurs, except clause skipped , execution of try statement finished. break except valueerror: #if exception occurs, except clause continues printing not valid number , letting re-enter offset , not throwing error. print ("not valid number") #print(mode, message, offset) #test check user input letter in message : secretmessage = ord(letter) if mode == "encrypt" : secretmessage += offset # add offset letter if mode == "de...

delphi - How to ease extraction of meticulously specified XML data? -

there xml data files need extract data from, along xsd describes structure. uses lots of complex types couple of namespaces, use more complex types more namespaces , on. after flattening, still 120 xsds used. here's xsd: copyright (c) un/cefact (2008). rights reserved. document , translations of may copied , furnished others, , derivative works comment on or otherwise explain or assist in implementation may prepared, copied, published , distributed, in whole or in part, without restriction of kind, provided above copyright notice , paragraph included on such copies , derivative works. however, document may not modified in way, such removing copyright notice or references un/cefact, except needed purpose of developing un/cefact specifications, in case procedures copyrights defined in un/cefact intellectual property rights document must followed, or required translate languages other english. limited permissions granted above perpetual , not revok...

Nginx configuration to work with Node.js -

i know there similar questions or walkthroughs here or in web although stuck on this. the background i trying set local virtual host ghost.local there ghost blog(which on node.js). want, when visit http://ghost.local on ubuntu 14.04 machine nginx pass request node.js , 'll able see ghost blog. the problem i 've set hosts file 've set nginx vhosts ghost running on node.js. although when visit http://ghost.local 503 service unavailable failed resolve name of server ghost.local my hosts file: 127.0.0.1 ghost.local 127.0.0.1 localhost my /etc/nginx/sites-available/ghost.local file: server { listen 80; server_name ghost.local; access_log /var/log/nginx/ghost.local.log; location / { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $remote_addr; proxy_set_header host $http_host; proxy_pass http://localhost:2368; proxy_redirect off; } } the link...

android - aidl is missing when trying buildToolsVersion "23rc1" -

was trying out buildtools 23rc1 , build fails aidl missing - project uses no aidl - smell bug in rc ( rc after ) - want ask here first before filing bug when use buildtoolsversion "23.0.0 rc1" in Мodule gradle, should use classpath 'com.android.tools.build:gradle:1.3.0-beta1' in project gradle file.

java - "null" value failing to serialize -

i using jersey client access rest service. i using jsonobject , setting "null" literal in it. fails while serialized. upon investigating, found jsonnull.equals() method has "null".equals(value) considers value jsonnull object. and then, jsonnull#isempty() throws exceptions. net.sf.json.jsonobject params = new net.sf.json.jsonobject(); params.put("pghidentifie", "null"); and when serialized throws: caused by: com.sun.jersey.api.client.clienthandlerexception: org.codehaus.jackson.map.jsonmappingexception: object null (through reference chain: net.sf.json.jsonobject["pghidentifie"]->net.sf.json.jsonnull["empty"]) how can serialize "null" value inside jsonobject? thanks! defaultclientconfig defaultclientconfig = new defaultclientconfig(); defaultclientconfig.getclasses().add(jacksonjsonprovider.class); client client = client.create(defaultclientconfig); webresource we...

Android sensor code example understanding -

i'm new android development , have code make shake event, not understand last_x used for? if understand correctly last_x detecting last x-axis value of when last shaking event happened. how works, when last_x = x , x event.values[0]. private float last_x; public void onsensorchanged(sensorevent event) { sensor mysensor = event.sensor; if (mysensor.gettype() == sensor.type_accelerometer) { float x = event.values[0]; //x value if (math.abs(last_x - x) > 2) { mmap.addmarker(new markeroptions() .position(new latlng(55.654929, 12.139613)) .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_orange)) .title("hey moved x axis on")); } last_x = x; } }

java - Collections.sort isn't sorting -

i building web application using java ee (although problem more java based) in servlet, getting list of orders ejb. in list of orders, there list of states order (sent, on dock, non received ...) i want sort list of states date of state. use collections.sort this: (command c : commands) { c.getstatelist().sort(new comparator<state>() { @override public int compare(state o1, state o2) { return o1.getstatedate().compareto(o2.getstatedate()); } }); c.getstatelist().sort(collections.reverseorder()); } request.setattribute("commands", commands); but when display results, states not sorted. i tried reverse order can see, isn't working either. as can see, replaced collections.sort listiwanttosort.sort. still not working. any ideas on why not work or how repair it? edit : here getter list , instanciation : @onetomany(cascade = c...

R: multicollinearity issues using glib(), Bayesian Model Averaging (BMA-package) -

i experiencing difficulties estimating bma-model via glib(), due multicollinearity issues, though have specified columns use. please find details below. the data i'll using estimation via bayesian model averaging: cij <- c(357848,766940,610542,482940,527326,574398,146342,139950,227229,67948, 352118,884021,933894,1183289,445745,320996,527804,266172,425046, 290507,1001799,926219,1016654,750816,146923,495992,280405, 310608,1108250,776189,1562400,272482,352053,206286, 443160,693190,991983,769488,504851,470639, 396132,937085,847498,805037,705960, 440832,847631,1131398,1063269, 359480,1061648,1443370, 376686,986608, 344014) n <- length(cij); tt <- trunc(sqrt(2*n)) <- rep(1:tt,tt:1); #row numbers: year of origin j <- sequence(tt:1) #col numbers: year of development k <- i+j-1 #diagonal numbers: year of payment #since k=i+j-1, have leave out dummy in order avoid multicollinearity k <- ifelse(k == 2, 1, k) i want evaluate effect of i , j both via...