Posts

Showing posts from June, 2011

wpf - Why are my TreeViewItems acting like RadioButtons? -

i have wpf treeview i've implemented small model class behind scenes. bind list of them treeview's itemssource when creating control. (i've pared code here down bit sake of simplicity, should reproducable.) public class treeviewitemmodel { public observablecollection<treeviewitemmodel> children { get; set; } public string name { get; set; } public bool isselected { get; set; } public treeviewitemmodel() { children = new observablecollection<treeviewitemmodel>(); isselected = false; } } public partial class mainwindow : window { public observablecollection<treeviewitemmodel> mytree { get; set; } public mainwindow() { initializecomponent(); // add dummy values list<treeviewitemmodel> items = new list<treeviewitemmodel>(); (int = 0; < 10; i++) items.add(new treeviewitemmodel() { name = ("node" + i) }); mytree = new observablecoll

html - CSS Bottom Positioning -

so, have this: .cmon { background-repeat: repeat-x; background-image: url("line2.png"); position:absolute; bottom:0px; } what should do, put image (line in case) on bottom of page, understand, , repeat it. put on bottom, doesn't repeat, knows what's problem? how looks when code on: http://goolag.pw/temptest.html also, in menu (top right corner) image doesn't show up, nor on bottom. more happy if knows whats problem. (sorry if links not allowed here, there no commercials on web, it's show what's problem) to position background images should use background-position property : .cmon { background-repeat: repeat-x; background-image: url("line2.png"); background-position: bottom; } the background-position css property sets initial position, relative background position layer defined background-origin each defined background image. you'll need ensure element has height , width , however, ba

javascript - HTML how to target a link in a iframe to another iframe -

working code assuming have page 2 different iframe first menu , second container of selected page. how can @ click of link in menu frame display selected page iframe container? in menu page have ... </li> <li class="title"><a href='javascript:parent.document.getelementbyid("frame").src = "pages/setting.php"'><?php echo $lang['menu_impostazioni']; ?></a> <img src="images/bullet_arrow_down.png" /></li> <li class="sub-menu"> <ul> ... in index this: ... <iframe id="menufrm" src="menu.php" width="250px" height="700px" frameborder="none"></iframe> <iframe name="frame" src="" width="99%" height="99%" frameborder="none"></iframe> ... but this, when click in button in menu page displayed correctly in

php - functions and if statements -

does know how echo rconresults , if not rconresults call rconresults1 or rconresults2? 1 works @ moment echo rconresults(); function @ bottom, new :p <?php define('include_check',true); include("../classes/functions2.php"); include("../classes/functions.php"); require '../classes/q3status.php'; require '../classes/q3rcon.php'; include("rconform.php"); include("rconresults.php"); include("rconresults1.php"); include("rconresults2.php"); $theme = $_cookie['currenttheme'];?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <?php echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../

c# - ASP.NET Session & Master Page -

i have created masterpage.aspx , other pages .i want if user click on mainpage anywhere on link or button without login must redirect login.aspx . how can create session ?.i need idea weather code in masterpage.cs page_load method or elsewhere ?. masterpage.aspx { //code here } login.aspx { //code here } use condition on master page: if (session["loggedusername"] == null && !request.path.endswith("login.aspx")) { response.redirect("~/your/path/login.aspx"); } you can use: membershipprovider this can see here: check session variable , redirect login page before page load

oracle11g - Oracle 11g XE installation not working. "Create CONTROLFILE failed" -

i installed oracle 11g xe on windows computer (running on windows xp pro), unfortunately, can't work. there no errors gui installer shows during installation , "installed successfully" message, when try connect oracle using sql command prompt, following error: sql> connect enter user-name: system enter password: error: ora-01033: oracle initialization or shutdown in progress process id: 0 session id: 0 serial number: 0 the 'get started' shortcut icon takes me : http://127.0.0.1:8080/apex/f?p=4950 which gives me "unable connect" message after having spent 2 days doing research on this, found out apart being listener issue, 'oradata\xe' folder located at: e:\oraclexe\app\oracle\oradata\xe empty . think should have contained control files etc. there errors related creation of control files etc. reported in log files located @ : e:\oraclexe\app\oracle\product\11.2.0\server\config\log , pasting them here -> clonedbcreation.l

Extract text between link tags in python using BeautifulSoup -

i have html code this: <h2 class="title"><a href="http://www.gurletins.com">my homepage</a></h2> <h2 class="title"><a href="http://www.gurletins.com/sections">sections</a></h2> i need extract texts (link descriptions) between 'a' tags. need array store these like: a[0] = "my homepage" a[1] = "sections" i need in python using beautifulsoup. please me, thank you! you can this: import beautifulsoup html = """ <html><head></head> <body> <h2 class='title'><a href='http://www.gurletins.com'>my homepage</a></h2> <h2 class='title'><a href='http://www.gurletins.com/sections'>sections</a></h2> </body> </html> """ soup = beautifulsoup.beautifulsoup(html) print [elm.a.text elm in soup.findall('h2', {

vbscript - SEND clip as keystrokes -

i wondering if there way in manner of psh or vbs paste/send text clipboard separate keystrokes rather string???? it important, since have automatic search in web ui drop down lists , passing text ctrl+v not work. need send each letter unique keystrokes. tried find way , searched on internet no luck. thank in advance there few ways interact clipboard in vbscript. here's 1 way read clipboard text: strtext = createobject("htmlfile").parentwindow.clipboarddata.getdata("text") once have text, send each letter in sequence: for = 1 len(strtext) sendkeys mid(strtext, i, 1) next

installation - Appcelerator Module titanium.py -

i'm new mac user , don't anderstand way create titanium.py http://docs.appcelerator.com/titanium/3.0/#!/guide/legacy_command-line_interface-section-29004835_legacycommand-lineinterface-osx how can create bash_profil, , must set links ? alias titanium.py="/library/application\ support/titanium/mobilesdk/osx//titanium.py" alias ios_builder="/library/application\ support/titanium/mobilesdk/osx//iphone/builder.py" can teach me step step :/ ? thx ! the problem in module configuration path titanium.py have add $home before /library , works...

asp.net web api - Umbraco 7 GetDictionaryItem in WebAPI return empty string -

i have umbraco 7.1.1 site. have webapi method returns string. string constructed template. issue having when in webapi getdictionaryitem nothing back. key , value definately exist becuase if getdictionaryitem in template works. in web.config have added: <globalization requestencoding="utf-8" responseencoding="utf-8" fileencoding="utf-8" culture="ru-ru" uiculture="ru-ru"/> but dictionaryitem still return empty string. how make works? regards, anton the umbraco dictionary items read language set in content section of cms. first have add language need (ru) in settings, apply language on node in content section. setting language on page/node tell umbraco umbraco should rendering template in russian.

graph - Select objects within an area using d3 -

Image
i creating tool displays graphs , want perform statistical analysis on select set of nodes in each graph. is there way detect nodes contained red area (see image) using d3.js. understand use coordinates rectangle draw implement more arbitary shapes.

ios - Text in search bar disappears when search button on keyboard is clicked in iPhone -

after typing text in search bar of iphone, when search button clicked on keyboard, text disappears. i've added <uisearchdisplaydelegate, uisearchbardelegate> , bool issearching; - (void)searchbartextdidbeginediting:(uisearchbar *)searchbar { issearching = yes; } - (void)searchbar:(uisearchbar *)searchbar textdidchange:(nsstring *)searchtext { nslog(@"text change - %d",issearching); nsstring *str = searchbar.text; self.searchdisplaycontroller.searchbar.text = str; //remove objects first. [filteredarray removeallobjects]; if([searchtext length] != 0) { issearching = yes; [self searchtablelist]; } else { issearching = no; } [self.tableview1 reloaddata]; } - (void)searchbarcancelbuttonclicked:(uisearchbar *)searchbar { nslog(@"cancel clicked"); } - (void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar { [self searchtablelist]; [searchbar resignfirstrespond

Mink+Behat: missing session -

i trying follow http://docs.behat.org/cookbook/behat_and_mink.html tutorial i installed mink+behat using following composer.json: "require": { "behat/behat": "2.4.*@stable", "behat/mink": "1.4.*@stable", "behat/mink-extension": "*", "behat/mink-goutte-driver": "*", "behat/mink-selenium2-driver": "*" }, "minimum-stability": "dev", "config": { "bin-dir": "bin/" } } i did init created features directory. bin/behat --init i created search.features in features directory: feature: search in order see word definition website user need able search word scenario: searching page exist given on "/wiki/main_page" when fill in "search" "behavior driven development" , press "searchbutton" should

bayesian - Weka machine learning - Interpeting naive bayes -

i got training dataset of ill horses, data contains surgeries , diseases. of fields of registers like: temperature of horse, age, pulse, respiratory rate etc .... what want clasificator on live/dead/euthanized column of every row. asked check is: think hypothesis of independence of variables check if got enought number of elements obtain reliable probabilities the dataset had 25% of missing values , them imputated using mimmi imputation. thinking possibility of getting reliable probabilities, can see training dataset little unbalanced: 179 horses live , 121 die (dead + euthanized). im not sure of that. 2 questions helpful me. === run information === scheme:weka.classifiers.bayes.naivebayes relation: horsecolic-weka.filters.unsupervised.attribute.remove-r25-27 instances: 300 attributes: 24 surgery age id temp pulse resprate tempextrem peripulse

ruby - Adding readline to sqlite3 -

i tried create script add readline abilities sqlite3 commands history , moving cursor. came far: #!/usr/bin/env ruby require 'pty' require 'expect' require 'readline' pty.spawn("sqlite3") |reader, writer, pid| reader.expect("sqlite> ") writer.puts(readline.readline("sqlite> ", true)) end but have no idea how print output of command entered. appreciate on this. thanks! i had play after finding this tutorial . require 'pty' require 'expect' require 'readline' pty.spawn("sqlite3") |reader, writer, pid| cmd = readline.readline("prompt> ", true); reader.expect(/^sqlite\>/) { |r| writer.printf("%s\n",cmd) } puts reader.expect(/^sqlite\>/)[0] end so in nutshell, example, need add this: puts reader.expect("sqlite> ")[0] playing bit more added little loop asks commands, sends them sqllite3 , sends result: requir

c++ - Where and why do I have to put the "template" and "typename" keywords? -

in templates, , why have put typename , template on dependent names? dependent names anyway? have following code: template <typename t, typename tail> // tail unionnode too. struct unionnode : public tail { // ... template<typename u> struct inunion { // q: add typename/template here? typedef tail::inunion<u> dummy; }; template< > struct inunion<t> { }; }; template <typename t> // last node tn. struct unionnode<t, void> { // ... template<typename u> struct inunion { char fail[ -2 + (sizeof(u)%2) ]; // cannot instantiated u }; template< > struct inunion<t> { }; }; the problem have in typedef tail::inunion<u> dummy line. i'm inunion dependent name, , vc++ quite right in choking on it. know should able add template somewhere tell compiler inunion template-id. exactly? , should assume inunion class template, i.e. inunion<u> names type ,

php - cant save multiple tables in cakephp -

i learning cakephp , have made quite bit already. reason asking question docs in cakephp wrong. cant see docs or past stackoverflow posts on issue why (child)teacher table doesnt save user_id id table in (parent)user table. no error user_id 0 in teacher table isnt picking user table. have one-one relationship on 2 models. testing saving on 2 models have user , teacher. enter data in form , create new user , new teacher user_id being foreign key in teacher table. loathe ask question there lot of material on cant see issue after following docs in cakephp. http://book.cakephp.org/2.0/en/models/saving-your-data.html public function addteacher() { if ($this->request->is('post')) { $this->user->create(); } if (!empty($this->request->data)) { // can save user data: // should in $this->request->data['user'] $user = $this->user->save($this->request->data); // if use

C redirect stdin to keyboard -

i have written smallish c program on mac osx following steps: reads input stdin , stores input memory. runs computations , prints output stdio in between steps 1 , 2, want prompt user , wait kind of keyboard input signal "keep proceeding step 2". problem stdin has been redirected when program called using command: $ ./simple < input.in i redirect stdin keyboard after reading file , not sure how this. have tried using fclose(stdin); freopen("newin", "r", stdin); but stdin fails read keyboard thereafter. suggestions on how appreciated. some further points: the real program more involved simple still illustrates question. the reason i'd pause program during execution have enough time load "simple" process osx app called instruments performance analysis. if helps, more example code provided below. int main(void) { // step 1 int array[arrlen]; readinput(array, arrlen); // wait keyboard input pro

html - CSS position absolute content area not growing -

Image
i trying create html of design. stuck 1 issue. css n html structure image have attached here. want footer in bottom of page content area when grows should push footer down. if there no content content area should till footer. content area coming on header , footer area. don't know if structured right. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style> html, body { height:100%;} body { background: #ebebeb; margin: 0px; padding: 0px; } #wrapper { width:100%; height:100%; margin: 0 auto; position:relative; } #header { width:100%; height:147px; background:#999; border-bottom:solid 5px #ddd; position:absolute; } #footer { bottom:0; width:100%; height:170px; position:absolute; background-color:#ccc; border-top:solid 5px #ddd; } #contentarea { width:300px; max-height:100%; position:absolute; z-index:999; left:0; right:0; top:0; bottom:

javascript - Trying to validate a form client and server side -

the client side validation looks this: function validatefname() { var x = document.getelementbyid('fname').value; if (x==null || x=="") { alert("first name must filled out"); return false; } } the server side below it: if(isset($_post['submitform'])){ if(empty($_post['fname'])){ echo "first name cannot empty!<br/><br/>"; return false; } and form below that: <form name = 'checkout' method='post' action="<?php echo $_server['php_self']; ?>" accept-charset='utf-8'> first name:<input type="text" name="fname" id="fname" onsubmit="return validatefname()" class="required" value="<?php echo $fname;?>" /> <input type="submit" name="submitform" value="send"/> ofcourse there lot more ive given 1 example above. trying figure

javascript - Why validation for password field validation not working? -

i'm new web programming can please tell me what's wrong following code? <!doctype html> <html> <head> <title>form validation</title> <script type="text/javascript"> function validate (form) { // valriable declaration var returnvalue = true; var username = form.txtusername.value; var password1 = form.txtpassword.value; var password2 = form.txtpassword2.value; // check username length if (username.length < 6) { returnvalue = false; alert("your username must @ least\n6 characters long.\nplease try again."); frmregister.txtusername.focus(); }; // check password length if (password1.length < 6) { returnvalue = false; alert("your password must @ least\n6 characters long.\nplease try again."); frmregister.txtpassword.value = ""; frmregister.txtpassword2.value = ""; frmregister.txtpassword.focus(); }; // check ma

Javascript in Wordpress: "Uncaught SyntaxError: Unexpected token <" -

i trying call function part of external javascript file. following error in line 1 of .js file. "uncaught syntaxerror: unexpected token < " i following error: "uncaught referenceerror: drawcolchart not defined". drawcolchart name of function calling. i calling drawcolchart function in functions.php file of wordpress. related code appended below: <script type="text/javascript" language="javascript"> drawcolchart('inc_exp_chart'); </script> the javascript file follows: <script type="text/javascript" src="https://www.google.com/jsapi"></script> google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawcolchart); function drawcolchart(divi) { var data = google.visualization.arraytodatatable([ ['year', 'sales', 'expenses'], ['2004', 1000, 400],

python - Is it really possible to use a different convention to lay out source directory without breaking intra-package references? -

suppose working on python package. here structure of package (expressed in terms of hierarchical file system): /packagename /src __init__.py /subpackage1 __init__.py module1a.py module1b.py /subpackage2 __init__.py module2a.py module2b.py /tests install license readme setup.py distutils used build, distribute , install package. in setup script possible tell distutils convention lay out source directory (see here ). in short put: package_dir = {'packagename', 'src'} however there issue when example module1a needs import module2a absolute import (see here ). in short put in module1a : import src.module2a once package distributed , installed pip simple: import packagename raises: importerror: no module names src.module2a a simple solution rename src directory packagename (as question states) there solution use different conven

c - Thread synchronizing with mutex -

i have 2 threads. first 1 should write: 1 2 3 4 5 6 7 8 9 second 1 should write: am 1 2 3 4 5 6 7 8 9 this code: #include <pthread.h> #include <stdio.h> #include <stdlib.h> pthread_mutex_t mutex; int firstcounter = 0; int secondcounter = 0; void *writeloop(void *arg) { while(firstcounter < 10) { pthread_mutex_lock(&mutex); firstcounter++; printf("%d\n", firstcounter); pthread_mutex_unlock(&mutex); } exit(0); } void *readloop(void *arg) { while(secondcounter < 10) { pthread_mutex_lock(&mutex); secondcounter++; printf("am %d\n", secondcounter); pthread_mutex_unlock(&mutex); } exit(0); } int main(void) { pthread_t tid, fid; pthread_mutex_init(&mutex, null); pthread_create(&tid, null, writeloop, null); pthread_create(&fid, null, readloop, null); pthread_join(tid, null); pthread_join(fid, nu

ruby on rails - Why does before_action :authorize fail with 'wrong number of arguments'? -

i have set pundit devise authorization on application. in 1 of controllers, have before_action :authorize . i have following test: describe somecontroller before(:each) login_user(factorygirl.create(:user, :user_type => :admin)) end describe "get index" "it retrieves index" = factorygirl.create(:something) :index assigns(:something).should eq([something]) end end end i receive error: wrong number of arguments (0 1) the login helper straight forward: module controllermacros def login_user(user) if user.nil? user = factorygirl.create(:user) end @request.env["devise.mapping"] = devise.mappings[:user] sign_in user end end update: stacktrace: failure/error: :index argumenterror: wrong number of arguments (0 1..2) # /users/me/.rvm/gems/ruby-2.0.0-p247/gems/pundit-0.2.3/lib/pundit.rb:62:in `authorize' # /users/me/.rvm/gems/ruby-2.0.0-p247/gems/activ

Save xml file in c# -

i have program take in name , score, compare score scoreboard located in xml file, , sort fro highest lowest score. works until shutdown program , restarts it, looks has not saved changes xml file. this xml file: <?xml version="1.0" encoding="utf-8" ?> <highscore> <data> <score number="1" value="250" name="per"/> <score number="2" value="200" name="ole"/> <score number="3" value="100" name="gunnar"/> <score number="4" value="50" name="lars"/> <score number="5" value="25" name="bob"/> </data> </highscore> and code in program: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.wind