Posts

Showing posts from January, 2015

iphone - Core Plot CPLineStyle compile error on readonly property -

trying build core plot , use cplinestyle compile error code... cplinestyle *linestyle = [cplinestyle linestyle]; linestyle.linecolor = [cpcolor blackcolor]; error: object cannot set - either readonly property or no setter found the property @synthesize'd , while it's declared @property (nonatomic, readonly, retain) cpcolor *linecolor; in header redeclared in category class as @property (nonatomic, readwrite, retain) cpcolor *linecolor; the compiler doesn't seem know redeclaration of property. what's wrong here? gonzalo please use way worked me ... cpmutablelinestyle *plotlinestyle = [cplinestyle linestyle]; plotlinestyle.linecolor = [cpcolor whitecolor]; plotlinestyle.linewidth = 2.0f; then apply style axis or whatever similar can textstyle using cpmutabletextstyle..

Why does setting autocomplete="on" via a user script still not allow storing of passwords in Chrome? -

Image
my goal use greasemonkey-style user script in google chrome enable remembering of passwords on specific form has autocomplete="off" attribute set. chrome's developer tools indicate autocomplete="on" being set script, not have expected effect of allowing storage of passwords on form. why doesn't work? example chrome offers remember passwords entered on test page (expected): <html><body><form action=""> <input type="text" name="username" /> <input type="password" name="password" /> <input type="submit" name="submit" value="log in" /> </form></body></html> chrome not offer remember passwords entered on test page (expected): <html><body><form action=""> <input type="text" name="username" /> <input type="password" name=&quo

css - Possibly transparent WebKit-Overlay in Gtk/Cairo? -

i'm building application, cross-platform (linux, win, os x), , graphics stuff via cairo(mm), supported little bit of gtk+ scaffolding (i.e. drawingarea ). need ui elements, require custom look. ideally should displayed transparent overlay (i.e. different opacities different parts of ui). as gtk+ hard customize (e.g. want edit-field suggestion-list above it), , me knowing how i'd achieve html/css, question popped up: why not let libwebkit handle ui stuff? i don't have experience webkit, need know is: does above reasoning make sense else? css has opacity , can interface webkit in such way renders onto rgba-offscreen surface, alpha-values inherited layout-processing of css styles? even if 2. not work, has used libwebkit on offscreen surface, afaik requires redirection of keyboard , mouse interactions, via gtk+s provisions? is possible render web content on clear background using webkit? gets.

ruby on rails 3 - Activerecord solution to postgres-mysql problems -

i have following scopes in job model , seems there's problem sql discrepancies in statements. our dev db mysql , apparently heroku has postgres , keeps complaining file_count reason. i plan convert these scopes class methods or @ least change sql statements active record ones db independent. possible @ , how start on one? i'm planning keep is_active because i'm pretty sure works it's simple scope statement, with_unclassified_files_available_count needs refactor , think ar refactor idea(if think isn't idea, please tell me so, i'm open suggestions) here's code: scope :is_active, where(:active => true) scope :with_unclassified_files_available_count, where("audio_files.category_id null") .joins(audio_files) .select("jobs.*, count(*) file_count") .group("jobs.id")

java - Synchronized JList and JComboBox? -

possible duplicate: synchronized jlist , jcombobox? hello, in java swing, what's best way jlist , jcombobox synchronized in terms of data, i.e., have same list of items @ given point of time? basically, if add items (or remove items from) one, other should reflect change automatically. i've tried doing following, doesn't seem work: jlist list = new jlist(); jcombobox combobox = new jcombobox(); defaultlistmodel listmodel = new defaultlistmodel(); // add items listmodel... list.setmodel(listmodel); combobox.setmodel(new defaultcomboboxmodel(listmodel.toarray())); you're creating 2 models in code. when construct new defaultcomboboxmodel passing in listmodel contents constructing second model starts same contents first. won't update same. want 2 components share model. in other words... jlist list = new jlist(); jcombobox combobox = new jcombobox(); defaultcomboboxmodel listmodel = new defaultcomboboxmodel(); // add items listmodel..

Insert an image into a word document in Java -

can point me in right direction on how insert image word document in java? just idea: at first need download wordapi, can downloaded right here . create word documents java, there's class doing need. class called wordprocessing . here's short preview of methods implemented in class: createnewdocumentfromtemplate(string templatename) createnewdocumentfromtemplatetoselectbyuser() setnotenotmatchingbookmarks(boolean notenotmatchingbookmarks) typetextatbookmark(string bookmark, string texttotype) typetextatbookmark(string bookmark, string[] linestotype) changedocumentdirectory(string documentdirectory) savedocumentas(string documentname) savedocumentasandclose(string documentname) closedocument() printandforget() printtoprintertoselectbyuserandforget() printandforget(string printername) executemacro(string macroname) <---- interesting you quitapplication() exec() as can see there lot of helpful functions create document. now can

c# - Is there a queriable distributed cache with high availability option for Windows? -

we trying integrate sort of distributed cache our system. have 2 major requirements: high availability, i.e. automatic data replication mirroring machines if 1 goes down, data around. searchabilty/quaribility of cache data, i.e. there need ranged searches. optional: returning complete snapshot of data stored. optional: ability persist cached data on periodic basis. so far have sharedcache candidate because allows @ least searching using regex. that's inherently slow though. sharedcache doesn't support high availability. windows app fabric offers no search far understand (if wrong can awesome). what options? ask? should give , think sort of custom solution? definitely include membase memcached list of considerations. solid , stable. can use "memcached" part if want there nosql document database available (which of course can used "cache persistence" too).

Question about Dijkstra's algorithm implementation on Wikipedia -

function dijkstra(graph, source): each vertex v in graph: // initializations dist[v] := infinity ; // unknown distance function source v previous[v] := undefined ; // previous node in optimal path source end ; dist[source] := 0 ; // distance source source q := set of nodes in graph ; // nodes in graph unoptimized - in q while q not empty: // main loop u := vertex in q smallest dist[] ; if dist[u] = infinity: break ; // remaining vertices inaccessible source fi ; remove u q ; each neighbor v of u: // v has not yet been removed q. alt := dist[u] + dist_between(u, v) ; if alt < dist[v]: // relax (u,v,a) dist[v] := alt ; previous[v] := u ; fi ; end ; end while ; return dist[] ; end dijkstra. the a

asp.net mvc 2 - Relations are not saved when updating the model using EF4 code-first -

like title says successful update, won't save relations user-role or whatever. works great when add user (in case) roles , all, update doesn't work, that's relation else updated. have problem other objects well. have idea why won't save relation if it's changed on update? posted code too, have feeling it's not important here. think i'm missing simple. if (modelstate.isvalid) { //hämta användaren och redigera parametrar var user = _userservice.getbyid(viewmodel.user.id); viewmodel.user.roles = user.roles; //kolla språken if (viewmodel.cultureselected != null) { foreach (var item in viewmodel.cultureselected) { viewmodel.user.languagecultures.add(_languagecultureservice.getbyid(item)); }

w3c - What is an XML processing instruction, and why is there so little information about them? -

i couldn't google explanation them. w3 has a little paragraph them . can explain them in clear form please? used for? "processing instructions (pis) allow documents contain instructions applications" definition w3 mean? still useful or long forgotten , substituted else? can explain them in clear form please? that paragraph clear. provide way give application instruction. it isn't detailed, because specifics depend on particular pi. what used for? describing encoding , version of xml pointing stylesheet embedding executable code many other things

asp.net - when selecting the datasource it is not showing properly -

Image
i trying see datasource added previously. while trying see..there not configure data source option..how it.. screen shot below. msdn: configure data source dialog box - sqldatasource

asp.net - date difference function -

can body can teach me how use date difference function? using asp.net? please... example var currentdate = datetime.now; var pastdate = new datetime(2004, 06, 16); var timespan = currentdate - pastdate; int hourspassed = timespan.totalhours; you can subtract 1 date timespan have properties such as: timespan.totalhours timespan.totalminutes timespan.totalseconds timespan.totalmilliseconds

php - Using simplehtmldom to grab a text snippet -

i'm trying use simplehtmldom script @ text. html structure follows <div id="posts"> <div align="center"> <several levels of html> <strong>xxx</strong> </several levels of html> </div> <div align="center"> <several levels of html> <strong>ignore</strong> </several levels of html> </div> <div align="center"> <several levels of html> <strong>ignore</strong> </several levels of html> </div> </div> the text i'm trying @ xxx string, in first <strong> tags inside first <div> attribute align="center" , inside <div> id="posts" . i'm not interested in text in <div align="center"> tags further down. the "several levels of html" include messy nested tables etc. my code: i'm using descendant se

Logic for JQuery Slideshow -

i want implement vertical slide show using jquery. using vertical reel(div) in turn contains images 1 one decrementing the reel top position image size every 2 second working fine when reach last image not able implement logic start reel first images. if explanation not clear appending code: <script type="text/javascript"> $(function() { setinterval(slideimage, 2000); }); function slideimage() { $("#imgreel").animate({ "margintop": "-=300px" }, 1000, function() { }); } </script> <style type="text/css"> img { width: 600px; height: 300px; } .imgcontainer { overflow: hidden; width: 620px !important; height: 300px !important; } div { width: 620px; } .current { z-index: 0; } .next { z-index: 1; } .imgreel { width: 620px !important; } . &l

html - What are the alternatives for radio buttons? -

i haven't seen radio buttons long time. used anymore, , if used , used them? what best alternatives radio button? can use instead of radio buttons? i had far "settings" page on gmail account before found radio button on web. the other widget provides simple "pick 1 choice many" option in html document <select> element. you can use multiple submit buttons same effect — submit form @ same time, isn't appropriate (although "preview" or "save" decisions).

android - Edittext want to go enable from disable after select the particular item in the spinner items -

i'm using spinner,edittext , button in 1 page.the spinner has these items ... following: string[] items = { "alarm", "office", "meeting", "party", "lunch", "breakfast", "supper", "home", "private", "outdoor", "family", "friends", "others" }; spinner s1; in if select "others" in spinner items means edittext has enable otherwise has disabled.if select other item edittext has disabled code snippet: s1 = (spinner) findviewbyid(r.id.spinner); arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, items); s1.setadapter(adapter); s1.setonitemselectedlistener(new onitemselectedlistener() {

php - problem getting the friends birthday with facebook api -

here code , supposed retreive birthday of friends corresponding today . $friends = $facebook->api('me/friends'); $uids = ""; foreach($friends $f) { $uids .= "uid=$f or "; } $query_uids = substr($uids,0,strlen($query_uids)-4); date_default_timezone_set('utc'); $current_date = date("m/d"); echo "<br />searching : $current_date<br />"; $data = $facebook->api(array('method'=>'fql.query','req_perms' => 'friends_birthday','query'=>"select name, uid user ( ($query_uids) , strpos(birthday_date,'$current_date') >= 0 )") ); if(count($data) > 0) { foreach($data $d) { print_r($d); } } else { echo "<br />no birthdays today<br />"; } in page have script retrive user friends above 1 , working , result shown snippet issearching , white space !!!! please thanks when mean getting friends' birthdays

asp.net mvc 3 - Enable Yellow Screen of Death on MVC 3 -

i had take on mvc 3 project developer. 1 of first things did stop yellow screen of death exceptions logged file. generic message saying error has occurred. i switch on (since gets annoying having check through logfiles whole time) - how do this. i checked through web.config can't see happens. i did try doing customerrors=off, didn't anything. removed global error handling attribute, didn't anything. on further clarification, seems if exception occurs in controller yellow screen of death, if occurs in (razor) view standard generic error. you can see web.config here can see global.asax here in global.asax can remove filters.add(new handleerrorattribute()); public static void registerglobalfilters(globalfiltercollection filters) . as pointed out in comments - problem custom base controller overriding onexception method.

flex - Retrieving Sub-XML Elements to display a Pie Chart -

Image
i have designed application load information xml file pie chart. first xml looked this <books> <stock> <booktype>novels</booktype> <amountofbooks>100</amountofbooks> </stock> </books> and code looked [bindable] private var bookstock:arraycollection = new arraycollection(); var mypieseries:pieseries = new pieseries(); mypieseries.namefield = "booktype"; mypieseries.field = "amountofbooks"; in result event this bookstock = evt.result.books.stock; now works , can see generated pie chart. but let's changed xml in following manner. <books> <stock> <bookinfo> <booktype>fiction</booktype> <amountofbooks>150</amountofbooks> </bookinfo> </stock> <stock> <bookinfo> <booktype>novels</booktype> <amountofbooks>100</amoun

objective c - When should i use a @property? -

when declare object class,when should use alloc , init , when should give @ property directive.under situations need use them.the property directives bit confusing.need help...... have read programming guide ? or other documentation? i'm not being rude, trying skim docs , asking questions here isn't going far reading documentation before diving in , trying write apps.

php - Is it safe to let the user specify the mysql field to search? -

i have search program has multiple input text boxes correspond fields in mysql database. know if safe have custom search box user can enter actual field searched , value. like this: <form method='post'> <input type='text' name='param1' /> <input type='text' name='param2' /> <input type='text' name='customfield' /> <input type='text' name='customvalue' /> </form> then when submitted: $param1 = mysql_real_escape_string($_post['param1']); $param2 = mysql_real_escape_string($_post['param2']); $customfield = mysql_real_escape_string($_post['customfield']); $customvalue = mysql_real_escape_string($_post['customvalue']); $query = "select * mytable field1 '" . $param1 . "' , field2 '" . $param2 . "' , " . $customfield . " '" . $customvalue . "'"; this internal webp

java - Improving performance of fuzzy string matching against a dictionary -

so i'm working using secondstring fuzzy string matching, have large dictionary compare (with each entry in dictionary has associated non-unique identifier). using hashmap store dictionary. when want fuzzy string matching, first check see if string in hashmap , iterate through of other potential keys, calculating string similarity , storing k,v pair/s highest similarity. depending on dictionary using can take long time ( 12330 - 1800035 entries ). there way speed or make faster? writing memoization function/table way of speeding up, can else think of better way improve speed of this? maybe different structure or else i'm missing. many in advance, nathan what looking bktree (bk-tree) combined levenshtein distance algorithm. lookup performance in bktree depends on how "fuzzy" search is. fuzzy defined number of distance (edits) between search word , matches. here blog on subject: http://blog.notdot.net/2007/4/damn-cool-algorithms-part-1-bk-trees

wpf - Binding problem when creating custom ProgressBar -

<usercontrol x:class="wpfapplication2.progressbar" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300"> <grid> <progressbar minimum="0" maximum="1" value="0.5" largechange="0.1" smallchange="0.01" margin="2,2,12,2" height="22"> <progressbar.template> <controltemplate> <border borderthickness="2" borderbrush="black"> <rectangle> &

ruby on rails - Ajax response from controller -

my javascript send ajax request invoke controller function, controller function response ajax request. problem in controller response part. my javascript send ajax request controller: var xmlhttp = new xmlhttprequest(); xmlhttp.onreadystatechange=function(){ if (xmlhttp.readystate==4 && xmlhttp.status==200){ //render response @cars here } } xmlhttp.open("get","/cars/reserved_cars/"+customer_id,true); xmlhttp.send(); so, above ajax request invoke carscontroller 's reserved_cars function customer_id parameter. my carscontroller: class carscontroller < basecontroller def reserved_cars customer_id=params[:customer_id] @cars = car.getcars(customer_id) end ... end my controller cars query car model customer_id. everything works fine, don't know how return @cars in controller response of ajax request javascript (the place in javascript commented " //render response @cars her

wordpress - Magic Fields (custom post types) and Custom Taxonomy permalink -

i'm using custom post template linked magic fields create custom post type named company . created custom taxonomy named city . city hierarchical (like categories), , every company has 1 city selected. for example: have company post title microsoft , city taxonomy redmond selected. want permalinks this: http://www.mysite.com/redmond/microsoft just when have post category , wordpress prepends first category selected permalink. can done? i've found solution problem. here code: add_filter('post_link', 'mba_courses_permalink', 10, 3); add_filter('post_type_link', 'mba_courses_permalink', 10, 3); function mba_courses_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, '%mba_courses%') === false) return $permalink; // post $post = get_post($post_id); if (!$post) return $permalink; // taxonomy terms $terms = wp_get_object_terms($post->id, 'mba_courses');

permissions - WPF Application not getting file access rights -

i have wpf app creates text files in own install directory. however, after uac prompt, windows vista , windows 7 users times still "file access failed" type errors. solution find executable in windows explorer , open compatibility tab under file properties , check "run administrator". terrible user experience i'm not sure how ensure app can secure these permissions without step being taken. not trying bypass uac prompts. you can force app start admin rights (uac show it's dialog box anyway) embedding custom manifest (project properties -> build -> manifest). manifest example ( requestedexecutionlevel part importaint): <?xml version="1.0" encoding="utf-8"?> <asmv1:assembly manifestversion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3

php - curl_init and curl_exec: extract table? -

hey guys, i'm new curl - i've never used before. if paste following 2 lines inside of sidebar ... <?php $objcurl = curl_init("http://www.domain.com/hptool/weather_v1.php?cid=43x1351&l=en"); curl_exec($objcurl); ?> ...i 2 divs , table inserted page. there method can kind of inspect gets loaded curl_init function? want specific stuff on page inserted , not everything? e.g. want insert table not 2 divs inserted page. i know hide them css, i'm curious. save result string instead of outputting it. $url = 'http://www.domain.com/hptool/weather_v1.php?cid=43x1351&l=en'; $curl = curl_init(); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_header, false); $str = curl_exec($curl); now can pull whatever need out of $str , display that. first place should go the documentation how use function/library.

php - Parallel, multiple SOAP requests/connections? -

i'm running following code: <?php $i=0; // connection credentials , settings $location = 'https://url.com/'; $wsdl = $location.'?wsdl'; $username = 'user'; $password = 'pass'; // create client resource - connection $client = new client($location, $wsdl, $username, $password); // stuff while($i<10) { $client-­‐>dostuff(); echo $client‐>response(); $i++; } ?> separately: <?php public function dostuff() { $this->response = $this->srv()->dostuff(array('stuff' => $this->get('stuff'))); return $this; } public function __construct($location, $wsdl, $username, $password, $proxyhost = null, $proxyport = null) { if(is_null($proxyhost) || is_null($proxyport)) $connection = new soapclient($wsdl, array('login' => $username, 'password' => $password)); else $connection = new soapclient($wsdl, array('login' => $username, 'password' =&

image - Android - how to avoid memory over load using bitmaps? -

my application using bitmaps , every time user come specific activity shows image second time stops working. bitmap bm = bitmapfactory.decodefile(environment.getexternalstoragedirectory()+"//pics/"image.jpg"); i have tried using things like... bitmapfactory.options options = new bitmapfactory.options(); options.intempstorage = new byte[16*1024]; not sure set too. doesnt help. once user leaves activity there not way clear bitmap etc? thanks call bitmap.recycle() when done using bitmap free memory.

javascript - Can I overload an object with a function? -

let's have object of functions/values. i'm interested in overloading based on calling behavior. for example, block of code below demonstrates wish do. var main_thing = { initalized: false, something: "hallo, welt!", something_else: [123,456,789], load: { sub1 : function() { //some stuff }, sub2 : function() { //some stuff }, : function() { this.sub1(); this.sub2(); } } init: function () { this.initalized=true; this.something="hello, world!"; this.something_else = [0,0,0]; this.load(); //i want call this.load.all() instead. } } the issue me main_thing.load assigned object, , call main_thing.load.all() call function inside of object (the () operator). can set code use main_thing.load access object, , main_thing.load() execute code? or @ least, similar behavior. basically, similar

php - Storage projects with eclipse -

regularly develop projects in php using dreamweaver start using eclipse. have machine in directory armaezandos projects, place projects published in apache. in dreamweaver in project settings map local directory, setting perform sending of files apache automatically after save them. i wonder correct way develop eclipse. if map project directly in apache directory (thus having 1 copy of project) or if eclipse has configuration achieve same functionality have in dreamweaver. problem when mapping project directly in eclipse created folders , files .settings, .buildpath , .project. note: keep copies of 2 projects (one local , 1 in apache) purpose of tests not send files, uploads, etc. in memoento publish project, , sending project folder location. i use eclipse helios. i use apatana based off of eclipse, pretty same way when storing projects. map virtual hosts files project folders. keep revision control through subversion if hiccups occur can fixed. map apache virtual h

iphone - Grabbing image of UIScrollView content - anti-aliasing problem -

i need grab scaled image of content visible in uiscrollview. i'm able image there discrepancy between anti-aliasing algorithm used scroll view , grabbing process. please @ image point: ( left : seen in uiscrollview, right : grabbed renderincontext) the image i tried set interpolation quality, edge antialiasing mask , allow/force anti-alias in context using cgcontextsetallowsantialiasing , cgcontextsetshouldantialias without success. image saved file png uiimagepngrepresentation. any ideas how grab exact copy of visible in scroll view?

android - How to download this source code file? -

android translate application how can download file in trunk link? can load eclipse ide, windows7 64-bit? follow instructions on other tab: checkout how eclipse: download svn client http://subversion.apache.org/packages.html read manual on how checkout. checkout explained on the checkout tab , using client , supplied url. import eclipse per eclipse manual.

jquery create new div with using array value as id -

hi trying create new div using value array id var divid = 'borough_'+boroughtagger.myidarray[intindex]; jquery('<div/>', { id: divid }).appendto('#results'); doesn't seem work ? ideas? update: removed comma line id: divid , <div></div> created no id property created. from ive tried far following joes answer works: $('#results').append(''); ie div created : <div id="borough_2"></div> i performing ajax call after creating div , wish do: success: function(data){ // data retrived ok var mydata = data; $("boroughid=" + boroughtagger.myidarray[intindex]).html(mydata) } using joes method div created still cant reference append data recived ajax request. there scope problem perhaps? try $('#results').append('<div id="borough_'+ boroughtagger.myidarray[intindex] +'"></div>'); if want keep reference id, not

assemblies - .NET - How can I tell if a dll is a 32bit or 64bit version of that dll -

we have project in our application builds in 32bit or 64bit version of dll depending on processor architecture on machine built on, facilitate testing. i can predict dll used on given machine, have several devs, 64bit machines, 32bit machines, , want able check if builds put live server have gone 32bit version of dll or 64bit version of dll. checking properties of dll doesn't give sort of information. there way of getting it? thanks i'm not sure if there way can see wether or not assembly compiled x64 / x86. can use corflags specify though. msdn page also could use this code: module.getpekind method

tcp - pcap python library? -

i'd ask recommendation of pcap library python. i'm doing project on .pcap file parsing. searched google , found pylibpcap. there else out there? lib prefer , why? thank you. try scapy . powerful program packet inspection, manipulation , creation. you can use build own tools .

What is a cookies domain set to when the cookie is set in a cdn (or other) hosted javascript file? -

given 1 website hosting "widget" of website, widget not in iframe js dom manipulation , content fed through jsonp connection. if js file serves widget writes javascript cookie cookie marked domain hosting widget js file or domain widget being displayed on (eg domain hosting html file including widget js file)? it's domain of user's http request (or html file, in example). here's why: imagine you’re on http://www.blackhat.com/test.html , include file on page http://www.facebook.com/cookielib.js . this not give right read or write facebook cookies js file, terrible. user agent considers domain in address bar execution context, , reading , writing of cookies happens on domain.

sql server - SQL : Test if a column has the "Not Null" property -

is there simple query return whether specific column allows nulls? want change part of db upgrade script. alternatively, better change it, if set? edit : sql server (needs support 2000 or later) any particular rdbms? in sql server use master select columnproperty( object_id('dbo.spt_values'),'number','allowsnull') or (more standard) select is_nullable information_schema.columns table_schema='dbo' , table_name='spt_values' , column_name='number'

How would I find the current address using iphone API -

is possible find current location of iphone address rather gps coordinates using api? what you're looking mkreversegeocoder .

asp.net - Client validation that acts the same as .NET page validator/XSS prevention? -

i've got free text form people submit feedback/support requests. people past in support ticket or error log contains triggers .net page validator xss attempt. takes user error page if site choked on input. preferably, i'd rather have page client-side validation when press save button before it's submitted. is there regex or method can hook same basic check on client side, or have write regex disallows characters < , > ? .net 4.0's internal crosssitescriptingvalidation uses isdangerousstring method match on these conditions: if occurrence of < or & @ end of post data, it's safe. if < followed a-z, a-z, /, ?, or ! it's unsafe. if & followed #(octothorpe!) it's unsafe. this regex in javascript should work: /^(?!(.|\n)*<[a-z!\/?])(?!(.|\n)*&#)(.|\n)*$/i

rails show errors in popup with ajax request -

i have a view = new_pack , in view user can create pack , product . product separated form inside popup. product created in ajax request want validate product , show errors inside popup using render update or other ajax action. thanks

binding - How can you make the color of elements of a WPF DrawingImage dynamic? -

we have need make vector graphic images change color of elements within graphic @ runtime. seem setting colors based on either static or dynamic resource values wouldn't work. want have multiple versions of same graphic, each abilty set graphic elements (path, line, etc) different colors don't think dynamic resource approach work. leaves data binding seems right approach. update graphic use data binding expr instead of hard-coded brush color so: <drawingimage x:key="graphic1"> <drawingimage.drawing> <drawinggroup> <drawinggroup.children> <geometrydrawing geometry="f1 m 8.4073,23.9233l"> <geometrydrawing.pen> <pen linejoin="round" brush="{binding line1brush, mode=oneway}"/> </geometrydrawing.pen> </geometrydrawing> <geometrydrawing geometry="f1 m 3.6875,2.56251l"> <geometrydrawing.

c# - Use XMLHttpRequest to execute a SQL Query and return the results.. help! -

i'm building web app company run query every few seconds against sql server, , data returns database restoring , how % complete is. have query set , works fine. what want on web form, have "div" element contain % complete of database restore, , have update every few seconds using javascript timer object: setinterval(function, interval) i figure need use xmlhttprequest send request web server run sql query. on right track? how start this? my sql query below: use master select der.session_id, der.command, der.status, der.percent_complete, * sys.dm_exec_requests der percent_complete > 0 just create regular asp.net page target ajax request. in page processing (authentication etc. if necessary) , db query usual. result may give javascript request via response.write(). on client side, parse request , display results. this rough overview. consider using api apropriate data / infrastructure. may take account things security, json/xml etc.

rspec2 - FactoryGirl + RSpec + Rails 3 'undefined method <attribute>=' -

i'm new rails , tdd (as no doubt obvious post) , having hard time wrapping brain around rspec , factorygirl. i'm using rails 3, rspec , factory girl: gem 'rails', '3.0.3' # ... gem 'rspec-rails', '~>2.4.0' gem 'factory_girl_rails' i have user model i've been running tests on during development, needed add attribute to, called "source". it's determining user record came (local vs ldap). in factories.rb file, have several factories defined, following: # alumnus account tied ldap factory.define :alumnus, :class => user |f| f.first_name "mickey" f.last_name "mouse" f.username "mickeymouse" f.password "strongpassword" f.source "directory" end i have macro defined (that's been working until now) looks this: def login(user) before(:each) sign_out :user sign_in factory.create(user) end end i'm calling in multiple

c++ cli - Wrapper to unmanaged code -

how build wrapper unmanaged code in order use in managed code, , when have that? you don't need wrapper, many dlls straight-forward exported c functions can pinvoked [dllimport] attribute. exception c exports poorly designed dll requires client code release memory, can't done managed code since doesn't have access allocator. the case have have wrapper native c++ class. managed code cannot pinvoke directly since doesn't know how create instance of class (which requires knowing size of object , calling constructor) nor how destroy (which requires calling destructor). pretty easy in c++/cli. mechanical, swig project can automatically. learning tool more of investment learning how write wrapper.

data binding - C# Bind ADODB.Recordest to TextBox -

i have application migrated legacy app, , want keep using com adodb classes (using interop). in original app had textbox control bound 1 of fields in recordset, cannot see how this. this i'm trying right now: txtbox.databindings.add("text", recordset, "fieldname"); but leaves textbox blank. i know recordset has data because i'm binding datagrid control same recordset , shows several records. any ideas?

c# - Enum.IsDefined with flagged enums -

i'm reading book c# 4.0 in nutshell , way think excellent book, advanced programmers use reference. i looking on chapters basics, , came across trick tell if value defined in enum when using flagged enums. book states using enum.isdefined doesn't work on flagged enums, , suggests work-around : static bool isflagdefined(enum e) { decimal d; return (!decimal.tryparse(e.tostring(), out d); } this should return true if value defined in enum flagged. can please explain me why works ? thanks in advance :) basically, calling tostring on enum value of type declared [flags] attribute return defined value: somevalue, someothervalue on other hand, if value not defined within enum type, tostring produce string representation of value's integer value, e.g.: 5 so means if can parse output of tostring number (not sure why author chose decimal ), isn't defined within type. here's illustration: [flags] enum someenum { somevalu

pivot - sql server - getting values from one table with columns' names stored in another table -

i have several tables. these simplified versions of tables: userstable: userid firstname lastname middleinit suffix age position 1 john graham p. jr. 35 analyst ii 2 bill allen t. iii 45 programmer 3 jenny smith k. 25 systems engineer 4 gina todd j. 55 analyst ii tabletypes: tabletypeid tabletype 1 names 2 positions 3 age tabletypeid primary key in tabletypes , foreign key in tablefields. tablefields: fieldid tabletypeid fieldname description 1 1 firstname descr1 2 1 lastname descr2 3 1 middleinit descr3 4 1 suffix descr4 fieldid primary key in tablefields , foreign key in modifieduserstable. i need fill modifieduserstable

How to make an ASP:Repeater control editable using C# or VB.NET -

i following tutorial make repeater control: http://www.w3schools.com/aspnet/aspnet_repeater.asp i have gotten far tutorial, make editable. how started? this should help.. http://www.ajaxtutorials.com/ajax-tutorials/using-repeater-to-edit-in-line-with-ajax-in-c/

ASP.NET Different Layouts within 1 Site -

a client has asp.net website master pages , layout directory. what need 2 different layouts on site. can have 2 layouts different master pages on same site? what's best way that? see setting asp.net master page @ runtime . can set page use masterpage programmatically @ runtime.

asp.net - Accessing code behind functions from WebMethod -

i have code behind page has several method; 1 of them page method. [webmethod] public static void resetdate(datetime thenewdate) { loadcallhistory(thenewdate.date); } protected void loadcallhistory(datetime thedate) { bunch of stuff } the method loadcallhistory works fine when page loads , can call other methods inside page. however, in web method part, gets underlined in red error "an object reference required non-static field". how access functions page method part of code? thanks. you cannot call non-static method static context without having instance of class. either remove static resetdate or make loadcallhistory static. however, if remove static resetdate must have instance of use method. approach create instance of class inside resetdate , use instance call loadcallhistory , this: [webmethod] public static void resetdate(datetime thenewdate) { var callhistoryhandler = new pages_callhistory(); callhistoryhandler.loadcallhisto

java - mockito - faking addObserver -

i beginning mockito , wondering how fake adding observer. want write test ensures observer count has increased after function call. example testing code: myclassundertest instance = new myclassundertest(); audiodevicemanager adm = mock(audiodevicemanager.class); assertequals(adm.countobservers(), 0); instance.setup(adm, microphone); //inside setup function, microphone added observer //to device manager: adm.addobserver(microphone); assertequals(adm.countobservers(), 1); since adm mock, know have define logic of addobserver not know - when(adm.addobserver(observer o)).then(?) brian, use verify. example instead of assert, run verify(adm).countobservers( anyobject) and check first chapter of http://mockito.googlecode.com/svn/branches/1.5/javadoc/org/mockito/mockito.html cheers, a.

PHP: Exploding array elements -

i have 2d array have exploded string. once has exploded output: ---> 0 - 16~4~0.0~~~~false~~~~ ---> 1 - 1000.0~21.75~l~1~2.0~2.0~l~2~ ---> 2 - ---> 0 - 2~5~951.3~6.4~~~false~~~~ ---> 1 - 1000.0~11.77~l~1~ ---> 2 - ---> 0 - 3~6~1269.02~5.1~~~false~~~~ ---> 1 - 5.0~213.66~l~1~4.9~2.56~l~2~4.6~19.5~l~3~ ---> 2 - 5.1~53.44~b~1~5.4~8.48~b~2~5.5~15.53~b~3~ i want make each position in array takes first value before ~. unsure how this. code have far: $test = explode(":", $string); foreach($test &$value) $value = explode('|', $value); just in case need original string input: 1~1~828.32~12.5~~~false~~~~|1000.0~41.73~l~1~2.0~2.0~l~2~|:4~2~4.16~12.5~~~false~~~~|1000.0~21.75~l~1~2.0~2.0~l~2~|:9~3~0.16~24.0~~~false~~~~|1000.0~21.75~l~1~2.0~2.0~l~2~|:16~4~0.0~~~~false~~~~|1000.0~21.75~l~1~2.0~2.0~l~2~|:2~5~951.3~6.4~~~false~~~~|1000.0~11.77~l~1~|:3~6~1269.02~5.1~~~false~~~~|5.0~213.66~l~1~4.9~2.56~l~2~4.6~19.5~l~3~|5.1~53.44~

How to handle the discrepancy in precision between .NET CLR DateTime and datetime in SQL Server (and SQL CE) -

in .net datetime data type precision 100ns. in sql server , sql ce datetime type not precise . i have tons of code uses datetime.now or datetime.utcnow. values returned calls stored in database. depending on value, when pull data out of database, not match entered value. result unit tests fail , business logic relies on comparisson fails this has common problem. have go everywhere in code see datetime.utcnow or datetime.now , round down? if that, have prevent future references datetime.now , datetime.utcnow. there way prevent that? are there other standard approaches? thanks

javascript - I'm getting 0 results in my search whenever i have the search input area prefilled -

i'm having trouble getting search results in form whenever use js pre-fill input field. wondering if workaround this. i'm using code - value="keywords" onfocus="if (this.value == 'keywords') {this.value = '';}" onblur="if (this.value == '') {this.value = 'keywords';}" /> thanks! whatever issue is, related other code have not yet shared (without seeing how you're processing form, can speculate might causing problem). below jsfiddle example shows code posted works perfectly. proof else in code causing error. http://jsfiddle.net/pulas/ i recommend taking hard @ server side code you're using read , process form, culprit in there.

cocoa touch - How to support Cyrillic in an iPhone/iPad app? -

i have simple program on app store using standard uikit controls, reviewers complaining cyrillic , korean not supported? uikit controls not using unicode out of box? how can fix issue ? all cocoa ns/cfstrings unicode-compliant (ucs-2 internally), russian , korean alphabets included. unless data are, @ point, passed through single-byte-char format (a c char[] string, example), sensible languages , charsets should supported automatically. pay careful attention storage , wire formats; that's ascii lurks. if downloading data web or http-based api, pay close attention charset within content-type header. when converting nsdata or raw memory chunks nsstring, encoding 1 of parameters. and, cajunluke said, start reproducing issue. if need "lorem ipsum"-type text, copy , paste random nonsense respective wikipedia. i have app in store deals russian , japanese @ same time (it's japanese-russian dictionary). no special measures taken ensure national charset s

java - Why isn't eclipse compiling my web app? -

when start tomcat server, linked java ee project, error listed below. 2 other people using same repository eclipse/tomcat/java , not having problems. creates package hierarchy, classes missing. tomcat develops web-inf/classes/com folders, contents empty. can me this? thank you. severe: context initialization failed org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping#0' defined in servletcontext resource [/web-inf/lightstanza-servlet.xml]: initialization of bean failed; nested exception org.springframework.beans.factory.cannotloadbeanclassexception: cannot find class [com.lightfoundryllc.lightstanza.login.loginvalidator] bean name 'loginvalidator' defined in servletcontext resource [/web-inf/lightstanza-servlet.xml]; nested exception java.lang.classnotfoundexception: com.lightfoundryllc.lightstanza.login.loginvalidator thanks help. set envir

c# - Linq update many-many relationship -

new linq entities. using entity framework , linq. in db have akin cars, users, usercars usercars holds id user , cars. standard stuff. ef maps car , user objects. now user has many cars. through application end new list of car ids. i need update usercars table new list of cars current user. so needs happen basically, current cars user deleted, , new list of car ids/userid inserted. what easiest way go using linq entities? the user entity should have cars property. can clear collection , add new cars reflect new state, i.e. this: user myuser = context.users.first(); var carcollection = context.cars.where( c => caridcollection.contains(c.id)); myuser.cars.clear(); foreach(car car in carcollection) myuser.cars.add(car); ... context.savechanges();

html - What is the best autogrow textarea plugin for jQuery? -

there seem ton of bad autogrow textarea plugins jquery. want autogrowing text box facebook's. want fit current line only, , add line right before it's needed. most of plugins i've reviewed try guess line height number of characters, seems naive. i've read 1 solution creates hidden div calculate height. seems right path, solution wasn't in plugin form. what's out there want , easy install? try it. http://www.jacklmoore.com/autosize thing here's best. it's one.

internet explorer 8 - Site is slow in IE8. jQuery to blame? -

some of pages of site extremely sluggish in ie8. pages lots of content load slowish in browsers slower in ie8. assume load slow begin because there lot of procedural php , database queries. but main concern how lumberingly slow these pages after load in ie8. there jquery slidedown effects , i'm wondering if ie8 sucks @ rendering them. here page little content: http://searchfornutrition.com/?pageid=topic&topicid=acai the slidedown buttons work fine , jquery fast/normal. now here page lots of content: http://searchfornutrition.com/?pageid=topic&topicid=vitamin_d the slidedown buttons sluggish. i've checked computer ie8 , it's same. did unique programming site , i'm no expert. doing site how learned know web development if it's not ie8 it's me. thanks can give. edit: i tried out network tab on chrome dev tools , helpful far why pages load in first place. of unnecessary .css links take seconds load it's document itself. can take 3

preprocessor - VB.NET Is there a way to create a pre-processor constant that behaves as a simple text substitution? -

vb.net 2010, .net 4 hello, i (something like) following: \#const t = "byte()" public class myclass inherits somegenericclass(of t) .. other code .. end class and have act same if i'd typed public class myclass inherits somegenericclass(of byte()) .. other code .. end class it's not have way, i'm curious if such thing possible. thanks in advance! brian no, not possible. visual basic , c# designers decided not allow c-like preprocessor, because felt led lot of errors , confusion. easy write c macros behave in unintended ways, , vb , c# designers felt safety broad range of developers took priority. therefore defines in vb , c# 'defined' or 'undefined' rather having values. eric gunnerson discusses c# perspective here , , think design reasoning vb.net same.