Posts

Showing posts from August, 2013

javascript - Delivering precompiled Handlebars Template on demand via JSON -

i want deliver handlebars templates ember.js application on demand via ajax -request. i'm able compile on server , i'm able deliver following output ( function ) string : ember.templates["authentication"] = ember.handlebars.template(function anonymous(handlebars,depth0,helpers,partials,data) { this.compilerinfo = [2,'>= 1.0.0-rc.3']; helpers = helpers || ember.handlebars.helpers; data = data || {}; var buffer = '', stack1, hashtypes, options, helpermissing=helpers.helpermissing, escapeexpression=this.escapeexpression; data.buffer.push("<h1>hooray! works!</h1>\r\n"); hashtypes = {}; options = {hash:{},contexts:[depth0],types:["id"],hashtypes:hashtypes,data:data}; data.buffer.push(escapeexpression(((stack1 = helpers.outlet),stack1 ? stack1.call(depth0, "main", options) : helpermissing.call(depth0, "outlet", "main", options)))); return buffer; }); this string i'

jsf - rich:scrollableDataTable with a 2 row header -

i'm developping scrollabledatatable header having 2 row in it. <rich:scrollabledatatable ... <rich:column...> <f:facet name="header"> <s:div> <h:panelgrid columns="1"> <h:outputtext value="hi" /> <h:outputtext value="all" /> </h:panelgrid> </s:div> </f:facet> ... </rich:column> but see 'hi' on video. in html produced see both rows, infact looking better in html code using web-browser-debug (f12) see header of column has height fixed 20px or 21px. to see second header-row must enlarge changing (using web-browser-debug): .rich-sdt-header-cell-body (height : 40px) gridbodytemplate (top: 42px) header:normalbox (height: 42px) gridheadertemplate (height: 42px) how can in xhtml? other scrollabledatatable&columns have header composed 1 row (and goes me). need, in 1 situation, have header more taller. possible, , how? thanks!

c# - Local NuGet - Notify on newer package? -

i running local nuget on our network folder/share. the official nuget source notifies me if there newer release of package i'm using, it's not work locally. can receive new releases via 'package manager console' , 'manage nuget packages'. is possible receive update notifcations locally or there reason why nuget not notifying me locally? i didn't found way nuget notifies me when using local network folder. easiest way use private gallery , ci server teamcity

java - System.out.println() and BufferedReader mixing up output in console -

i working on program, uses bufferedreader read input, , system.out.println() output. here code: public void choosemethod() throws ioexception{ int in = 0; while(true){ system.out.println("what want do? (0 exit, 1 read bank account, 2 write bank account, 3 read bill, 4 write bill): "); in = integer.parseint(cin.readline()); if(in == 0){ break; }else if((in < 0) || (in > 4)){ system.out.println("invalid choice."); }else if(in == 1){ showbankaccount(); }else if(in == 2){ insertbankaccount(); }else if(in == 3){ showbill(); }else if(in == 4){ insertbill(); } } dbm.close(); } public void insertbankaccount() throws ioexception{ int banknr = 0; int sortcode = 0; int accountnumber = 0; int balance = 0; int interest = 0; string details; string name; while(

osx - modify PackageMaker installer variables from a script -

i attempting create mac os x installer (tried both packagemaker , packages) 2 things on install: check if application installed (by looking through folder structure in applications directory) , set component selections accordingly. setting destination folder of package according folder found in 1. plugin needs go subdirectory of application folder. the former seems it's relatively simple, can add script requirement choice associated each package , let result drive state of component checkbox. the latter feels tricky. know how figure out location of application first step, have no idea whatsoever of how change destination folder that's set in package. can somehow access installer variables preflight script? the idea have installing temp directory , moving stuff in post flight script, seems error prone , awkward. rule out possibility make installation paths editable (in case user has several instances of software we're plugging installed , picked wrong one).

iphone - KVC vs fast enumeration -

which of following faster , why? cgfloat sum = 0; (uiview *v in self.subviews) sum += v.frame.size.height; or cgfloat sum = [[self.subviews valueforkeypath:@"@sum.frame.size.height"] floatvalue]; really, lot of how elegant (or clever) language comes down how avoids loops. for, while; fast enumeration expressions drag. no matter how sugar-coat them, loops block of code simpler describe in natural language. "get me average salary of of employees in array", double totalsalary = 0.0; (employee *employee in employees) { totalsalary += [employee.salary doublevalue]; } double averagesalary = totalsalary / [employees count]; versus... fortunately, key-value coding gives more concise--almost ruby-like--way this: [employees valueforkeypath:@"@avg.salary"]; kvc collection operators allows actions performed on collection using key path notation in valueforkeypath: . any time see @ in key path, denotes particular aggregate funct

Will this CUDA code execute in-order and asynchronously? -

will code below execute in order? (i cannot put device-to-device copy of cudamemcpy2darraytoarray() in stream ) will code below execute asynchronously? ( cudamemcpy2darraytoarray() not have asynchronous counterpart) i know code sample can implemented more efficiently, it's merely intended example. for( i=0; i<10; i++ ) { cudamemcpy2darraytoarray( dst, src ); // device device copy. cudabindtexturetoarray( texture_reference, dst, ... ) // bind dst texture. kernel<<< dimgrid, dimblock, 0, stream >>>( out ) // compute array. cudamemcpy2dtoarrayasync( src_p, out, stream ) // copy result src. } since kernel calls , cudamemcpy2dtoarrayasync calls use same stream, processed synchronously. 1 streams can't multiple things @ same time. however, if wanted multiple streams work, of form: nstreams = 8; cudastream_t streams [nstreams ]; (unsigned int ii = 0; ii < nstreams; ++ii) handle_e

class - c++ segmentation fault when copying a matrix -

i'm having problem matrix, , problem when try copy it gives me error 'segmentation fault'. code involved: main.cpp void principal(tauler &tauler) { generadorpuzzle puzzle; pilamoviments pilamovs; int npuzzle, cont=0; bool valid; cout << "joc del rush hour" << endl; cout << "entra el puzzle jugar:" << endl; cin >> npuzzle; valid=puzzle.espuzzlevalid(npuzzle); if(!valid) { { cout << "puzzle no valid. entra el puzzle jugar:" << endl; cin >> npuzzle; valid=puzzle.espuzzlevalid(npuzzle); }while(!valid); } puzzle.posarpuzzleactiu(npuzzle); tauler=tauler(puzzle.midapuzzle(),puzzle.totalvehicles()); for(int i=0;i<puzzle.totalvehicles();i++) { vehicle v(cont, puzzle.midavehicle(i),puzzle.filavehicle(i),puzzle.columnavehicle(i),puzzle.direcciovehicle(i)); valid=tauler.esva

php - Can I use a variable as table name in a MySQL query? -

i want mysql query variable table. here i'm looking for: mysql_query("select * $var $anothervar ='1'")) how can this? first of all, stop using mysql_ functions. have been deprecated. check out mysqli or pdo . when using php query database can build entire query please. can type out full query or add variables more dynamic queries. did correct (except double parenthese on right). <?php $query = "select * users id ='1'"; //the above same $var = 'users'; $anothervar = 'id'; $query = "select * $var $anothervar ='1'"; //execute query. ?> so yes, can use variable table name when constucting query in php. need keep in mind variables use can lead sql injection. if getting values table , column names user input, make sure validate them properly! simply using mysql_real_escape_string() or mysqli_real_escape_string() not work on table , column names, because not enclosed in quotes. vote

Facebook Graph API error: Application must be whitelisted or users must be testers -

applications can invite users group issuing post request /group_id/members/user_id app access_token. when user tester works fine. if try non tester error message: (#3) application must whitelisted or users must testers. anyone idea means? cannot find error message anywhere. regards, roy i think application proably in sandbox mode. try change in app settings , think help. best regards chris

php - AJAX value sending error -

hi have problems script below. problem think lies on data need sent php via ajax. jquery $('.send').live("click", function(){ $.ajax({ url:'foobar.php', type:'post', data: 'id=' + $(this).attr('id'), datatype:'json', contenttype: 'application/json; charset=utf-8', success: function(data) { switch (data.status) { case "a": alert(data.text); break; case "b": alert(data.text); break; } }, error: function(xmlhttprequest, textstatus, errorthrown) { alert ("error: "+textstatus); } }) } and, php $id = $_request['id']; switch ($id) { case "foo": $data["status"] = "a";

performance - python script keeps using 120% CPU -

i'm having issue websocket script. on time consumes more , more cpu. 1 remedy i've discovered clear associated logfile. resolves problem little while, cpu usuage builds 120% in little on day or so. (using top command on linux server) the part of script file write looks bit odd me. here code: f = open(file, 'a') f.write(line+"\n") os.fsync(f.fileno()) f.flush() f.close i'm not python expert, starters, last 3 things rather same in opinion. python manual states http://docs.python.org/2/library/os.html#os.fsync f.flush , os.fsync should in reverse order... can use: f = open(file, 'a') f.write(line+"\n") f.close and should not be: f.close()?? any ideas? use open (and automatically close) files: with open(filename, 'a') f: f.write(line+"\n")

When we use 'notEmpty' and 'blank' model validation rules in cakephp? -

while doing validation..i question in mind " when use notempty , blank model validation rules? ". goggled there no clarification. please clarify example. thank in advance. 'blank' - must empty or whitespace characters. 'notempty' - cannot empty all of information explained in cakephp book under "validation": http://book.cakephp.org/2.0/en/models/data-validation.html

jquery - Safari browser ajax request error -

i'm making ajax request generic handler handler.ashx , forwards request rest service in domain. handler used achieve cross-domain call. data in firefox & chrome. not in safari on windows 7(ver. 5.1.7) $.ajax({ url: 'handler.ashx', type: 'get', contenttype: 'application/json; charset=utf-8', datatype: 'json', async: false, timeout: 20000, data: data, success: function (received_data) { // process data }, error: function (err) { console.log(err); } }); my handler.ashx code: httpwebrequest req = (httpwebrequest)webrequest.create(new uri("http://xxx.xxx.xx.xxx/mywebservice/service.svc/downloadfile")); req.contenttype = "application/json; charset=utf-8"; req.timeout = 60000; using (webresponse resp = req.getresponse()) { streamreader reader = new streamreader(resp.getres

php - Selection list populated from database -

i have been having problem trying figure out how create selection list populated data table in database, namely options being customer's last names. here have tried: i trying make selection list access table "customer" , fields "customerid" appreciated, if more information needed ask. you messing in quotes. try below. $options .= "<option value='" . $id ."'>" . $name ."</option>"; and use like, <select> <option value=0>choose</option> <?php echo $options; ?> </select>

django is there a way to annotate nested object? -

i have following situation. have 3 models, post, user , friends. class user(models.model): name = models.charfield(max_length=100) class friend(models.model): user1 = models.foreignkey(user,related_name='my_friends1') user2 = models.foreignkey(user,related_name='my_friends2') class post(models.model): subject = models.charfield(max_length=100) user = models.foreignkey(user) every time bring users, want bring number of friends: user.objects.filter(name__startswith='joe').annotate(fc=count('my_friends1')) this works fine. however, want make work when bring users nested objects of post. i'm using there select_related minimized db calls, want like: post.objects.filter(subject='sport').select_related('user').annotate(user__fc=count('user__my_friends1')) however, creates field user__fc under post, , not field fc under post.user . there way achieve functionality? you can define custom mange

c# - StyledStringElement 'Tapped' event -

so, attempting open email interface when user clicks on 'styledstringelement' - have been calling tapped event yet have gained error - "error cs1502: best overloaded method match `monotouch.dialog.section.add(monotouch.dialog.element)' has invalid arguments (cs1502)" and "error cs1503: argument #1' cannot convert void' expression type `monotouch.dialog.element' (cs1503)" the code using - section.add(new styledstringelement("contact email",item.email) { backgroundcolor=uicolor.fromrgb(71,165,209), textcolor=uicolor.white, detailcolor=uicolor.white, }.tapped += delegate { mfmailcomposeviewcontroller email = new mfmailcomposeviewcontroller(); this.navigationcontroller.presentviewcontroller(email,true,null); }); what causing error , how can fix it? you need initialize "styledstringelement" separately for exa

plugins - NSIS Invalid command: ShellExecAsUser::ShellExecAsUser -

when try use shellexecasuser plugin nsis, following error. invalid command: shellexecasuser::shellexecasuser this started happen after upgraded nsis script compiler, guess helpfully changed how makensis searches plugins. you need use !addplugindir compiler utility command, tells nsis plugin.

database - i used the program SQL Fiddle and it keeps telling me that the table doesn't exist,what can i do to fix the two tables referencing each other? -

the staff table references branch table create table staff( staffno varchar(5) not null, firstname varchar(15) not null unique, lastname varchar(15) not null, position varchar(10) not null, salary integer default 3000, check (salary between 3000 , 25000), email varchar(25), branchno char(6) not null, primary key (staffno), foreign key (branchno) references branch (branchno)); and @ same time branch table references staff table create table branch( branchno char(6) not null primary key, street varchar(30) not null, city varchar(20), postcode char(5) not null, managerno varchar(5) not null, foreign key (managerno) references staff(staffno)); since tables reference each other in foreign keys error on either table creation if other table has not been created yet. suggest remove creation of foreign keys separate alter table statements: create table staff( staffno varchar(5) not null, firstname varchar(15) not null unique, lastname varchar(15) not null, position

ruby - Why do I get a cross-site scripting warning with Rails? -

in rails application's view template have assign instance value coffeescript variable. did this: :coffeescript 44 @selected_tab = "#{@tab}" it works fine, getting cross-site scripting warning: unescaped parameter value (around line 44) find_and_preserve(haml::filters::coffee.render_with_options("@selected_tab = "#{params[:tab]}" ", _hamlout.options)) i think you'd better off not inserting variables directly coffeescript. check out these methods: http://railscasts.com/episodes/324-passing-data-to-javascript

What is the difference between operator() and operator< in C++? -

whenever have c++ entities want compare implement operator< . however, reading other people's code saw same can achieved implementing operator() . what difference between two? when should each of these operators used? operator< canonical way define comparison operator: struct { /* members */ }; struct b { /* members */ }; // comparison operator bool operator<(const a&, const b&); this gives conventional usage: int main() { a; b b; const bool result = (a < b); } what you've seen people creating functors ; is, entire classes sole purpose wrap comparison. make these bit functions calling code, use operator() : struct { /* members */ }; struct b { /* members */ }; // comparison functor struct comparator { bool operator()(const a&, const b&); }; this gives less conventional usage in code equivalent previous example: int main() { a; b b; comparator c; const bool result = c(a,b); } however, wou

android - values fetched from database are not going to edit -

i developing database app. succeeded in inserting data data not going edit . following editing class please solve problem.... import java.util.calendar; import com.smartwallet.database.dbadapterdlicense; import android.app.activity; import android.app.datepickerdialog; import android.app.dialog; import android.database.cursor; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.datepicker; import android.widget.edittext; import android.widget.toast; public class edit_dlicense extends activity implements onclicklistener { private edittext et_cnm,et_idt,et_edt,et_lno,et_add,et_cno,et_ltype; private button bt_add; private long dlid; private cursor c; private int myear,mmonth, mday; static final int date_dialog_idi = 0; static final int date_dialog_ide = 1; private string imei_id; private datepickerdialog.ondatesetlistener mdatesetlisteneri; private datepickerdialog.ondatesetlistener m

makefile - One child process per for loop in make? -

let me first write quick makefile showcase: #!/bin/make -f folders := $(shell find -mindepth 1 -maxdepth 1 -type d -print) make_dir: @mkdir -p "test0" pwd_test: @cd "test0" && pwd @pwd pwd_all: @for f in $(folders); \ cd "$${f}" && pwd; \ pwd; \ cd ..; \ done first make make_dir , see different results: ➜ make pwd_test /data/cache/tmp/so/test0 /data/cache/tmp/so ➜ make pwd_all /data/cache/tmp/so/test0 /data/cache/tmp/so/test0 you see in loop necessary cd .. . apparently, there no child process spawn cd x && pwd command, while case. behaviour specific make or specific shell? make spawns new process each command in rule. since loop 1 command 1 process. take @ recipe execution edit: each line in makefile gets own subshell. commands have \ tells make next line should part of current line. the reason loop own subshell because make see line @for f in $(

I am using devise and cancan gems. When I sign_in I get redirect back to sign_in page -

here log started post "/users/sign_in" 127.0.0.1 @ 2013-05-02 09:57:19 -0400 processing devise::sessionscontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"abc=", "user"=>{"email"=>"xyz@abc.com", "password"=>"[filtered]", "remember_me"=>"0"}, "commit"=>"sign in"} user load (0.1ms) select "users".* "users" "users"."email" = 'xyz@abc.com' limit 1 completed 401 unauthorized in 9ms processing devise::sessionscontroller#new html parameters: {"utf8"=>"✓", "authenticity_token"=>"xyz=", "user"=>{"email"=>"xyz@abc.com", "password"=>"[filtered]", "remember_me"=>"0"}, "commit"=>"sign in"}

mysql - using BETWEEN operator twice in one SQL statement -

this have tried, did not work. select count(*) month_count `wp_postmeta` `meta_key`='from_dt' , (`meta_value` between '$st' , '$end') , (`meta_value` between '$st1' , '$end1'); i'm trying count number of months come between epoch time of $st , $end of year & between $st1 , $end1 of next year. have 2 dates (feb 2013 , feb 2014)in meta_value fields, want query return 2(as there 2 february's). how use 2 between operators in 1 sql statement? nothing technically wrong query, depending on desired results, want using or -- make sure parentheses in correct place: select count(*) month_count `wp_postmeta` `meta_key`='from_dt' , ((`meta_value` between '$st' , '$end') or (`meta_value` between '$st1' , '$end1')) your current query requiring meta_value between both sets of numbers may problem.

c# - ToolBartray.Orientation = vertical and width of toolbar -

i have problem width of toolbars in toolbartray if set orientation vertical. width has minimum size of overflow item. i want toolbar width has size of first button. <toolbartray orientation="vertical" dockpanel.dock="left" > <toolbar> <button content="ii" /> <button content="iizzuzzuzuz" toolbar.overflowmode="always"/> </toolbar> </toolbartray> how can that? has same problem? kind regards, kevin

c# - Passing an array within a structure in CUDAfy -

using vs 2012, .net 4.5, 64bit , cudafy 1.12 , have following proof of concept using system; using system.runtime.interopservices; using cudafy; using cudafy.host; using cudafy.translator; namespace test { [cudafy(ecudafytype.struct)] [structlayout(layoutkind.sequential)] public struct childstruct { [marshalas(unmanagedtype.lparray)] public float[] farray; public long farraylength; } [cudafy(ecudafytype.struct)] [structlayout(layoutkind.sequential)] public struct parentstruct { public childstruct child; } public class program { [cudafy] public static void kernelfunction(gthread gthread, parentstruct parent) { long length = parent.child.farraylength; } public static void main(string[] args) { var module = cudafytranslator.cudafy( eplatform.x64, earchitecture.sm_35, new[] {typeof(childstruct), typeof(parentstruct), typeof(program)}); var dev = cudafyhost.getdevice(); dev.loadmodule(modul

java - Get word part from a variable String -

i've been implementing application retrieve word inside incoming string parameter, string parameter can vary since url, pattern incoming url's same. instance have: get /com.myapplication.v4.ws.monitoring.modulesystemmonitor http/1.1 or get /com.myapplication.filesystem.ws.modulefilesystem/getidfolders/jsonp?idfolder=idfis1&callback=__gwt_jsonp__.p0.onsuccess&failurecallback=__gwt_jsonp__.p0.onfailure http/1.1 so in case, want extract word starts module, example, first incoming parameter want get: modulesystemmonitor. , second 1 want word: modulefilesystem. this requirement, i'm not allowed else this: method receives line , try extract words mentioned: modulesystemmonitor , modulefilesystem. i've been thinkng of using stringtokenizer class or string#split method, i'm not sure if best option. tried , easy word begins module using indexof, how cut word if cases comes white space first sample or comes "/" (slash) in second. know can m

Excel Password and carving out Tab name -

i'm in process of setting macro open files in directory , copy tab each combined file (merge them in 1 workbook). have 2 problems. firstly files password protected - when use line opens file. set gwkbinputdata = workbooks.open(grnct_file_loc & gsinputfilename) however when it's password protected fails. added following end still fails. set gwkbinputdata = workbooks.open(grnct_file_loc & gsinputfilename),password = "openfile" 2nd issue - when copy tabs (sheets) in want name them file name took them from. file name long - want take name first space (e.g. "test file may 13" = sheet name "test"). how code work. any appreciated. full code below: * grnct_file_loc = directory location. * gsinputfilename = file name. code date: sub pulldata() application.screenupdating = false application.displayalerts = false set grwksconfigeration = sheets(gcsconfigsheetname) grnct_file_loc = grwksconfigeration.range(ct_file_loc) grnc

How to create unique constraints using hibernate for an existing table -

i have existing table in database , want update table adding unique constraints it. i have updated model class appropriate annotations related unique constraints. now, if call localsessionfactorybean.updatedatabaseschema() method, unique constraints not created, when first drop table , call localsessionfactorybean.updatedatabaseschema() method creates unique constraints in table. how can create unique constraints existing table using hibernate without dropping table? also let me know whether feasible in hibernate or not?

javascript - Google Maps API Circle Icons -

i trying make map using google maps api , red dot icons (aka earthquake icons). i have several locations , several magnitudes, since of magnitudes lower therefore not visible red dot icons apply locations. var marker1; var marker2 (var = 0; < locations.length; i++) { if (locations[i][3] > 5){ alert("i in");} marker1 = new google.maps.marker({ position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map, icon: getcircle(locations[i][3]) }); if(locations[i][3] < 5){ marker2 = new google.maps.marker({ position: new google.maps.latlng(locations[i][1], locations[i][2]), map: map, animation: google.maps.animation.bounce }); } google.maps.event.addlistener(marker, 'click', (function(marker, i) { return function() { infowindow.setcontent(locations[i][0]); infowindow.open(map, marker1); } })(mar

Logging Spring using Log4j2 -

i'm trying use log4j2 print spring logs file , console. guess problem in log4j2 configuration. have not been able working. have configuration in log4j2.xml file: <?xml version="1.0" encoding="utf-8"?> <configuration name="defaultconfiguration" status="warn" strict="true" monitorinterval="5"> <properties> <property name="patternlayout">%d{iso8601} [%t] %-5level %logger{36} - %msg%n%throwable{full}</property> <property name="filename">${env:my_root}/logs/mylog.log</property> <property name="filenamepattern">${env:my_root}/logs/mylog-%d{yyyy-dd-mm}-%i.log.gz</property> </properties> <appenders> <appender name="console" type="console" target="system_out"> <layout type="patternlayout" pattern="${patternlayout}" /&

c++ - Display multiple OpenCv IplImages over VLC Video Output -

i'm trying send multiple frames (previsously taken actual video file) via socket (c++) play vlc. i've searched lot , didn't find solution. hope can me. so, code: #include <stdio.h> #include <stdlib.h> #include <direct.h> #include <iostream> #include <winsock2.h> #include <windows.h> #include <iostream> #include <string.h> #include <time.h> #include <errno.h> //#include <fstream> #include <opencv2/core/core.hpp> // basic opencv structures (cv::mat, scalar) #include <opencv2/highgui/highgui.hpp> // opencv window i/o using namespace std; #define port 6666 #define group "127.0.0.1" //#define inaddr_any int serversock, clientsock; int is_data_ready = 0; struct sockaddr_in server, client; int bytes = 0; int count = 0; int addrlen = sizeof(server); int clielen = sizeof(client); int opt = 1; //methods void quit(char* msg, int retval); void quit(char* msg, int retval) {

JPA/Hibernate duplicate records -

i have one-to-many relationship between entities. when doing jpql query: select parent parent parent join parent.child child ... i duplicate records when parent has 2 children, 1 when parent have 1 child, none when there no child (none when no child fine). note there no duplicate of parent in sql database. the entities declared follow: @entity(...) public class parent { @id long parentid; @onetomany(mappedby = "parentid") list<child> children; } @entity(...) public class child {a long parentid; } i omitted lot of code brevity's sake, should give strong idea of trying do. note relationship defined on parent's side because need list of parents along children returned query. you can rid of duplicates using distinct keyword: select distinct parent parent parent join parent.child child ... edit: distinct keyword used remoe duplicates query results regardless of teh reason existence of these duplicates. reason dupli

java - Regular expression on a string -

i have string below string phone = (123) 456-7890 now program verify if input same pattern string 'phone' i did following if(phone.contains("([0-9][0-9][0-9]) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]")) { //display pass } else { //display fail } it didn't work. tried other combinations too. nothing worked. question : 1. how can achieve without using 'pattern' above? 2. how pattern. tried pattern below pattern pattern = pattern.compile("(\d+)"); matcher match = pattern.matcher(phone); if (match.find()) { //displaypass } string#matches checks if string matches pattern: if (phone.matches("\\(\\d{3}\\) \\d{3}-\\d{4}")) { //displaypass } the pattern regular expression. therefor had escape round brackets, have special meaning in regex (they denote capturing groups). contains() checks if string contains substring passed it.

formatting sql server PRINT messages? -

i have following print statement print details not tabbed , looks awful. there way print them in tabbed format meet @ same place in end of line. print'bylineid: '+ convert (varchar,@bylineid,1 )+' , '+ convert(varchar,@count,1)+ ' matching records found, '+ convert(varchar,@@rowcount,1)+' updated.' end result: bylineid: 119952 , 168 matching records found, 0 updated. bylineid: 93979 , 56 matching records found, 0 updated. bylineid: 266021 , 45 matching records found, 0 updated. bylineid: 105976 , 44 matching records found, 0 updated. bylineid: 97525 , 40 matching records found, 0 updated. bylineid: 94138 , 39 matching records found, 0 updated. bylineid: 88967 , 37 matching records found, 0 updated. print 'bylineid: '+ convert (varchar,@bylineid,1 ) + char(9) + ' , ' + convert(varchar,@count,1) + char(9) + ' matching records found, ' + convert(varchar,@@rowcount,1) + cha

Python Neural Network Backpropagation -

i'm learning neural networks, looking @ mlps back-propagation implementation. i'm trying implement own network in python , thought i'd @ other libraries before started. after searching found neil schemenauer's python implementation bpnn.py. ( http://arctrix.com/nas/python/bpnn.py ) having worked through code , read first part of christopher m. bishops book titled 'neural networks pattern recognition' found issue in backpropagate function: # calculate error terms output output_deltas = [0.0] * self.no k in range(self.no): error = targets[k]-self.ao[k] output_deltas[k] = dsigmoid(self.ao[k]) * error the line of code calculates error different in bishops book. on page 145, equation 4.41 defines output units error as: d_k = y_k - t_k where y_k outputs , t_k targets. (i'm using _ represent subscript) question should line of code: error = targets[k]-self.ao[k] be infact: error = self.ao[k] - targets[k] i'm wrong clear confusion pl

Has Paypal changed or stopped using the https://fpdbs.paypal.com/dynamicimageweb link to display Paypal buttons? -

i getting broken image when try https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamicimage . this error message comes back: "exception while trying build protected config application" , "failed load cdb file /x/web/live6-nonversioned-640-20100706-1/web/fpdbs.paypal.com/cgi-bin/protected//client_sessions.cdb" this raw output: handler_cmd=_dispatch-failed&reason=exception%20while%20trying%20to%20build%20protected%20config%20for%20application%3a%20asf%3a%3aconfigureexception%3a%20failed%20to%20load%20cdb%20file%3a%20/x/web/live6-nonversioned-640-20100706-1/web/fpdbs.paypal.com/cgi-bin/protected//client_sessions.cdb%20backtrace%3a%2083e58fd%2083d1495%208425b41%20846a2af%2084627cf%208462cc5%20843154f%208058f51%208087926%208090902%2080654fc%20f6bbfe9c%2080578e1&failed_application=dynamicimageweb correct there issue this. working towards resolving issue.

sql - PostgreSQL: How to list all available datatypes? -

question: in postgresql ( using sql, not console ), how can list available datataypes ? ideally this: http://www.java2s.com/code/postgresql/postgre-sql/displaysalldatatypesintheconnecteddatabasewithcomments.htm it should list user defined types, if there any. list in pgadmin3 define datatype new column in table. "data types" in postgresql includes primitive (built-in) types, types added extensions, user-defined composite types, domains, , table rowtypes. isn't clear of these of interest you. types available in given database listed in database's pg_catalog.pg_type may need filter results. see the documentation pg_type system catalog table . types available not installed extensions not listed. there's no way list types provided extensions not installed in current database. to prettier listing of types use psql 's \dt * command. can see underlying sql executes running psql -e flag: $ psql -e regress regress=> \dt * ********* qu

licensing - License boilerplate for research project -

my software project based in canada , part of larger university research project. in process of cleaning code , asked add comments describing each class, method, etc. have been looking writing software license boilerplate each of class files. lot of templates have seen online gnu gpl don't think appropriate project since software commercialized. is there other licensing more suitable? have never written commercial software before not know kind of licensing type of code have. i think key thing need know owns copyright on code? belong or belong university? if belongs university, ask university point of contact guidance. if agreement university says retain rights code, put simple copyright notice in there, name , year. further, want consult job know kind of thing.

ruby on rails - cattr_accessor default value syntax -

i'm bit miffed why this: cattr_accessor :aggregate { true } fails error: syntax error, unexpected '{', expecting keyword_end cattr_accessor :aggregate { true } ^ while same thing, do/end seems doing right thing: cattr_accessor :aggregate true end (but whhhay verbose ;) the source : http://api.rubyonrails.org/classes/class.html#method-i-cattr_writer bit crufty given time have spend on this. thoughts? isn't following language binding precedence? brace form has higher precedence , bind last parameter if invocation made w/o parens. do/end form has lower precedence , bind invocation without parens. if don't want write end form, need put parenthesis around call. cattr_accessor(:is_admin) { true }

php - My edit page doesnt edit the rows -

i have 2 buttons on table delete , edit data table, (data database) delete button works edit isnt working.. runs working when list data created in phpmyadmin.. here main edit code: <?php // editar um registo de user if (isset($_get['editequip']) == false) { // caso seja chamado directamente na url o ficheiro "editar.php", // este é redireccionado para o ficheiro "lista.php" header("location:javascript:history.go(-1);return false;;"); } else { $editequip = trim($_get['editequip']); } $connection = new mysqli('***', '****', '****', '****'); $obterequip = "select * fichas id_ficha '$editequip'"; $resultequip = $connection->query($obterequip); // se devolveu 0 ou mais que um utilizador, termina script if ($connection->affected_rows != 1) { header("location:javascript:history.go(-1);return false;"); exit(); } $objequip = $resultequip->fetch_object(); $id_ficha = $ob

dependency injection - What is the advantage of autowiring in spring -

what advantages of autowiring spring? an example of autowiring in spring like public class testclass { testmethod() { // ..... }; } public class mainclass { public static void main(string[] args) { applicationcontext ctx = new classpathxmlapplicationcontext("test.xml"); testmethod obj = (testclass) ctx.getbean("test"); obj.testmethod(); } } test.xml <bean id="test" class="testclass"> same in normal operation done using: public class mainclass { public static void main(string[] args) { testclass obj = new testclass(); obj.testmethod(); } } what advantage of spring, mean have heard terms inversion of control , dependency injection. in both examples reference of testclass used once through spring xml again through new oerator. can in simple terms explain advantage. autowiring in spring autowiring feature of spring framework enables inject ob

c++ - Why does this code generate the compiler error C2227? -

i'm working on integrating current game engine irrklang sound engine, , dealing persistent error. simplified: fscore.h class fsengine { public: static fsengine *getinstance(); static void release(); ; private: static fsengine *instance; static fsbool exists; irrklang::isoundengine *soundengine; }; fscore.cpp #include "fscore.h" void fsengine::release() { exists = false; delete instance; soundengine->drop(); //c2227 }; the engine being declared correctly, , singleton performing expected. ideas? explanation of c2227 can found here: compiler error c2227 . when compiler gets line: soundengine->drop(); //c2227 it tells soundengine must pointer class / struct / union in order call drop() on it. actual problem here you're trying access non-static data member static function. also note delete doesn't changes value of pointer itself, after line executed: delete instance; the value of instance

In MATLAB, why can't I compose transpose and colon operators? -

this question has answer here: how concatenate rows of matrix vector? 1 answer how can index matlab array returned function without first assigning local variable? 9 answers in matlab can vector of elements of matrix in column major order using (:) operator follows... edu>> = 1 2 3 4 5 6 edu>> a(:) ans = 1 3 5 2 4 6 however, vector of elements in row major order. figured transpose matrix before using (:). error... edu>> a'(:) a'(:) | error: unbalanced or unexpected parenthesis or bracket. why won't ' , (:) compose here? can in 2 steps prefer more concise , avoid variable. edu>> b = a' b = 1 3 5 2 4 6 edu>> b(:) ans =

json - public photo album suddenly requiring access_token -

i have been porting albums in websites below code , has stopped working. albums , photos public seems want access_token. here graph particular album: https://graph.facebook.com/483171821709416/photos here javascript i've been using: $.getjson('//graph.facebook.com/483171821709416/photos?callback=?',function(json){ $.each(json.data,function(){ $('<li></li>') .append('<span class="thumb" style="background: url(' + this.images[1].source + ') center no-repeat; background-size: 140%;"><a href=' + this.images[0].source + ' rel="gallery"></a></span>') .appendto('#album-gallery'); }); }); assuming own these photos, , indeed public, need produce page access token, has no expiry. creating app clicking button, , setting domain, no actual coding needed. go through scenario when user grants app manage_pages permission, app able obtain page access tokens

javascript - Best Approach for Configuration File for an Angular/RequireJS Application? -

is there commonly accepted best practice maintaining configuration file available on client side (sort of equivalent of appsettings section on server side in asp.net application)? our application based on angular. our desire externalize environment-specific settings (like remote system urls, etc) code itself, ideally ops person , not developer can modify settings in 1 place. thanks in advance insight! i don't think it's idea use config.js file when developing angularjs apps. reason being, break possibility automatic testing. instead, create "settings" service in specify app specific context. example: angular.module('settings',[]).factory('settingsservice',function(){ var service={}; // insert settings here service.serverpath = 'whateverwhatever'; service.imagepath = 'bla bla bal'; return service; }); then inject settingsservice controllers need access settings. ofcourse, (which omitted simpl

c++ - Create PHP P2P game client tracker -

at moment i'm looking creating networked game using p2p. game not high paced , don't have access dedicated server, p2p seems choice me. have access online domain. programming done in c++. oblivious perils of game networking thought p2p did not need sort of centralized server communication. thought 'but how on earth can find other game users hosting game without knowing ip?'. thought need kind of central 'hub' game can connect list of available peer hosts ip , port. connect host , send data using udp (i know it's connectionless, seems enet has tricks that). if idea absurd, let me know. i had idea make simple php client-ip-switch-thingy on online domain. game won't attract more 2 3 people because it's personal learning goals load on domain won't of issue, think. problem can't find usable information on making of sort using php. tried through 'similar questions' bit of so, still can't find lot of info. my question is: how c