Posts

Showing posts from August, 2014

javascript - Code to find absolute position of an element of DOM in Java -

i working on project in java . in project, have find absolute position of element of dom. don't know how this. i searched on net, found same javascript. found here . code this , function getposition(element) { var xposition = 0; var yposition = 0; while(element) { xposition += (element.offsetleft - element.scrollleft + element.clientleft); yposition += (element.offsettop - element.scrolltop + element.clienttop); element = element.offsetparent; } return { x: xposition, y: yposition }; } when try write code in java, offsetleft, offsettop variable not found. can tell me, how can write code in java? edit no. 1 is there method using jsoup same? there 2 methods giving position in jsoup: element.elementsiblingindex() node.siblingindex() (you can count of childs too) but there's no offsetleft or offsettop in jsoup

javascript - Submitting Data from tokeninput.js -

i have set https://github.com/loopj/jquery-tokeninput on 1 of web sites. i trying allow users of sites create list number of options give them.. once user done selecting items , click submit no values back. can let me know doing wrong.. html <div> <input type="text" id="demo-input" name="name" /> <input type="submit" value="submit" /> </div> js <script type="text/javascript"> $(document).ready(function() { $("#demo-input").tokeninput("json.php"); }); </script> php $name =$_post["name"]); this doing far around issue.. as user adds , removes items list using onadd , ondelete functions add id's hidden field .. once id's populated can use standard $_post[] command in php read values here sample of code else might have same issue html <div> <input type="text" id="list_of_ite

Connect javascript and HTML -

i'm beginning learn javascript , , browser api. why, if press "save" button , pop window not appears in browser ? wrong? <label for="txtnome"><input id="txtnome" type="text" value=""/><br/></label> <label for="txtcognome"><input id="txtcognome" type="text" value=""/><br/></label> <button id="btnsalva"/>salva</button><br/> <script> var model = { nome: "mario", cognome: "rossi" }; var view = { txtnome: document.getelementbyid("txtnome"), txtcognome: document.getelementbyid("txtcognome"), btnsalva: document.getelementbyid("btnsalva") }; var controller; controller = { init: function () { view.txtnome.value = model.nome; view.txtcognome.value = model.cognome; view.btns

JavaScript: passing built-in objects' methods as callback functions -

i've been working through eloquent javascript 's exercises , found out think odd. wrote trivial array-flattening piece of code: var arrays = [[1, 2, 3], [4, 5], [6]]; var out = arrays.reduce(function(acc, next){ return acc.concat(next); }); console.log(out); // → [1, 2, 3, 4, 5, 6] so far good. didn't seem pretty me, rewrote as: var arrays = [[1, 2, 3], [4, 5], [6]]; var my_concat = function(acc, next){ return acc.concat(next); } var out = arrays.reduce(my_concat); console.log(out); // → [1, 2, 3, 4, 5, 6] it better, need introduce function, anonymous or named, such basic thing? array.prototype.concat.call 's call signature need! feeling smart, rewrote code again: var arrays = [[1, 2, 3], [4, 5], [6]]; var out = arrays.reduce([].concat.call); // → typeerror: arrays.reduce not function (line 2) well, haven't turned out expected. error message seemed cryptic me. i decided investigate. works: var arrays = [[1, 2, 3], [4, 5], [6]]; var my_concat = fu

c++ - string.find() doesn't return -1 -

the code below simple. know, if string::find() didn't find matches returns -1. reasons code below doesn't work. everytime run code endless loop. thank help! #include <string> #include <iostream> using namespace std; int main() { string text; text = "asdasd ijk asdasd"; string toreplace = "ijk"; cout<<text<<endl; int counter = 0; while ( text.find(toreplace) != -1) counter++; cout<<counter<<endl; system("pause"); } aside other answers correct, wanted add while loop have produced endless loop anyway. example: while(text.find(toreplace) != std::string::npos) counter++; will endless loop because keep trying find toreplace string in text , find (that's because find starts beginning of string each time). not intended.

restore backup database with out sql server management studio -

i have 1 database backup. now want install backup friend's system. his system not contain sql server management studio. how can install backup system, both using sql server 2005. statement 1: his system not contain sql server management studio statement 2: both using sql server 2005... doesn't above 2 statements contradict each other? update please ignore previous answer run following command on command promt: sqlcmd -e -s myserver –q “restore database [mydb] disk=’d:backupsmydb.bak(your backup databse file)’” i got refrence here

Can't connect with MySQL DB in CLI mode (Being connected in GUI Mode) in PHP -

i'm trying connect mysql in command line php script file. have file i'm running in gui mode, in command line mode giving me below error @ time of mysqli_connect: mysqlnd cannot connect mysql 4.1+ using old insecure authentication. please use administration tool reset password command set password = password('your_existing_password'). store new, , more secure, hash value in mysql.user. if user used in other scripts executed php 5.2 or earlier might need remove old-passwords flag my.cnf file i understand can update password. due reason, can't update old password new passwords. need connect mysql support of old password. again, mentioning same code working fine in gui mode not in cli mode on same server. how happening. has idea? can check php.ini files used web server , command line php? web server, create page phpinfo() , check location of php.ini file. once php.ini file location used web server, can execute php script command line u

joomla2.5 - form type calendar and editor -

i have in component on frontend 2 field calendar , editor. have problem both, files: <field name="description" type="editor" label="com_betting_field_desc_label" description = "com_betting_field_desc_desc" class="inputbox" filter="safehtml" buttons="false" /> <field name="start_data" type="calendar" label="select date" description="" format="%d-%m-%y" /> and problem in calendar dont display popup window choice data. , in editor need change under field use editor not, default textarea. try add not work. editor="desired" when use editor="none" work , have textarea without option change editor.

android - score increase the chance of apperance -

hello i'm developing game each time user blows block users 1 point , point added overall score while game running. the game consists of 4 standard views want done more chance increase more background appear on views. in way higher score more chance of background bind view when user reach's 50 starts bind background , when user reach's 200 chance of binding becomes 100% this.bcolor=random.nextint(4 - 1 + 1) + 1; // generate random color between 1 , 3 if(fallanimationactivity.score % 100 == 0) { // here want apply chance alogrithm. fallanimationactivity.showcolorbuttons(); switch (bcolor) { case 1: this.setbackgroundcolor(color.blue); break; case 2: this.setbackgroundcolor(color.red); break; case 3: this.setbackgroundcolor(color.green); break; case 4: this.setbackgroundcolor(color.blac

How to create a Alphanumeric Serial Number in Javascript? -

i trying create alphanumeric serial number in javascript, serial number governed following rules: 3-digit alphanumeric series allowed values 1-9 (zero excluded) , a-z (all capitals exclusions of , o) the code should able give next number after getting input number. the last part tricky, code fetch existing value of serial number , give output next number. for example: if input number 11d output number should 11e. please let me know if description enough explain requirement. the excel sheet same attached here also part of code script fetch starting value 11d code: cur_frm.add_fetch('item_group','serial_number','serial_number'); var alphabet = "123456789abcdefghjklmnpqrstuvwxyz"; var alphabetlen = alphabet.length; function nextdigit(digit) { nextdigitpos = (alphabet.indexof(digit)+1) % alphabetlen; return alphabet.charat(nextdigitpos); } /** * computes next serial id. * @param i

sockets - C++ send data size before sending data via TCP -

disclaimer: new , clear can. i have variable "packet" size of data. know tcp streaming protocol - streams bytes, not packets. now, tell client size of data read stream (which constitutes 1 of 'packets'). the data sending in std::string format if string called outstring , how populate uint8 buff[4] size of string needs read on client? my client, written in c#, looks this: int total = 0; int read; byte[] datasize = new byte[4]; read = socket.receive(datasize, 0, 4, 0); int size = bitconverter.toint32(datasize, 0); int dataleft = size; byte[] data = new byte[size]; while (total < size) { read = socket.receive(data, total, dataleft, 0); if (read == 0) { break; } total += read; dataleft -= read; } apologies, isn't direct answer question, may useful. programming raw sockets sucks. there's lot of work make program deal them robustly. example, in code snippet attempt receive 4 bytes datasize. there no guarantee that sing

hidden html form in php with javascript -

i'm trying pass parameter html form in php, have php page fill html table: $html = ''; $html .= '<form id="form1" action="search.php" method="post">'; $html .= '<tr>'; $html .= '<td>id</td>'; $html .= '<td><a href="javascript:;"onclick="document.getelementbyid(\'form1\').submit();">name</a></td>'; $html .= '<td>surname</td>'; $html .= '<td>language_id</td>'; $html .= '<td><span class="label label-success">status_code</span></td>'; $html .= '</tr>'; $html .= '<input type="hidden" name="mess" value=\'hello\'>'; $html .= '</form>'; i can see in html table, when click on href, search.php page it's open, can't see 'hello' value, search.php: <?php $name0 = $_post[&#

php - Is there a way to get this by .htaccess file? -

in site root directory. there donghua.php , index.php. now, there way use .htaccess file let visitor access site .the default shows example.com/donghua.php . not example.com/index.php . thank you. server apache. ps:the user still can access example.com/index.php i using directoryindex donghua.php in .htaccess. default page ok. when access example.com/index.php redirect example.com/donghua.php . if forbid redirect how do? if have access virtual host config file (or should able in htaccess) can set directoryindex donghua.php if want, i.e. instead of this: directoryindex index.html index.php default.html just do: directoryindex donghua.php so whenever goes website, example.com, apache installation read donghua.php default index file.

email - Center HTML in OUTLOOK not working -

i have spent day reviewing fixes issue. html looks great on email clients except outlook, layout not center in preview. i've tried <center> tag , fixing .externalclass nothing works. can help? <!doctype html> <html> <head> <meta charset="utf-8"> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <meta content="telephone=no" name="format-detection"> <meta content="width=mobile-width; initial-scale=1.0; maximum-scale=1.0; user- scalable=no" name="viewport"> <meta content="ie=9; ie=8; ie=7; ie=edge" http-equiv="x-ua-compatible"> <link href="https://fonts.googleapis.com/css?family=lato:400,700" rel="stylesheet" type="text/css"> <title>iaed ace website</title> <style href="">a {text-decoration: none} </style> <style type="text/css">

Chrome Memory Leak with moving SVG text and blur filter -

i have page several svg elements , each of them has svg blur filter applied it. noticed chrome running out of memory if elements keep moving continuously. to reproduce check codepen: http://codepen.io/anon/pen/xzjmvz <html> <head> <meta charset="utf-8"> <style> body {padding: 0; margin: 0;} </style> <svg height="0" width="0"> <defs> <filter id="f1"> <fegaussianblur in="sourcegraphic" stddeviation="2" /> </filter> </defs> </svg> </head> <body> <svg height="30" style="position: absolute; top: 100px; width: 1000px;height: 500px;"> <text x="0" y="15" fill="black" id="t0">blur test!</text> </svg> <script> (function() { var svgtext = document.getelem

html - Stange PRE tag (or lack thereof) behavior -

Image
given html <pre> <div class="px_xml">&lt;addfiledialogplaces id="<b>rvt_2016 places</b>" delete_prior="true"&gt; <div class="px_ind">&lt;place id="favorites"&gt;c:\users\[px~user]\links&lt;/place&gt; &lt;place id="datasets"&gt;c:\programdata\datasets&lt;/place&gt; <div class="px_ind">&lt;place id="families"&gt;c:\programdata\assets\revit\2016\libraries&lt;/place&gt;</div> &lt;place id="desktop"&gt;desktop&lt;/place&gt; &lt;place id="my computer">::{20d04fe0-3aea-1069-a2d8-08002b30309d}&lt;/place&gt; &lt;place id="my network places"&gt;::{208d2c60-3aea-1069-a2d7-08002b30309d}&lt;/place&gt; &lt;place id="documents"&gt;personal&lt;/place&gt; &lt;delete&gt;revit server netw

Change the color of a table's cell on mouse click using Javascript -

how assign 3 colors cell, , change them on every click? let's have 10x10 table, , default colour white, on first click on cell changes black, on second changes grey, , on third it's white again, , every colour cells value, like: white: 0 black: 1 grey: 2. i want make puzzle game (griddler exactly) , every cell must black , grey if puzzle solved correctly. here working fiddle inside window.onload (or dom ready, whichever you'd like): var colors = ["white","black","gray"]//array of colors var reverseref = {"white":0,"black":1,"gray":2}; var cells = document.getelementsbyclassname("block");//block class name should give blocks for(var i=0;i<cells.length;i++){//attach event blocks cells[i].onclick = function(){//when click them //change background color //(reverseref[this.styles.backgroundcolor]+1)%3 means number value color, increase one, , modulus 3 (which

optimization - In golang, how can you get a reflect.Type instance of an struct without physically creating the struct? -

i want create registry of struct types enable dynamic loading of solutions 'project euler' problems. current solution requires struct first created , zeroed before it's type can registered: package solution import ( "errors" "fmt" "os" "reflect" ) type solution interface { load() solve() string } type solutionregister map[string]reflect.type func (sr solutionregister) set(t reflect.type) { fmt.printf("registering %s\n", t.name()) sr[t.name()] = t } func (sr solutionregister) get(name string) (solution, error) { if typ, ok := sr[name]; ok { sol := reflect.new(typ).interface().(solution) return sol, nil } return nil, errors.new("invalid solution: " + name) } var solutionsregistry = make(solutionregister) func register(sol solution) { solutionsregistry.set(reflect.typeof(sol).elem()) } func load(s string) solution { sol, err := solutions

linq - C# functions in LinqToSql request -

i have 1 problem. need use c# function in linq sql request. example: void request() { var db = new dataclasses1(connectionstring); var result = in db.stats function(a.sourcename) select a; } bool function(string sourcename) { return true; } this dont work because boolean function(string sourcename) cant change sql request. need use c# functions in linq sql? you need add asenumerable linq query: void request() { var db = new dataclasses1(connectionstring); var result = in db.stats.asenumerable() function(a.sourcename) select a; } bool function(string sourcename) { return true; }

VB.NET TableLayout MouseEnter and leave event -

i'm trying looks "simple" since several hours, cannot understand how it...and lurking on or different sites seems maybe not obvious. the question simple: have tablelayoutpanel multiple rows, each 1 of them contains panel, contains several other controls. i want when mouse enters row, row background changes , when mouse leave row, comes original color. these simple event trappers, pnllayoutrow name of panel containing other controls: private sub devrowmouseenter(sender system.object, e eventargs) handles pnllayoutrow.mouseenter pnllayoutrow.backcolor = drawing.color.fromargb(&hffffeeaa) end sub private sub devrowmouseleave(sender system.object, e eventargs) handles pnllayoutrow.mouseleave pnllayoutrow.backcolor = drawing.color.fromargb(&hffe7debd) end sub the problem is: mouseenter correctly fired each time enter row, mouseleave fired mouse reach 1 of controls inside panel..that drives me crazy. in other environment, solve placing transpare

Android get items from sqlite db with date of today or previous -

i'm struggling implementation of dates in sqlite3 (for android). according documentation ( https://www.sqlite.org/datatype3.html , http://www.sqlite.org/lang_datefunc.html ), sqlite doesn't have datatypes date , time , therefore can either stored text or integer. i've tried both, give same erroneous results. after reading lot on internet , trying can think of, come here last resort. so, problem. idea simple. have table containing items, date column. want select items database have date of today, or before (i.e. today or in past). in current implementation store dates integers, since people seem agree that way go. below (simplified) code inserting item. calendar calendar = gregoriancalendar.getinstance(); calendar.set(calendar.hour_of_day, 0); // might not necessary calendar.add(calendar.day_of_year, 4); // today plus 4 days sqlitedatabase db = dbopenhelper.getwritabledatabase(); contentvalues values = new contentvalues(); values.put(column_date, calendar.gettim

c# - LINQ dynamic case -

i have method: private string getlanguage(string currentlanguage, dynamic entity) { return (currentlanguage == "de" ? entity.language.german : currentlanguage == "fr" ? entity.language.french : currentlanguage == "en" ? entity.language.english : entity.language.english); } and need return linq expression sql statement: select (case when [french] null [english] else [french] end) language how can achieve this? tks edit: to more specific: i have this: myid = 1; objects in context.objects objects.id== myid select new { myobject = new models.myobjects() { id = objects.scrid, title = languagefactory.getlabellanguage(objects.labels) } }).firstordefault(); and myobject.title mus

Node.js Express -

i have express server, , write like for(p in params) app.get("/"+p,function (req, res) {res.send(p)}); now, params[0], request arrives, response params[n-1] you can use anonimous function make copy of 'p' on each iteration. var http = require('http'); var express = require('express'); var app = express(); var params = { 'a' : 1, 'b' : 2, 'c' : 3 }; (p in params) { (function (p) { app.get('/' + p, function (req, res) { res.send(p); }); })(p); } http.createserver(app).listen(1339, '0.0.0.0');

iphone - How to make a UITableViewController transparent on the top? -

in iphone application have presented controller: shareresourceitemviewcontroller* controller = [[shareresourceitemviewcontroller alloc] initwithsharedresourceitem:[selecteditems objectatindex:0]]; [self presentviewcontroller:controller animated:yes completion:nil]; then in controller want make transparent on top. tried: -(void)viewdidload{ [super viewdidload]; [self performselector:@selector(test) withobject:nil afterdelay:3]; } -(void)test{ self.tableview.backgroundcolor = [uicolor clearcolor]; self.tableview.opaque = no; self.tableview.backgroundview = nil; } the background cleaned controller not transparent , can not see previous controller? how can fix this? make tableview cells background color clear color.

javascript - Angularjs, How make checkbox array to insert in mongoDB -

i created collection in mongodb call mangas , has " name , autor, genre , info " gender array. i have form receive name values, , autor info, checkbox come array filled values entered in form question. how make checkbox has 2 options ** " adventure ** , ** action " ** , enter mongodb array? same collection below. mongodb mangas db.mangas.insert({ nome:'toriko', autor:'não sei', gender:['adventure','action'], info:'...' }) index.html <tr> <td><input class="form-control" ng-model="manga.nome"></td> <td><input class="form-control" ng-model="manga.autor"></td> <!-- aqui precisa ser checkbox que irá ter os valores array e inseridos no gender --> <td><input class="form-control" ng-model="manga.info"></td> <td><button class="btn btn-pr

javascript - how to pass arguments to PhoneGap database transaction executeSql functions -

i'm new phonegap i'm using database , working fine below code db = window.opendatabase("sample", "1.0", "phonegap demo", 200000); db.transaction(getdetails, transaction_error); function transaction_error(tx, error) { $('#busy').hide(); alert("database error: " + error); } function getuserdetails(tx) { var sql = "select id, name, displayname details name=name"; try { tx.executesql(sql, [],getlist_success); } catch(err) { alert(err); } } function getlist_success(tx, results) { var len = results.rows.length; for(var i=0; <len; i++) { //some code goes here } db = null; } now want use functions getuserdetails , getlist_success passing paramenters, tried below code giving error db = window.opendatabase("sample", "1.0", "phonegap demo", 200000); getuserdetails(db); function getuserdetails(tx) {

swift - SKScene View Rendering Issues (see photo) -

click ----> pic :) this gamescene of now, hard coded , linked global file of holds scene data override func didmovetoview(view: skview) { super.didmovetoview(view) playbutton.hidden = true let background = skspritenode(imagenamed: "us-flag") background.position = cgpoint(x: size.width/2, y: size.height/2 ) background.blendmode = .replace background.zposition = -1 background.size = self.size addchild(background) gameoverbutton = skspritenode(imagenamed: "gameover") gameoverbutton.position = cgpoint(x: size.width / 2 , y: scene!.frame.height - 200) gameoverbutton.zposition = 3 gameoverbutton.xscale = 1.5 gameoverbutton.yscale = 1.5 gameoverbutton.hidden = true addchild(gameoverbutton) gamescore = customsklabel(fontnamed: "chalkduster") gamescore.text = "votes: 0" gamescore.position = cgpoint(x: int((self.size.width - gamescore.frame.width )) , y: 22)

windows - ucrtbase and compiler redistributables found _how_ at program load time? -

some dlls special , operating system load official installed copy regardless of whether file name found on path. what makes special ? on versions of windows earlier win10, “universal crt” might installed via ms-supplied official installer. happen put in system32 directory found , or make special ? likewise compiler rtl redistributals (msvcp140.dll, vccorlib140.dll, vcruntime140.dll). i suspect programs drop these locally, in same directory exe, , put directory on path, causing load errors in unrelated programs don't. in particular, if 1 of dlls found along path , wrong platform (32-bit vs 64-bit) cause cryptic dialog box appear when program attempts run. even though local installation of aforementioned dlls discouraged in favor of using official installers, work or every app need install locally prevent being damaged unrelated programs on path? how can "local install" program (that is, unpacking directory , running there) cope? i'm interested in

automation - How to run Webtests during a TFS Build? -

Image
i need run webtests (defined in files extension ".webtest") in automated tfs build. can run these web tests locally visual studio 2015 cannot them execute during team build. in team build definition, have tried "test assembly file specification" value = "*.webtest". fails pick web tests. can see .webtest files have been copied under "binaries" directory i'm bit puzzled why not found. test specification configurations what missing? how .webtest files run under team build? note: tfs version: 2013 (agent has vs2015 installed) open ellipsis in test source field: specify mstest.exe runner (vs2010 compatible) test runner , change test assembly file specification run has extension of .webtest. more details - http://www.codewrecks.com/blog/index.php/2013/08/16/build-deploy-web-performance-test-with-tfs-build/

javascript - Best practices for attaching a variable to XMLHttpRequest? -

var xhr=new xmlhttprequest(); xhr.open('get','example.php'); xhr.myvar=0; xhr.onreadystatechange=function(){ this.myvar=this.responsetext.length; var s=this.readystate+":"+this.myvar+":"+this.responsetext; document.getelementbyid('x').innerhtml=s; }; i have script on web page (and <p id="x"></p> ). want attach variable use in onreadystatechange function (obviously, in real code more interesting here). this works fine in browsers i've tried in, makes me nervous. there convention should following? e.g. prefix custom variables underline, or that? btw, attaching member variable otherwise feels right: main alternative use global variable, don't @ (i might have 2 xmlhttprequest objects on page). you can use closures . assuming ajax request inside function body, can declar myvar using var keyword , use inside onreadystatechange function if local variable. function x() { .... .

python - How do I multiply each element in a list by a number? -

i have list: my_list = [1, 2, 3, 4, 5] how can multiply each element in my_list 5? output should be: [5, 10, 15, 20, 25] you can use list comprehension: my_list = [1, 2, 3, 4, 5] my_new_list = [i * 5 in my_list] >>> print(my_new_list) [5, 10, 15, 20, 25] note list comprehension more efficient way for loop: my_new_list = [] in my_list: my_new_list.append(i * 5) >>> print(my_new_list) [5, 10, 15, 20, 25] as alternative, here solution using popular pandas package: import pandas pd s = pd.series(my_list) >>> s * 5 0 5 1 10 2 15 3 20 4 25 dtype: int64 or, if want list: >>> (s * 5).tolist() [5, 10, 15, 20, 25]

Webview issue with android 4.0 and 3 .2 -

i created android application in 3.2. in application using using web view display html content/website (any website) , working fine in samsung tablet (v 3.2) after upgrade tablet 3.2 4.0, displaying content in first time in web view,once exit apps , try again second times web-view not working displaying white screen repeatedly. perhaps trouble in activity life cycle. are trying load webpage oncreate method? if so, try put in onstart method.

android - I want kill app , but my app suspend condition. how can I surely kill app? -

this question has answer here: is quitting application frowned upon? 37 answers if press button ,kill app app suspend condition. uses public void onclick(view v){ movetasktoback(true); finish(); android.os.process.killprocess(android.os.process.mypid()); } }); } but app suspend onresume . surely , how can kill app? use this: getactivity().finish(); system.exit(0); or this: finish();

php - Disable menu option for current page with preg_replace -

i'm trying disable link current page in drop down menu using preg_replace. specifically, i'm attempting append class name , "disabled" attribute menu option points current page (the page name in query string). so far can load menu, preg_replace doesn't (preg_replace confusing me @ times). <?php $menu = file_get_contents("menu.php"); $q_param = $_server['query_string']; $menu = preg_replace("|<option value=\"routemap.php?$q_param\"></option>|u", "<option value=\"routemap.php?$q_param\" class=\"red\" disabled=\"disabled\">$1</option>", $menu); echo $menu; ?> edit: fixed with: <?php $menu = file_get_contents("menu.php"); $param = $_server['query_string']; $menu = preg_replace("/$param/", "$param\" class=\"red\" disabled=\"disabled", $menu); echo $menu; ?> it problem beginning , en

c# - Very strange MySQL timeouts occurring on just one developer machine -

i'm not optimistic getting answer one, since it's such weird , seemingly machine-specific issue, i'm posting in hopes else has figured 1 out. i'm developing application in c# using visual studio , mysql.data ado.net driver (version 6.9.8) database access. twice, i've run situation simple sql queries worked moments before start timing out. point forward, never succeed again -- on machine. every other query in application (and there hundreds) works fine, 1 query, if change slightly, never works again. if push code , developer runs it, code works on machine. as example of how simple these queries are, here's 1 i'm having issues with: select * user_preferences (user_id=@user_id) limit 1 the table i'm selecting has 1 row , 4 columns. couldn't simpler. while query waiting time out, not appear in process list mysql, have assume either never made server or server returned instantly , mysql connector failing return response. i'd figure out whi

javascript - How do I make a div hide onclick and make it show when it's clicked again? -

i have code: <script> (function ($) { $(document).ready(function () { $("#thisclick, #thisclick2").click(function () { if ($('.example').is(":hidden")) { $(this).html($(this).html().replace(/hide/, 'show')); } else { $(this).html($(this).html().replace(/show/, 'hide')); } // afterwards operation async $(".example").hide(); }); }); })(jquery); </script> the way current code works if #thisclick clicked hides #example . require when #thisclick clicked again want show #example . using above code, won't work. must achieve this? you should able change code follows work: (function ($) { $(document).ready(function() { $("#thisclick").click(function () { $("#example").slidetoggle("slow"); }); }); })(jquery); here link quick sample:

Bind TextBox Width from ColumnDefinition Width XAML WPF -

in wpf project want bind textbox width property columndefinition width. now, it's not working ! i used converter (gridlengthconverter) convert data width. this code : <textbox grid.column="1" grid.row="1" style="{staticresource searchwhite}" name="tbsearch" visibility="{binding relativesource={relativesource ancestortype={x:type mic:datagrid}}, path=showsearchboxes, converter={staticresource visibleconverter}}" width="{binding relativesource={relativesource findancestor,ancestortype={x:type columndefinition}}, path=width, converter={staticresource gridlengthconverter}, mode=twoway}"/> gridlengthconverter gridlengthconverter assembly : presentationframework. i error "unable convert data attribut 'converter'..." (translation french). someone can helps ? <grid> <grid.columndefinitions> <columndefinition name="col1" width="200&q

html - Can I get two value in a select option tag, then call it in a servlet? -

here want 2 option value, project.id, , project.name <select name="project" id="project"> <option value="0" selected>select project</option> <c:foreach var="project" items="${project}"> <option value="${project.id project.name}">${project.name}</option> </c:foreach> </select> and in servlet, want this, possible? int projectid = integer.parseint(request.getparameter("project")); int projectname = request.getparameter("project"); how do this? you have write value in option using seperator. @ servlet end, use split function seperate values , use them. check answer : split string function . or, can use javascript so, have take 2 other hidden inputs pass values. check script : function splitvalue(){ var optval=document.getelementbyid("instno").value; var valarray=optv

node.js - Including Jasmine-node files in Karma's runner -

currently have set of node.js javascript files along side set of "regular" javascript files send down browser, using angular client side framework. unit testing using jasmine-node test server , using jasmine via karma client side files. there way can include jasmine-node files karma have single test runner? i have node.js server angular.js client code , using jasmine-node. not know if there way (or if desirable) use jasmine-node test client code. using karma (which formerly testacular) , works beautifully. need create config file loads project , angular.mock.js , points test files. i'm sorry doesn't answer question painless testing method. http://karma-runner.github.com/0.8/index.html

osx - character_set_database not updating on mysql -

so followed "tutorial" here: http://outofcontrol.ca/blog/comments/change-mysql-5.5-default-character-set-to-utf8 and after doing so, mysql 5.7 servers on linux updated , showing expect. but, did same on development machine, macbook pro, el capitan, , see following: character_set_client utf8 character_set_connection utf8 **character_set_database latin1** character_set_filesystem binary character_set_results utf8 character_set_server utf8 character_set_system utf8 character_sets_dir /usr/local/mysql-5.6.10-osx10.7-x86_64/share/charsets/ why still latin1? other entries updated utf8 , worked on linux. character_set_database of virtually no use. don't worry it. when creating table, explicitly state create table (...) ... character set utf8; that helps avoid various changes defaults may occur or in future. actually, future utf8mb4 collation utf8mb4_unicode_520_ci . as long going 5.7, may go combo. utf8mb4

html - display triangle on left side of screen -

i have following div aligns left side of screen css #nav { position: fixed; height: 50px; width: 50px; display: block; background-color: #000; } this div contains icon acting link html <div id="nav">icon</div> i want div triangle (pointing towards right) , not square i find site useful: https://css-tricks.com/examples/shapesofcss/ right-facing triangle: #triangle-right { width: 0; height: 0; border-top: 50px solid transparent; border-left: 100px solid red; border-bottom: 50px solid transparent; } you can adjust border properties change width, height, , color of triangle. something you're looking for: https://jsfiddle.net/kh2xsoh2/1 html <div id="nav"><span>icon</span></div> css #nav { width: 0; height: 0; border-top: 25px solid transparent; border-left: 50px solid #000; border-bottom: 25px solid transparent; position: fixed; } #nav span

Why do maildirs need the `new` folder? -

i understand reason why tmp needed in maildir : makes possible not have half-written mails in cur . however, why new needed? couldn't mails dropped cur folder directly name <uniq>: or so? mua wants add flags, initialize uniq part. make things (well, tiny) bit simpler code.

php - Wordpress last revision date -

i try add column date of last revision , use code. there wrong here? thing is, doesn't work, doesn't give me error message add_filter('manage_pages_columns', 'add_revised_column'); add_action('manage_pages_custom_column', 'echo_revised_column', 10, 2); function add_revised_column($columns) { $columns['revised'] = 'revised'; return $columns; } function echo_revised_column($column, $id) { if ('revised' == $column) echo get_post_field('post_modified', $id); } this looks fine me in general. similar add media height x width dimensions on manage media page, , code pattern identical. but: recommend create constant, , use throughout avoid issue, eg: define('col_name_revised','revised'); ... $columns['col_name_revised'] = 'revision info'; ... if (col_name_revised == $column) ... edit : had answered key-names mismatched, on re-visiting question realised not m

JavaScript Why return function in a function? -

var favoritecolor = "blue"; function colorgenerator(color) { return function () { return color; }; } var getcolor = colorgenerator(favoritecolor); why getcolor not blue. getcolor() blue. getcolor becomes function? because return function in colorgenerator? i confused these. thank help. let's dissect this: var favoritecolor = "blue"; function colorgenerator(color) { return function () { return color; }; } this method returns function that, in turn, returns value ( color ). doing this: var getcolor = colorgenerator(favoritecolor); means getcolor function() {return "blue";} . therefore, doing: getcolor(); after setting value return "blue" . test: var favoritecolor = "blue"; function colorgenerator(color) { return function () { return color; }; } var getcolor = colorgenerator(favoritecolor); document.getelementsbyclassname("foo")[0].innerhtml = "colorgenerator r

floating point - How to quadruple an unsigned number using bit-wise and logic operator in C -

goal: 4x ( 4.400000095 ) = 17.60000038 legal ops: integer/unsigned operations incl. ||, &&. if, while max ops: 30 return bit-level equivalent of expression x + x + x + x for floating point argument f. my code: unsigned 4x(unsigned uf) { unsigned expn = (uf >> 23) & 0xff; unsigned sign = uf & 0x80000000; unsigned frac = uf & 0x007fffff; if (expn == 255 || (expn == 0 && frac == 0)) return uf; if (expn) { expn << 2; } else if (frac == 0x7fffff) { frac >> 2; expn << 2; } else { frac <<= 2; } return (sign) | (expn << 23) | (frac); } as can guess, code not work. instead of quadrupling input, input doubled. don't know why since fraction , exponent being right / left shifted 2 instead of 1. im working single precision floating point values in 32 bit machines. some untested code - leave op. (gtg) the tricky bit dealing sub-normal numbers when *4 become norm

c# - Running process from hidden window -

i have faced strange problem when trying run process hidden window - process run runs in hidden process, doing wrong? want run child process not hidden. process.start(path.gettemppath() + "cleanup.exe", path.getdirectoryname(application.startuppath); you can try creating object of process class below : process objprocess = new process(); objprocess.startinfo.useshellexecute = false; objprocess.startinfo.redirectstandardoutput = true; objprocess.startinfo.createnowindow = true; objprocess.startinfo.windowstyle = processwindowstyle.hidden; // passing batch file/exe name objprocess.startinfo.filename = string.format(strbatchfilename); // passing argument objprocess.startinfo.arguments = string.format(strargument); try { objprocess.start(); } catch { throw new exception("batch file not found processing"); }

database - DBInputFormat multiple records processing -

when connect rdbms mysql using hadoop record db user-defined class extends dbwritable , writable. if our sql query generates n records output act of reading record user-defined class done n times. there way in can more number of records mapper @ same time instead of 1 record each time ? if understand correctly, think hadoop causes n select statements under hood. not true. can see in dbinputformat 's source , creates chunks of rows based on hadoop deems fit. obviously, each mapper have execute query fetch data process, , might repeatedly, that's still near number of rows in table. however, if performance degrades, might better off dumping data hdfs / hive , processing there.