Posts

Showing posts from July, 2014

python - Simple for loop explanation -

why code... alist = ['cat','dog','cow'] item in alist: print alist output ['cat', 'dog', 'cow'] ['cat', 'dog', 'cow'] ['cat', 'dog', 'cow'] while changing print alist item outputs: cat dog cow i understand when printing alist print list many times there elements in list guess don't understand why different. i grateful if explain difference me or point me in right direction. you have list - contains cat, dog, , cow. then say: each thing in list, print list. you have 3 things in list (cat, dog, , cow) list gets printed 3 times. when switch statement print item instead of print alist saying each thing in list print thing - each thing in list gets printed, ie cat, dog, cow.

codeigniter - CI Form validaion returns false but validaion_errors() is blank -

my code : public function add() { if ($this->input->post()) { //echo '<pre>';print_r($this->input->post());exit; $this->form_validation->set_rules('agency[title]','title','required'); $this->form_validation->set_rules('agency[first_name]','first name','trim|required|min_length[3]'); $this->form_validation->set_rules('agency[last_name]','last name','trim|required|min_length[3]'); $this->form_validation->set_rules('agency[email]','email','trim|required|valid_email|is_unique[agency.email]'); $this->form_validation->set_rules('password','password','trim|required|min_length[3]'); $this->form_validation->set_rules('conf_password','confirm password','required|matches[password]');

matlab - Finding the area of some specific graph color in a 3D graph -

Image
i have graph (and raw data) shown below. the axis in graph in cm. want know area of deep blue area in graph (the answer should 20 sq.cm. or that). there way find it? if you're sure literally mean deepest shade of blue, corresponds minimum of data. can find minval = min(mydata(:)); . once have minimum value, select points equal value minvals = mydata == minval; . note collect elements equal deepest blue, in floating point sense. if didn't literally mean deepest shade of blue, might want consider selecting points within threshold of minimum value instead. count them total = sum(minvals(:)); . then multiply number of points value representing area of each point in cm2.

haskell - UndecidableInstances and newtypes -

i have undecidableinstances problem haven't been able figure out how avoid using newtype . here's had originally: {-# language typefamilies, flexiblecontexts #-} class record r key :: r -> string class (record r) => sizedrecord r size :: r -> int class database d type dbrecord d class (record a) => agent agentid :: -> string agentid = key class (database (uagentdb u), agent (uagent u), record (uagent u)) => universe u type uagent u type uagentdb u -- plus other stuff data simpleuniverse d = simpleuniverse { sudb :: d -- plus other stuff } deriving (show, eq) instance (record (dbrecord d)) => universe (simpleuniverse d) -- line 28 type uagent (simpleuniverse d) = dbrecord d type uagentdb (simpleuniverse d) = d -- plus other stuff the message is amy9.hs:28:10: constraint no smaller instance head in constraint: record (dbrecord d) (use -xundecidableinstances permit this) in instance de

c++ - How to make my application DPI-aware? -

when user sets dpi scaling draw fonts , windows larger in displays, don't want application affected (i don't want application's fonts , controls larger) i tried use setprocessdpiaware() function or add manifest file, didn't work. how can prevent windows (xp, 7 , 8) change application's font size? you're asking wrong question. want dpi-independent. answer size in points, , relative in ems. avoid dpi , pixels completely.

javascript - Chrome extension Content Security Policy directive error -

i'm trying make radio stream chrome extension there problem. when run script in browser normal js+html+css works, when try runing chrome extension error: refused execute inline script because violates following content security policy directive: "script-src 'self' chrome-extension-resource:". either 'unsafe-inline' keyword, hash ('sha256-...'), or nonce ('nonce-...') required enable inline execution. after added manifest: "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" but after getting error message(error in manifest line code above) this manifest: { "background": { "scripts": [ "jquery.js", "jquery-ui.js", "plate.js" ] }, "browser_action": { "default_icon": "images/action-normal.png", "default_popup": "player

mysql - java.sql.SQLException Parameter index out of range (1 > number of parameters, which is 0) -

after validation of select combo box have selected not able insert in database. tomcat gives following error java.sql.sqlexception: parameter index out of range (1 > number of parameters, 0). how caused , how can solve it? you error when call of setxxx() methods on preparedstatement , while sql query string not have placeholders ? this. for example wrong : string sql = "insert tablename (col1, col2, col3) values (val1, val2, val3)"; // ... preparedstatement = connection.preparestatement(sql); preparedstatement.setstring(1, val1); // fail. preparedstatement.setstring(2, val2); preparedstatement.setstring(3, val3); you need fix sql query string accordingly specify placeholders. string sql = "insert tablename (col1, col2, col3) values (?, ?, ?)"; // ... preparedstatement = connection.preparestatement(sql); preparedstatement.setstring(1, val1); preparedstatement.setstring(2, val2); preparedstatement.setstring(3, val3); note parameter i

PHP Recordset Paging, changing url Parameter -

bit of newby php & mysql, , use dreamweavers inbuilt functions, trying hands dirty , understand things little more , subsequently fix couple of problems. i have file (search.php) when viewed has 2 url parameters ' letter ' , ' search ' 'search.php?letter=a&search=no' within body of page, have recordset paging function (from dreamweaver). when using paging, end url similar this 'search.php?pagenum_results_empty=1&totalrows_results_empty=2937&letter=a&search=no' very want change parameter ' search ' ' no ' ' yes '. can work out, need remove ' search=no ' query string, , add ' search=yes ' link. i'm not not able remove query string, or barking wrong tree. any advice gratefully received php code $issearch = $_get['search']; $querystring_results_empty = ""; if (!empty($_server['query_string'])) { $params = explode("&", $_server['que

android - how to show other application inside my main xml? -

how show other activity inside activity idea how that? want show other activity inside main layout , take 50% of screen not show on full screen idea??? string packagename = "com.mobile_banking"; // must know package name intent = new intent(intent.action_main); packagemanager manager = getpackagemanager(); = manager.getlaunchintentforpackage(packagename); startactivity(i); with activity, can't show 2 activities in single one. what looking fragmentactivity , fragments custom sizes in it. first learn fragments , fragmentactivity once learn basics, can follow these links: android 2 fragments in same activity how implement 2 fragments in single view?

Check if selected dropdown value is empty using jQuery -

here dropdown in question: <select name="data" class="autotime" id="eventstarttimemin"> <option value=""></option> <option value="00">00</option> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> </select> what want check if current value empty: if ($("eventstarttimemin").val() === "") { // ... } but not work, though value empty. appreciated. you forgot # on id selector: if ($("#eventstarttimemin").val() === "") { // ... }

winapi - How to get a user input on a MessageBox on C++? -

i have application on c++ (on windows api) , ask user approve task using messagebox. however, it's bit sensible task , nobody reads message, want change have input box , user type "i agree". does know simple way that? find dialogboxparam() can it, it's overkilling needs, can think on more simple (or simple way use it)? i found prompting user input box? [c++] quite similar question, there no satisfactory answer me (using lib not option). you have write own dialog that. messagebox , related apis not offer such functionality. use task dialog api (introduced in vista) show dialog box button having customised caption. might little better plain messagebox limited set of buttons. i'm little cynical trying achieve in case. if force users type i agree ignore content of dialog box , type ask them type. the difference in outcome between typing dialog , standard button press dialog user take longer past dialog, , dislike software, still not have read

php - Trouble with password verification with salt/password/hash -

i've got 1 function create new user generating salt, appending password, , hashing combination. i've got function user login verification, takes user's entered password , adds user's unique salt, hashes, , compares encrypted password in database (see comments throughout code). i've echoed out important variables in uservalidate() function, can never hash+user password match encrypted password database. can tell me i'm doing wrong? create user function: function createnewuser($firstname, $lastname, $email, $password, $address, $city, $state) { $conn = connectpdo(); // create salt $salt = mcrypt_create_iv(64, mcrypt_dev_urandom); // add salt password $salted_password = $salt.$password; // hash salt/password combination, added "password" column of database $encrypted_password = hash('sha256', $salted_password); $datetime = date("y-m-d h:i:s"); $stmt = $conn->prepare("insert user

sql - sqlException (0x80131904) The name'...' is not a valid identifier -

i have stored procedure dynamic based on database needs access. running procedure program gives me error: system.data.sqlclient.sqlexception (0x80131904): name '...' not valid identifier..... when run stored procedure ssms, same error, if print instead of exec, run code manually, works fine. declare @sql varchar(8000) if @provider='' set @sql = ' update ' + @linkserver + '.dbo.[billing header] set [bill primary]=1 billing in( select distinct billing ' + @linkserver + '.dbo.[history detail] ' + @wheredatefacility + ' , [insurance code] = rtrim( '''+ @primarycode +''')); select @@rowcount rc;' else set @sql = ' update ' + @linkserver + '.dbo.[billing header] set [bill primary]=1 billing in( select distinct hd.billing ' + @linkserver + '.dbo.[history detail] hd inner join ' + @linkserver + '.dbo.[billing header] bh on bh.billing=hd.bi

animate not working-JQuery -

am doing wrong simple animate not work? fiddle $('#my_btn').click(function(){ alert('clicked'); $("#my_txt").animate({left:'350px'}); }); thanks an element must have position other default static top , left have effect #my_txt {position: relative; } fiddle preferably have initial left style set well #my_txt { position: relative; left : 0; }

How to store and get a pointer reference in a global scope in GO -

i have got follow code: package main func main() { // create pointer referece of session of mongo db session := mongodb.createsession() // question 1 : how store pointer reference in global scope , using anywhere of code defer session.close() // note suppose code call handler methods call process in package controller(the last 1 code) } code of creating session of mongodb package mongodb func createsession() *mgo.session { session, err := mgo.dial("192.168.0.108:27017/databasename") if err != nil { panic(err) } session.setmode(mgo.monotonic, true) return session } place want use pointer reference store in main package controller func process() { // question 2 : how can pointer reference store in question 1 if posible collection := mongodb.createcollection(session, "namedatabase", "colectiondata") mongodb.insertdata(collection, "ale", "45646565") } the idea avoid passing reference ses

java - Balance Check if brackets are closed in a string using stacks -

i writing program check see if sets of brackets closed in user-inputed string, confused how because need use stacks accomplish it. my idea add brackets stack if exist, if closing bracket shows up, pop off top 2 characters stack , if second popped off character matches first (as in type of bracket matches , both opening , closing bracket) line balanced. however, need have able work strings multiple brackets , characters in them, example: wfsfs[{{{(s;dkls(dslkf)s;dlkf}]}]}}}sd i confused how make work using stacks! ideas? here code came far doesn't work multiple brackets (int = 0; < x.length(); i++){ if (x.charat(i) == '('){ stack.push('('); } if (x.charat(i) == '['){ stack.push('('); } if (x.charat(i) == '{'){ stack.push('('); } if (x.charat(i) == ')'){ stack.pop(); if (stack.em

javascript - Syntax error when trying to test for empty string -

in javascript, trying simple task of testing , returning longest of 2 words. if words empty return should "empty string". keep getting syntax error when testing empty string or elseif statement. using (!word1) , (!word2) because understanding in javascript boolean statement , should false. please tell me going wrong: function longest(word1, word2) { if (word1.length >= word2.length) { return (word1); } else { return (word2); } else if (!word1) || (!word2) { return "an empty string"; } } console.log(longest('hi')); if conditions should surrounded 1 pair of parentheses. change else if (!word1) || (!word2) else if (!word1 || !word2) .

python 2.7 - Why does this runs twice? -

i made program runs using systrayicon and thou works fine, every time checks something, twice. can fix reducing chance half, that's shortcut not proper fix. from systray import systrayicon random import randint def shutprogram(systrayicon): = getsomething() while true: if getsomething() != : = getsomething() if randint(0,100) <= 10: print "stop, hammer time!" stopthis() else: print "you may pass" menu = (('start', icon.next(), shutprogram),) systrayicon(icon.next(),"shut program",menu) oh, got. when tried 'getsomething', had wait bit because had delay prompted returning string 'wait, getting info'.

javascript - PersistJS the call back function is not working -

i have found library handle client storage, latest version found here https://github.com/jeremydurham/persist-js but 1 thing not work call function var result = store.get('saved_data', function (ok, val) { console.log(ok, val); }); i retrieve result except call function not working. 1 appreciated. there no callback persistjs. use result needed.

node.js - Error on installing Zombie package in nodejs -

my requirements scrape third party https websites posting details. clicking button using nodejs. i found client side event handling can achieved using zombie package in node. have followed steps in https://www.npmjs.org/package/zombie by existing command "npm install zombie" getting below error, not install zombie package successfully. any suggestion on this,,,,,,,,,, npm http https://registry.npmjs.org/zombie npm http 304 https://registry.npmjs.org/zombie npm http https://registry.npmjs.org/eventsource npm http https://registry.npmjs.org/encoding npm http https://registry.npmjs.org/jsdom npm http https://registry.npmjs.org/html5 npm http https://registry.npmjs.org/q npm http https://registry.npmjs.org/ms npm http https://registry.npmjs.org/request npm http https://registry.npmjs.org/ws npm http https://registry.npmjs.org/mime npm http https://registry.npmjs.org/tough-cookie npm http 200 https://registry.npmjs.org/eventsource npm http https://registry.npmjs.org/ev

node.js - How mongodb connection works on concurrent requests in NodeJS express server? -

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

Jasper plugin in Grails: org.hibernate.LazyInitializationException: could not initialize proxy - no Session -

i trying generate report in doc format using jasper plugin, exception generated at: jasperreportdef report = jasperservice.buildreportdefinition(params, request.getlocale(), result) line in controller exception: could not initialize proxy - no session. stacktrace follows: org.hibernate.lazyinitializationexception: not initialize proxy - no session @ org.apache.commons.beanutils.propertyutilsbean.invokemethod(propertyutilsbean.java:2170) @ org.apache.commons.beanutils.propertyutilsbean.getsimpleproperty(propertyutilsbean.java:1332) @ org.apache.commons.beanutils.propertyutilsbean.getnestedproperty(propertyutilsbean.java:770) @ org.apache.commons.beanutils.propertyutilsbean.getproperty(propertyutilsbean.java:846) @ org.apache.commons.beanutils.propertyutils.getproperty(propertyutils.java:426) @ net.sf.jasperreports.engine.data.jrabstractbeandatasource.getbeanproperty(jrabstractbeandatasource.java:111) @ net.sf.jasperreports.engine.data.jrabstractbeandatasource.getfieldvalu

html - Android: How to show only one class from website in webview in android -

webviewclient yourwebclient = new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return false; } @override public void onpagefinished(webview view, string url) { webview.loadurl("javascript:document.getelementbyclassname('storytieup');"); } }; webview = (webview) findviewbyid( r.id.browser ); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setsupportzoom(true); webview.getsettings().setbuiltinzoomcontrols(true); webview.setwebviewclient(yourwebclient); webview.loadurl("http://stars.nhl.com/club/newsindex.htm"); this webviewclient code want display div contents class name 'storytieup', when run code shows whole website contents, need 1 div show in webview, use jsoup in portions here don't want use jsoup because of reasons, there solution display 1 div class name, in advance

See object changes in post_save in django rest framework -

i curious if there way see has changed on object after saving using django rest framework. have special behavior need check if field has been changed original value hoping handle using post_save on generics.retrieveupdatedestroyapiview . my first thought check using pre_save seems pre_save 's object argument has changes applied it. old answer django rest framework version 2.3.12: to check if has changed on update, have compare unchanged model instance self.object changed model instance serializer.object. the object argument passed pre_save method serializer.object not yet saved in database new changes. the unchanged model instance self.object has been fetched database using self.get_object_or_none(). compare obj argument in pre_save method. def pre_save(self,obj): unchanged_instance = self.object changed_instance = obj ..... # comparison code new answer django rest framework 3.3: pre_save , post_save no longer valid http://www.django-rest-f

Java Lambda Iteration List from JPA -

this question has answer here: why stream return no element? 1 answer i found strange behaviour when using lambda jpa, seems java 8 lambda don't iterate when list object. for example: list<myobject> list = anotherobject.getmyobjectlist(); // list list.foreach(myobject -> system.out.println("not printed")); system.out.println("size?: " + list.size()); // print size = 2 i try list.stream().foreach() same results.. after hours of testing found trick list<myobject> copylist = new arraylist<>(list); // copy list copylist.foreach(myobject -> system.out.println("omg printed!")); huh? ideas?, bug? or im doing wrong? entity clases working good, relations good... :) thanks in advance :). it know concrete class of list returned anotherobject.getmyobjectlist() . may have bug i

c# - Removing duplicates from datatable -

i'm trying remove duplicates in datatable similar this question . however, when need on ordered dataset, 1 of criteria time 1 of columns, , need earliest time instance remain. i came across question on ordered lists datatable , i'm not sure how combine two. basically, i'm reading file dataset, want sort on time , 3 other columns, , delete duplicates leaving earliest time instance. columns in question name (int), phone number (long), time (int) , location (string). if name, phone , location duplicated, remove after first (earliest) time. dsholdingset.tables["filedata"].columns.add("location", typeof(string)); dsholdingset.tables["filedata"].columns.add("name", typeof(int)); dsholdingset.tables["filedata"].columns.add("field", typeof(string)); dsholdingset.tables["filedata"].columns.add("time", typeof(int)); dsholdingset.tables["filedata"].columns.add("phone", typeof(

javascript - trigger colorbox resize on parsley validation -

ok using parsley.js validate , colorbox submit form via ajax the problem facing cannot figure out how resize colorbox dynamically when validation errors appear.i trigger function when pasreley loads in errors. $.colorbox.resize(); this form submit code looks like $("#form").submit(function(e) { if ( $(this).parsley('validate')) { var postdata = new formdata(this); var formurl = $(this).attr("action"); $.ajax({}); }; e.preventdefault(); }); try $.listen('parsley:field:error', function(){$.colorbox.resize();}) if wish handle error event. see official documentation know event want handle. http://parsleyjs.org/doc/index.html#psly-events-list

python - Administrating CQ5 via command line NOT using cURL or wget -

i'm trying write script administrating cq5 via command line not using curl or wget. when try upload package following error message: {"success":false,"msg":"package file parameter missing"} when using curl works fine. looked @ header , body curl sends , rebuilt both via python without success. curl doesn't seem send "file" parameter (or @ least didn't see it). what file missing? how provide missing file? i assume you're using ken reitz's excellent requests library http requests (if not, should be!) most likely, problem requests doesn't add 'content-type' header multi-part uploads, , packmgr doesn't read multi-part bodies no 'content-type' header. so, while normal 'requests' post of multipart-encoded file go this: url = 'http://localhost:4502/crx/packmgr/service/.json?cmd=upload' files = {'package': open('package.zip', 'rb')} r = requests

python - download file link produces 404 page -

i trying create link allows user download zip file that's been generated earlier in python script. script writes html link web page. user should able click link , download zip file. import os,sys downloadzip = ("http://<server>/folder/structure/here/" + zipfilename + ".zip") print """<h3><a href="{}" download>download zip file</a></h3>""".format(downloadzip) the result link when clicked opens 404 page. i've noticed on page, displays physical path c:\inetpub\wwwroot\inputted\path\here\file.zip i testing on same server processing occurring on. wouldn't think should make difference, here am. end result should zip file downloaded user's pc. not sure if helpful or not have noticed 'server package apps' disallow execution/download of filetypes. had similar thing happen years ago. to test if case, create new folder in web directory , add index.ht

c# - DataBind on CompositeControls -

i have composite control has dropdownlist inside. the problem have next one: when load data on page_load (the first time page loaded) works fine, when there postback , want refresh datasource (i mean, different one), datasource saved viewstate, not databinded dropdownlist. i found out happening because page lifecycle changes first time rendered second time: 1st time: page_load - createchildcontrols 2nd time: createchildcontrols - page_load - function_called_on_postback so problem databind in createchildcontrols() datasource setted on function_called_on_postback() , so, dropdownlist doesn't changes. do know how can fix this? have @ least advice? thanks lot! i'm assuming post being caused event on page such selected index changed on our ddl or click event button. if case, should able set data source of ddl in event handler method of event in question. for work correctly, have load data ddl in page_load method on initial load not on post backs. can

java - NullPointerException initializing variable with string length -

we told implement method detect if string palindrome iteration , recursion. successful in implementing method iteration getting error when try , recursively. exception in thread "main" java.lang.nullpointerexception @ recursion.recursivepallindrome.ispallindrome(recursivepallindrome.java:14) @ recursion.recursivepallindrome.main(recursivepallindrome.java:44) i'm clueless on has gone wrong. package recursion; public class recursivepalindrome { static string word; public recursivepalindrome(string a) { = word; } public static boolean ispalindrome() { int start = 0; int end = word.length()-1; //line 14 char = word.charat(start); char z = word.charat(end); character.tolowercase(a); character.tolowercase(z); if(start >= end) { if(character.isletter(a) && character.isletter(z)) { if(a == z) { a++; z--; } else

python - How to get the "result" from a contextmanager using 'with' -

i found demo of file locking class (here: https://groups.google.com/forum/#!topic/pug-pe/mqr7kx-cenu ), don't quite understand mechanics of using it. @contextmanager def filelock(lock_file): if os.path.exists(lock_file): print 'only 1 script can run @ once. '\ 'script locked %s' % lock_file sys.exit(-1) else: open(lock_file, 'w').write("1") try: yield finally: os.remove(lock_file) i believe says "if file passed in not exist, open it. when done, delete it. the demonstrated use is: with filelock('/tmp/my_script.lock'): print "i here , sleeping 10 sec..." time.sleep(10) and works correctly - if run script once see "i here , sleeping 10 sec...", , if run again within 10 seconds, see "only 1 script can run @ once. script locked /tmp/my_script.lock". however, use file lock, 1 typically want "wait unti

android - add radio buttons inside LinearLayout to a RadioGroup -

i have 4 radio buttons want group in radio group , display each 2 of them in row, used linearlayout radio buttons inside seem ignore inside radiogroup( wan select more 1 radio button). <radiogroup android:id="@+id/radiogroup1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignright="@+id/linearlayout1" android:layout_below="@+id/linearlayout1" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" > <radiobutton android:id="@+id/radio1" android:layout_width="wrap_content"

apache - Using .htaccess to make subdirectory act like subdomain -

it's little difficult me ask question correctly in title, here's i'm trying figure out. if use .htaccess on website , i'm trying create specific path "redirect" inside path uses it's non-redirected path it's relative path. sorry structure of sentence. so example... i have website as- http://www.example.com/ i want keep things organized create sub-folder/subdirectory keep these folders inside of. http://www.example.com/projects/ so folder projects place holder future projects , want create folder inside projects each project, can define url each 1 such... http://www.example.com/superfish/ http://www.example.com/aquafear/ now folder superfish , aquafear under http://www.example.com/projects/ in own folder say... http://www.example.com/projects/01/ http://www.example.com/projects/02/ now it'd fine , dandy keep links such, memory purposes , share other people links projects, i'd create nice simpler url custom "na

html - change height of right border -

Image
this question has answer here: border length smaller div width? 9 answers my right border 100% height: border-right:1px solid #000000; i'd make shorter: is achievable using css without changing height of div? need div 100% height , change border. you can use pseudo element replace right border. can choose size/position of can simulate border : fiddle html : <div></div> css : div { height:200px; width:500px; background:gold; position:relative; border-top:10px solid grey; border-bottom:2px solid #000; } div:after { content:""; position:absolute; top:20%; right:0; width:2px; height:60%; background:#000; } supports ie8 see caniuse

Make node.js app work on ubuntu server -

i've created simple node application, , works on local environment. the app listening port 8000 like: var app = express(); // ... codes in between ... app.listen(8000); and on local environment can access node app like: http://localhost:8000 however, when i'm trying make work on linode server (ubuntu 10.04), can't access node app with: http://mydomain.com:8000 i'm sure have node_modules in place, because when do node app.js it returns no error message , looks it's running. i'm thinking maybe it's because have apache2 setup http://mydomain.com , , should kind of proxy setup, or issue don't know @ all. clueless , can't find related documents on google... know there must lot of things don't understand in between... please me understand how deploy node.js app server. thank much it sounds may firewall issue. did ever follow linode guide on creating firewall ? if so, you'll need explicitly allow port 8000: -a i

python - How does auto-login Outlook successfully when in AD environment? -

when logon company's computer ad username/password, find outlook launch successfully. means ad authentication has passed. in opinion, outlook retrieves ad user information, sends ldap server verify. but don't know how retrieves information, or other methods? you right, there ongoing communication between workstation , active directory server, can use ldap protocol. since don't know tried far, suggest python module python-ldap . have used in past connect, query , modify information on active-directory servers.

jquery set selected attribute on an option using like -

how can set ubuntu selected following select box tried following below <select> <option value="val1">val 1</option> <option value="val2">val 2</option> <option value="val3">val 3</option> <option value="val3">ubuntu -12.04 amd......</option> </select> $('#image_id').find('option[text="ubuntu"]').attr('selected'); try, $('#image_id').find('option:contains("ubuntu -12.04")').prop('selected',true); working demo so per new request can like, $('#image_id').find('option:contains("ubuntu"):contains("-12.04")').prop('selected',true); working demo

spring - @Autowired(required=false) on constructor giving NoSuchBeanDefinitionException -

in spring application, have used @autowired(required=false) on constructor. means if bean autowired not available in xml file, no nosuchbeandefinitionexception should thrown ( required=false ) mentioned. getting unsatisfieddependencyexception , nosuchbeandefinitionexception exception. ---- texteditor public class texteditor { private spellchecker x; private string name; @autowired(required=false) public texteditor(spellchecker x) { system.out.println("inside texteditor constructor." ); this.x = x; } public spellchecker gety() { return x; } public void setname(string name) { this.name = name; } public string getname() { return name; } public void spellcheck() { x.checkspelling(); } } ---- spellchecker public class spellchecker { public spellchecker() { system.out.println("inside spellchecker constructor."); } public void c

c++ - I need a replacement for goto -

i have searched forums looking post can explain replacement goto on extremely basic level. reading book on cpp have been trying create project requires jumping around program. when ever use goto prints things weirdly, , when around on forums either advanced or not explained @ all. #include <iostream> int main() //this example of i'm trying not actual program { using namespace std; int a; cout << "pick 1 or two.\n"; cin >> a; if ( = 1 ) goto start1; if ( = 2 ) goto start2; start1: cout << "words\n"; start2: cout << "more words\n"; return 0; } it print: pick 1 or two. (pick 2) words more words i've tried using functions , same thing. if explain replacement or send me link that'd great. you can use switch way clearer solution: #include <iostream> using namespace std; int main() //this example of i'm trying not actual program

Reverse image search using Google api -

i trying write java program loop image files in folder and reverse image search on google (just trying 1 image in question) i find example below , result give me url preformed reverse image search. while wondering how can download 1 of image result site. some things add have read new google api(?) , find allow me search 100/day, hence choose use old version(?) although warn me method deprecated. import java.io.bufferedreader; import java.io.file; import java.io.ioexception; import java.io.inputstreamreader; import org.apache.http.httpresponse; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.entity.mime.multipartentity; import org.apache.http.entity.mime.content.filebody; import org.apache.http.entity.mime.content.stringbody; import org.apache.http.impl.client.defaulthttpclient; public class reverseimagesearch{ public static void main(string args[]){

delphi - Tclientsocket if socket can't connect -

i want sockets connects backuphost when socket can't connect host, tried this: if prclient.socket.connected = false begin prclient.active := false; prclient.port := port; prclient.host := host; prclient.active := true; prclient.open; sleep(500); if prclient.socket.connected = false begin prclient.active := false; prclient.host := backuphost; prclient.active := true; prclient.open; end; end; but doesn't connect @ all. knows working script? if using socket in blocking mode both active:=true , open() (which should not using together!) raise exception if connection fails: prclient.port := port; prclient.host := host; try prclient.open; except prclient.host := backuphost; prclient.open; end; if using socket in non-blocking mode, no exception raised (unless socket api function fails), conection attempted in background, , notified of final result via onconnect or onerror event depending on whether connection succeeds or fails, respectively.

Can't access static resources (.html) files in Apache Tomcat 7.0.52 -

even though found similar queries on topic can't find answer suitable problem. requirement follows - i have installed app (myapp) in webapps dir of apache tomcat ver 7 web server. dir structure / | |----api/ | |----web-inf/ | |----meta-inf/ i have static html files in "api" dir(say index.html) want access in following way through browser - http://localhost:8080/myapp/api/index.html however, can't access static resources (html files) in way. far know static outside web-inf can accessed directly through browser can't it. my web.xml looks - <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version

jquery - Remove CSS atribute from body::after -

this question has answer here: selecting , manipulating css pseudo-elements such ::before , ::after using jquery 18 answers i'm trying remove background-image attribute jquery had no success until now. '::after' don't let me remove-it. how can that? body::after { background-image: url(../images/16_sm.jpg); } try this, html: <body class='test'> css: .test::after{ background-image: url(../images/16_sm.jpg); } js: $('body').removeclass('test');

.net - Unable to update NuGet package "Microsoft ASP.NET MVC" from version 4.0.20710.0 to 5.1.2 -

Image
i have following out of date package in nuget: however, when click on update button, following error: error: updating 'microsoft.aspnet.mvc 4.0.20710.0' 'microsoft.aspnet.mvc 5.1.2' failed. unable find version of 'aspnetmvc' compatible 'microsoft.aspnet.mvc 5.1.2'. this happens on both projects use package: i'm running on .net 4.5 framework on both projects. there can upgrade package, or not compatible 4.5, or should using different nuget package now? as far can tell, upgrading 4.5.1 did not fix problem. in fact able fix while leaving target framework 4.5. here black magic performed seemed fix it. first, uninstall 3 old mvc libraries (as suggested in comment ), reinstall new ones, rebuild. @ least part in nuget manage packages ui, update failed in same place. @ point nuget happy, can compile, app not work. next, sure follow absolutely every step in upgrade asp.net 4 document referenced in other comment . when ac

linear regression - MATLAB Fitting Function -

i trying fit line data without using polyfit , polyval. got on how implement , have gotten work simple sin function. however, when applied function trying fit, not work. here code: clear clc lb=0.001; %lowerbound of data ub=10; %upperbound of data step=.1; %step-size through data a=.03; la=1482/120000; %1482 speed of sound in water , 120khz ep1=.02; ep2=.1; x=lb:step:ub; r_sq_des=0.90; %desired value of r^2 fit of data without noise present i=1; x=lb:step:ub g(i,1)= abs(sin((a/la)*pi*x*(sqrt(1+(1/x)^2)-1))); n(i,1)=2*rand()-1; ghat(i,1)=(1+ep1*n(i,1))*g(i,1)+ep2*n(i,1); r(i,1)=x; i=i+1; end x=r; y=g; v=[x.^0]; vfit=[x.^0]; i=1:1:1000 v = [x.^i v]; c = v \ y; vfit = [x.^i vfit]; yfit=vfit*c; plot(x,y,'o',x,yfit,'--') drawnow pause end the first 2 sections defining variables , function. second loop making fit. can see, have pause after every nth order in order see fit. as dennis m

objective c - MKPointAnnotation is overlaying my MKMapView -

this problem , i'm trying achieve http://i.stack.imgur.com/xpdqn.jpg this tried achieve goal http://i.stack.imgur.com/lf5hy.png and didupdatelocations delegate - (void)locationmanager:(cllocationmanager *)manager didupdatelocations:(nsarray *)locations{ cllocation* location=[locations lastobject]; mkpointannotation*annotation=[[mkpointannotation alloc]init]; annotation.coordinate=location.coordinate; annotation.title=@"me"; annotation.subtitle=@"current location"; mkcoordinateregion region; region.center=location.coordinate; if(mylocation!=nil){ [_mapasset removeannotation:mylocation]; mylocation=nil; } [_mapasset addannotation:annotation]; mylocation=annotation; [self zoomtofitmapannotations:_mapasset]; } as can see in screenshot, mkpointannotation overlaying mkmapview.i tried put mapview in uiview (to use container) didn't work. believe reason why happening beacuse i'm put

c# - Why 0.3 - (3 * 0.10) = 5.4411512312578E-17? -

this question has answer here: understanding floating point problems 4 answers i'm confused. code: console.writeline(mychanges + " ten method " + (ten_num * ten));(this debug) if ((mychanges - (ten_num * ten)) >= 0) { }else print error message like mychannges = 0.3 ; ten = 0.1; ten_num = 3, when print (mychanges - (ten_num * ten)) equals 5.4411512312578e-17 why not 0? solutions? this due rounding errors inherent floating point operations. see http://docs.oracle.com/cd/e19957-01/806-3568/ncg_goldberg.html details.

jquery - On Button Click Send Javascript Array To Rails Controller Via Ajax Request -

thanks in advance, 1 has stumped me few days. i have view in rails app randomize word in spanish while presenting same word in english. example: dog oprer the user able toggle letters of spanish word , forth 'create' correct word, in above example 'perro'. user clicks button submit answer , javascript correctly alerts array 'perro' or whatever user has generated. goal pass javascript array (sortedids in below code) rails 'lang' controller after user clicks next button. ajax code below doesn't seem because when try access array in controller using single line of code below, nil error: data = params[:order].split(',') my javascript code looks this: $(function() { $(" #sortable ").sortable({axis: "x", containment: "window"}); $( ".clicked" ).click( function() { var sortedids = $( "#sortable" ).sortable( "toarray", {attribute: 'custom-cl'} );