Posts

Showing posts from March, 2013

html5 - difference between iframe, embed and object elements -

html5 defines several embedded content elements, which, bird's-eye view, seem similar point of being largely identical. what actual difference between iframe , embed , object ? if want embed html file third-party site, of these elements use, , how differ? <iframe> the iframe element represents nested browsing context. html 5 standard - "the <iframe> element" primarily used include resources other domains or subdomains can used include content same domain well. <iframe> 's strength embedded code 'live' , can communicate parent document. <embed> standardised in html 5, before non standard tag, admittedly implemented major browsers. behaviour prior html 5 can vary ... the embed element provides integration point external (typically non-html) application or interactive content. ( html 5 standard - "the <embed> element" ) used embed content browser plugins. exceptions svg , html handled...

Rails custom routes, the point of the as: symbol? -

in example, point of as: :logout parameter? get 'logout', to: 'devise/registrations#destroy', as: :logout in views, can call route specifying logout_path. as: :logout parameter that's doing this? exactly, can specify how want path named using as in routes. you can read more naming routes here . the as parameter doesn't need match in path or action: get 'get-me-outta-here', to: 'devise/sessions#destroy', as: :logout # note logging out devise sessions not registrations

Graph API Returning All Status Results as Undefined -

i creating search bar queries facebook results. when type word search , click search, results posted "status"....i lot of undefined fields. says "'user' shared status", , under photo section says undefined, , there's no actual status. it's blank. how can fix this? anything else fine...."'user shared photo" shows photos shared. there description...sometimes. shared link works too. i want able type more 1 word in search bar, , able search again. of now, have refresh page in order search again. i've checked other topics answer, topics aren't how i'm doing search. haven't found answer yet. can help! thanks....here's link page search bar is. i'll include code well. http://ericnaff.com/html5/p3/ also- how can make "enter/return" starts search well? code- function searchfb(usersearchparameter) { $.getjson('https://graph.facebook.com/search?q=' + usersearchparameter + '&callbac...

c++ - Function that takes an array of integers as a parameter and returns the sum of odd numbers in the array -

i keep getting error: "run-time check failure #3 - variable 'x' being used without being initialized." i thought initialized numbers put in array? #include <iostream> using namespace std; const int max = 10; int odd(int sumodd[]) { int sum = 0; for(int = 0; < max; ++) { if(sumodd[i] % 2 != 0) sum+=sumodd[i]; } cout << "sum of odd integers in array: " << sum << endl; return sum; } int main() { int x[max] = {13,14,8,7,45,89,22,18,6,10}; int returnarray(x[max]); cout << "sum of odd integers in array" << endl; system("pause"); return 0; } int returnarray(x[max]); // in main should be returnarray(x); you've declared function taking array , returning integer, need call function array parameter.

Why does JavaScript make it so difficult to check if an image is loaded? -

why difficult check if img has loaded in javascript? other languages can solved doing loop, , breaking when image has loaded. here function returns loaded img after passing file path. nothing other onload seems work check if image has loaded. unable use img.complete or other method loop checking each time until load has completed because not work (the browser hang). global_image_loaded = 0 function loadimage(imagesrc) { global_image_loaded = 0 var img = new image(); img.src = imagesrc + "?" + new date().gettime(); img.onload = function() { global_image_loaded = 1; } if ( global_image_loaded = 1 ){ return img; } else { return 0; } } this function works fine, until try draw image canvas following function: function image(elementid, img, x, y, w, h) { var mode = 0; if ( w === undefined) { mode = 1; } if ( h === undefined) { mode = 1; } ...

Query has_many through association Rails -

i have has_many though association this: user.rb has_many :memberships, :dependent => :destroy has_many :groups, :through => :memberships group.rb has_many :users, :through => :memberships has_many :microposts membership.rb belongs_to :user belongs_to :group first need know query groups of user, after need way show microposts of groups. possible 1 query information? thanks lot! to user's groups: some_user = user.find(some_id) some_user.groups to microposts, do: some_user.groups.each |group| puts group puts group.microposts end however, cause separate query generated collect microposts of each group. can fixed eager-loading microposts using includes : some_user.groups.includes(:microposts).each |group| puts group puts group.microposts end now 2 queries generated - 1 fetch groups, , 1 fetch all microposts associated these groups. behind scenes, activerecord match microposts correct group, , return them accordingly when calling .m...

xslt - FORX0003: The regular expression in tokenize() must not be one that matches a zero-length string -

hi working "," , other delimiters it's not working pipe(|) symbol it's giving forx0003: regular expression in tokenize() must not 1 matches zero-length string <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="text/text()" name="tokenize"> <xsl:param name="separator" select="'|'"/> <xsl:for-each select="tokenize(.,$separator)"> <item> <xsl:value-of select="normalize-space(.)"/> </item> </xsl:for-each> </xsl:template> you need replace <xsl:param name="separator" select="'|'"/> <xsl:param name="separator" select="'\|'"/> if want tokenize '|' character. have sample xs...

javascript - Using websocket with Thin -

i trying use websocket on thin server. following code attempt run clock updates time on web page every 0.1 second. page content of initial page rendered. the thin server initiated serve , session methods. websocket initiated websocket method. tick_every utility function calls block @ right timing every time interval given. code: require "rack" require "thin" require "em-websocket" page = <<_ <html> <body><div id="output"></div></body> <script> window.addeventlistener("load", init, false); function init(){ websocket = new websocket("ws://localhost:4000"); websocket.onmessage = function(evt){ document.getelementbyid("output").innerhtml = evt.data; }; } </script> <div id="output"></div> </html> _ def serve rack::handler::thin.run(rack::builder.new map("/"...

c# - Executing SSIS 2012 package that has script components from external application -

i'm writing application execute ssis 2012 package using microsoft.sqlserver.manageddts v 11.0 assembly. package i'm trying execute designed , executed ssdt-2012, , has script components handle rows don't transfer correctly. when try run application error message each of script components: ssis.pipeline: run ssis package outside of sql server data tools must install [script component name] of integration services or higher. configuration: building application x86 on windows following app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0"/> <supportedruntime version="v2.0.50727"/> </startup> </configuration> the relevant code is: using system; using system.data; using system.data.common; using system.io; using microsoft.sqlserver.dts.runtime; cl...

HTML link with a php action -

i creating website stores information of homes address, city etc. got upload database part done , got search database , display information done. but plan search results , there suppose option view full profile of home via link. displaying full profile information gathered database done through separate php file. when link php file display last column in database. how can link when click on "view full profile" connect correct data/profile corresponds different address or price. or if cant use html link can use? impossible? here code displays search results have been able search database , display it <?php if($sql->num_rows){ while ($row = $sql->fetch_array(mysqli_assoc)){ echo '<div id="listing"> <div id="propertyimage"> <img src="images/'.$row['imagename1'].'" width="200" height="150" alt=""/> ...

Binary streams parsing library for C -

could advise proven binary stream parsing library c? nice if declarative c allows. i need binary protocol parsing , describing quite complicated protocol it's formal specification, that's why want declarative possible. haskell's data.binary.get great. i've found binpac, seems heavyweight , oriented c++ , project pure c. example describing mean: parser_t parsers[] = { { get_bit, out_field1, &pkt.field1 } ,{ get_bit7, 0, 0 } // skip 7 bits ,{ get_word16be, out_field2, &pkt.field2 } ,{ 0, 0, 0 } // end }; // skip // char *data, char *data_end, map_parsers(data, data_end, parsers); // parse stream upd. it's fine have fast library sequential reading bits, words, aligned, unaligned, etc memory. may write declarative frontend or dsl on own. there's pads nice people @ at&t. there's ragel can used same thing. i've not used either myself, found hints of existence ...

.net - Not able to use Modern UI Charts for Windows 8 -

i trying use modern ui charts windows store app not able working.(cannot see chart) a similar issue logged person here along code can please help?? update 1 getting started free metro (modern ui) charts windows 8 i have created nuget package of modern chart . install there. uninstall previous library of modern chart. i giving demo of chart. first create new page , add code. that's it! mainpage.xaml <page ... ... ... xmlns:chart="using:de.torstenmandelkow.metrochart" --> ... ... ...> <grid background="{staticresource applicationpagebackgroundthemebrush}"> <chart:piechart width="400" height="400" horizontalalignment="center" verticalalignment="center" chartsubtitle="chart fixed width , height" charttitle=...

Unable to setup JavaFx platform in Netbeans -

Image
i using jdk 8 access (build 90) netbeans 7.3 in windows while enabling javafx in java platform says javafx platform not correctly defined . tried give jre8 path still error continues. error not shown when set javafx runtime jre 1.7 in case javafx code compiled jdk8 tried run using jre7 ending incomparable class version error . note need use jdk 8 experimental project needs latest features , moving jdk 7 not option. running jar separately in command line every time compile using netbeans take lot of time reducing productivity. netbeans 7.3 doesn't support javafx 8. netbeans 7.3 incompatible javafx 8 because looks javafx classes in wrong place. see javafx mailing list post details . there corresponding bug in netbeans fix javafx classes in new location, not deliberately not addressed in netbeans 7.3 (i can't find bug in netbeans bug tracker reference here, recall seeing earlier). i have managed hack of netbeans 7.3 configuration can used develop javafx 8, ...

iphone - Update views while being touched -

i having app load images in uitableview . each row has image view. i download images url , assign uiimageview . problem here image views not updating if dragging table view. updates when release finger. another problem have label in cells shows counter incremented using timer. timer action not getting called when finger on table view. how do updates in both these cases? may basic question. have no clue. thanks everyone! edit: have noticed -connection:didreceiveresponse: method not getting called when view being touched. edit 2: tried adding run loop nsurlconnection. method looks this. - (void)start { nsmutableurlrequest* request = [[nsmutableurlrequest alloc] initwithurl:self.imageurl cachepolicy:nsurlrequestreturncachedataelseload timeoutinterval:self.timeoutinterval]; [request setvalue:@"gzip" forhttpheaderfield:@"accept-encoding"]; _connection = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:...

html - PHP - Could you use POST method to stream data to a server over a long period of time? -

caveat, know has potential ridiculously stupid question, had thought , want know answer. aim: run interactive session between browser , server single request without ajax or websockets etc.. scenario: php file on server receives data post method user. content length in header 8mb keeps connection open until receives full data of 8mb. on user side delivering data very (simulating terrible connection, example). server receiving data bits @ time. [can passed php file process bits @ time? or passed once data received?] whatever wants bits, , delivers browser, in echo loop). @ time intervals, user injects new data 'stream' surrounded continuous stream of padding data. is of possible? or cgi? expecting not possible really, stops process timing out if have terrible connection , post data huge? as far know, this, php file calling post data called webserver once has received data. otherwise, sending image post, , php script moves image tempfiles directory directory, b...

JQuery .load JSP File -

i trying load jsp file. jsp file getting load jstl tags inside jsp not getting rendered. thoughts? process.jsp has jstl tags not getting rendered. <script> $(document).ready(function(){ $("button").click(function(){ $("#holder").load("/process.jsp"); }); }); </script> <button>get data</button> <div id="holder"> </div> never mind, tags scope not define. works

r - How to show image at node & how to plot graph for relation "From & To" in igraph which can work similar to qgraph -

#here plot between , column of data frame using qgraph #we require same using igraph functionality if(!require(qgraph)){ install.packages(qgraph) }else{ require(qgraph) } demo_adj <- data.frame(from=c(1,2,'b','x','y','a'),to=c('a','b','a','y','1','y')) qgraph(demo_adj) how plot same relation using igraph , how use image instead of default node in igraph ?

c++ - How to tell advance() to use += operator on input iterators if they aren't random access -

consider input iterator join_iterator : iterates on concatenation of other ranges. calling ++i repeatedly can much slower simple i += n . nevertheless, c++ code requires advancing iterator arbitrary amount uses std::advance , automatically resorts calling ++i when iterator isn't random-access. (sadly, people use std::advance(i, n) instead of using std::advance; advance(i, n) , can't supply advance iterator , rely on adl.) on other hand, can't use + or += because input iterators don't have implement them. so question is: how go supporting such scenario , when: implementing such iterator? using input iterator might have optimized operator += ? (note advance , + isn't scenario in matters -- distance , - has same problem.) according c++11 §24.4.4, since random access iterators provide + , - operators, library provides 2 function templates advance , distance . these function templates use + , - random access iterators (an...

php - Website reported as malicious because redirecting -

i have example site example.com in index.php i'm redirecting site if ($_server['http_host'] == 'www.example.com') header('location: http://www.example.com/ru/'); antivirus detect redirecting malware, how change code that, antivirus not detect malware in redirecting ? maybe way use .htacces rewrite: rewriteengine on rewritebase / rewritecond %{http_host} ^www\.example\.com$ rewriterule ^$ maindomain.com/ru [l] ? may there script effecting use meta tag below: echo '<meta http-equiv="refresh" content="0; ,url=http://www.example.com/ru">';

How to save .ods spread sheet (OpenOffice.org) to .xlsx (MS Office Excel 2007) -

recently switched ms office openoffice.org 3.4.1 . here questions: i not able save .ods spread sheet .xlsx 2007 format. option got when use save as microsoft excel 97/2000/xp (.xls) (*.xls) i not able use in ms office excel 2007 formula in open office org. example formula like =if(and(a2<>"";b3<>"");"";if(and(b3="";b2<>"");"go";if(a3="";",";""))) here test file formula ms excel 2007 , office org edit: problem 2 solved. formula couldn't copies @ first. instead of , have use ; in openoffice.org but still couldn't figure out how save xlsx. i hope can me. apache openoffice 3.4.1 (and earlier versions) not store in ooxml formats (.docx, .xslx, .pptx). don't know if remedied in forthcoming apache openoffice 4.0 or not. an alternative have conversion capability ooxml in both directions libreoffice .

google maps - Issue with panTo() and how to change coordinates -

Image
i've got little issue while placing panto() google maps v3. here description of problem: in case, goes well, map moves , animates until stops @ right point. var infowindow = new google.maps.infowindow({ content: strhtml }); google.maps.event.addlistener(marker, 'click', function() { var latitude = marker.position.lat(); var longitude = marker.position.lng(); var panningpoint = new google.maps.latlng(latitude, longitude); activeinfowindow.close(); map.panto(marker.getposition()); infowindow.open(map, marker); activeinfowindow = infowindow; }); in other case, wrote down map go panning point decided, instead of animating map, refreshes (not animate) , similar function "setcenter". var infowindow = new google.maps.infowindow({ content: strhtml }); google.maps.event.addlistener(marker, 'click', function() { var latitude = marker.position.lat(); var longitude = marker.position.lng(); var panningpoint = new google.ma...

c - If C99 lifted "variable declaration at top of block" constraint, why doing so in a "for loop" showing error? -

i read site c99 lifted restriction variables in c must declared @ top of block. tested in program below , indeed true no errors. in th e same program if declare variable in first statement of for loop, error: 'for' loop initial declarations allowed in c99 mode| two things here. since indeed allowed declare variables in middle of program,as did i , why not allowed in for loop statement? , second, if compiler (codeblocks/gcc) not in c99 mode already, why didn't error when declared variables in middle instead of top? #include <stdio.h> int main (void) { //proof initialization in middle works (for i) printf("enter\n"); char string[20]; scanf("%s", string); int i=20; printf("%s,%i", string, i); //proved works for(int j=0; j<10; j++) //this not allowed printf("%d\n", j); } by default gcc compiles code own "dialect" extension of c89. idea new code , learning c nowadays pass more m...

c++ - Balancing robot PID tuning -

Image
i'm trying build two-wheeled balancing robot fun. have of hardware built , put together, , think have coded well. i'm using imu gyro , accelerometers find tilt angle complimentary filter smoothing signal. input signal imu seems pretty smooth, in less 0.7 variance + or - actual tilt angle. my imu sampling rate 50 hz , pid calculation @ 50 hz too, think should fast enough. basically, i'm using pid library found @ pid library . when set p value low wheels go in right direction. when set p value large output graph. from graph looks system not stable. hope have tested each subsystem of robot before directly going tuning. means both sensors , actuators responding , acceptable error. once each subsytem calibrated external error. can start tuning. once done can start valid value of p may (0.5) first achieve proper response time, need trials here, them increment cut down steady state error if , use d when required(in case of oscillation). suggest handle p,i ...

Guest user permissions with Rails and CanCan -

do need define permissions creating user guest? mean can sign out permissions? this relative need, in cases not set specific permissions guest users. have @ how ryan bates suggest handeling cancan http://railscasts.com/episodes/192-authorization-with-cancan in effect capture in initialisation of ability model: def initialize(user) user ||= user.new # guest user if user.role? :admin #admin permissions else #default permissions end end

java - How can utility classes be used to group methods on a final class, instead of extending the class? -

joshua bloch mentions in book ( effective java - 2nd ed ) in item 4 :- classes containing static fields , static methods (utility classes) can used group methods on final class, instead of extending class. can explain sentence? a common mistake (or, hopefully, was) create class contains common static methods, , use inheritance able access methods classes require methods. so have: class utility { static utilitymethod() { // usefull } } class application extends utility { somemethod() { utilitymethod(); } } this breaks object oriented principles, applicationclass was never supposed subclass of utilityclass . instead should use: final class utility { utility() { // avoid instantiation } static utilitymethod() { // useful } } class application { somemethod() { utilityclass.utilitymethod(); } } now there several ways java language designers using make above more appealin...

java - Xml List to Jaxb -

what way jaxb give convert type of xml conversion <options> <option name="name">https://abc.com/</option> <option name="name2">https://abc.com/</option> </options> i created 2 object classes it. not fill object data , set null values tag should set url https://abc.com/ . options.java , option.java options class contain setter @xmlelement(name = "option") public void setoption(list<option> option) { this.option = option; } option.java class is: @xmlrootelement(name = "option") public class option { string name; string option; public option() { super(); } public option(string name, string option) { super(); this.name = name; this.option = option; } public string getname() { return name; } @xmlattribute public void setname(string name) { this.name = name; } public string getoption() { return option; } public v...

translation - How to use HTML inside of translatable strings in Qt? -

the qt tutorial translatable texts not mention whether possible use html inside of translatable string. however, some examples found use it, seems possible. however, if use "<b>text</b>" in .ts file, qt linguist not open it. displays error message "unexpected tag" instead. the ts file xml. if want use html tags need escape them. example: <source>&lt;b&gt;text&lt;/b&gt;</source> note recommended way of managing translations in qt run lupdate tool on source code , have qt generate .ts file, in case done automatically.

How to apply a decorator to all views (of a module) in django -

it happens lot, when views in specific module supposed available when user authorized, or should same checks. how avoid repeating annotations on file? when using class-based views can create base class/mixin these views implements desired functionality (also using decorators ) , have views inherit base view. from django.views.generic import templateview class baseview(templateview): def get(self, request, *args, **kwargs): # checking here if not request.user.is_authenticated(): # if anonymous user return super(baseview, self).get(request, *args, **kwargs) class myview(baseview): pass

javascript - How do you send payload data with initial request? -

lets say, example, have page has table list of users. render html table of users, isn't friendly angular. can ajax server data, have wait initial page render , make additional http request, adds additional delay. is there way send payload data along initial request don't have ajax data , can still use angular binding (e.g. ng-repeat)? the way access server data without executing javascript have server include data in initial request web page. require using server side language such php, ruby, or asp.net can query data, add web page, , send updated web page in it's inital http resonse. however, concept undermines purpose of using client side framework such angularjs. angular wants in charge of data access, , recommend letting be. angular doesn't know data didn't retrieve, going have dynamically modify page scripts tell angular data server retrieved. going down dark road not want go down. doing double work. if concern users see brief delay betw...

c# - Textbox - bound property value does not update immediately -

i have textbox bound property itemid so. private string _itemid; public string itemid { { return _itemid; } set { _itemid = value; } } the xaml of text box follows: <textbox text="{binding path=itemid, mode=twoway}" name="txtitemid" /> the problem is, value of itemid not update type, causing add button disabled (command), until lose focus of text box pressing tab key. yes, default, property updated on lost focus. improve performance avoiding update of bound property on every keystroke. should use updatesourcetrigger=propertychanged . try this: <textbox text="{binding path=itemid, mode=twoway, updatesourcetrigger=propertychanged}" name="txtitemid" /> you should implement inotifypropertychanged interface viewmodel. else, if property changed in viewmodel, ui not know it. hence not updated. this might in implementation.

Rails: Do something once per page reload -

how invoke method once per page reload? defining before_filter in applicationcontroller failed because of multiple controllers used perform action when multiple controllers used in 1 action, more specific? before_filter in controller responsible action suffice. if want before filter affect specific methods in multiple controllers place method in applicationcontroller before_filter in each of controllers contain action. class applicationcontroller def foo @bar = 'bar' end end class usercontroller before_filter :foo, :only => [:method1] def method1 ... end def method2 ... end end class stuffcontroller before_filter :foo, :only => [:method2] def method1 ... end def method2 ... end end class unimportantcontroller # no before filter, neither of these methods call :foo def method1 ... end def method2 ... end end

regex - PHP : complex Regular expression -

hi have created example page .please see here i want event name , timing seperately. can me? for example. line ***english* mlb: philadelphia phillies @ miami marlins 12.00am-3.00am stream 7** note: ** english varies time...time varies am,pm i want event name,timing,and stream number below seperately mlb: minnesota twins @ atlanta braves 12.00am-3.00am 7 i've tried $game = file_get_contents("http://livestreamly.com/"); preg_match_all('/<font color="gold">(.*?)<p>/',$game,$match); this gives whole live. please me. i've checked site , regex valid problem /<\/font>([a-za-z0-9\'.: -]+)([0-9]{1,2}.+?[0-9]{1,2}[a,p,a,p,m,m]{2})-([0-9]{1,2}[.:]+?[0-9]{1,2}[a,p,a,p,m,m]{2}) <font color="red">stream ([0-9]+)<\/font>/ i've checked http://regexpal.com/ when use preg_match_all; output array matches contain information need. need escape chars in regex put php variable. php valid...

jquery validation checks not working properly -

$(document).ready(function(){ $(".submit").click(function(){ if($('.disrtrict')[0].selectedindex<=0){ $("#error1").html("district field empty"); } if($(".block")[0].selectedindex<=0){ $("#error2").html("block field empty"); } if($(".village")[0].selectedindex<=0){ $("#error3").html("village field empty"); } }); }); above jquery script.i new jquery , try learn jquery. problem use return false.what concept of return true , false , use if($(".block")[0].selectedindex<=0) can use if($(".block").val()==" ") if 1 have standard checks please provide help.thank in advance. if form submission return true allow form submit form later executing of javascript ,...

How to pass exactly selected listview row text in android? -

i have listview manipulates 10 row. each row has 2 textview. if select row, want know current textview text. know getview() method call multiple times. reason did not exact text. suppose if select first row last row text. how rid of problem. suggestion appreciated. here getview() method: public view getview(int position, view convertview, viewgroup parent) { viewholder holder = null; rowitem = getitem(position); layoutinflater minflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); if (convertview == null) { convertview = minflater.inflate(r.layout.listview_layout, null); holder = new viewholder(); /* * holder.rllistviewimg = (relativelayout) convertview * .findviewbyid(r.id.rl_listview_img); */ holder.ivmain = (imageview) convertview .findviewbyid(r.id.image_view_main); holder.tvmodule = (textview) convertview .findviewb...

PowerShell HTML Output not displaying correctly -

i have powershell script outputting html. below snippet of code. #services check write-host "services check" $html = $html + @" <h3>services checks</h3> <table> <tr> <th>name</th> <th>result</th> </tr> "@ get-service -computername server01 -name *service* | foreach-object{ if($_.status -ne "running"){ write-host $_.name "is not running" -foregroundcolor "red" $html = $html + @" <tr> <td class="name">$_.name</td> <td class="red">is not running</td> </tr> "@ }else{ write-host $_.name "is running" -foregroundcolor "green" $html = $html + @" <tr> <td class="name">$_.name</td> <td class="green...

Can I use Javascript string object methods on jQuery .text() -

would manipulate text upon click: $('.jserep').change(function () { $(".jappended").text().replace("&lt;serep&gt;y&lt;/serep&gt;", 'serep&gt;n&lt;/serep&gt;') }); but doesn't work. .text() return native string object can use replace on? $(".jappended").text($(".jappended").text().replace("&lt;serep&gt;y&lt;/serep&gt;", 'serep&gt;n&lt;/serep&gt;')) assign result text

c# - MVC 4 Forms Authentication not working with [Authorize] -

i'm learning mvc4 right now, , following pro asp net mvc4 4th edition book create sports store project. i have developed in webforms, , trying figure out how forms authentication working in mvc4. here have achieved: web.config <authentication mode="forms"> <forms loginurl="~/account/login" timeout="2880"/> </authentication> accountcontroller login action: [httppost] public actionresult login(loginviewmodel model, string returnurl) { if (modelstate.isvalid) { if (authprovider.authenticate(model.username, model.password)) { return redirect(returnurl ?? url.action("index", "admin")); } else { modelstate.addmodelerror("", "incorrect username or password"); return view(); } ...

devexpress - Custom draw cell focused rectangle -

Image
i have 1 xtrgrid first 3 columns customdrawn. if select cells in non custom drawn column showing focus rectangle. not case when select custom drawn column cells. not showing focus rectangle. there way show focus rectangle on custom drawn cells well? tried following code, not working. if(view.focusedcolumn == e.column && view.focusedrowhandle == e.rowhandle) { if(!view.isediting) e.cache.paint.drawfocusrectangle(e.cache.graghics, e.bounds, e.getforecolore(), e.backcolore(); } i got solution problem below link. http://www.devexpress.com/support/center/question/details/q400321

php - expression engine SEO URL disable option? -

i need disable default functionality of expression engine create url, can't figure out option disable it? removed htaccess did't resolve.. set option allowoverride none in virtual host file , complete .htaccess file ignored.

php - How to store and get exact characters in mysql db? -

content special characters e.g. ' " - when stored replace characters these � . not instances of characters changed characters these � . little odd why affects characters , not all. after reading articles online , in found out table collation , charset i using php mysql i use prepared statements when storing , getting values database tables collation set utf8_unicode_ci my pages html5 <meta charset="utf-8"> with above settings still black diamonds. help? little desperate. edit: maybe of go through exact same problem in future. might find answer below exact same solution. cheers! my pages html5 <meta charset="utf-8"> whatever meta s quite useless. page charset determined content-type http header only, have contain proper character set. $mysqli->set_charset('utf8') / ;charset=utf8 in pdo's dsn ought used, seems not issue in case.

jsf 2 - JSF 2.0 h:panelgroup render by h:commandButton through f:ajax, which is inside ui:repeat -

<h:panelgroup id="userpanel" > <ui:repeat value="#{searchview.userlist}" var="user" rowkeyvar="index" > //other code <h:commandbutton value="test" action="#{searchaction.dofindusers}" > <f:ajax execute="@this" event="action" render="userpanel" /> </h:commandbutton> </ui:repeat> when use render inside ui:repeat tag showing following error <f:ajax> contains unknown id 'userpanel' - cannot locate in context of component j_idt870 when specify client id without : prefix, it's searched relative parent namingcontainer component. in code, <ui:repeat> closest parent namingcontainer . however, component you're targeting not inside <ui:repeat> , instead it's outside <ui:repeat> . explains why cannot found using relative client id. you need specify absolute client id instea...

ruby on rails - How to override default foreign key? -

i have has_many , belongs_to association between 2 models below: class section < activerecord::base self.primary_key = 'id' has_many :rights end class right < activerecord::base self.primary_key = 'id' belongs_to :section end the section table has id , section_id column well. above code associates right section via id column in section table. want associate through section_id column. how do that? edit: on second read think misunderstood question, want relate field other primary key in section table? it's not common, hence misunderstanding. you need use :primary_key => 'field_name' instead of :foreign_key belongs_to :section, :primary_key => 'section_id'

Security: Passing a function as a parameter in JavaScript -

i very new javascript, please bear me!. i wondering if pass function parameter function in javascript, example (disclaimer: code may not 100% correct, should idea!): function(param1, param2) { .... // param 1 param1 += 10; .... // param 2 function, call param2(); ..... } is potential security risk , or common way of programming in javascript?. thanks. in javascript, functions first class citizens. can assign function var , pass functions arguments other functions or return function result function. there many methods in javascript accept function argument(also called callback functions). 1 such example foreach array.prototype.foreach(); var elements = [42, 33, 45, 5]; elements.foreach(/*anonymous function*/function(element, index) { // element }); elements.foreach(callback); function callback(element, index) { //do element }

c# - A static factory method on a generic or a non-generic class? -

i have generic class, let's call myclass<t> , need have factory method abstract constructor details away client code. which of 2 options correct? (example instantiation code included) static non-generic factory method on original generic myclass<t> : myclass<sometype> instance = myclass<sometype>.createnew(); static generic factory method on dedicated, non-generic static myclass implementation: myclass<sometype> instance = myclass.createnew<sometype>(); on first sight, looks proper answer question #1. because class myclass<t> , hence factory should t -specific. there more simple answer. before proceeding, add third possibility: non-static factory class. object relies on factory have public property through receives factory object. getter of property instantiate default factory if no other instance has been assigned. allows dependency injection later, , helps write unit tests rely on own fake factory. solutio...

php - Get a value of an array within an array -

not sure on 1 , hoping able me out on 1 ... here's code loader::library('file/types'); $ih = loader::helper('image'); $names = explode("||",$this->tname); $urls = explode("||",$this->turl); $fids = explode("||",$this->fid); loader::model('file'); $i = loader::helper('image'); $v = array(); $cc = 0; foreach ($names $k=>$n){ if (intval($fids[$k]) > 0 ) : $img = $test = file::getbyid($fids[$k]); $fv = $img->getextension(); $ft = filetypelist::gettype($fv); $img = $ft->type == 1 ? $img : false; else : $img = false; endif; $v[$cc]['name'] = $n; $v[$cc]['url'] = $urls; $v[$cc]['src'] = $img ? $ih->getthumbnail($img,100,100)->src : false; $cc ++; } return $v; and i'm having issues getting array values $urls within co...

iphone - Whats the difference between saving content at document directory or temp folder? -

i want save multipel photos in application, application run in background. main difference between saving photos in doc dir or temp path. and suggest me best way save photos document dir temp folder nsuserdefaults thanks in advance the main difference path: <sandbox>/documents or <sandbox>/tmp . some more differences: the documents directory can accessed via itunes if app has file sharing enabled. the contents of tmp directory volatile, os free purge in order save space. about nsuserdefaults : that's different, it's mechanism stores app-specific configuration data in property lists, can't imagine how and/or why use storing images.

blogs - Adding javascript inside blogger Post -

Image
how can add following javascript inside post <script type="text/javascript">ch_client = "dddsul";ch_width = 550;ch_height = 250;ch_type = "mpu";ch_sid = "chidefault";ch_color_site_link = "0000cc";ch_color_title = "0000cc";ch_color_border = "ffffff";ch_color_text = "000000"; ch_color_bg = "ffffff";</script> <script src="http://scripts.chitika.net/eminimalls/amm.js" type="text/javascript"></script> when editing post in blogger, click on html button shown below: this display content of post in html, copy / paste javascript code there.

jquery mobile - Android opening new page after onActivityResult -

for html5 - jquery mobile android app use native code access camera. have succeeded in getting images camera , showing them on local webpage. problem i'm experiencing when camera intent closes web page seems reopen second time time javascript isn't executed. when press button on device redirected right page again. how can keep page opening twice? i'm using following code access camera: mwebview.addjavascriptinterface(new object() { @suppresslint("simpledateformat") public void performclick() { intent cameraintent = new intent( android.provider.mediastore.action_image_capture); string timestamp = new simpledateformat("yyyy.mm.dd_hh.mm.ss") .format(new date()); img = new file(app_location + file.separator + "images", timestamp + ".jpg"); img_location = uri.fromfile(img); cameraintent.putextra(...

apache - Allow to send Javascript Code with Method Post in PHP -

i have problem submitting form app. i need send javascript code form controller page. code in html like: <form method="post" action="controller/mycontroller.php"> <textarea name="code"></textarea> <input type="submit" value="send" /> </form> if send on textarea "hello world" example, controller works fine, if try send javascript code alert(1); forbidden message server. any solution send javascript code server string filters or allowing on .htaccess file? thanks! re-edit: test example: http://pruebas.intelectiva.biz/test/ you must convert @ first text of textarea javascript replace code brakets random letters never use. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $(document).ready(function() { $("#send").click(function(event) { event.preventdefault(); var code = $(...

c - Is it possible to swap two variables with only += and -= no other operators or variables? -

i want swap 2 variables += , -= operators , without temporary variables. know standard solutions like: a = a+b; b = a-b; = a-b; and xor : a ^= b; b ^= a; ^= b; but cannot figure out how += , -= . possible? my classmates offer nice solution: answer no lets denote a (1 0) , b (0 1) the matrix a is 1 0 0 1 += , -= mean adding or subtracting lines each other. means determinant either not change sign or equal 0 . end matrix is 0 1 1 0 with determinant equal -1 , can not it update: have these operations: a-=a . 1 line becomes 0 , det=0 a+=a . means multiplying line 2 , det a'= 2*det a a+=b . means elementary transformation, not change value of det a-=b . same thing 3. then apply proof b-=b , b+=b , b+=a , b-=a . determinant not change sign or 0 update 2: @tom said here example of how in c#: http://ideone.com/uzvlml . however, in c thats not correct: http://codepad.org/rmhn9iqb . can clarify difference of b -= b += b in c , c#? ...

testing - Behat/Mink: how can I evaluate a xml response -

i trying test rss feed via behat/mink. unfortunately getting error message time: the current node list empty. does know how test xml response (search string in xml) via behat/mink? edit i need find way, , best running behat/mink. if thats not possible @ all, can live workaround too. example on how great! in featurecontext.php file can raw content by $xml = $this->getsession()->getdriver()->getcontent(); and can use regex/domdocument test returned xml content.

Coded UI test Single Thread Apartment (STA) error occurred while executing [ClassCleanup] method -

why sta error while class performing clean-up method in coded ui test seems concrete test methods works fine. code looks ff: [codeduitest] public class concretecuit : testbase { [classinitialize] public static void initialize(testcontext context) { //do init } [classcleanup] public static void cleanup() { //do clean-up - sta error!!! } [testmethod] public void concrete1crudtest() { //do ui test } [testmethod] public void concrete2crudtest() { //do ui test } } and got following error below: class cleanup method samplecuit.cleanup failed. error message:microsoft.visualstudio.testtools.uitest.extension.uitestexception: coded ui test running in single thread apartment (sta) mode of com. in mode, playback calls should happen testmethod thread , uitestcontrol should not shared across testmethods.. ...

jquery - Open file in new window -

i have jquery function calls action getreport returns pdf file. action return file(renderedbytes, mimetype); this function function showreport() { var clinic = $("#selectedclinic").val(); var date = $("#selecteddate").val(); var url = "/reports/getreport"; $.get(url, { selectedclinic: clinic, selecteddate: date }, function (data) { $("#output").html(data); }); } this result in the div $("#output") %pdf-1.3 1 0 obj [/pdf /text /imageb /imagec /imagei] endobj 5 0 obj << /length 4660 /filter /flatedecode >> stream x ������wॳ ��k����8�zo�f剥�,9������d�w�К_���ʶ��t��*�������r��z���7k{`[tuÙ·m���{��ж����� ;��e=�g}7j��.n~��ÞŽ0xy'o7���.n�[��w�d��q���1��u:����u��#�����n�v���t~���7ecwd��=fx��i�7�dj;�i��l��� i ideally open pdf file in new window or tab. might show file div $("#output") real question how open in new window. by way works @html.actionlink("view in new tab...

bitmap - Load Texture from File in HLSL -

i want blend (in postprocessing-shader) camera output texture. there method load texture? like texture mytexture = "file.bmp" sampler2d smp = sampler_state { texture = <mytexture>; ... } a shader micro-program, runs on gpu. therefore isn't capable of complex loading textures disk. right way this, load texture program via directx-api (e.g. d3dx11createtexturefromfile ) , set resource @ rendercall in shader use there.

javascript - How to store user input urls (anchor links) and redirect user using window.location? -

i managed create condition detect anchor link, after how store anchor link in anchor_num variable, can redirect use specific url? <script type="text/javascript"> $(function(){ if(window.location.hash){ var anchor_num = "anchorstring"; window.location = "#"+ anchor_num; } else { //redirect default page } }); </script> by appending or changing hash browser wouldn't refresh page. should call window.location.reload() after you've set hash: window.location = "#"+ anchor_num; window.location.reload()

Changing texbox values from another project C# -

where form layout, 3 textboxes. kinect coor x, y , z. i have second project, where, coordinates of hand kinect. main project referencing second project. now need update these textboxes, coordinates, kinect in second project. how can it? when try, add main project references in second project, visual studio says circular dependency.

How to set font from file in Pango and Mono -

i have simple application prints text , determines size in pixels. static void main(string[] args) { application.init(); var screen = screen.default; var layout = new pango.layout(pangohelper.contextgetforscreen(screen)); layout.fontdescription = new fontdescription(); layout.fontdescription.family = "times new roman"; layout.fontdescription.size = units.frompixels(18); layout.settext("my text"); int width; int height; layout.getpixelsize(out width, out height); console.writeline("{0} - width:{1} height:{2}", layout.text, width, height); console.readline(); } but want use own font. how can load own font file , use in pango in mono? short answer is: can't use uninstalled fonts pango. :( longer answer is: can, if using fontconfig backend (pangofc; eg on linux). in case need make few calls fontconfig before using pango, make fonts available fontconfig. however, don't think font...

winforms - Update the GUI from another thread in C# - change back to the main thread or not? -

i know simplest way update label thread is: void dosomething() { if (invokerequired) { invoke(new methodinvoker(dosomething)); } else { // } } my question if instead of if require update gui thread possible change main thread , update gui there ? actually, simplest way is invoke(new methodinvoker(dosomething)); if call thread sure, ie. if know, invokerequired true. also, use winforms timer poll changes of, say, text field. timer runs in gui thread. pretty solution if have hundreds of events per second. or @ least "a lot of". way don't have many switches gui thread (which take considerable amount of time).

php - Unreachable website -

i have problems website being ureachable every few minutes. happens when try upload photos , site becomes unreachable. if try proxy works fine @ same time. if in errorlog fills errors "file not found...". i have been using cloudflare development mode on. when site unreachable gives cloudflare error this: http://shrani.si/f/1a/ly/pciy0el/cf1.jpg use htaccess friendly urls. .htaccess: #---------www fix-------# rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] #---gzip compression----# ######################### <ifmodule mod_gzip.c> mod_gzip_on yes mod_gzip_dechunk yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^content-encoding:.*gzip.* </ifmodule> #-----files expire------# #############...