Posts

Showing posts from January, 2011

android - Actionbar and toplayout scroll when keyboard open -

i've created listview edittext. if use android:windowsoftinputmode="adjustpan" in manifest file ,i able edit text field. if not , unable edit text. but if use "adjustpan", actionbar , toplayout scroll. how prevent actionbar , toplayout scroll when keyboard open.? you can use "adjustresize", , when notice keyboard shown (link here know when occurs), you'd act accordingly. for example, if have chatting app, done on whatsapp , hangouts, if on bottom, scroll bottom.

class - () operator overloading c++ -

i have confusion calling of overloaded operator(). there 2 functions in class matrix: float operator()(int, int) const; // suppose call function rvalue float& operator()(int, int); // , lvalue now when call them in main, in way : matrix m2(3, 2); m2(0, 0) = 1; // here lvalue should called int c=m2(0,0); // , here rvalue but in both cases calls lvalue function. why?? if comment lvalue function , do int c=m2(0,0); // calls rvalue function but in presence of both functions, calls lvalue function. why? hope, question clear. rvalues of class types not const might think. const overload called on const qualified objects, otherwise least qualified version preffered. what can overload ref-qualifiers (c++11 only): float operator()(int, int) && const; // called when object rvalue float& operator()(int, int) &; // called when object lvalue

jquery - Javascript hide element (when clicked outside) with certain conditions -

so there questions here hiding div when clicking outside of it. have 1 thing, there div(accounts-edit-table-name-edit) showing hidden div(account-edit-group) on click first. , - if click somewhere else out of div(account-edit-group) - must hide. here code trying 2 different conditions (or): $(document).click(function(event) { if($(event.target).parents().index($('.account-edit-group')) == -1 || $(event.target).parents().index($('.accounts-edit-table-name-edit')) == -1) { if($('.account-edit-group').is(":visible")) { $('.account-edit-group').removeclass('acc-edit-f'); alert("hiding") } } }); html: <div class="accounts-edit-table-name-edit">"button"</div> <div class="account-edit-group">block</div> (class "acc-edi...

c# - Linq Query with a where condition - count items -

how can change request : query = query.where(item => (from table in context.table table.amount == item.amount select table).count() >= 10); to not use subquery (from ... in ...) ? i tried create subquery separately, use condition : var subquery = table in context.table select table.amount; var list = subquery.tolist() but don't know how can use after that, because of .count() operation. thank comments. how this: query = query.where(item => context.table .count(t => t.amount == item.amount) >= 10); or reduce number of round-trips: var counts = context.table .groupby(t => t.amount) .select(g => new {amount = g.key, count = g.count()}); query = q in query join c in counts on q.amount equals c.amount c.count >= 10 select q;

How to calculate the position (x,y) of an element on the page without triggering reflow using Dart (in js)? -

i calculate position of element in page using dart (compiled js). read might trigger reflow, make costly in time? true? reflow/layout performance large application position offset(element elem) { final docelem = document.documentelement; final box = elem.getboundingclientrect(); double left = box.left + window.pagexoffset - docelem.clientleft; double top = box.top + window.pageyoffset - docelem.clienttop; int width = box.width.truncate(); int height = box.height.truncate(); return new position(left.truncate(), top.truncate(), width, height); } the key minimizing reflows batch reads , writes. read might trigger reflow if there pending writes happened before it, sequential reads not trigger reflows. in isolation it's hard tell whether trigger reflow or not. can protect against requesting reflow first requestanimationframe . helps when have multiple reads , want trigger single reflow before of them, must use requestanimationframe ...

bash - shell script - looping line by line - space vs line brake -

i have simple script: $ cat $$.sh #!/bin/sh -x var="one 2 3 four" in $var ; echo $i done $ run output: $ sh -x $$.sh + var='one 2 3 four' + in '$var' + echo 1 one + in '$var' + echo 2 two + in '$var' + echo 3 three + in '$var' + echo 4 four $ seems it's looking space , need line break instead if you're reading multiple lines, line-by-line, while read loop common way this: var="one 2 3 four" while ifs='' read -r ; echo "$i" done <<< "$var" this produces: 1 2 3 4 note in example, while loop taking input $var variable using bash here-string redirection . redirection file or pipe.

Android SharedPreferences clear values -

if sp.clear(); , sp.commit(); executed clear values of sharedpreferences. it clear values particular instance used initialize sharedpreferences? it not clear whatever values stored on sharedpreferences other application? use sp.remove().the remove() method remove shared preference.

javascript - resolved: jquery .hover() confusion -

i programming portfolio page , came across strange behaviour off hover states don't understand. have links in navigation bar @ top of page. links defined :hover , everything. want colour of links change when hover mouse on different sections of site links refer to. wrote this: /* navlink colors */ $('#portfolio').hover(function() { $('#portlink').css('color','#ff9900'); }, function() { $('#portlink').css('color','inherit'); }); $('#about').hover(function() { $('#abolink').css('color','#ff9900'); }, function() { $('#abolink').css('color','inherit'); }); ... at first seems work, when scroll blog , move mouse on navigation css :hover doesn’t seem work anymore. test site: http://www.henning-marxen.de/test/index.html (don't laugh placeholders^^) know why behaves this? confused. thank in advance. you need mix of js , c...

sql server - Checking if an id exist in another table -

i have customer table , order table , i'm trying check make sure customer in order table exists in customer table before i'm allowed execute rest of script. this code that's causing problem, alter proc order @customerid int declare @cusid int select @cusid = dbo.customertable.customerid dbo.customertable inner join dbo.orderstable on dbo.customertable.customerid = dbo.orderstable.customerid dbo.orderstable.customerid = @customerid if(@cusid != @customerid) begin raiserror('the customer not exist') return 1 end exec order 44 when try execute script customerid that's not in table doesn't give me error message. appreciated. alter procedure dbo.[order] --<-- avoid using key words object names @customerid int begin set nocount on; if not exists (select 1 dbo.customertable inner join dbo.orderstable on dbo.customertable.customerid = dbo.orderstable.customerid dbo.orderstable.c...

html - How Do I Center my Nav Bar -

this question has answer here: how center container in html/css? 2 answers i have question. how center nav bar following code? can see nav bar @ mineflow.us/hitest <div align="center"><div class="special_container last"><div class='m_html' ><style><!--@import url(http://fonts.googleapis.com/css?family=pt+sans:400,700);#cssmenu { background: #ffffff; margin: 0; width: auto; padding: 0; line-height: 1; display: block; position: relative; font-family: 'pt sans', sans-serif;}#cssmenu ul { list-style: none; margin: 0; padding: 0; display: block;}#cssmenu ul:after { content: ' '; display: block; font-size: 0; height: 0; clear: both; visibility: hidden;}#cssmenu ul li { margin: 0; padding: 0; display: block; position: relative;}#cssmenu ul li { text-decoration: none; display: block; margin: 0; -webkit-...

java - Play 2.2.2 ArrayLists return null when trying to access -

i have play-2.2.2 installed having trouble ebean @onetomany relationships when trying access arraylist. i have user class contains arraylist of address class. code follows: @entity @inheritance(strategy= inheritancetype.single_table) @discriminatorcolumn(name="type", discriminatortype = discriminatortype.string) public class user extends model{ @id private long id; @onetomany(cascade=cascadetype.all) private arraylist<address> addresslist = new arraylist<address>(); ... public void addadress(address address){ this.addresslist.add(address); } and class address @entity public class address extends model { @id private long id; @manytoone private user user; ... now lets make new user , new address. want add address new user's arraylist , save them. bit this: user newuser = new user(); address newaddress = new address(); newuser.addaddress(newaddress); newuser.save(); the problem code ad...

class - python import nested classes shorthand -

how import nested package using "as" shorthand? this question similar importing module in nested packages nesting within same .py file, not across folders. in foo.py (all python files in same package, , version 3.4): class foo: class bar: ... i can access these subclasses in .py file: from . import foo ... bar = foo.foo.bar() what do: from . import foo.foo.bar bar # not work: "unresolved reference" error. ... bar = bar() # saves typing. bar2 = bar() ... is there way this? there little point in nesting python classes; there no special meaning attached doing other nesting namespaces. there rarely need so. use modules instead if need produce additional namespaces. you cannot directly import nested class; can import module globals, foo in case. you'd have import outer-most class , create new reference: from .foo import foo bar = foo.bar del foo # remove imported foo class again module globals the del foo entirely...

Android android.view.windowmanager$badtokenexception progressdialog -

i try use progressdialog in button click ,but have android.view.windowmanager$badtokenexception error. code: starus_fail.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { dialog = progressdialog.show(getapplicationcontext(), "please wait... ", "loading... "); dialog.setprogressstyle(progressdialog.style_spinner); handler handler = new handler(); handler.postdelayed(new runnable() { public void run() { somefunction(); if (dialog != null) { dialog.dismiss(); } } }, 1000); } }); just have answer above, progressdialog uses context of activity calling it. so pass youractivity.this instead of getapplicationcontext see www.doubleencore.in/2013/06/context/ more detailed understanding of...

php - Having problems adding a timeout to socket_connect() -

i'm sorry if has been asked before. i've looked everywhere can't find solution issue. i have written socket client function project of mine, , add timeout doesn't take forever load if failed. i've tried quite few things suggested docs , other answers on stackoverflow, nothing has worked far. here's function; public function send($cmd, $host, $port){ if(!($socket = socket_create(af_inet, sock_stream, sol_tcp))) { $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("error (#300)"); } if(!socket_connect($socket, $host, $port)) { $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("error (#400)"); } if(!socket_write($socket, $cmd, strlen($cmd))) { $errorcode = socket_last_error(); $errormsg = socket_strerror($errorc...

c++ - Updating a Prims algorithm for Minimum spanning trees -

i need doing c++ or java method prints minimum spanning tree prints minimum spanning tree without of vertices in graph. if min span tree has weight 37 min span tree without edge b has weight 49, , next tree out edge b c has weight 50. so question is, how can take out arbitrary edges of mst , calculate new 1 without edge minimal time complexity.

java - How can I use my encryption program to create a decryption program? -

how can convert encryption code used decryption? not want them in same program used in 2 different files. need figuring out how take parts of code use decryption code. need use code , find way use parts of create program decrypt codes created code below. the code using encryption is: import java.util.*; public class cipher //this class encrpyt program { public static char cipher (int j){ //this mehtod generates random letter char[] cipher1 = {'a','b','c','d','e','f','g'}; //characters char array j = (int) (math.random() * cipher1.length);//choose random element array return cipher1[j]; //this return letter } //end of cipher method public static void main (string[] args){ //main method system.out.print("please type sentence encrypted\n");//asks user word encrypted scanner inputscanner = new scanner(system.in); //imports scanner reader string userinput = inputscanner.next(); //assi...

How to save quiz results to database in PhP/HTML -

i started working on project (not school), & ran problem. stated, have multiple quizzes on site, , have results (percentage correctly answered) saved database (that pertains user logged in , answered them), can called on completed quizzes page, & have averaged it's category (displayed @ top of page). , want quiz results viewable other accounts (like teacher/student style). appreciated! `cheers!

java - Calling a variable or method in the activity class from a class that extends view? -

i new android , need help. i have got gameactivity class , set setcontentview gameview class. want access variable located in gameview class gameactivity class. is possible? public class gameactivity extends activity { @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); view gameview = new gameview(this); setcontentview(gameview); } } and gameview class public class gameview extends view { private static final string tag = null; // log.e private ball ball1; // ball1 private gamecontainer gamecontainer; // frame game private racket racket; // controller int viewwidth = 0; // width onchange int viewheight = 0; // height onchange private score score; // constructor public gameview(context context) { super(context); ball1 = new ball(color.g...

C++ using multiple strtok() -

hello have following text: htttp://zbw.eu/stw/descriptor/17782-1> htttp://www.w3.org/2004/02/skos/core#inscheme> htttp://zbw.eu/stw> . htttp://aims.fao.org/aos/agrovoc/c_2678> htttp://www.w3.org/2004/02/skos/core#exactmatch> htttp://zbw.eu/stw/descriptor/15918-5> . #komentar k totte hlouposti ..and fucntion tokenize data, when new line occurs: bool iscorrect(char* buffer){ char* tok; tok = strtok( buffer,"\n"); while(tok != null){ bool = istriple(tok); tok = strtok(null, "\n"); } return true; } when have separate token want tokenize more, tok sent function istriple(char * token): bool istriple(char* token){ char* tok; tok = strtok(token, " "); while(tok != null){ tok = strtok(token, " "); } return true; } in function input token divided more tokens when white space occurs. in function want theese new tokens send function mul...

angularjs - Steam:// link not "unsafe" -

i'm trying steam's add friends' link work reason sanitation isn't working. i'm new angular (first app) , may missing huge/obvious. code added config , html. i'm using angular 1.1.5. link steam below displays "unsafe" , not function. sanitation doesn't seem working intended. thanks in advance! @app.config(['$routeprovider', ($routeprovider) -> $routeprovider. when('/casters', { templateurl: '../templates/casters/index.html', controller: 'casterindexctrl' }). otherwise({ templateurl: '../templates/home.html', controller: 'homectrl' }) ], ['$compileprovider', ($compileprovider) -> $compileprovider.urlsanitizationwhitelist(/^\s*(https?|steam|mailto|file):/); ]) <tr ng-repeat="caster in casters"> <td><a ng-href="steam://friends/add/{{caster.steam_id}}"><button type="button" class=...

How to handle null string in java -

i .net programmer , new in java. facing problem in handling null string in java. assigning value string array string variable completeddate. tried didn't work. string completedate; completedate = country[23]; if(country[23] == null && country[23].length() == 0) { // ... } if (completedate.equals("null")) { // ... } if(completedate== null) { // ... } if(completedate == null || completedate.equals("null")) { // ... } for starters...the safest way compare string against potentially null value put guaranteed not-null string first, , call .equals on that: if("constantstring".equals(completeddate)) { // logic } but in general, approach isn't correct. the first one, commented, generate nullpointerexception it's evaluated past country[23] == null . if it's null , doesn't have .length property. meant call country[23] != null instead. the second approach compares against literal st...

Python script to remove multiple blank lines between paragraphs and end of file -

i wrote python script capture data want have resulting text file contains multiple paragraphs each paragraph separated varying blank lines - anywhere 2 8. my file has multiple blank lines @ end of file. i python leave no more 2 blank lines between paragraphs , and no blank lines @ end of text file. i have experimented loop , line.strip, replace etc have little idea how put together. examples of have been using far wf = open(file,"w+") line in wf: newline = line.strip('^\r\n') wf.write(newline) wf.write('\n') it's easier remove blank lines , insert 2 blank lines between paragraphs (and none @ end) counting blank lines , removing if there's more two. unless you're dealing huge files don't think there's going performance difference between 2 approaches. here's quick , dirty solution using re : import re # reads file f = open('test.txt', 'r+') txt = f.read() # removes blank...

android - change the state of toggle on correct password and dismiss the dialog -

in application,i need off toggle if password correct else should on always. showing dialog box asking password on setoncheckedchangelistener, , change state of toggle if password correct. my problem toggle changes state shows dialog again. dialog should dismiss if password correct ,same time state of toggle should change off. how solve this. my code: onoffswitch.setoncheckedchangelistener(new oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if(iscorrectpin) { onoffswitch.setchecked(false); } log.v("switch state=", ""+ischecked); if(ischecked) { //tv_switch_status.settext(""); } else { ...

c++ - codeblocks shows error in a program but i can't find it -

void print_lcs(int b[][], string x, int i, int j){ if(i==0 || j==0) cout<<x[0]; if(b[i][j] == 1){ print_lcs(b, x, i-1, j-1); cout<<x[i]; } else if(b[i][j] == 2) print_lcs(b, x, i-1, j-1); else print_lcs(b, x, i, j-1); } this program don't know why first line has error. error messages given below: error: declaration of 'b' multidimensional array must have bounds dimensions except first| error: expected ')' before ',' token| error: expected initializer before 'x'| you have pass second (column) dimension of 2d array when declaring array in function arguments. in case: void print_lcs(int b[][column], string x, int i, int j) //replace column no of cols in 2d array

Add JavaScript documentation Sencha Architect -

is possible add documentation (not comments) javascript methods in sencha architect. cannot seem add lines above methods because of specific method views in architect. i talking following documentation: /** * documentation */ bla: function() { //i know how add comment! } update: seems not possible :( http://www.sencha.com/forum/showthread.php?281079-sencha-architect-code-documentation-%28jsdocs% i keep thread open see if knows workaround problem. architect 3.1 or 3.1.1 add commenting. it's done in prototype form racing add ext js 5 it's on burner until then.

AngularJS circular dependency -

i'm making logger service, extend angular's $log service, saving errors (or debug if enabled) indexeddb database. here's code: angular.module('applogger', ['appdatabase']) .service('logservices', function($log, database) { // ... this.log = function(type, message, details) { var log = {}; log.type = type log.context = this.context; log.message = message; log.datetime = moment().format('yyyy-mm-dd hh:mm:ss'); log.details = details || ''; $log[type.tolowercase()](log); if (type === 'error' || this.logdebug) { database.logsave(log); } }; // ... }) this working in services intended. problem can't use logger inside database service, because throws circular dependency error. understand problem have no clue how should resolve it... how should around ? thanks helping :-) the reason angular complaining circula...

php - Symfony2 Routes doesn't find route (multilingual) -

i'would redirect visitor project:index page if types in www.url.com/project or www.url.com/en/project somehow doesn't find routes devined (yes cache cleared several times) here routes: dbe_projectlang: path: /project/ defaults: { _controller: dbedonacibundle:project:root } requirements: _locale: en|fr|de dbe_project: resource: "@dbedonacibundle/resources/config/routing/project.yml" prefix: /{_locale}/project/ requirements: _locale: en|fr|de and here route controller <- 1 works normally public function rootaction(request $request) { $locale = $request -> getlocale(); return $this -> redirect($this -> generateurl('dbe_project', array('_locale' => $locale))); } here error message get: no route found "get /project/" thanks help! the solution described above works. necessary clear cache (it's needed changes in routing): php app/console cache...

ios - UIWebView content how to resize/scale it? -

i came point able lock horizontal scroll wanted when rotate landscape portrait content still large. need resize/scale down myself don't know how far use : - (void)viewdidload { [super viewdidload]; nsstring *fullurl = @"http://igo.nl"; nsurl *url = [nsurl urlwithstring:fullurl]; nsurlrequest *requestobj = [nsurlrequest requestwithurl:url]; [_webview loadrequest:requestobj]; _webview.scrollview.bounces = false; _webview.scalespagetofit = yes; _webview.contentmode = uiviewcontentmodescaleaspectfit; } - (void)didrotatefrominterfaceorientation:(uiinterfaceorientation)frominterfaceorientation { if(frominterfaceorientation == uiinterfaceorientationportrait) { //_webview.scrollview.contentsize = cgsizemake(320, _webview.scrollview.contentsize.height); } else { //[_webview reload]; _webview.bounds = cgrectmake(0, 0, 320,_webview.bounds.size.height); ...

javascript - jquery regexp - HTML tag from string -

how can separate html table tag string using regular expression? var stabstring =' ... <table > <table ... string ... id="unique_1" ... string ...> abc def <table > ... '; var sreg = '< *table .* id *= *"unique_1" .*>'; var sregex = new regexp(sreg); var sresult = stabstring .match(sregex); alert(sresult); i expect open tag attributes follows: <table ... string ... id="unique_1" ... string ...> this every <table> element (and attributes) in string. var regex = new regexp("<table.*?>", "g"); var result = str.match(regex); (var i=0; i<result.length; i++) { // <table> elements here console.log(result[i]); }

Android call intent getting wrong telephone number -

i'm trying make button (r.id.buttonring) call phone number entered in textview called tvtelefon. however, when click button, phone trying call "w4126848130,511290,549" instead of phone number entered in textview. ideas how come? don't receive error messages i'm clueless! thanks! public class activity2 extends activity { public static final string sparad_data = "sparaddata"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_2); sharedpreferences sp = getsharedpreferences(sparad_data, context.mode_private); textview tvrubrik = (textview)findviewbyid(r.id.textviewrubrik); tvrubrik.settext(sp.getstring("rubrik", "rubrik saknas")); textview tvnamn = (textview)findviewbyid(r.id.textviewnamn); tvnamn.settext(sp.getstring("namn", "namn saknas")); textview tvt...

android - Navigation with drawer and tabs like in Newstand -

Image
i'm trying replicate google newstand app navigation system, can use navigation drawer menu , tabs @ same time, this: i'm trying achieve exact same effect newstand, single color action bar , tabs, , tabs not spanning whole lenght of screen able decompile app, , i've seen source of app uses (series guide) they're quite complex , can't find , figure out , how it's implemented. i have tried using template android studio has created me navigation drawer , adding tabs no effect protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mnavigationdrawerfragment = (navigationdrawerfragment) getsupportfragmentmanager().findfragmentbyid(r.id.navigation_drawer); mtitle = gettitle(); // set drawer. mnavigationdrawerfragment.setup( r.id.navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_...

How to check if a url is indexed by google using Google Custom search API and Python? -

i need check if urls indexed google using python script , google custom search. i'd obtain in script same results obtain when browser google site:www.example.it. code is: import urllib2 import json import pprint data = urllib2.urlopen('https://www.googleapis.com/customsearch/v1?key=aizasya3xnw1dooc4rjougc7sq1gltqvogalhqa&cx=017576662512468239146:omuauf_lfve&q=site:http://www.repubblica.it/politica/2014/04/07/news/governo_e_patto_su_italicum_brunetta_a_renzi_riforma_elettorale_entro_pasqua_o_si_dimetta-82947958/?ref=hrea-1') data=json.load(data) print data the output of is: { u'kind': u'customsearch#search', u'queries': { u'request': [ { u'count': 10, u'cx': u'017576662512468239146:omuauf_lfve', u'inputencoding': u'utf8', u'outputencoding': u'utf8', ...

javascript - Angular A-Z reverse sorting -

i'm sure there must simple solution right in front of face 1 damned if can find it. i sort large ng-repeat various sort options, pass array of sort options. user can choose how data sorted. i can sort a-z fine, reason reverse of (z-a) isn't working expected. here's fiddle http://jsfiddle.net/tk39p/4/ all i'm doing same i've used in lots of other sorting functionality across other angular apps: return -result.whatever; so, have done wrong? :) cheers change code bit according $scope.orderby = 'price-low-high'; $scope.predicate='price'; $scope.reverse=true; $scope.orderbyoptions = function (result) { if ($scope.orderby == 'price-high-low') { $scope.predicate='price'; $scope.reverse=false; } else if ($scope.orderby == 'letter-az') { $scope.predicate='letter'; $scope.reverse=false; } else ...

java - How to see what a use has chosen from a JList? -

recently, have been working on java jukebox program. far in program, user selects song jlist, , hits "play" jbutton. need have program find out choice chosen list , launch corresponding constructor. suggestions on how that? -john take @ jlist 's getselected methods, in particular getselectedvalue() , getselectedvalues() .

java - Specify DB2 driver properties in persitence.xml -

i have question regarding driver specific properties in persistence.xml. db2 has secific properties need set on datasource see: com.ibm.db2.jcc.db2simpledatasource ds = new com.ibm.db2.jcc.db2simpledatasource(); ds.setdrivertype(4); // set driver type ds.setdatabasename("******"); // set location ds.setservername("******"); // set server name ds.setportnumber(******); // set port number ds.setuser("*******"); // set user id ds.setpassword("*******"); // set password ds.setdrivertype(4); ds.setsecuritymechanism(com.ibm.db2.jcc.db2basedatasource.encrypted_user_and_password_security); ds.setencryptionalgorithm(2); ds.setclientaccountinginformation("********"); when create connection in netbeans generates following persistence.xml file: <?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3....

php - Multiple databases with prefixes -

i novice zend framework 2 , doctrine developer. not find answers problems described below. i using multiple databases 1 website. example there users database user details , database statistics. it's possible there statistics user there relations (constrains) between both databases. previous projects used 1 configuration file , 1 class/directory entities (for 1 db). how can use multiple databases in 1 project correct table relations? how/where should store database configuration? how/where should store entities? in same project use multiple versions of databases (develop, testing, production) want use prefixes database name. example dev _users , tst _users. think should use prefix configuration file , use somewhere prefix databases. how should prefix databases? at last curious how other people use database entities when have multiple modules using them. how can use multiple databases in 1 project correct table relations? doctrine uses 1 entity manag...

postgresql - Postgres pg_trgm not working -

i'm new on postgres, i'm working project necessary check text similarity. found pg_trgm module have several functions work with. i've installed postgres + contrib package on ubuntu, can't have similarity , other. mydb=# create extension pg_trgm; error: extension "pg_trgm" exists mydb=# \dx list of installed extensions name | version | schema | description ---------+---------+------------+------------------------------------------------------------------- pg_trgm | 1.0 | extensions | text similarity measurement , index searching based on trigrams plpgsql | 1.0 | pg_catalog | pl/pgsql procedural language (2 rows) mydb=# select similarity('hello','hell'); error: function similarity(unknown, unknown) not exist line 1: select similarity('hello','hell'); ^ hint: no function matches given name , argume...

Breadth-First Search Algorithm JAVA 8-puzzle -

im trying implement breadth-first algorithm 8 puzzle game. know not new case , theres bunch of solutions on web, want make on way of thinking. this code finds node result, 123 456 780 but takes 350,000 steps it! any thoughts appreciated! =) //this method receives collection of `nodo` objects, each 1 checked , compare finalgoal public void percorrenodos(collection<nodo> nodosbase) { //in class have array has ids os nodes has been checked //the id of node, representation: 123456780, 354126870 , etc.. system.out.println("idspercorrido.size() = " + idspercorridos.size()); //check if collection nodosbase contains finalgoal iterator<nodo> iterator = nodosbase.iterator(); while( iterator.hasnext() ) { nodo nodobase = (nodo) iterator.next(); //if current node has been checked, dont h...

java - JRuby Warbler not creating usable executable JAR files -

i've been trying jruby script simple in nature requires net::ssh perform task on remote computer , exit. when issue command jruby testssh.rb , program works flawlessly, however, when use warbler compile jar, receive errors not being able load net::ssh. > java -version java version "1.7.0_45" java(tm) se runtime environment (build 1.7.0_45-b18) java hotspot(tm) 64-bit server vm (build 24.45-b08, mixed mode) > pik use jruby-1.7.1 > jruby -s warble jar c:/ruby/jruby-1.7.10/lib/ruby/gems/shared/gems/rawr-1.7.0/lib/zip/zip.rb:28: use rbconfig instead of obsolete , deprecated config. rm -f test-ssh.jar creating test-ssh.jar > java -jar test-ssh.jar loaderror: no such file load -- net/ssh require @ org/jruby/rubykernel.java:1085 require @ file:/c:/users/user/appdata/local/temp/jruby4935218336857439685extract/jruby-stdlib-complete-1.7.11.jar!/meta-inf/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55 (root) @ test-ssh.rb:7 load @ o...

How to Configure Google Translate API v2 on localhost -

i trying translate text on basic webpage created on localhost however, keep receiving access not configured. please enable google api error. have enabled translate api in google developer account, created both server , browser api key (any suggestions on should add in referers great thanks, screen dump link underneath may option). i wondering if there alternative way can api v2 work on localhost machine? please see screen dump link error. here on website, trying translate uk word on google.com, translate api v2 enabled , browser key running in background of application using process, uk word should translate language of choice, however, shown below, error pops up. here link shows screen dump any 1 can me issue, or if have further questions please let let me know? assistance appreciated. thanks

javascript - jQuery 'on mousemove' not slide when mouse out of the frame -

i want make slider jquery. when pulled out frame "sildercontainer", "sliders" stop moving , when returned through "slidercontainer", "slider" move again. want how "slider" still moving when pulled mouse out of frame. here code: <style> body{ padding:60px; height:800px; } .slidercontainer{ //position:relative; width:200px; background-color:#ccc; height:30px; margin-top:16px; cursor:pointer; } .slider{ position:absolute; width:50px; height:30px; background:#fa565a; float:right; } </style> </head> <body> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script> $(document).on('ready', function(){ function moveslider(e){ e.preventdefault(); ...

Selenium how to work with safari Cookies -

i try work selenium , have problem cookies return cookie equals null in method findcookie, google chrome , firefox works good public void setcookie(string cookiename, string cookievalue) { var cookie = new cookie(cookiename, cookievalue); driver.manage().cookies.addcookie(cookie); // driver.manage().cookies.addcookie(new cookie(cookiename, cookievalue, "/")); } public string findcookie(string cookiename) { var cookienamed = driver.manage().cookies.getcookienamed(cookiename); if (cookienamed == null) return null; return cookienamed.value; } how can works cookie safari?

python - AttributeError: 'str' object has no attribute 'regex' -

working legacy django 1.3.1 , having problem in using url name patterns in template. urls.py : urlpatterns = patterns( 'project.views', url(r'^web/login/', 'login', name="web_login"), ) in views rendering template like: return render_to_response('index.html', context_instance=requestcontext(request)) in template using url naming pattern like <form id="loginform" action="{% url web_login %}" method="post"> getting error while rendering template attributeerror: 'str' object has no attribute 'regex' you forgot quote marks. action="{% url 'web_login' %}"

hibernate - @OneToOne not deleted referred element on change -

i have @onetoone unidirectional relation between parent , child . when parent being merge want delete child , when provided child object different existed in database. relation in parent class: @onetoone(fetch = fetchtype.eager, cascade = cascadetype.all, orphanremoval = true) @joincolumn(name = "object_id") private child child;

Regex validation with decimal -

working on regex validation, validate xx,xx. mine regex can write 2,233 , still go through: 'regex:/[\d]{1,2},[\d]{2}/', maybe should add start , end limits follows: 'regex:/^\d{1,3},\d{2}$/' demo: http://regex101.com/r/qw1cv2

sql - Why does speed increases when updating datetime column with index -

i have sql server 2014 ctp2 database table datetime column called expirationdate has non-unique, non-clustered index. the index creation statement is: create index ix_expirationdate on my_table (expirationdate); my c# application (self-hosted wcf service) uses ado.net select & update queries my_table table. i created test application performs following scenario: select 1 item database select top (1) id, expirationdate, ... my_table (nolock) status = 1 , ... order my_table.expirationdate asc change item in test application item.status = 2; item.expirationdate = datetime.now.addhours(2); update item in database update my_table set expirationdate = @expirationdate, status = 2, ... (my_table.id = @id); i have 2 cases in application: change expirationdate in test application before database update not change expirationdate in test application before database update i run test application 10000 items in database , results show first case 4x faste...

html - How do I make my footer stick to the bottom of the page? -

i have been playing around content in order achieve desired effect footer not @ bottom of page below content. fixed @ bottom of page, overlaps navigation bar running down left hand side. have main body of content inside div - main container, footer outside of this. html footer: <div class="footer"> <div class="footercontent"> <p>copyright &copy; 2014 <a href="#" title="danielparry">www.danielparry8.com</a></p> </div> </div> css footer: .footer { width: 100%; z-index:999; bottom:0; clear:both; position:fixed; } .footercontent { font-family: sans-serif; color: #fff; float:left; width:100%; margin-top: 10px; margin-bottom: 10px; } .footer p { float:left; width:100%; text-align:center; } i understand fixed positioning not method use, when use other methods rises towards top of page, , still overlaps content. all content inside main content div ...

android - Espresso - Click by text in List view -

i trying click on text in list view using espresso. know have this guide , can't see how make work looking text. have tried espresso.ondata(matchers.allof(matchers.is(matchers.instanceof(listview.class)), matchers.hastostring(matchers.startswith("asdf")))).perform(viewactions.click()); as expected, didn't work. error said no view in hierarchy. know how select string? ( "asdf" in case) in advance. update due @haffax i received error: com.google.android.apps.common.testing.ui.espresso.ambiguousviewmatcherexception: 'is assignable class: class android.widget.adapterview' matches multiple views in hierarchy. second error with code ondata(hastostring(startswith("asdf"))).inadapterview(withcontentdescription("maplist")).perform(click()); i error com.google.android.apps.common.testing.ui.espresso.performexception: error performing 'load adapter data' on view 'with content description: ...

javascript - Retrieve label HTML from node -

i have node of spacetree graph (from jit library) , i'd modify html of label in click listener. trivial if had reference label object passed parameter onplacelabel() , oncreatelabel() functions, cannot find way reference. there easy way of obtaining reference node object? i figured out. can the label of node using st.labels.getlabel(node.id) assuming st spacetree object , node node label.

java - Why can't i use keyPressed anymore once the if-statement is true in the run()-methode? -

i'm trying make kind of brickbreaker game once press start button ("starten" = true). can't use keypressed()-utility anymore before pressed start button use keypressed()-utility. please tell me why can't use keypressed()-utility anymore , give me possible solution too? import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class vgkernel extends jpanel implements keylistener { public rectangle screen, ball, block; // screen area , ball location/size. public rectangle bounds; // boundaries of drawing area. public jframe frame; // jframe put graphics into. public vgtimertask vgtask; // timertask runs game. public boolean down, right, starten = false; // direction of ball's travel. public jbutton start; public vgkernel(){ super(); screen = new rectangle(0, 0, 600, 400); ball = new rectangle(0, 0, 20, 20); block = new rectangle(260, 350, 40, 10); bounds = new rectangle(0, 0, 600, 400); // give ...

kineticjs - Tap and Drag events not working on objects inside a clipped layer -

i have layer->group->shape. group , shape both draggable , have applied tap event on shape. i can drag around group touch events don't work on shape if clip layer. mouse events work fine on shape, works on pc browser, clipped layer. wrong here? update: happens on ipad retina. works on ipad non-retina.

php - Lavarel Error : ErrorException Missing argument 1? -

i using laravel 4 , getting error: when visit admin/profile/: missing argument 1 admincontroller::getprofile() my admincontroller code : public function getprofile($id) { if(is_null($id)) redirect::to('admin/dashboard'); $user = user::find($id); $this->layout->content = view::make('admin.profile', array('user' => $user)); } my routes.php : route::controller('admin', 'admincontroller'); my admin/profile (blade) view : @if(!is_null($user->id)) {{ $user->id }} @endif how fix / want when go admin/profile without ($id) redirect dashboard? please help!!! try setting default null value $id : public function getprofile($id = null) { ... }