Posts

Showing posts from January, 2011

ajax - how to get django's HttpResponse status code with jQuery? -

my server "return httpresponse()" when succuess, "return httpresponse(status=400)" when failed. client has following jquery ajax function: $('#submit').click(function(){ $.post("{% url 'addcomment' %}", {msg:$('#newcomment').val()}, function(data,status){ if (status==200) { location.reload() } else { alert("comment failed") } }); }); but ajax code doesn't work. idea? as documentation states, success callback returns data , textstatus , jqxhr argument http://api.jquery.com/jquery.post/#jquery-post-url-data-successdata--textstatus--jqxhr-datatype if want response status third argument jqxhr.status

html - jQuery reinitiate css :after on div after jquery function terminated -

i creating justified gallery using code here: http://jsfiddle.net/thirtydot/edp8r/3/ i use infinitescroll load more items. current js: $("#posts").infinitescroll({ navselector : '#page_nav', // selector paged navigation nextselector : '#page_nav a', // selector next link (to page 2) itemselector : '.item', // selector items you'll retrieve loading: { finishedmsg: 'no more pages load.', img: 'http://i.imgur.com/qkky8.gif' } }, function( newelements ) { $( newelements ).each(function() { $(this).css("width", $(this).width()); }); $('#posts').removeclass('posts').addclass('posts'); } ); css: #posts.posts{ text-align: justify; -ms-text-justify: distribute-all-lines; text-justify: distribute-all-lines; } #posts.posts .post{ height: 250px; vertical-align: top; display: inline-block; *

In what structure does Windows keep data about what is the working directory (or the current directory) of the process? -

Image
while reading on working directory , script directory (or directory contains image of executable file) directories are, started wondering, how windows know, directory pass process working directory, when don't specify working directory when launch given program: through command line, pass location of script directory (~as zeroth parameter). note script directory not working directory. i know can use getcurrentdir() retrieve working directory inside of program, i'm wondering, windows have 'internal' structure stores working directory of given process? (and if yes, there documentation on structure). i've found out following process related structures, appears none of them contains working directory property. process_information peb peb_ldr_data rtl_user_process_parameters the shell (or program launches script), calls createprocess() function. createprocess function has lpcurrentdirectory parameter. shell (or other program launches sc

How to close the session in asp.net if computer idle for 5 mins -

i m developing web application using asp.net , want close current user session if computer idle 5 minutes. idle not means web application only, full system means if no keystroke received keyboard 5 mins. i got info thru google idle tracker in vc++ dont know how use dll in web application. link here . please guide me how achieve this. want total computer active time , idle time thru asp.net employees productivity report. asp.net bad choice requirement. asp.net runs on server, while want track client side events. for security reasons, web page can't have such privileges without use of activex or browser plugin, it's complex write, complex deploy , big opened window security breaches. you should create classic desktop application, or search option in gpos, there's maybe something. the simple solution can suggest : create small script file logoff user (search logoff command line) create scheduled task : triggers when specified amount of idle time has

javascript - How to make a multi pane on highstock (highcharts) which contain a stacked area graph? -

i want know if possible use 2 pane view (as this example ) stacked area graph ? i tryed make works in fiddle http://jsfiddle.net/g2xdj/2/ , but, stacked area graph not displayed. var stacked_data = [{ name: 'asia', data: [[1364292000,502], [1364294000,635], [1364296000,809], [1364298000,947], [1364300000,1402], [1364302000,3634], [1364304000,5268]] }, { name: 'africa', data: [[1364292000,106], [1364294000,107], [1364296000,111], [1364298000,133], [1364300000,221], [1364302000,767], [1364304000,1766]] }, { name: 'europe', data: [[1364292000,163], [1364294000,203], [1364296000,276], [1364298000,408], [1364300000,547], [1364302000,729], [1364304000,628]] }]; var line_data = [[1364292000,502], [1364294000,635], [1364296000,809], [1364298000,947], [1364300000,1402], [13643

PHP Session register error -

i hope ill witht his. when im trying log in system im getting errors session register: *fatal error: call undefined function session_register() in c:\xampp\htdocs\check.php on line 18* btw i'm started learn php i'm newbie in there :) there code register.php: <?php include('mysql.php'); include('password.php'); $username = $_post['user']; $password = $_post['password']; $re_password = $_post['password2']; if($username == "") { die("you don't enter username!"); } if($password == "" || $re_password == "") { die("you didn't enter 1 of passwords!"); } if($password != $re_password) { die("your passwords don't match! try again."); } $query = mysql_query("select * users username='$username'"); if(mysql_num_rows($query) != 0) { echo "username exists"; } else { $hash = password_hash($password, password_bcrypt); if (password_verif

python - FeinCMS allow a contenttype only once per page object -

is there default action allow contenttype once per page, other overriding admin form? documentation unclear this i don't think there's out-of-the-box implementation, suggested 1 @ github . since feincms content type abstract django model class use clean method, e.g. class foocontent(models.model): content = models.bar('...') class meta: abstract = true def clean(self): if self.parent.foocontent_set.count() >= 1: raise validationerror('foocontent allowed once per page.') def render(self, **kwargs): return render_to_string('content/foo.html', { 'content': self.content }) this raise non field error on admin form.

Magento PHP : Products without parents -

in magento, on script filter products don't have parent product. : $products = $this->_productmodel->getcollection() ->addattributetoselect('*') ->addstorefilter($this->_storeid) ->addattributetofilter('type_id',array('in'=>$_types)) ->addattributetofilter('status',array('in'=>$_status)) ->jointable('cataloginventory/stock_item', 'product_id=entity_id', array('qty'=>'qty','is_in_stock' => 'is_in_stock'), $this->_getstocksql(), 'inner'); i got products, can "give me products without parents" using getcollection() ? thanks parent product , child product avialable in grouped, configurable, , bundle product. if don't want parent product check if id in parent_id in catalog_product_relation , catlog_product_super_link parent product

.htaccess - shorten/compress mod_rewrite rules -

amongst rules have.. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&submenu=$2&info=$3&id=$4 [qsa,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&submenu=$2&info=$3 [qsa,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&submenu=$2 [qsa,l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/\.]+)/?$ index.php?page=$1 [qsa,l] which seems little bulky me , repeats lot of stuff, ideas on how can shorten it? can set "global" conditions? can have 1 rule captures ones below (i dont care if sends through empty varibles) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule **clever stuff here** index.php?page=$1&

Mocking Google Maps in RequireJS for running tests offline -

i using async plugin https://github.com/millermedeiros/requirejs-plugins load google maps api: define(['async!//maps.google.com/maps/api/js?libraries=places&sensor=false'], function () { // ... }); this has consequence of requiring internet connexion when running unit tests. there way mock or otherwise allow code loads run offline without raising "failed load resource" error? my solution use empty module in place of google_maps module when running qunit tests. google_maps.js : define(['async!//maps.google.com/maps/api/js?libraries=places&sensor=false'], function () { return window.google; }); google_maps_stub.js : define(function () { window.google = {}; return window.google; }); requirejs_config_qunit.js : define(['./requirejs_config_development.js'], function () { requirejs.config({ paths: { 'google_maps': 'js/lib/google_maps_stub' } }); });

php - Only in few pages show the error Fatal Error: mysql_real_escape_string() -

this question has answer here: error while using mysql_real_escape_string() 3 answers i got error in pages, cannot identify why is,! please help. thnx., fatal error: mysql_real_escape_string(): access denied user 'flatsloo'@'localhost' (using password: no) fatal error: mysql_real_escape_string(): link server not established my connection code public function openconnection() { try { $this->_objmysql = mysql_connect($this->getdbconfig()->gethostname(), $this->getdbconfig()->getusername(), $this->getdbconfig()->getpassword()); if (mysql_errno()) // check if error occurred { return mysql_error(); } mysql_select_db($this->getdbconfig()->getdatabase()); if (mysql_errno()) // check if error occurred

wpf listbox and datatemplate with grid inside -

i have following question. want have listbox datatemplate grid . grid has 2 two columns. want set first column width 3* , * . how this? copy code. <listbox x:name="commandlistbox" grid.row="1" grid.column="0" grid.columnspan="2" horizontalalignment="stretch"> <listbox.itemtemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition width="3*" /> <columndefinition width="*" /> </grid.columndefinitions> <textblock grid.column="0" text="{binding}"/> <textblock grid.column="1" text="icon" /> </grid> </datatemplate> </listbox.itemtemplate> </listbox> better store template in resources: <window.resou

internet explorer - CGridView disable ajax update on IE<10 -

can disable ajax update in cgridview on internet explorer < 10? you can ie version manualy , add use in widget: $isie10 = !preg_match('/(?i)msie [1-9]/',$_server['http_user_agent']); $this->widget('zii.widgets.grid.cgridview', array( ................. 'ajaxupdate' => ($isie10?'id':false), ................. ));

django - Detecting a response redirect in middleware -

i have custom middleware creates stack of previous urls can navigated subsequent pages. in 1 of views adds url stack, there logic can redirect response different page, so: @middleware_decorator # tells middleware add views url stack when called def some_view(request): ... stuff ... if some_condition: return httpresponseredirect(url, kwargs) the issue have is, if hit response redirect condition, don't want add current url stack, because when go next page, hit same condition again , redirected page left. have "remove" function in middleware can't call so: if some_condition: middleware.remove("this views url") return httpresponseredirect(url, kwargs) because view url added in process_response stage of middleware logic reasons occurs after redirect has taken place. hoping there way detecting in middleware after first view has been redirected from- "a redirect has happened" , in middleware can decide whether add or

How to tell if Java is running as a windows service and if the -Xrs flag is being used -

one reoccurring problem our java application on windows customers running windows service without specifying java -xrs flag. way when administrator logoff windows machine java process receives termination signal , terminates causing seems random production down situation. i add server log files , monitoring tool warning configuration problem. in order know: 1. java application running windows service ? 2. -xrs flag specified part of java.exe command ? ideas how achieve welcomed. found how check -xrs flag, still need determine if running service: import java.lang.management.managementfactory; import java.util.list; public class getcommandlineflags { public static void main(string[] args) { system.out.println(new getcommandlineflags().isreducedsignal()); } public boolean isreducedsignal() { list<string> flags = managementfactory.getruntimemxbean().getinputarguments(); (string flag : flags) { if ("-xrs".equals(flag)

Jquery: selecting elements that do not only have children with the same class name? -

how make jquery selector selects elements class name "foo", except have children class name of "bar". <!-- don't select --> <div class="foo"> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> <!-- don't select --> <div class="foo"> <div class="bar"><p>some text</p></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"><p>some text</p></div> <div class="bar"></div> </div> <!-- select --> <div class="foo"> <p>some text</p> <div class="bar"></div> <div clas

asp.net - pass authentication header to image requests in iframe -

i sure title of question doesn't makes sense, couldn't think better now. problem: main task show all pages of ssrs report in popup inside 1 of pages of asp.net mvc application. to achieve used below approach: add jquery popup in mypage.cshtml(i need report contents inside popup) when popup opens(on client action), make jquery ajax request second page proxypage.aspx on proxy page make webrequest reportserver network credentials , report html webrequest request = webrequest.create( "http://myreportserver/reportserver?/ myreportname&rs:command=render&rs:format =html4.0&rc:toolbar=false&param1=blabla123"); request.credentials = new networkcredential(myusername, mypassword); httpwebresponse response = (httpwebresponse)request.getresponse(); stream receivestream = response.getresponsestream(); streamreader readstream = new streamreader(receivestream, system.text.encoding.utf8); string str = readstream.readtoend();

java - Register more than one MBean of same MBean class -

i want register more 1 mbean of same class. i have hello class implementing hellombean interface. now in main have 2 object of hello class , want register them both mbeanserver mbs = managementfactory.getplatformmbeanserver(); objectname name = new objectname("mbeans:type=hello"); hello h1 = new hello(); hello h2 = new hello(); mbs.registermbean(h1, name); mbs.registermbean(h2, name); this throws instancealreadyexistsexception . how can register both h1 , h2, , using jconsole view both of them? reason of this, i want change attribute value of both h1 , h2 object through mbean you need register each mbean unique name. if no longer receive exception when registering second mbean. have manage each bean separately (i.e. attribute on each home object set through individual mbeans). mbeanserver mbs = managementfactory.getplatformmbeanserver(); hello h1 = new hello(); hello h2 = new hello(); mbs.registermbean(h1, new objectname("mbeans

ubuntu - Linux how to use rm and exclude switch -

i wondering how can use linux rm command --exclude switch ? for example grep has exclude function when searching on files. here 1 specific rm `find . -name "safe_room*" ! -name "safe_rooms.php"` i used git git rm `find . -name "safe_room*" ! -name "safe_rooms.php"` explanation: rm - linux command delete `` - signs used within mysql. on keyboard ctrl + 7 find . -name "safe_room*" - find safe_room* ! - not logical operator -name "safe_rooms.php" - exclude except safe_rooms.php hope :)

git - What minimal files needed for Microblaze rebuild -

i working on xilinx project contains microblaze design. curious minimal file set needed store hardware portion of project in git (or other cm tool) , still able rebuild on different machine. have far been unable narrow down, there lot of files generated sure can rid of. inside top directory there directories _xps, bootloops, data, etc, hdl, implementation, pcores, revup, sdk, , synthesis. directories totally unneeded, , files must within remaining folders? so far have been unable find list anywhere (and attempts narrow down myself have been fruitless). there target in makefile clean up. iirc called hwclean - there used swclean also. if run those, left more limited file set. seem recall leaves __xps think unnecessary. coming @ other way, off top of head, need: the xmp, mhs , mss files the data directory any project-local pcores have created the etc directory that should "empty" bitstream no code in microblaze bram the software in sdk fo

vsto - Outlook Add-In becomes inactive after Windows Update -

i have written outlook add-in (vsto in c#) , problem occurs on machines (all windows 7) office 2010 installed outlook add-in becomes inactive after windows update (including @ least 1 office update). it can reactivated without issues though , working fine, including user-settings. do know cause behavior? thanks.

ruby on rails - rspec mock not getting called on belongs_to association -

i'm trying test controller in rails rspec, it's not calling 1 of mocks made , i'm not sure why. my model has user class, , game class, , player class, belongs user , game. i'm trying test this player = player.find_by_id(params[:id]) if player != nil && player.user == current_user && player.game.remove_player?(player) redirect_to games_url yet can't seem mock remove_player? correctly. i'm doing pretty this: @player = double("player") player.should_receive(:find_by_id).with(mock_player_id.to_s).and_return { @gplayer } @player.stub(:user).and_return(@current_user) fakegame = double("game") @player.stub(:game).and_return(fakegame) fakegame.should_receive(:remove_player?).with(@player).and_return(true) i'm getting error saying remove_player? never called. idea i'm doing wrong? can't tell sure if it's reaching player.user == curent_user, calling find_by_id , not complaining @ all, imagine must reach

javascript - Use i in var name on a for cicle -

this not working have no idea how correct it: for(i=1; i<=3; i++){ var address_con+[i] = document.getelementbyid("address_con[i]") var cap_con+[i] = document.getelementbyid("cap_con[i]") var city_con+[i] = document.getelementbyid("city_con[i]") } it should produce: //first element address_con1 = document.getelementbyid("address_con1") etc. //last element city_con3 = document.getelementbyid("city_con3") the error on: var name+[i] thank you there no replacement of variables inside strings in javascript (unlike in php, possible). similar creating new variables, can't in way, trying. to naming, can use following code, store values inside result variable. var result = {}; for(var i=1; i<=3; i++){ result[ "address_con" + ] = document.getelementbyid("address_con" + i) result[ "cap_con" + ] = document.getelementbyid("cap_con" + i) result[ &qu

android - Allow network connection to a specifc app -

i developing application mobile (iphone , android) maps based company. company has deployed wireless network allow, subscribing, internet access. the idea of mobile app give internet access specific app ones have it. in other words, company wants allow application connect network. my question is: possible give access specific application , appropriate way? app "recognize" network or network in charge of give access specific app? suggestion appreciated. if want provide app connect network need put rules in iptables in linux core ( this needs application have root access ) firewall applications android monitors uids of applications accessing network but can other way, implement server calls particular network of company accessed through particular app, use validation in http requests such maintain unique id differentiate app/user can create during registration , during interacting network use key validation .

java - Jahia6.6 deployment error in maven-built module -

i trying develop template-set module jahia site. i used step-by-step procedure described in official documentation available here : http://www.jahia.com/cms/home/download/jahia-academy/documentation.default.html?displaytab=technical-documentation " templating , integration guide ". basically, implies use maven archetype initialize, build , deploy project on server. 2 first steps correctly done. generates module's skeleton , mandatory files. then, can build create .war file. mvn archetype:generate -darchetypecatalog=http://maven.jahia.org/maven2 >> [info] project generated mvn clean install >> [info] build success but error occurs during deployment. mvn jahia:deploy >> [info] build failure >> [error] failed execute goal org.jahia.server:maven-jahia-plugin:2.81:deploy (default-cli) on project test-template-set: >> error while validating deployers:factory not initialized properly, >> must set targetserverdirectory v

javascript - Script dosen't work in IE -

this works fine in other browsers except ie. in ie10 doesn't want cooperate. appreciated. have form drop down menu when different user makes selection brings div different form have 10 forms in can choose from. right nothing in ie, no console errors or anything. script var sections = { 'second': 'section2', 'third': 'section3', 'forth': 'section4', 'fifth': 'section5', 'sixth': 'section6', 'seventh': 'section7', 'eigth': 'section8', 'ninth': 'section9', 'tenth': 'section10', 'eleventh': 'section11' }; var selection = function (select) { (i in sections) document.getelementbyid(sections[i]).style.display = "none"; document.getelementbyid(sections[select.value]).style.display = "block"; } $("#target option") .removeattr('selected&

zend framework2 - How do I send the same header with every response in zf2? -

i send header "x-content-type-options: nosniff" every response in zend framework 2 application. how can without explicitly coding in every single controller method? you can modify response object via bootstrap: module.php /** * on bootstrap event * * @param \zend\mvc\mvcevent $e */ public function onbootstrap(mvcevent $e) { $headers = $e->getresponse()->getheaders(); $headers->addheaderline('x-content-type-options: nosniff'); }

version control - File/Folder Structure in Team Foundation Service -

when adding projects tfs, i'll add project specific website. works fine, , folders , files within root of website available in tfs. however, there shared files above root of website, , not included in specific website project/solution, since reside outside root of website. example, when add existing files project, outside root, creates duplicates within project. or, when adding existing file project, creates wrong folder hierarchy in project (appears though folder above root inside website), result in problems publishing , sharing source in tfs. what appropriate way include these files in project, files can remain outside root, included in project in tfs. one way might achieve having one team project websites , , logically break different sites backlogs/iterations/work items etc using teams/areas. source code within correct hierarchical structure within 1 team project, , can shared between subprojects within team project. see following posts discussion of ap

java - Create new object with Builder pattern with "old" object reference -

i playing around builder pattern , stuck how add new "property" new-created object: public class msprojecttaskdata { private boolean isalreadytransfered; private string req; public static class builder { private boolean isalreadytransfered = false; public builder withtransfered(boolean val) { isalreadytransfered = val; return this; } public msprojecttaskdata build() { return new msprojecttaskdata(this); } } private msprojecttaskdata(builder builder) { isalreadytransfered = builder.isalreadytransfered; } public msprojecttaskdata(string req) { this.req = req; } } i can create new object builder this: msprojecttaskdata data = new msprojecttaskdata.builder().withtransfered(true).build(); but approach req string new-created object lost (of course). is there possibility create new object new set isalreadytransfered variable , with "old" req string "old" obj

git tag - Reverting a branch changes tag name of git describe -

i learned how revert branch. works fine. thing is, tagged master's commits , plan use git describe command create deployments based on latest tag. reverting commit creates new commit, git describe command outputs tag commit ammend, so: before: git describe 1-2-0 after revert 'back' commit: git describe 1-2-0-1ga99ae04 is there way overcome this? or should latest tag differently? just clear. dont revert "back". have following history. a<--b<--c<--d | (tag:1-2-0) now revert c . happens. a<--b<--c<--d<--e | (tag:1-2-0) as can see have moved forward in history. if tag has been released, want consider "hotfix", , tag again 1-2-0-1 , or along lines. not sure version number scheme is, work hotfixes process. considering change hotfix result in this. (tag:1-2-0-1) | a<--b<--c<--d<--e | (tag:1-2-0) however

Android opening application settings not working on Android 4.1.1 -

i have used following code opening application settings code , worked fine on samsung galaxy tab. private void showsettingsforpackage(string packagename) { intent intent = new intent(); final int apilevel = build.version.sdk_int; if (apilevel >= 9) { // above 2.3 intent.setaction(settings.action_application_details_settings); uri uri = uri.fromparts("package", packagename, null); intent.setdata(uri); } else { // below 2.3 string apppkgname = (apilevel == 8 ? "pkg" : "com.android.settings.applicationpkgname"); intent.setaction(intent.action_view); intent.setclassname(app_details_package_name, app_details_class_name); intent.putextra(apppkgname, packagename); } this.startactivity(intent); } my problem above code not opening settings in htc 1 x+ android 4.1.1. please let me know there solution? thanks , regards @nish

css - Can't change footer colour in wordpress -

This summary is not available. Please click here to view the post.

c# - Using correct encoding when reading from TCP/Port -

i'm reading byte stream ( byte[] ) tcp/port, , converting subsection of recieved array char[] assume not familiar characteristics of port, nor environment on other side of port. know there port. part of data recieve encoded uk pound currency symbol (£). when use ascii encoding conversion, these symbols come through ? var chararray = encoding.ascii.getchars(bytearray); however, when use utf-7, ok: var chararray = encoding.utf7.getchars(bytearray); i should add when trying utf-8, doesn't work. this trial , error, , i'm not entirely sure why might have worked. rather go ahead , deploy solution, thought i'd try understand more why might have worked. is system on other side of port transmitting in utf-7, or there else going on?

syntax - How can I add only a file to zip and not the folder path leading to it in Python? -

i'm using code below zip backup file created daily. import os, zipfile zf = zipfile.zipfile("test.zip", "w") root, subdirs, files in os.walk("c:/users/bob/desktop/zip"): filename in files: zf.write(os.path.join(root, filename)) zf.close() the problem when open zip, includes folders in path leading file. example, inside zip, have folder called users/bob/desktop/zip/file.gdb but want file.gdb inside zip. reason because when includes these folders, doesn't compress file. same size when it's not inside zip. if zip file.gdb 30mb 3mb. any appreciated. you need @ arcname parameter of zipfile.write : zipfile.write(filename[, arcname[, compress_type]]) write file named filename archive, giving archive name arcname (by default, same filename , without drive letter , leading path separators removed). in case, want: zf.write(os.path.join(root, filename), filename, zipfile.zip_deflated)

java - how to select an object from a jTable by a click -

i have made class called clients, has simple attributes client_id, client_name , client_age. have programmed small gui netbeans after input data client pressing button displayed in jtable. the source code adding in jtable is: for (int i=0;i<customerv.length;i++){ jtable2.setvalueat(customerv[i].getname(), i, 0); } i if click 1 element on jtable able add orders client making using of jbutton. if program in console like: order order1=new order("1000","41211") in first field order id , second order number, if want assign customer 1 like. c1.assignorder(order1) how can using java swing? mean select whole object element click in jtable set instances of clients table model instead of client names (like: jtable2.setvalueat(customerv[i], i, 0); ) implement custom renderer render client class needed (e.g. display client's name) , set table. (easier) option override tostring on clients return client's name, or whate

c++ - Internet Explorer Add-on to detect Ajax calls -

using iwebbrowser2 interface easy know when navigation took place (onbeforenavigate) , finished (ondocumentcomplete). however, lot of work in browsers done through ajax calls (which use xmlhttprequest). is there way subscribe events tracking when ajax call occurred , finished in ie? the official way create changelog using ihtmlchangesink . it's not complicated, it's bit tedious implement don't lose requests. i think best way may create http proxy server , use internetsetoption set proxy (note first argument null set current process) local http proxy server.

sockets - Why do we need SocketOptions.SO_BROADCAST to enable broadcast? -

if want broadcast information socket, need enable socketoptions.so_broadcast . however, don't understand why necessary. my understanding set packet broadcast address, same way set unicast address. need send through regular socket. if udp socket, udp header added packet, , ip header containing receiver's ip address (in case broadcast address in form of 192.168.255.255 ), , mac address (ff:ff:ff:ff) added. i think router packet , perform broadcast. don't understand why need set socket attribute so_broadcast . "socket semantics require application set so_broadcast option on before attempting send datagram base or broadcast address. protects application accidentally sending datagram many systems." source

Does SignalR work with series 40? -

i'm trying use signalr, want know whether it's supported on series-40, whether it's supported on nokia asha phones. knows? thanks. the answer yes, working using nokia web tools. please refer this blog post things need make work.

java - Hibernate - updating object with many to many relationship -

i have class person , class role. there many many bidirectional relationship between person , role. if create new person, load existing role db , set role person, works. if load existing person db (already has roles), load role db, set role person - org.hibernate.nonuniqueobjectexception different object same identifier value associated session: role. i don't know problem. there hbm.xml <class name="person" table="person"> <id column="id" name="id" type="java.lang.integer"> <generator class="native"/> </id> <property column="name" name="name" type="string"/> <property column="surname" name="surname" type="string"/> <property column="email" name="email" type="string"/> <set name="roles" table="role_person" inverse="false" lazy="

c# - In ServiceStack is it possible to mock the Request.OriginalRequest object for unit tests? -

i'd make servicestack service testable. presently have: [requireformsauthentication] public object delete(deleterequest request) { var originalrequest = (httprequest)request.originalrequest; var identity = originalrequest.requestcontext.httpcontext.user.identity; return othercode(identity); } where requireformsauthentication is public class requireformsauthenticationattribute : requestfilterattribute { public override void execute(ihttprequest req, ihttpresponse res, object requestdto) { var originalrequest = (httprequest)req.originalrequest; var identity = originalrequest.requestcontext.httpcontext.user.identity; if (!identity.isauthenticated) { res.statuscode = (int)httpstatuscode.forbidden; res.endservicestackrequest(skipheaders: true); } } } i've mocked out dependencies used 'othercode()' , that's left stuff that's in base class service. there pattern/str

c# - How to retrieve Display attribute in the Html Helper (GroupName) -

in htmlhelper i'm trying retrieve displayattribute.groupname of property, using modelmetadata.fromlambdaexpression(expression, html.viewdata) however, property "groupname" missing in modelmetadata. i googled solutions , saw quite complex manipulations, while hope can solved easier. any suggestions appreciated! i have example may work. use create custom helper. hope works you: public static mvchtmlstring datepickerfor<tmodel, tproperty>(this htmlhelper<tmodel> htmlhelper, expression<func<tmodel, tproperty>> expression, string classname) { if (expression == null) { throw new argumentnullexception("expression"); } var expressiontext = expressionhelper.getexpressiontext(expression); var metadata = modelmetadata.fromlambdaexpression(expression, htmlhelper.viewdata); var me = (expression.body memberexpression); var display = me .member .getc

Change reference level for variable in R -

i have data set, (call data) variable, color. mode of color numeric , class factor. first, i'm bit confused "numeric" -- when printed out, data color not numeric -- character values, white or blue or black, etc. clarification on appreciated. further, need write r code return levels of color variable, determine current reference level of variable, , set reference level of variable white. tried using factor, entirely unsuccessful. thank taking time help. mode(data$color) "numeric" because r internally stores factors numeric codes (to save space), plus associated vector of labels corresponding code values. when print factor, r automatically substitutes corresponding label each code. f <- factor(c("orange","banana","apple")) ## [1] orange banana apple ## levels: apple banana orange str(f) ## factor w/ 3 levels "apple","banana",..: 3 2 1 c(f) ## strip attributes numeric vector ## [1] 3 2 1

c# - MonoTouch - creating a UILabel that has both bold and plain text in single label -

can provide me simple example showing creation of uilabel has both bold , plain text in single label? i have searched around , managed piece dramatically modifies uilabel's look, can't figure out how change parts of label... surely can't difficult? imagine need create uilabel, use nsattributedstring text, , specify nsrange parts of want bold? to clarify, using monotouch. something this, although you'll need use more complicated set of attributes nsattributedstring label.attributedtext = new nsattributedstring ( "label", underlinestyle: nsunderlinestyle.single);

uml - Representing insertion of a already created object -

i'm modeling sequence diagram code this: void myobject::createadevice{ device* somedevice = new device(); devices[i] = somedevice; screen* scr = new screen(); somedevice->addscreen(scr); ... } this code have doubts. i'm modelling no problem until call of somedevice->addscreen() . i've created self message object creation device , screen objects. i'm failing represent last line. how can that? p.s: i'm using enterprise architect the device , screen objects needs own lifelines. new operator can represented messages device , screen. addscreen message device.

ruby on rails - Model/ActiveRecord not saving new data -

i have confirmed method works. takes email controller , changes email of specific user. however never saves data. pass wrong email format , returns false if pass correct email method returns true means assigned new email , called safe. # allows user change email address def change_email(newmail) address = emailveracity::address.new(newmail) if address.valid? self.email = newmail self.save return true else return false end end i checked logs first hints nothing is: started post "/members/editmail" 127.0.0.1 @ 2013-04-25 17:33:44 +0200 processing memberscontroller#editmail html parameters: {"authenticity_token"=>"*****=", "mail"=>"*****@gmail.com"} ←[1m←[35muser load (1.0ms)←[0m select `users`.* `users` `users`.`id` = 1 limit 1 ←[1m←[36mcharacter load (0.0ms)←[0m ←[1mselect `characters`.* `characters` `characters`.`user_id` = 1←[0m ←[1m←[35m (0.0ms)←[0m begin ←[1m←[36muser exists

c# - Return anonymous types from stored procedure -

this question duplicate of question here: returning anonymous types stored procedure linq2sql but been 4 years , no 1 has answered it, hoping like..bump up. need answered, been struggling same issue. thanks you can generate xml-like string in store procedure , use xmlserializer deserialize more complex object in runtime. use attribute in xml can distinguish between different types of objects returning value referring to. edit: 1 other workaround returning varbinary object stored procedure include binary data needed instantiate desired object. of course using method, difficult maintain code.

asp.net mvc - Using one dropdownlist for two different forms in ASP MVC -

using mvc4, have drop-down list contains value user may select. have 2 different actions pass value into. how accomplish this, if possible? view: @using (html.beginform("action1", "controller", formmethod.post, new formcollection())) { @html.dropdownlist("item", model.getlistvalues(model.items)) <input type="submit" value="goto action1"> } @using (html.beginform("action2", "controller", formmethod.post, new formcollection())) { <input type="submit" value="goto action2"> } controller: public task<actionresult> action1(string item) { //logic } public task<actionresult> action2(string item) { //logic } right now, code allow me pass in value in dropdown first form, how include in second form? might involve use of @html.hiddenfor? don't want duplicate drop-down list. with jquery, things possible. as mentioned, add hidden field second f

actionscript 3 - How to fix Error "A conflict exists with definition * in namespace public." using ASC2.0? -

in class hierarchy where: mnglayers extends manager_panel , extends manager_base ... -- in manager_base , i've defined init() method: public class manager_base { //.... public function init():void { //do initialization here... } } -- in manager_panel , not override init() method. -- in mnglayers , override init() method. public override function init():void { super.init(); //do custom initialization here... } when attempt compile this, unhelpful compilation error: error: conflict exists definition init in namespace public. i'm not sure matters, i'm using asc2.0 compiler (from air sdk 3.7) -inline support. is there broken in compiler prevents doing simple method-overriding compilation previous compiler could? ah! damn, it's asc2.0 not being descriptive enough! my bad, had duplicate init() overriden method in leaf sub-class (mnglayers) time. of helped if compiler pointed out duplicate 1 instead!

javascript - Persistent Cookie -

document.setbackground.bgcolor.value certifiably works , stores hex value (such "000000" black. script works changing color of background of page when new 1 selected live form updates value. my problem while code stores cookie browser, not work when close browser , reopen. want background start out whatever stored in cookie. there wrong code or browser settings? function setbackground () { if (document.setbackground.bgcolor.value != "none"){ document.body.bgcolor = "#" + document.setbackground.bgcolor.value; document.cookie = "bgcolor=" + document.setbackground.bgcolor.value + ";expires=wednesday, 02-mar-2020 12:00:00 gmt;"; } } this code embedded following html in setpreference.js file: <html> <head> <script src="setpreference.js"></script> </head> <body bgcolor="#9999cc"> <center> <form name="

html5 - Compatibility of omitting tags -

i read using html5 standard of omitting tags. example, head tag can removed if content following element. i want know if knows if there compatibility problem associates using this, if instance usage poses problem in older browsers or fails validate in w3c html validation?

c++ - Creating a struct and a class with the same name -

summary : happens if declare struct , class same name. details : i'm reviewing code , saw warning this: warning: struct 'foo' declared class when compiling clang there couple of places clang added notes saying: foo.h:29:1: note: did mean struct here? class foo; ^~~~~ struct obviously not coding practice have struct , class same name. looks happened developer writing own class , used name in use in file including , did not notice that. however, question compiler able tell difference between variables declared class foo , ones struct foo ? edit : actually happening developer using class foo in class bar had created. think in meantime place class foo declared had been changed struct bar . why code compiling. guess answer question struct , class interchangeable when declaring objects. still guess it's idea use them consistently. the keywords struct , class largely interchangeable. if write struct foo , have created class type n

using filters with django-endless-pagination -

i'm using django endles-pagination load pages in infinite scroll. have filters filter data according criteria (for eg, price slider filtering according price). when page loads, filter right filters page loaded, though want filter pages have been or loaded. there way (by making ajax request or something)? any on great. lot. to filter data have redefine get_queryset() method in views requesting filtered query. for example request current language in template filter blog posts based on language: class blog(ajaxlistview): context_object_name = "posts" template_name = 'cgapp/blog.html' page_template = 'cgapp/post_list.html' def get_queryset(self): if self.request.language_code == 'en': #request value of current language return news.objects.filter(language='en') #return filtered object if current language english else: return news.objects.filter(language='uk') to filter queryset b