Posts

Showing posts from February, 2011

html - duplicating github's topbar behavior with a bootstrap navbar? -

Image
github's bar @ top i'm attempting duplicate using bootstraps navbar class ( https://github.com/ ). notice how bar extends fill entire browser window, while core elements stay in place in fixed column? that's i'm attempting figure out. i have following code. <body> <div class="container"> <div class="row"> <div class="span12"> <img src="/img/logo_sml.png"> </div> </div> </div> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#">home</a> </div> </div> my thinking was, if close main container , place navbar , have fill entire length of browser. worked planned, when add things navbar appear way on left side of page (as expected). so! thought start new container put menu items, having appear in central column should.

c# - Converting windows sockets to .NET -

i have pretty simple sockets connection seems work under winsock 2.0 not @ under .net. thing know 1 works , other not @ all, i'm not sure how debug it. windows sockets version: int_ptr callback connectdialogproc (hwnd hwnddlg, uint umsg, wparam wparam, lparam lparam) { socket connectme; int status, cremoteaddr; lresult itemdata; sockaddr_in sockaddr, remoteaddr; cerdispinfo info; bool freuseaddr = true; switch (umsg) { case wm_initdialog : memset (&sockaddr, 0, sizeof(sockaddr)); sockaddr.sin_family = af_inet; sockaddr.sin_port = htons(987); sockaddr.sin_addr.s_un.s_addr = htonl(inaddr_any); connectme = socket (af_inet, sock_dgram, 0); setsockopt (connectme, sol_socket, so_reuseaddr, (char *)&freuseaddr, sizeof(freuseaddr)); bind (connectme, (sockaddr *)&sockaddr, sizeof(sockaddr)); wsaasyncselect (connectme, hwnddlg, wm_connect_me, fd_read); setwindowlong (

html - Making background-image page specfic -

i'm using squarespace platform website, , trying change background image of homepage, after searching forums , viewing source code of website told id #collection-51648018e4b0d7daf0a7cece work alter homepage, when code #collection-51648018e4b0d7daf0a7cece { background-image: url('image-location.png'); } is added nothing happens, using code #navigator { background-image: url('image-location.png'); } it change, applies of pages. know work-around this? i've submitted ticket squarespace no @ all. also, please realize cannot alter actual code of website because squarespace. can add custom css or inject code < head> tags thanks! make #navigator selector specific homepage: #collection-51648018e4b0d7daf0a7cece #navigator { background-image: url('image-location.png'); } edit: based on code, want this: #collection-51648018e4b0d7daf0a7cece #navigator { background: #fff url('image-location.png') scroll no-repeat

regex - Regular Expression capturing records PHP 2 -

i'm trying result below, can not, give me idea? my cod.: $string ='zamm et est hac pid pid sit amet, lacus nisi zppp scelerisque sagittis montes, porttitor ut arcu zamm tincidunt cursus eu amet nunc zamm c ac nunc, et pid pellentesque amet, zsss m urna scelerisque in vut'; if(preg_match_all("/zamm.*/", $string, $matches)) { foreach($matches[0] $match){ echo $match; echo "<br />"; } } expected result: 1: zamm et est hac pid pid sit amet, lacus nisi zppp scelerisque sagittis montes, porttitor ut arcu zamm tincidunt cursus eu amet nunc zamm c ac nunc, et pid pellentesque amet, zsss m urna scelerisque in vut 2: zamm tincidunt cursus eu amet nunc zamm c ac nunc, et pid pellentesque amet, zsss m urna scelerisque in vut 3: zamm c ac nunc, et pid pellentesque amet, zsss m urna sceleri

Haskell type of specific data constructor -

suppose have following haskell code: data option = | opt1 int double string -- more options here in real case handleoption :: option -> io () handleoption option = case option of -> handlehelp opt1 n f s -> handleopt1 n f s handlehelp :: io () handlehelp = print "help" handleopt1 :: int -> double -> string -> io () handleopt1 n f s = print (n, f, s) in above code, seems me waste deconstruct object ahead of time in sense keep data bundled neatly together. have pass each part of opt1 individually or create single separate data type haul them along. possible pass in entire opt1 handleopt1 while not allowing general option instance being passed in, such making handleopt1 help compile error? example pseudo code below: data option = | opt1 int double string handleoption :: option -> io () handleoption option = case option of -> handlehelp opt1 @ opt1{} -> handleopt1 opt1 handlehelp :: io () handle

css - how to link wp tamplate to different stylesheet -

i trying have own stylesheet linked custom page inside theme on wordpress. im using code on header.php /my-own-styles.css" /> there 2 changes in code made: 'my-template.php' , 'my-own-styles.css' nothing other that. (do need change 'template_directory' too?) inside theme directory have 'my-own-styles.css' doesn't seem it. also need .js file have put in same directory wouldnt work.. please help! in wordpress, need hook javascript , css includes onto wp_enqueue_scripts action, , tell wordpress load them using wp_enqueue_style , wp_enqueue_script functions. in functions.php file, or other file loaded prior template file (say plugin example), add this: add_action('wp_enqueue_scripts' , 'enqueue_my_scripts_and_styles'); function enqueue_my_scripts_and_styles() { wp_register_style('my-own-styles.css',home_url('/').'wp-content/themes/**yourthemename**/my-own-style.css');

java - Checking Network Connectivity before dismissing Alert Dialog - RESOLVED -

so have webview based app. question when onreceivederror called when there internet loss, i'd when user clicks "ok" on dialog check connectivity, if connectivity available dismiss alert , call web.reload(); if there isn't web connectivity (wifi or mobile) call finish(); resolved following: changed alert dialog postive button following .setpositivebutton(r.string.alert_dialog_ok,new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog,int id) { the issue following dialoginterface paramdialoginterface,int paramint) context context; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.context = this; ... @override public void onreceivederror(webview view, int errorcode, string description, string failingurl) { alertdialog.builder localbuilder2 = new alertdialog.builder( webview_main.this); localbuilder2.settitle(r.str

c# - How to programmatically set a custom icon on an Outlook search folder? (i.e. Outlook Folder SetCustomIcon) -

i attempting use folder.setcustomicon() method place custom icon on saved search folder programmatically created. setcustomicon() documentation sparse can found here reference . also, object expects here , again examples sparse. would know how set custom icon folder? following code have far: searchfolders = inboxfolder.store.getsearchfolders(); foreach (outlook.folder folder in searchfolders) { if (folder.name == "expiring retention policy mail") { folder.showitemcount = microsoft.office.interop.outlook.olshowitemcount.olshowtotalitemcount; folder.setcustomicon(new bitmap(32, 32)); // <=-- isn't working because it's expecting stdpicture has sparse information on how convert type. globals.thisaddin.application.activeexplorer().currentfolder = folder; } } you need use picturedispconverter go image/icon ipicturedisp . below example msdn . works in outlook 2010+ . view custom folder icons in outlook 2013,

javascript - :visible length returning 0 when item is visible -

i have if statement check if div has nothing visible under it, , if so, hide siblings of child element. var $remainingprojects = $searchproject.show().filter(function () { var text = $(this).text().replace(/\s+/g, ' ').tolowercase(); return !~text.indexof(val); }).parents('.srcprojects'); var $remainingprojectscontainer = $remainingprojects.parents('.projectscontainer'); $remainingprojects.hide(); $remainingprojectscontainer.each(function() { if($(this).children('.srcprojects:visible').length == 0){//this line console.log($(this).children('.projectschildren').html()); $(this).children('.projectschildren').hide(); $(this).children('.projectschildren').siblings('.destarrow').hide(); $(this).children('.projectschildren').siblings('.destproject').hide();

c# - How do I bind a datatrigger in xaml to a code-defined dependency property? -

my code behind window defines dependency property, "active"... public partial class mainwindow : window { public mainwindow() { initializecomponent(); } public bool active { { return (bool) getvalue(activeproperty); } set { setvalue(activeproperty, value); } } public static readonly dependencyproperty activeproperty = dependencyproperty.register("active", typeof(bool), typeof(mainwindow), new uipropertymetadata(false)); } and bind property using 2 checkboxes in xaml. want change fill of rectangle based on property. how can make work? <window x:class="wpftest.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" datacontext="{binding relativesource={relativesource self}}"> <stackpane

javascript - How to load another domain content inside a div? -

i have <div id="content"> . want load content http://vietduc24h.com div : <html> <head> <script type="text/javascript"> $(document).ready(function() { $("#content").attr("src","http://vietduc24h.com"); }) </script> </head> <body> <div id="content"></div> </body> </html i don't want use iframe. how can this? you need think cors in aspect. code need have is: <script type="text/javascript"> $(document).ready(function() { $("#content").load("http://vietduc24h.com"); }) </script> when domain not inside vietduc24h.com , might security exception. in order avoid that, can host local proxy here. in php, way ( url.php ): <?php $url = file_get_contents(urlencode($_get["url"])); echo $url; ?> and in script, need modify way: <script

Can Authority Ruby Gem be used with logged out users? -

i following error: undefined method `can_read?' nil:nilclass ..when trying access product page logged-out user. @ moment have class productauthorizer < applicationauthorizer def self.readable_by?(user) true end end i'd allow non-logged in users see page. possible? i tried changing default user method to: config.user_method = :current_user ||= user.new however, causes problems, , server won't start. ok found @ https://github.com/nathanl/authority/pull/32 : ok! sake of else reading issue, chris , chatted , agreed best way proceed. here's gist of it. authority won't specially handle nil users or give specific option so. want limit authority authorization , keep authentication totally separate. if there's no user signed in, that's authentication concern; authority can't meaningfully answer question "can user x?" if isn't given user or quacks one. besides philosophical poin

c - sscanf returns 1 when searching for float in a string starting with the character n or i -

in following code expect sscanf return 0, returns 1 , assigns 0.000000 float variable x. same behavior occurs when string begins letter i, no other letter. void main() { int ss_return; float x; char str_to_sscanf[] = "noduh"; ss_return = sscanf( str_to_sscanf, "%f", &x ); printf( "\n\nthe word passed sscanf %s", str_to_sscanf ); printf( "\n\nwhen looking float, sscanf returned %d", ss_return ); printf( "\n\nand assigned %f x (declared float)", x ); printf( "\n\nwhy did sscanf not return zero????" ); } the output of program is: "two weird looking characters"duh what missing? my guess library's state machine seeing "n" possible start of "nan" , "i" possible start of "inf" letting fall float conversion code. bails out because can't finish parsing , assigns default value.

Magento can't save new products anymore -

everything fine 'til morning. i've tried clearing cache, re indexing, tips find on internet. here message i'm getting fatal error: call member function getid() on non-object in /home5/rockbott/public_html/app/code/core/mage/adminhtml/controllers/catalog/productcontroller.php on line 578 here line 577 , 578: if (mage::app()->issinglestoremode()) { $product->setwebsiteids(array(mage::app()->getstore(true)->getwebsite()->getid())); a newly created product gives me fatal error message. duplicated product gives me same, when go manage products appears, without sku# , 0 stock count. when try edit product again - fatal error. please me problem. thanks in advance. thanks response. suggested clear log file , did. i'm sorry don't have log file. compiler disabled well. kind enough take here: http://www.magentocommerce.com/boards/viewthread/347764/ i've posted more information there including reports. thank anna i realize

Python: C for loop with two variables -

i'm new python. there similar way write c loop 2 variables in python? for (i = 0, j = 20; != j; i++, j--) { ... } python 2.x from itertools import izip, count i, j in izip(count(0, 1), count(20, -1)): if == j: break # stuff python 3.x: from itertools import count i, j in zip(count(0, 1), count(20, -1)): if == j: break # stuff this uses itertools.count() , iterator iterates starting point indefinitely: itertools.count(start=0, step=1) make iterator returns evenly spaced values starting n . used argument imap() generate consecutive data points. also, used izip() add sequence numbers. in python 2.x have use izip because py2k zip tries create list of results, opposed izip returns iterator on results obtained. unfortunately dealing infinite iterators here zip won't work... point why zip has been changed perform role of izip in py3k ( izip no longer exists there). if crazy being functional (but looks ugly in opinion si

php load up a .php page and replace variable, and then store the output -

i load different .php page (the .php contain html , php variable need replaced. for example: load.php $output = ''; load test.php , replace $this->name value. store html $output load test1.php , replace $this->name value. append previous $output variable so @ end have $output variable have updated html any suggestion appreciated. test.php > <html> <?php echo $this->name; ?> </html> test1.php > <html> <?php echo $this->address; ?> </html> you want use output buffering require or include statement: ob_start(); require('load.php'); $output = ob_get_contents(); ob_end_clean(); $output should contain contents of load.php variables processed. to process multiple files (or else) run between ob_start() , last 2 lines, grab 2 files so: ob_start(); require('test.php'); require('test1.php'); $output = ob_get_contents(); ob_end_clean();

ruby on rails - Migration for Users Following Posts -

in application, have models users , projects. i want users have ability follow many projects. users has_many projects, , projects belongs_to users not created them users follow them too. so generated migration called projectrelationship , tried make flow below, doesn't seem work. can me fix associations? thanks help! project_relationship.rb class projectrelationship < activerecord::base belongs_to :user belongs_to :project end project.rb belongs_to :user has_many :project_relationships has_many :followers, through: :project_relationships, source: :user user.rb has_many :projects has_many :project_relationships has_many :projects_followed, through: :project_relationships, source: :project schema.rb create_table "project_relationships", :force => true |t| t.integer "follower_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "projectuser

php - How to perform MySQL 'SUM' but to '0' decimal places? -

i have mysql table containing account balances, stored floats, 2 decimal places, in varbinary column type (because values aes_encrypted). i realise it's not ideal storing values floats , in later tables no longer are, can't legacy table yet, need work is. i'm trying compute sum of balances, able code below: $s=$dbh->prepare(" select sum(aes_decrypt(a.acct_balance, '".dbkey."')) tbal accounts inner join coa c on a.acc_id = c.acc_id c.acc_type_id = ? , a.acc_type = 1 "); however, reports display balances individually 0 decimal spaces , if add up, different result above query computed using values 2 decimal places, after converting result 0 decimal places. i think need inform mysql temporarily convert each value 0 decimal spaces before adding running total, how that? the values i'm displaying in report converted using: $val = number_format($val, 0, &#

str_replace (or another option) for replacing content located inside a php document -

i'm attempting make template file cms i'm making template file can contain variables {username} regular text replaced when page gets included on index.php page. example: index page: <?php include('templates/123/index.php'); ?> templates/123/index.php page <?php include('header.php'); ?> welcome {username} <?php include('footer.php'); ?> i've tried several methods; however, run problems because page i'm trying change content on includes php code. every method try either 1) messes because opening , closing of php tags within document or 2) echoes out php code in document. there way can still achieve this? maybe class of kind? want able achieve safely. i using custom variables {content1} replaces php code ioncubed retrieves data database content located in column1, same {column2} {column3} , {column4}. i'm trying make creation of templates extremely easy. (so i'd make code work well) my prefe

I want to correct PHP encoding problems on PHPLIST for SHIFT-JIS and UTF-8 foreign fonts -

i have phplist on server jammed encoding japanese fonts . i installed foreign language pack, still cannot encode shift-jis , utf-8 . how correct php' s encoding in files encoding definition lines correct encoding in each page php makes? i think problem script of program not define encoding each page, since encoding correction of version program . 2 possible source of problems: php script , database @ (if any). by sending approiate header before content has been sent client (simply speaking, headers must sent @ beginning of code possible), encoding "defined" by <?php header('content-type: text/html; charset=utf-8');?> edit! esailija gave review , correction (see comments below) on answer not correct question. suggested esailija, should check transmission encoding instead on storage encoding itself. my original answer kept here "hall of shame". note if using dbms mysql, encoding in database should set ( utf8_gen

Cakephp form validation using plugin -

i using jquery in cakephp forms. want add validation using way have added plugin. putting required on selected input element automatic validates it. no matter if add plugin or not. have included js helper.. public $helpers = array('html', 'form', 'js'=>'jquery', 'text'); like this. want stop traditional way follows auto validation. , put validation according requirement. know cakephp 1.x version follows same way want. changes have been made in cakephp 2.x version autovalidation ? how can stop ? html5 form validation depending on browser you're using, validation-messages see part of html5 validation performed browser . recent versions of chrome automatically perform form validation input elements have required attribute. you can disable html5 validation adding novalidate attribute <form> tag. see question more information: disable validation of html5 form elements note although validating jquery can ni

asp.net - Should I use transacion scope in a shared hosting server? -

suppose have different methods , place them in transaction scope . every method open it's connection. need enable msdtc service in windows server. shared hosting server , can not enable it. class debit { public void inserta() { //insertcode } } class credit { public void insertb() { // insertcode } } using (transactionscope ts = new transactionscope(transactionscopeoption.required)) { debitbal debit = new debitbal(); creditbal credit = new creditbal(); debit.inserta(); credit.insertb(); ts.complete(); } i use entity framework statements. idea using transaction scope in shared hosting server? see link how use transaction scopes entity framework in link , explained 3 cases in transaction scope being used show rollback when error occurs during update of multiple entities: 1: when have multiple save calls context; 2: when have single save multiple object; 3: , transa

firemonkey for xcode 4.6 or a link to download Xcode 4.1 -

i'm using delphi xe2- firemonkey ios app development. firemonkey-ios.dmg file provided in delphi directory can not installed xcode 4.6. requires xcode 4.1 no longer available in apple development downloads. (trust me, looked for million times!!!) anybody can me find proper firemonkey xcode 4.6 or @ least link download xcode 4.1 please? i'm using macos lion. cheers !

Redis DB Master Slave set up -

i have installed redis nodejs application , configured slave instance of redis db running on different server. can have same instance (different db) of redis (running slave) act master locally installed application? thanks in advance yes, can, big caveat . any slave instance can master of 1 or several other instances. can imagine daisy chaining slaves , build hierarchical replication system. now, understanding don't need slave feed redis instance, allow application perform read/write operations in database of slave instance. to allow it, need set value of slave-read-only parameter "no" in slave configuration: # can configure slave instance accept writes or not. writing against # slave instance may useful store ephemeral data (because data # written on slave deleted after resync master) # may cause problems if clients writing because of # misconfiguration. # # since redis 2.6 default slaves read-only. # # note: read slaves not designed exposed untrus

android - Not able to show line chart of currency code -

i developing app based on currency converter. i using yahoo finance api takes currency code of 2 countries , convert them , working fine.but have show line chart between 2 currency , did not api able return information. any appreciable.

java - Should tricky questions exist on the OCPJP exam? -

Image
when practice take ocjp exam, see questions i'm suppose practice on trick questions try fool answering wrong. example bathes / sierra book , typical trick question is: now wonder if can tell me if questions on real exam trick questions these or if actual exam has style, or if close should expect? the given example not tricky. measures whether know difference between constructors , methods . constructors , methods might have same name, not compilation error. the exam may contain questions these trip participants. however, should keep in mind every question in exam measuring ability , knowledge in exam objectives . should ask while reading question: "what objective might question measuring?"

mysql - Two SELECT's in one query in the same table -

i have 1 table: id | parent_id | name 1 | null | audi 2 | 1 | a5 3 | 1 | a6 4 | null | opel 5 | 4 | astra 6 | 4 | vectra i want name of record , name of record's parent. one example fetch name id=5 , parent name. id | name | parent_name 5 | astra | opel what sql query this? my query: select name, parent_id `cats` `id` = 5 or `id` = cats.parent_id limit 0 , 30 didn't work. you can use below query: select t1.id, t1.name, t2.name parentname table1 t1 inner join table1 t2 on t1.id = t2.parent_id t2.id = 5 sql fiddle

android - Motion detection versus conserving battery -

in app, have service running in background, in time ranges user determines. in theory, need know user's distance destination. optimizations, i'm implementing own proximity alert, sleeps time frames according current distance. moreover, if user not in motion @ all, stop locations updates, since know it's not moving. used listener acceleration sensor. leaving on long ranges of time draining battery, since minor updates arrive constantly. i know increase time frames of locationing (i read great article in android developers..), it's highly risky correctness. did 1 ever face similar problem? suggest different designing? thanks help android kitkat adds new sensor type, type_significant_motion , designed solve problem. if supported, causes motion sensor wake system motion events significant enough cause location change.

javascript - how to get google places autocomplete to work if the textbox is initially hidden and should be shown only after a postback -

i've got 2 textboxes need use google places autocomplete. these textboxes contained in panel hidden on page load. there list of options select, , once user input obtained, hidden panel should shown. i've tried both panel.visible = false; and panel.style["display"] = "none"; panel.style["visibility"] = "hidden"; but neither work. once panel hidden autocomplete textboxes stop working. cannot show panel initially. there work around this? can trigger autocomplete after specific postback? or other way? here's javascript i'm using autocomplete <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script> <script type="text/javascript"> var defaultbounds = new google.maps.latlngbounds( new google.maps.latlng(7.623887, 68.994141), new google.maps.latlng(37.020098, 97.470703)); var input1

python - Simple password check TypeError: 'NoneType' object has no attribute '__getitem__' -

i'm getting error , highlighted code passw[0] what error mean exactly? it's simple comparison since returned tuple can't compare it. need change password tuple? or have other way around come out equal? here's full code. it's simple password check. def check_login(db, useremail, password): """returns true if password matches stored""" cur = db.cursor() password1 = db.crypt(password) ur = "select email users email = ?" cur.execute(ur, (useremail,)) user = cur.fetchone() if user[0] == useremail: pas = "select password users email = ? , password = ?" cur.execute(pas, (useremail, password1,)) passw = cur.fetchone() if passw[0] == password1: return true else: return false passw = cur.fetchone() cur.fetchone() returns none when there in no match. since you're taking password user, , looking , email, if pas

html - javascript not working -

i new html , trying output of following prog unable output dont no whats wrong pls help... <html> <body bgcolor="pink"> <script src="valid.js" type="text/javascript" > </script> <form id="frm"> <center> <table cellspacing="10" cellpadding="10"> <tr> <td align="center" style="vertical-align:middle"><font size="6">login<font> </td> </tr> <tr> <td align="center" style="vertical-align:middle"><font size="4">user id <font></td><td> :<input type="text" id="user"></td> </tr> <tr> <td align="center" style="vertical-align:middle"><font size="4">password<font></

java - system tray background image on linux is not transparent -

i developing java application system tray. using systemtray class avaiable on java , png image icon. image has transparent background , works fine on windows , mac, image displayed white background on linux. someone knows what's problem , how can fix it? i searched lot it, didn't find solution.

linux - Getting the current cpu information -

this question has answer here: how can cpu core number within user-space app (linux, c)? 4 answers i'm having fun writing simple applications use pthreads. possible thread information core running on? i'm trying play around thread affinity of thread, useful know details of core thread running on. you can use top command. in particular: top -h -p pid you can see list of threads (for single process) , cpu cores threads running on. in alternative can take @ /proc/pid/task/tid/stat . to have reference read informations /proc/ take at: kernel.org for particular tid if execute: `cat /proc/pid/task/tid/stat` you'll like: 1469 (proc_name) s 1 1463 1463 0 -1 4202560 32 0 0 0 0 0 0 0 25 5 3 0 1287407887 305942528 507 102400000 1 1 0 0 0 0 0 4096 83179 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 where third field start state of threa

windows 7 - Editing hidden files in Netbeans -

i have hidden files displaying in netbeans 7.3.1. can open files , make changes when try save (access denied) message. just check tried opening same file in notepad, attempted same thing , save successful. i assume has permission issue between netbeans , file on windows system. i'm running windows 7 x64 sp1 i cannot run netbeans administrator. i can't seem find online this, every link comes has displaying hidden files in netbeans have done already. the files downloaded began . (.header.html, etc) know means hidden. in order proceed work manually removed dot assuming allow me edit files. did not, went ahead , checked file properties , apparently still considered hidden. unchecked hidden , saved , able edit files in netbeans fine. wanted see if can keep . , have hidden field unchecked , works fine. i know . signifying hidden more or less linux specific, in every version of windows i've used seemed . had same effect. happened copied these fil

internet explorer 8 - IE8 print preview displaying blank space in between contents -

Image
in ie 8 print preview page page displaying space between contents. original html file don't have space between contents. there no <br> tag also.please refer image reference. mozilla shows = 6 page ,ie shows = 9 page. 1 came across strange problem?? can please share link trying view? try adding following in print css file <link href="http://www.your-domain.com/css/print.css" rel="stylesheet" type="text/css" media="print" /> css: html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video, container { margin:0; padding

datagridviewcolumn - C# DataGridView: Value disappearing in dynamic added column -

i coming across strange or maybe way works , lack of understand of how datagridview works. dynamically adding column when click on button private void btnassign_click(object sender, eventargs e) { if (!gvdata.columns.contains("departmentid")) { datagridviewtextboxcell cell = new datagridviewtextboxcell(); datagridviewcolumn dc = new datagridviewcolumn(); dc = new datagridviewtextboxcolumn(); dc.headertext = "departmentid"; dc.name = "departmentid"; dc.celltemplate = cell; gvdata.columns.add(dc); } foreach(datagridviewrow row in gvdata.selectedrows) { row.cells["departmentid"].value = getselectedvalues(clbdept); } } first checks if departmentid column in datagridview (dgv). if not create new datagridviewtextboxcolumn , sets appropriate settings. adds values cells. far good... weird thin

asp.net - XML output is incorrect -

i have form written in vb.net asp.net writes users data xml file. each time form used, new xml file generated data provided via form. problem i'm trying xml output resemble: <personaldata> <products> <product> <productid>1</productid> <productnumber>123456</productnumber> </product> </products> <customers> <customer> <lastname>winchester</lastname> <firstname>sam</firstname> <address>1234 elm rd</address> <city>san antonio</city> <state>texas</state> <zipcode>76345</zipcode> </customer> </customers> </personaldata> however, end with: <personaldata> <products> <product> <productid>1</productid> <productnumber>123456</productnumber> <customers> <customer

jquery - add class to parent li if Child element is actve -

i have searched on can't seem figure how this. have menu has sub navigation in. want able highlight parent li when child li selected. have figured out how child selected not parent. please help. javascript $('.nav a').each(function (index) { if (this.href.trim() == window.location) { $(this).addclass("selected"); } }); html <ul class="nav"> <li><a id="a2" href="~/" runat="server">home</a></li> <li><a href="/about.aspx">about us</a></li> <li class="dropdown"><a href="#contact" role="button" class="dropdown-toggle" data-toggle="dropdown">products</a> <ul class="dropdown-menu" role="menu"> <li><a href="/products-access-control.aspx">product 1</a></li> <li><a

c# - Storing integers from Console to an array -

im writing program asks console x numbers console. if pick number 4, 4 different numbers should stored. program must store these inputed numbers in array, , add numbers , print out in console. so, tried do: console.writeline("write out number: "); int[] x = int[].parse(console.readline()); and apparently cant read in array elements console on way, need store them inside variabel , add them new array? console.writeline("enter number of numbers add: "); //yes, know should validation here var numofnumberstoadd = int.parse(console.readline()); int value; int[] arrayvalues = new int[numofnumberstoadd]; for(int = 0; < numofnumberstoadd; i++) { console.writeline("please enter value: "); //primed read var isvalidvalue = int.tryparse(console.readline(), out value); while(!isvalidvalue) //loop until value { console.writeline("invalid value, please try again: "); //tell user why entering value again

javascript - Getting XML information -

i'm having intense problems. i've found many questions similar , worked...for while. decided time ask own question. i uploading xml file using filereader api , reading in string , looking elements , attributes so: reader.onload = function (e) { var library = new string(e.target.result); if (window.domparser) { parser = new domparser(); xmldoc = parser.parsefromstring(library, "text/xml"); $(xmldoc).find('book').each(function () { pages = []; $(this).find("page").each(function () { page = []; try { page[0] = this.getattributenode("number").nodevalue; page[1] = this.getattributenode("words").nodevalue; } catch (err) { console.log(err); } pages.push(p

if statement - Equivalence of IF and WHERE -

we know do loop more powerful forall statement in fortran. is, can substitute forall do , not vice versa. what where statement , block? can substitute if where ? possible code conditionals , bifurcations where , avoiding if ? where statements reserved arrays assignments , nothing else, e.g.: integer, dimension(100,100) :: a, b ... define ... where(a < 0) b = 1 elsewhere b = 0 endwhere if tried adding in something, write statement, inside where block, see following compiling error (compiler dependent): error: unexpected write statement in block @ (1) edit note nested where blocks legal: where(a < 0) where( abs(a) > 2) b = 2 elsewhere b = 1 endwhere elsewhere b = 0 endwhere

c# - "File opened that is not a database file" opening firefox's cookies.sqlite -

http://www.codeproject.com/articles/330142/cookie-quest-a-quest-to-read-cookies-from-four-pop i implemented code above link read cookies firefox, internet explorer, , chrome. methods internet explorer , chrome both work. however, sqlite throwing connection firefox method on conn.open() reads "file opened not database file." file there , everything. can tell me why might happening? here methods used firefox throw exception: private static bool getcookie_firefox(string strhost, string strfield, ref string value) { value = string.empty; bool frtn = false; string strpath, strtemp, strdb; strtemp = string.empty; // check see if firefox installed strpath = getfirefoxcookiepath(); if (string.empty == strpath) // nope, perhaps browser return false; try { // first copy cookie jar can read cookies unlocked copy while

breeze - delete entities from junction table in many to many relationship -

i have many many relationship junction table. public class contact { public int id { get; set; } public string name { get; set; } public virtual icollection<contactcontactgroup> contactcontactgroups { get; set; } } public class contactcontactgroup { public int id { get; set; } public int contactid { get; set; } public int contactgroupid { get; set; } public virtual contact contact { get; set; } public virtual contactgroup contactgroup { get; set; } } public class contactgroup { public int id { get; set; } public string name { get; set; } public virtual icollection<contactcontactgroup> contactcontactgroups { get; set; } } if delete relation following exception: uncaught typeerror: unable parse bindings. bindings value: text: contact().name message: cannot read property 'name' of null this delete function: that.deleteme = function (contactcontactgroup) { // doesn't work also, duplicates e

java - Google Play Services "Not Authentic" on Glass -

i'm attempting user's current location on glass. calling mlocationclient.connect() fails without resolution. checked if google play services available on device with: googleplayservicesutil.isgoogleplayservicesavailable(this); this returns connectionresult.service_invalid , according documentation means "the version of google play services installed on device not authentic." the setup google play services sdk guide not describe scenario. does appear bug on glass itself? if so, i'll file bug report. google play services not available on glass @ time. may have unpredictable results if attempt use it, or related features. if care about, please let google know. file issue in glass platform issue tracker and, if possible, describe use case you're working on requires it. helps glass team prioritize features.

asp.net - Find out if row /item in DataGrid is in edit mode -

in asp.net 3.5 have datagrid. has several rows of data. have radio buttons out of datagrid. data grid has column drop down list in edit mode. click 1 of radio buttons , postback. want know in check changed event radio button if of rows in datagrid in edit mode. how do that? can loop through datagrid this for each item datagriditem in dgedittime.items trace.warn("the item index is:" & item.itemindex) next but how find out if row in edit mode? if using gridview can editindex calling: int editindex = yourgridview.editindex if using old datagrid control, can call edititemindex: int editindex = yourdg.edititemindex if code doesn't work expect, rebinding data on every postback , hence, edititemindex (or editindex depending on actual control using) therefore reset original state.

java - Update listview from inside the list adapter -

here's problem: have listview several rows. rows have single type of listadapter(though there several types of rows). if user selects row, row needs un-selected. way row selected dependent on row type. rows selected when have written in edittext field,etc. suffice say, row selection algorithm must inside listadapter class. one solution used have "selection" display algorithm @ getview() row initialization part , when row selected, call notifiy this.notifydatasetchanged(); refreshing entire listview. this, of course, costly , causes whole other set of issues. so need way update other rows inside listview within custom adapter class. how access selected row's "brothers" ? any input appreciated! thanks! well, astute colleague, believe have found solution problem: use listview need constructor custom adapter! so in custom adapter constructor : public subeventlistadapter(context context, arraylist<mobilesubevent> items, mobile

plyr - Shapiro.test in R giving "all x values are identical"? -

i've been working on getting table of shapiro-wilkes normality hypothesis test p-values on data frame of mine. here data frame (named "mdf1") comma-delimeted csv . shapiro-wilkes testing in r requires sample size greater 3. in order subset data frame (which contains 2 pertinent factors, "variable", , "site"), used following code: z <- as.data.frame(data.table(mdf1)[, list(freq=.n, value=value), by=list(site,variable)][freq > 3]) this resulted in data frame "z" contained values belonged "site"*"variable" combination of n greater 3. then, try pass z ddply function obtain table of shapiro-wilkes p-values: norm2 <- ddply(z, .(site, variable), summarize, n=length(value), sw=shapiro.test(value)[2]) the result of command is: error in shapiro.test(val) : 'x' values identical how can be? thoughts? your value variable string here. ??shapiro.test(x) says x numeric vector of dat

javascript - Simple setTimeout not working? -

i trying create basic script in tampermonkey. visit 1 url, wait 1 second , visit another: $(document).ready(function() { document.location.href = 'http://www.google.com'; settimeout(dostuff ,1000); }); function dostuff(){ document.location.href = 'http://www.stackoverflow.com'; } the function dostuff not appear called ever. whenever run script, redirected google.com, not stackoverflow.com. a javascript execution environment lasts lifetime of page. when set location.href leave page, pending javascript won't run because environment no longer exists.

PDF file or images for a book in android application -

i developing android book selling application problem don't know if should use books pdf file or images. reading of books inside application. you should use .pdf extension ebook. because images tend become pixelerated when zoomed level. pdf preserves vectors , not reduce quality of content (images, text, etc) when zoomed. along that, pdf wrapped collection of pages in single file. instead of many different image files single ebook. there many open source libraries rendering pdfs in android have used mupdf library rendering pdf files in android app.

How to Insert Data with Mysql Trigger After Insert? -

this database vehicle table's trigger drop trigger if exists insertvehtrig; delimiter $$ create trigger insertvehtrig after insert on vehicle each row swl_return: begin declare cph char(50); declare devid char(12); declare vehid bigint; declare tmpid bigint; declare devcount int; set cph = rtrim(ltrim(new.cph)); set vehid = new.id; set devid = new.devid; if(vehid null) select count(id) @devcount vehicle (cph=@cph) or (devid=@devid); -- 条件:当前的车牌号 或 设备id end if; if (devcount > 1) -- 如果记录数,超过1,则认为有重复 -- rollback not supported in trigger set @swv_null_var = 0; leave swl_return; else if (devcount = 1) select id @tmpid vehicle (vehicle.cph = @cph) or (vehicle.devid = @devid); if (tmpid != vehid) -- --如果增加的车牌号码与数据库中的在相同的,则不允许增加 -- rollback not supported in trigger leave swl_return; set @swv_null_var = 0; end if; end if;

python - explain the print strategy in below codes -

i started learning python , while using lists faced problem. here assigned movie names variable movies : >>> movies = ["dragon","dragon warrior","kungfu","kungfu panda"] after assigning, used print command execute it: >>> print(movies) the output below: ['dragon', 'dragon warrior', 'kungfu', 'kungfu panda'] in same way, when started using for-loop in lists same print command, output entirely different. can't understand how changed because of for-loop: >>> fav_movie in movies: print(fav_movie) output: dragon dragon warrior kungfu kungfu panda why same print command working differently? print(movies) prints str version of list object, while in loop you're printing str version of individual items inside list. >>> print(movies) ['dragon', 'dragon warrior', 'kungfu', 'kungfu panda'] is equiv

spring jdbctemplate delete syntax -

please can point out mistake in following code of spring jdbc template. when click delete, record not getting deleted , there no errors showing. public void delete(string id) { logger.debug("deleting existing person"); // prepare our sql statement using unnamed parameters style string query = "delete person id = ?"; // assign values parameters object[] person = new object[] {id}; // delete jdbctemplate.update(query, person); } here example. pay attention: integer id public boolean delete(integer id){ string sql = "delete organization id = ?"; object[] args = new object[] {id}; return jdbctemplate.update(sql, args) == 1; }