Posts

Showing posts from July, 2011

php - Form validation - security -

so i'm working on register form , have 4 fields: name, username, email , password. pick values of these fields in jquery , depending on if fields filled, pass them onto php script via ajax. safe form validations? worried data getting manipulated user. further on in php script, check if posted values have data in them, proceed onto doing validations... validations parts i'm worried it's not best , there many flaws it. $name = $_post['name']; $username = $_post['username']; $email = $_post['email']; $password = $_post['password']; if (!preg_match("/^[a-za-z '-]+$/i", $name)) { $errors = "please enter valid name."; } else if (!preg_match("/^[a-za-z]+\s[a-za-z]+$/", $name)) { $errors = "please enter first , last name."; } else if (strlen($username) <= 3 || strlen($username) > 15) { $errors = "please pick username between 4 - 15 ch...

android - Working with JSON Arrays -

http://pastie.org/8269975 . if @ code, don't know how access individual fields account_id, hero_id, , etc. have code. jsonobject match = getmatchdetails("281699681"); if want access individual fields account_id, code not working. int = match.result.players[0].account_id; please me , if want @ json script, here's link https://api.steampowered.com/idota2match_570/getmatchdetails/v001/?match_id=281699681&key=8f48de9ebf9c9ea121a6a9ef2e30b7c7 json uses javascript objects, not java objects , hence cannot directly access members if java objects. need gson convert between json representation , java object representation.

ios - How do I make a button stay pressed? -

okay have app i'm building complete. i'm having 1 problem, when press button makes sound , button's image changes. image changes when being touched or "highlighted" , buttons image remain changed through duration of sound effect after sound effect revert original image. there anyway can set uibutton "set time" or "highlighted" option? i feel embarrassed sometimes, because seem tripped these trivial things, when handle core coding exceptionally , near finish full app in days time, first app , i'm still newbie xcode. appreciate community's answer pushes me forward appreciated! i further apologize questions formatting typed on iphone hope it's not awkward or lacking in detail. if needs more detail ask! 1.you dont want reflection of image @ highlighted , selected state. put same image state like [btnclear setbackgroundimage:[uiimage imagenamed:@"blue_button.png"] forstate:uicontro...

time - Yii 1.1.14 absoluteAuthTimeout -

i download 1.1.14,and try , question user authtimeout 1 can me? when used configration this: 'comments'=array( `user`=array( ... 'absoluteauthtimeout' => 60*100, ... and logined, ,click user pannel @ once , logout auto. regards you can implement session timeout in config file like 'components' => array( 'session' => array( 'timeout' => 300, ), ),

angularjs - How to get the authenticated user info and use in all controllers and services? -

i'm using angularfireauth , want retrieve logged in user's info , use in controllers or services when app initial. currently, used in every controller having problem. $scope.$on("angularfireauth:login", function(evt, user){ console.log(user); }); the callback not call if not full page load or return null when app initial. i need tips how can return authenticated user's info can use when app initial , in controllers , services. example when in controller or services $scope.auth.user.id return user's id $scope.auth.user.name return user's name etc i start userservice this: angular.module('eventbaseapp').service('userservice', function userservice() { return { islogged: false, username: null } }); and write loginctrl controller: angular.module('eventbaseapp') .controller('loginctrl', function ($scope, userservice, angularfireauth) { var url = "https...

libtiff.net - How do you convert from CCITT Group 4 to JBIG/JBIG2? -

would possible point me general direction on how convert ccitt group4 jbig and/or jbig2 compression? either single page , multi page tiffs. after further research source code not possible libtiff.net compression type jbig placeholder in library , codec not implemented. looking answer ended using jbig2enc following links... blog compiled exe wrapper jbig2enc , python script convert output of jbig2enc pdf. http://soft.rubypdf.com/software/windows-version-jbig2-encoder-jbig2-exe more information on how call jbig2.exe , pdf.py python script. http://blog.rubypdf.com/2009/10/29/convert-jbig2-to-pdf-with-free-and-open-source-software-agls-jbig2enc/ jbig2enc c/c++ library adam langley https://github.com/agl/jbig2enc

c - Comparing non null-terminated char arrays -

i have compressed unsigned char array of known size. due compression considiration don't store null-terminator @ end. want compare array of same format. best way so? i thought duplicating comparessed arrays new array, add null-terminator, , compare them using strcmp() . any better suggestions? you can use strncmp() function string.h strncmp(str1, str2, size_of_your_string); here can manually give size of string(or number of characters want compare). strlen() may not work length of string because strings not terminated nul character. update: see code comparison of unsigned char array #include<stdio.h> #include<string.h> main() { unsigned char str[]="gangadhar", str1[]="ganga"; if(!strncmp(str,str1,5)) printf("first 5 charcters of str , str1 same\n"); else printf("not same\n"); }

vb.net - The form referred to itself during construction from a default instance, which led to infinite recursion -

i trying create simple client (initiator) using quickfix graphical user interface. i'm using visual studio 2012 , programming in vb.net. here problem : when launch app, have error : "an unhandled exception of type 'system.invalidoperationexception' occurred in windowsapplication1.exe additional information: error occurred creating form. see exception.innerexception details. error is: form referred during construction default instance, led infinite recursion. within form's constructor refer form using 'me.'" i have 2 files in project client gui.vb ( http://pastebin.com/virgvnys ) , myquickfixapp.vb ( http://pastebin.com/tq1gxnsx ). second 1 contains class integrates iapplication, subs. the error happens when executes line : "dim initiator new socketinitiator(myapp, storefactory, settings, logfactory)" client gui.vb software highlights line file application.designer.vb : protected overrides sub oncreatemainform() me.mainform...

html5 - HTML input type time not working in firefox -

below works in chrome not in mozilla firefox (23.0.1) @html.textboxfor(model => model.endtime, new { type = "time"}) is there hack make work in firefox . or else, possible solution that. please refer below link, http://www.miketaylr.com/code/input-type-attr.html fyi: if textbox red type not supported particular browser.

Group by - MS SQL Server -

i have table status - count delivrd - 68926 failed - 6369 exp-sms-tmout - 101 exp-nw-tmout - 97 exp-mem-excd - 17 exp-nw-fail - 109 exp-hdst-busy - 113 exp-abssubs - 5732 & want result delivered - 68926 failed - 6369 exp - 6169 [total(exp-sms-tmout,exp-nw-tmout,exp-mem-excd,exp-nw-fail,exp-hdst-busy,exp-abssubs)] how can using group by. please share query asap. select case when status 'exp%' 'exp' else status end , sum([count]) [count] table1 group case when status 'exp%' 'exp' else status end sqlfiddle demo

r - Building packages with Rcpp, Attributes not handled correctly -

i've been playing around setting r package aims make use of rcpp in rstudio, i'm struggling things work rcpp attributes. my understanding of how works tenuous, understanding follows: in source c++ files, can add rcpp attributes, example tag // [[rcpp::export]] marks c++ function exporting, making available r. when build package, rcpp generates appropriate c++ code in file rcppexports.cpp , , wrapper functions in r source file rcppexports.r . this doesn't seem working (as expect) when build package. roxygen isn't playing nicely when generating namespace file (so i've disabled that). tag // [[rcpp::export]] seems mark function exporting r, rather marking function being exported package namespace. more importantly, rcpp attribute tag // [[rcpp::depends()]] isn't being handled correctly. if copy code here new source file, , rebuild package, gcc throws errors on rcppexports.cpp file saying bigmatrix identifier undeclared indicating attribute ta...

c3p0 seems to close active connections -

i set unreturnedconnectiontimeout release stale connections. assumed going close connections without activity looks closes every connection after specified time. is bug or 'as designed'? the manual states: unreturnedconnectiontimeout defines limit (in seconds) how long connection may remain checked out. if set nozero value, unreturned, checked-out connections exceed limit summarily destroyed, , replaced in pool. obviously, must take care set parameter value large enough intended operations on checked out connections have time complete. can use parameter merely workaround unreliable client apps fail close() connections from conclude activity not influencing throwing away of connections. me sounds strange. why throw away active connections? thanks, milo i'm author of c3p0, , of paragraph quote. unreturnedconnectiontimeout name , documentation state: timeout unreturned connections. implemented reluctantly, in response user feedbac...

sass - Why is Compass/Scss setting list-style: none by default? -

it seems scss turning off ordered list styles default, seems little strange / annoying. can explain why that? this line mysteriously added css: /* line 24, c:/ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ ol, ul { list-style: none; } a little splunking showed result of these lines in _utilities.scss file: ol, ul { @include reset-list-style; } // reset list style of element. @mixin reset-list-style { list-style: none; } i'm fixing issue adding: ol { list-style-type: decimal; } to scss file. better modify _utilities.scss file? sounds if did might screw how scss translates css ol, ul elements? if don't behavior, can take out reset that's included compass. when start new compass project, generates screen.scss following: /* welcome compass. * in file should write main styles. (or centralize imports) * import file using following html or equivalent: * <link href=...

sql - Update trigger when row doesn't exist -

i have 2 tables orderitems: "order_items_code" varchar2(20) not null enable, "order_code" varchar2(20) not null enable, "item_code_orders" varchar2(20) not null enable, "order_quantity" number(4,0) not null enable, "order_unit" varchar2(5) not null enable, "unit_price" number(38,5), "ordered_in" varchar2(6), "or_quantity_ton" number(38,5), "warehouse_code" varchar2(20) not null enable the other table inventory: "inventory_code" varchar2(20) not null enable, "item_code" varchar2(20) not null enable, "warehouse_code" varchar2(20), "in_q_ton" number(38,5), "or_q_ton" number(38,5) i created trigger calculate "or_quantity_ton" = sum ("or_qn_ton") create or replace trigger sum_or_it after insert or update or delete on orderitems begin update inventory set or_q_ton = ( select sum(or_quantity_ton) ...

asp.net - Why Appharbor not create all tables -

why appharbor not create tables. i have following entity framework configuration. public class rezawebcontext : dbcontext { public rezawebcontext() : base("defaultconnection") { } public dbset<userprofile> userprofiles { get; set; } public dbset<registrantinfo> registrantinfos { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.conventions.remove<pluralizingtablenameconvention>(); modelbuilder.entity<registrantinfo>().hasrequired(x => x.userprofile).withoptional(x => x.registrantinfo); } } public class registrantinfo { public virtual int registrantinfoid { get; set; } public virtual string name { get; set; } public virtual string sex { get; set; } public virtual string birthplace { get; set; } public virtual string birthdate { get; set; } public virtual string address { get; set; } public virtual string exa...

Making jquery ajax call from view to controller in cakephp 2.x -

i trying make ajax request view controller, ajax requst working fine, controller nothing returned view. don't know problem.. trying in view side displaying data controller , there 1 select box. whe select city select box, calls ajax request , should show result particular city in view.ctp. $('#cityid').change(function() { $city_id= $('#cityid :selected').val(); alert($city_id); $.ajax({ url : "<?php echo router::url(array('controller' => 'deals', 'action' =>'topdeals'), true); ?>", type : "post", cache : false, data : {city_id: city_id}, success : function(data){ alert(data); } }); }); }); and in view <div id="form"> <?php echo $this->form->create('deal', array('...

php - Too big POST data. Reduce the data or increase the "post_max_size" -

i'm trying upload gzipped mysql backup (71,2mb) through adminer , throws me error: too big post data. reduce data or increase "post_max_size" configuration directive. even though post_max_size , other php.ini settings this: post_max_size = 1024m upload_max_filesize = 1024m why keep getting error? don't check values in php.ini , can overwritten .htaccess file or in php code. run phpinfo() , compare values in left & right column. values in right column in use. also take notes documentation account: sets max size of post data allowed. setting affects file upload. upload large files, value must larger upload_max_filesize. if memory limit enabled configure script, memory_limit affects file uploading. speaking, memory_limit should larger post_max_size. so, might need change memory_limit : memory_limit > post_max_size > upload_max_filesize

cocoa - Read data from serial port using thread -

at first - sorry english i need read data serial port (from gps reciever) wrote small app using serialport x2. works. but. read data every 1 sec (on timer fire). , recieving data not well. without first bytes or last bytes. need read data "thread" (i did when wrote using delphi in windows). know using objc, quit newbie in c if have small example (with tons of comments) on how - helpfull thanks xcode 4, macosx 10.6

angularjs - access controller scope from Bootstrap-UI Typeahead template -

i unable call controller function inside custom-template ui-typeahead: <input typeahead="val val in autocomplete($viewvalue)" typeahead-template-url="searchautocompletetpl.html" ng-model="query"/> <script type="text/ng-template" id="searchautocompletetpl.html"> <span ng-repeat="eqp in match.model.equipment"/> <a href="" ng-click="showitem(eqp.model)"> found in: {{eqp.model}} </a> </script> the problem controller's scope seems absent in template: showitem(eqp.model) is never called. have tried with: $parent.showitem(eqp.model) to no avail. how can call function/value on controller's scope then? i ran same problem , had @ typeahead code on github see if might offer clues. appears there several directives involved in creation of suggestions list , each gets own child scope. in other words, $parent.showitem(eqp.mode...

Communicating between databases Ruby on Rails -

i have 2 rails servers running. 1 dedicated towards handling login part of applicating , other 1 handling data associated rest of application. reason, login database not meant integrated main application database. however need keep track of data associated particular user requires communication between databases.rabbitmq or zeromq might haven't quite figured out yet. for mysql can use cas https://github.com/intinno/ruby-cas-server authenticate centralize server. might in other database well.

java - Regex checking runs infinite time -

i have written below regex that,this regex not match input; working loop runs infinite time. how resolve issue string originalregex ="(?s)\\00|\\+adw-|\\+ad4-|%[0-9a-f]{2}|system[.][a-z]|javascript\\s*:|>(?:\".*|^'.*|[^a-z]'.*|'[^a-z].*|')[-+\\*/%=&|^~\"']|\\?.*<:|\\(\\s*[a-z]{2,}\\.[a-z]{2,}.*\\)"; string xmldata = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration xmlns=\"http://www.example.com/api/2.2\" timestamp=\"str111\" version=\"2.2\"><domain account=\"4af17966-c841-4b97-a94a-edd7a0769\" /></configuration>"; string freetext = ">(?:\".*|^'.*|[^a-z]'.*|'[^a-z].*|')[-+\\*/%=&|^~\"']|\\?.*<:"; final pattern pattern_1 = pattern.compile(freetext); matcher matcher = pattern_1.matcher(xmldata); while (!matcher.find()) { system.out.println("good job"); } java...

android - listview data from database by using hashmap does not working -

this question has answer here: runtimeexception: content must have listview id attribute 'android.r.id.list' 7 answers i tried android project listview.i added values in db using hashmap , display result in listview. couldn't started correctly..pls me solve this... here java code package com.example.subitemlistviewdb; import java.util.arraylist; import java.util.hashmap; import android.r; import android.os.bundle; import android.app.activity; import android.app.listactivity; import android.view.menu; import android.widget.listadapter; import android.widget.listview; import android.widget.simpleadapter; public class mainactivity extends listactivity { dbcontroller dbc=new dbcontroller(this); listview l; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r...

linux - Usage of SO_REUSEPORT with multicast UDP -

in discussion on so_reuseport, following question posted reddit , there no answer. wondering if stack overflow knows answer. can tell me how interacts multicast? i've got application program should listen multicast udp messages, , program may started multiple times on same computer. when message comes it, listening processes should it. i've noticed on linux, works fine if don't set so_reuseport, , if understand correctly, setting so_reuseport may wrong thing -- don't want udp messages distributed between processes, want processes copy. however, on os x, second execution of program fails find free port unless so_reuseport set. tl;dr: expected set so_reuseport when using multicast? with so_reuseport, 1 can bind multiple sockets same port , address. requirement earlier sockets must have set option. thus, if want 2 sockets, sock1 , sock2 bound ot same port (and address), s2 able reuse port/address if both sock1 , sock2 set so_reuseport....

android - Starting up Service with AlarmManager , which already might be running -

i need run service in time interval, example every 2 minutes. register alarmmanager, works fine when service stops before 2 minutes up, there great chance take more 2 minutes, in case i'll need service terminated , start new one, how can this? alarmmanager = (alarmmanager) getsystemservice(context.alarm_service); intent = new intent(getapplicationcontext(), sender.class); pendingintent pi = pendingintent.getservice(getapplicationcontext(), 0, i, 0); am.setrepeating(alarmmanager.rtc_wakeup,system.currenttimemillis(),1000 * 30, pi); instead of starting service alarmmanager use broadcast. set alarmmanager send broadcast intent. create own broadcastreceiver receive intent , in onreceive method restart(stop , start) service. //start alarmmanager sending broadcast intent intent = new intent(context, mybroadcastreceiver.class); // explicit peningintent = pendingintent.getbroadcast(context, 0, intent, 0); malarmmanager.setrepeating(alarmmanager.rtc_wa...

c# - Configuring SSL on ASP.NET Self-Hosted Web API -

i'm creating self-hosted web api service. secure it, i've studied , implemented this article, generated local ssl certificate using makecert , service authenticated , generates tokens fine, if i'm using http://localhost/webapi/authentication/authenticate link, when try access service using https, following on firefox: ssl_error_rx_record_too_long and same request fiddler shows me: http/1.1 502 fiddler - connection failed date: mon, 26 aug 2013 10:44:27 gmt content-type: text/html; charset=utf-8 connection: close timestamp: 13:44:27.433 [fiddler] socket connection localhost failed. failed negotiate https connection server.fiddler.network.https> failed secure existing connection localhost. handshake failed due unexpected packet format.. my self-host configuration: private httpselfhostserver _server; private extendedhttpsselfhostconfiguration _config; public const string serviceaddress = "https://localhost/webapi...

javascript - Propper way of saving an admission ticket -

what state of art when comes saving admission ticket on mobile devices? i have webseite , struggling problem when user finish checkout, find himself on overview of tickets bought. clicking 1 of tickets gets ticketdetails barcode. gets email site overview. but customers asked me why there no possibility save tickets locally . looked way html pdf . serverside , looks there no way javascript. so there other options? maybe andoid/os onboard functions can use save sites images or that? you can create generated pdf file saved data on server using javascript. use premade library such jspdf http://code.google.com/p/jspdf/

iphone - Download Progress Status, when file is downloading from Google Drive? -

i able download files google drive, want know download progress. can 1 tell me how it? i have tried downloading files: nsstring *downloadurl = [[self.drivefiles objectatindex:indexpath.row] downloadurl]; gtmhttpfetcher *fetcher = [self.driveservice.fetcherservice fetcherwithurlstring:downloadurl]; filename=[[nsstring alloc] init]; [fetcher beginfetchwithcompletionhandler:^(nsdata *data, nserror *error) { gtldrivefile *file = [drivefiles objectatindex:indexpath.row]; nslog(@"\n\n\n\n\n"); nslog(@"this file size=====>%@",file.filesize); nslog(@"this file name===>%@",file.title); if(file.downloadurl!= nil) { if (data!=nil) { filename=file.title; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; documentsdirectory = [[paths objectatindex:...

javascript - How to store JSON in a variable -

how store data json database, when user registers information should stored in variable? example: my html form consists of input text fields firstname, lastname. clicking register button of form should store values of firstname , lastname in variables. how can this: var txt = '{"employees":[' + '{"firstname":"john","lastname":"doe" },' + '{"firstname":"anna","lastname":"smith" },' + '{"firstname":"peter","lastname":"jones" }]}'; easily use jquery var jsonarray; jsonarray.push($("#firstname").val(); jsonarray.push($("#lastname").val(); var myjsonstring = json.stringify(jsonarray);

php - Mysql query error with syntax -

i have query , can't figure out incorrect: mysql_query ("update 'users' set 'profile'='".$file_path."'where 'id'=".(int)$user_id)or die ("error in query: $query. ".mysql_error()); here error: error in query: . have error in sql syntax; check manual corresponds mysql server version right syntax use near ''users' set 'profile'='images/profiles/7fe0e816b0.jpg'where 'id'=72' @ line 1 try backticks instead of single-quotes like mysql_query ("update `users` set `profile`='".$file_path."' `id`=".(int)$user_id) or die ("error in query: $query. ".mysql_error()); and try avoid mysql_* statements due entire ext/mysql php extension, provides functions named prefix mysql_* , officially deprecated of php v5.5.0 , removed in future . there 2 other mysql extensions can better use: mysqli , pdo_m...

ruby on rails - to make .ransack(params[:q]) operate on the array -

question model has_many answers. lines below count how many answers question has , order them according amount of answers in desc order. so, answered questions first. @search = question.find(:all, joins: :answers, select: ' "questions".*, count("answers".id) answers_count', group: '"questions".id', order: "answers_count desc").ransack(params[:q]) @questions = @search.result i use ransack gem. ransack make search need add .ransack(params[:q]) @search array , call result method on array. though work, doesn't. what use ransack start searching? you should ransack first, use it's result chaining. ransack_result = question.ransack(params[:q]).result @questions = ransack_result.find(:all, joins: :answers, select: ' "questions...

c# - Error: Object reference not set to an instance of an object./The connection was not closed. The connection's current state is open -

for longest time, code has been running, lately encounter error, object reference not set instance of object. don't know if related creation , usage of new database. here code: con2.open(); sqlcommand cmd = new sqlcommand(); cmd.connection = con; cmd.commandtext = "select qtyinhand inventory productid=@productid"; cmd.parameters.add("@productid", sqldbtype.int).value = productid; int existingqty = (int)cmd.executescalar(); cmd.parameters.clear(); cmd.commandtext = "update inventory set qtyinhand=@qtyinhand productid=@productid"; cmd.parameters.add("@qtyinhand", sqldbtype.int).value = existingqty - int.parse(quantity); cmd.parameters.add("@productid", sqldbtype.int).value = productid; cmd.executenonquery(); con2.close(); error on part: int existingqty = (int)cmd.executescalar(); when tried using other sqlconnection: con con.open(); sqlcommand cmd = new sqlcommand(); c...

sql - Better database structure -

i'm developing app wp8 can store documents of dozen predefined types (e.g. passport, insurance...). so, have table columns this: int id, string name, int order the problem other fields not same different document types. for passport be: number int, photo bitmap for insurance: number int, holder string first way resolve problem: store data in xml column. second: store each type in dedicated table (i'm afraid linq query huge , slow data 10 different tables). third: store meta in tables (e.g. table field_types , field_to_docs , field_values ). i think fastest way be, of course, xml. think it? how storing bitmaps in xml, or i'll need create table specially storing bitmaps , sync them references xml? i'd model main table document, , small table each document type peculiarities. in document you'd have common fields plus type of document in small tables id main table , fields unique type of document. when retrieving documents, you'd have join...

c# - How do I get Wordpress custom Post Type through ASP.Net? -

our client has website in wordpress , contains custom post type (like post_type=recent-news). need fetch , show custom post types , content in asp.net website. we have tried "cookcomputing.xmlrpcv2" doesn't support custom post type. have checked json api need deploy php code don't want do. have checked wordpress json .net ( http://wordpressjsonnet.codeplex.com/ ) not officially released / not working. is there option (any free dll or rest api plugin) custom post type asp.net? 4 years late might else. try wordpresssharp 's method: wordpressservice.getposts(wordpresssiteconfig.blogid, wordpresssiteconfig.username, wordpresssiteconfig.password, new postfilter() { posttype="recent-news"});

ruby - rails model file path -

how can obtain model file path in rails? want that: mymodel.file_path expected result: "/app/models/my_model.rb it's possible in rails or need create file name models name , find in models directory? i think have build it, simple. here goes: def model_path model_file = self.class.name.split("::").map {|c| c.downcase }.join('/') + '.rb' path = rails.root.join('app/models/').join(model_file) end

MS Excel Pivot Table - Error when removing values from filter -

i face following problem on ms excel (both on 2010 , 2013, think not have officer version) : i have pivot table connecting analysis services cube. i drug 2 dimensions in filter field, , 1 measure in worksheet. calculation formula measure, using options -> olap tools -> convert formulas, , copy cell. so, let's original measure lies on a10 , calculated on b10. the problem happens first of 2 dimensions. when select "all" members dimension fine, when remove member (any member) , original measure (a10) ok, mine on b10 gets error ('n/a'). this not happen when making changes selection of second dimension filter though. any ideas on one? thank in advance.

java - Glassfish: Silently ignore unavailable data source at application start up -

i have ejb application uses jpa 2.0 on glassfish 3.1.2 (provider eclipselink). when database down application not start , more: can't deployed. because eclipselink initial verification. is there way application can deloyed , started if database down? background: resource being unavailable comes not play until first business function called accesses database. application startup till first business function call there time window database may started. changing defaults in glassfish-resources.xml attributes connection-creation-retry-attempts , connection-creation-retry-interval-in-seconds of <jdbc-connection-pool> helps in way still check database availabilty @ startup not @ first use. exceptionhandler eclipselink not way have in mind: when exception handler comes play eclipselink has started verification process , hence has tried connect database. way looking postpone verfification process until first business call. eclipselink database verification i...

jquery - Show options of selected options inside the same <div> -

there unordered list of 3 items, a,b , c inside <div> . if select option a, should again show list of p, q , r inside same <div> , if select b, should show unordered list of x,y , z plus should have button well. <div> <ul> <li><a href="#">a</li> <li><a href="#">b</li> <li><a href="#">c</li> </ul> <div> now upon selecting option a, following list should displayed inside same <div> <ul> <li><a href="#">p</li> <li><a href="#">q</li> <li><a href="#">r</li> </ul> and this, upto 3-4 levels down, eg:- from a->p,q,r . from p->d,e,f . from d->s,r,t , similarly. should displayed inside same <div> tag. i have searched bootstrap didnt got expected result. can done in bootstrap. if not,...

javascript - RequireJS: Config parameters not being passed into package -

i'm trying send configuration parameters package's main.js file , doesn't seem working. doing wrong? here's files , path information /config.js require.config({ baseurl : '../src', config : { 'aam' : { : null, set : null } }, packages : [ 'aam'] }); /src/aam/main.js require.config({ paths : { aamaspermission : 'aam/perms/aspermission' } }); // start main app logic. requirejs(['aamaspermission'], function(aamaspermission) { }); /src/aam/perms/aspermission define(['module'], function(module) { module.config() // empty object. why? .... }); in /src/aam/perms/aspermission, object returned module.config() empty. why? according documentation : for passing config package, target main module in package, not package id: so should configure this: require.config({ baseurl : '../src', config : { ...

Reg - QTP - Automation Batch Run -

i have doubts on automation batch run through qtp , quality center. in case have 50-100 automation tests running in batch in test set in test lab in quality center: when start batch run, possible run both "application under test",qtp , qc in hidden mode. if yes, how make of them hidden mode? when automation tests running in sequence in visible mode, use same computer other activities? or move away focus of application? when automation tests running , if system goes locked or sleep mode, automation test keeps running or stopped. any other , don'ts in automation batch run please kindly share me. thanks in advance answer question 1: believe no. depending on gui technical details, might possible execute aut on separate desktop, or winstation, neither qtp nor else build support afaik. knowing subtle details 1 has pay attention if example qtp , aut running in remote desktop session makes believe not feasible goal hide or execute triple on machine want u...

c# - Defining Web API routes -

i'm exposing functionality through web api, , urls want expose example: /api/organizations (returns list of organizations (get)) /api/organizations?$top=2 (returns list of organizations filtered odata (get)) /api/organizations/2 (returns details of organization id 2 (get)) /api/organizations/addinstitution (adds new institution organization (post)) /api/organizations/removeinstitution (removes institution (post)) in order that, had change routing in webapiconfig class like: config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional }, constraints: new { id = @"\d*" } ); config.routes.maphttproute( name: "specificactionsroute", routetemplate: "api/{controller}/{action}/{id}", defaults: new { id = routeparameter.optional } ); this seems w...

html - How to highlight syntax? -

i want lean how highlight syntax of various programming , markup languages. admit have no prior knowledge of might off-topic. say, example, want highlight html tags. think can done use regex find tags. can find tags using regex , start , end position. then, can change color of particular text. however, above approach not work if tags had attributes them. <img src="..."> so, can please guide me how how can achieved. third-party api fine learn how can done :) you want highlight html code? can use syntaxhighlighter javascript library this. if want learn how, see css syntaxhighlighter 2.0: short tutorial on how create own syntax highlighter . also, try simple search “how build syntax highlighter” .

php - Using preg_match many time to check if strings are in text -

i have text text area, contains 4 necessary strings. before insert text on database check presence of strings. is there better , alternative way 4 preg_match operations, maybe using preg_match_all ? if i'd replace 4 strings else, difference between preg_replace , str_replace . should use? here code: if(isset($_post['text'])){ $text= $link->real_escape_string($_post['text']); $string = $text; $pattern1 = '/limite_type/'; $pattern2 = '/limite_set/'; $pattern3 = '/today_price/'; $pattern4 = '/auto_sign/'; if(preg_match($pattern1, $string) && preg_match($pattern2, $string) && preg_match($pattern3, $string) && preg_match($pattern4, $string)) { echo 'ok'; }else{ echo 'not found'; } die(); } if want check presence of exact words, don't need use regex, use strpos instead faster: $word1 =...

ios - Objective C assigning a value to a variable -

Image
i have line in header file @property (strong, nonatomic) nsmutabledictionary *weatherdata; and i'm truing following on implementation -(void)dosomething { nsmutabledictionary *data = [[nsmutabledictionary alloc] init]; //after adding items data self.weatherdata = data; } then have function -(nsmutabledictionary *)getweaterdata { nslog([self.weatherdata description]); return self.weatherdata; } why noting gets printed, above data has data in it. edit self.weather data getting populated asynchronous method. take while. when i'm using nslog, wasn't populated yet. that's why nothing getting printed :d all fixed adding delegate call back i not believe problem rests code you've shared far. might want try adding "watch" of variable backing class property (basically, tell debugger stop execution every time code tries update value property). if want this, can: add breakpoint in code before set property first time; run app in ...

apache camel - How to get the information that throttling limit has been reached? -

inside camel route, need throttle messages when limit of request/s reached. i've found throttler eip. works fine need when limit reached raise alert, there way ? i had @ code don't found way extend it. thanks & regards this not possible know out of box. need extend it, or build own throttler. i logged ticket can expose in jmx number of messages hold-back throttler: https://issues.apache.org/jira/browse/camel-6670 if altering tooling can react on jmx can react if jmx attribute > 0 , send email etc.

c# - Memory-mapped files -> Checking for duplicate file names -

working on app use memory-mapped files inter-(or intra?)application communication, , want make sure when randomly generate memory-mapped memory-only file, don't accidentally generate or duplicate exists (that ultra-rare case when planets align , might happen). ideas on how prevent that? system.io.memorymappedfiles not appear have file.exists() method...i guess try openorcreate() , deal access violations, etc., getting nasty quick. using file.exists() wouldn't concurrency-safe anyway. the best thing do: base filename on guid.

java - Guice injecting a generic list -

i inject list of various objects differentiate generic type. i have mainview accepts list of contentpanels (a subtype of jpanel) want display. so have @inject mainview(list<contentpanel<?>> contentpanel){ ... } the content panels differ in generic type, there 1 books, 1 movie etc. i tried bind them bind(new typeliteral<abstractcontentpanel<book>>(){}) .to(new typeliteral<bookcontentpanel<book>>(){}) .in(singleton.class); and bind(new typeliteral<abstractcontentpanel<movie>>(){}) .to(new typeliteral<bookcontentpanel<movie>>(){}) .in(singleton.class); but how can make list of them , inject them mainview? if want inject bindings list, cannot that. if want inject list, should bind directly, this: bind(new typeliteral<list<string>>() {}) .toinstance(new arraylist<string>()); but in case list must known beforehand (or supplied via prov...

ios - UISegmentedControl messed up after customization -

Image
so after customize uisegmentedcontrol, got messed up, label got shifted , there white vertical line don't know came from. divider got off-center, have checked black line @ 40-41px of 80px image, must centered. want doing wrong or have experience before? before customization: after customization: note: divider images horizontal flip of each other. code: uiimage *un_sel = [uiimage imagenamed:@"divider-un-sel"]; uiimage *sel_un = [uiimage imagenamed:@"divider-sel-un"]; [_segmentcontrol setdividerimage:un_sel forleftsegmentstate:uicontrolstatenormal rightsegmentstate:uicontrolstateselected barmetrics:uibarmetricsdefault]; [_segmentcontrol setdividerimage:sel_un forleftsegmentstate:uicontrolstateselected rightsegmentstate:uicontrolstatenormal barmetrics:uibarmetricsdefault]; uiimage *normal = [[uiimage imagenamed:@"segment-normal"] stretchableimagewithleftcapwidth:20 topcapheight:0]; uiimage *selected = [[uiimage imagenamed:@"segm...

javascript - Why won't Jplayer CirclePlayer play mp3, the other Jplayer skins all do? -

i new coding (playing html5 ccs3 , javascript 2 mths now) , i'm trying jplayer circleplayer play mp3 format using demo file "demo-05.htm". here's snipit of code in i've altered per information i've found here in other posts, still can't make circleplayer work in either ie10 or current release google chrome, though other jplayer skins play mp3's. i've added error alerts received none on last try. if can me figure out appreciate it, i'm new coding stuff , keep coming against strange anomalies. if can work, need figure out how use circleplayer play multiple mp3 files on same page! here's code i've been working far. media files @ same folder level htm file, js js , skin folders @ same level htm file i'm working out of demo folder while testing player. <script type="text/javascript"> //<![cdata[ $(document).ready(function(){ var mycircleplayer = new circleplayer("#jquery_jplayer_1", { mp3: ...

junit - Java Unit test for Exception -

public document query(string uri) throws ioexception, illegalargumentexception { final httpget httpget = new httpget(uri); final httpresponse response = httpclient.execute(httpget); final httpentity entity = response.getentity(); document doc = null; try { documentbuilderfactory factory = documentbuilderfactory.newinstance(); documentbuilder builder = factory.newdocumentbuilder(); doc = builder.parse(entity.getcontent()); } catch (saxexception e) { logger.error(e); throw new illegalargumentexception("parse error" + e); } catch (parserconfigurationexception e) { logger.error(e); throw new illegalargumentexception("parameter factor invalid: " + e); } catch (illegalstateexception e) { logger.error(e); throw new illegalargumentexception("null entity contetents" + e); } return doc; } @test(expected = illegalargu...

javascript - Extend template for js inclusion -

i have web project. project based on smarty templates. have base.tpl common structure, pages of site. the base.tpl have next line, thats includes template requested user: {include file="{$request}"} for example. when user request http://mydomain/contact , $request have "contact.tpl" value. and bottom of base template have inclusion of commons js files: {block name="javascript"} <script src="{$base_url}/assets/js/libs/jquery-1.10.2.min.js"></script> <script src="{$base_url}/assets/bootstrap/js/bootstrap.min.js"></script> <script src="{$base_url}/assets/js/common.js"></script> {/block} so, templates requested user, requires inclusion of mores javascript files, insert in "javascript" block. i try, example in contact.tpl next code: {block name="javascript" prepend} <script src="{$base_url}/assets/js/libs/validation/jquery.validate.j...

ios - How to handle long text UILabel -

i have view has lot of labels. of them text set dynamically. text long display within 1 line. know how can display text in multiple lines. problem when display text in multiple lines margins broken between labels. label swapes content of next label. i want avoid fixing "by hand" (repositioning of other elements). maybe autolayout can fix this, sadly i'm not able use now. argument convert project springs&struts autolayout. however, maybe there way fix issue. nice if can me out. in advance! you can use sizewithfont:constrainedtosize:linebreakmode: calculate height required each of labels. should use in loop iterates on each label in order should appear on screen. go, increment y position height of current label , margin. each label have correct position , @ end of loop y hold full required height.

php - my google snippet is not showing the data from the correct url -

this may little confusing, added example, http://searchengineland.com/bing-rises-above-17-search-market-share-as-google-slips-comscore-159746 when clicking +1 button here, inside snippet shows text , url page. however, snippet shows text homepage url, not url gave it. why , how can fix it? sorry if i'm unclear. code i'm using below. <g:plusone size="medium" count="true" href="http://aaaaaa.com/social/comments/'.$row["id"].'"> </g:plusone> the snippet generated using schema.org markup on page. update text, update itemprop="description" value in markup each page within site. markup looks like: <body itemscope itemtype="http://schema.org/product"> <h1 itemprop="name">shiny trinket</h1> <img itemprop="image" src="{image-url}" /> <p itemprop="description">shiny trinkets shiny.</p> </body> for ...

android - How to handle orientation changes for home screen app widget? -

can me on how handle orientation change app widget? on orientation change widget showing layout empty view , removing listeners. after research , studying of folks answers , came know mistake have done. after initial setup of widget , again initializing remote views , trying change few views when user taps on refresh button , iam making view visibility gone , making circular progress loading view visibility visible , not again adding other views , click listeners updating widget. appwidget manager use last remote views object. whenever orientation changes appwidget manager trying load latest remote view object ignoring pending intent listeners , views. i resolved creating remote view object required view , listeners.

c# - Weird "Random" behaviour with Random -

this question has answer here: random number generator generating 1 random number 9 answers random number behaves weird, not random 3 answers on again i´m needing here, today doin c# homework consist in creating method can sum result of 2 dice rolls, far, good!, no hard thing do... but, when run code odd thing happens, let code , results speak them self: using system; class program { public static string gettimestamp() { datetime savenow = datetime.now; return savenow.tostring("yyyymmddhhmmssffff"); } public static int throwdice() { int randval1, randval2; string ts1, ts2; random rand = new random(); randval1 = rand.next(1,6); ts1 = gettimestamp(); randval2 = rand.next(1,6); ...