Posts

java - From File[] files to directory -

i have problem code: public class files { public static void main(string[] args) throws ioexception { // filter files aaa.txt , bbb.txt another's file f = new file("d:\\dir"); // current directory file f1 = new file("d:\\dir1\\"); filenamefilter textfilter = new filenamefilter() { public boolean accept(file dir, string name) { if (name.startswith("a") && name.endswith(".txt")) { //system.out.println(name); return true; } else if (name.startswith("b") && name.endswith(".txt")) { //system.out.println(name); return true; } else { //system.out.println(name); return false; } } }; file[] files = f.listfiles(textfilt...

MySQL many-to-many SELECT query -

i have product table, tags table , table links them together, producttags . product id producttags productid tagid tags id i want query producttags table productids have both tagid 1 , 2. how this? select * producttags tagid = 1 , tagid = 2 this won't work... can't quite head round how it! any appreciated! this "set-within-sets" query , solve these using group by , having . here 1 method: select productid producttags tagid in (1, 2) group productid having count(distinct tagid) = 2;

jquery .val() to change attribute selected state -

i'm using jquery update select option when value returned via ajax call. i've put simplest form , whilst visible value changes, 'selected' attribute stays jquery(document).ready(function($) { $("#fetchcap").on('click',function (e) { $('#used_car_colour').val('grey'); }); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type="button" class="button button-primary" name="fetchcap" id="fetchcap" value="fetch"> <select name="used_car_colour" id="used_car_colour"> <option class="colour-option" value="">none</option> <option class="colour-option" value="black" selected="">black</option> <option class="colour-option" value="brown">brown</option...

How to make PHP recognize multiple instance of parameter as an Array? -

is there option in php via (php.ini) recognize parameter passed multiple times in url array? /cars.php?color=a&color=b the above query should result in array of colors ['a','b'] instead of second parameter 'b' overwriting first parameter 'a' use this: /cars.php?color[]=a&color[]=b //^^ ^^ no need enable in php.ini, accessing $_get['color'] return array.

How can we post XML strings along with text strings in iOS -

nsstring *starcardstr=@"https://starcardsindia.com/test/api/userauthentication"; //nsstring *poststr=[nsstring stringwithformat:@"https://starcardsindia.com/api/otpverification"]; // nsurl *url=[nsurl urlwithstring:poststr]; nsurl *url=[nsurl urlwithstring:starcardstr]; nsmutableurlrequest *request=[[nsmutableurlrequest alloc]init]; [request seturl:[nsurl urlwithstring:starcardstr]]; [request sethttpmethod:@"post"]; nsstring *contenttype = [nsstring stringwithformat:@"text/xml"]; [request addvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *pbody=[nsmutabledata data]; [pbody appenddata:[[nsstring stringwithformat:@"<xml>"] datausingencoding:nsutf8stringencoding]]; // create post [pbody appenddata: [[nsstring stringwithformat: @"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"] datausingencoding: nsutf8stringencoding]]; //[pbody appenddata:[...

How to add credentials to jenkins without using UI? -

as part of automating jenkins setup need add credentials use svn configuration in build jobs. manually add domain here http://< server >:8080/credential-store/ then add credentials here: http://< server >:8080/credential-store/domain/< domain >/newcredentials has managed automate this? there doesn't seem usable api , xml files contain hashed passwords stops me copying files around (plus worry security this)

python - Overwriting the save method of a Django model -

i have table of symbols. before add new symbol validate symbol. for purpose have overwritten save method in model: def save(self, *args, **kwargs): if self.check_exist(self.name): # call "real" save() method. super(assetssymbol, self).save(*args, **kwargs) else: # yes, symbol not saved in database # that's good. using 1 or 2 lines of code in else how can inform user has submitted invalid symbol? django still reports symbol "test" has been saved (which misleading) i try avoid using modelforms etc. here's more current implementation: @admin.register(assetssymbol) class assetsymboladmin(admin.modeladmin): list_display = ("name", "group", "alive", "internal") list_filter = ("name", "group", "alive", "internal") ... def save_model(self, request, obj, form, change): if self.check_exist(obj.name): ...

c# - Unity project character only moving one way no matter where you touch on an IOS device -

this code movement when touch on ios device in 2d game creating in unity. when run game loads when touch right moves left , when touch left moves left. i have used screentoworldpoint told use dont seem work move 1 direction void playerwalkmobile() { // force push player float force = 0.0f; // players velocity float velocity = mathf.abs(getcomponent<rigidbody2d>().velocity.x); if (input.touchcount > 0) { counttouches++; touch h = input.touches[0]; vector2 position = camera.main.screentoworldpoint(new vector2(h.position.x, h.position.y)); debug.log("the postion of touch " + h.position); if (position.x > 0) { // if velocity of player less maxvelocity if (velocity < maxvelocity) force = speed; // turn player face right vector3 scale = transform.localscale; scale.x = 1; transform.localscal...

dotnetnuke - DNN Editing Icon Suddenly Disappear -

i've got dnn community edition 06.02.01 it happens that, while site management, suddenly, modules' editing icons disappear. i have no idea i'm doing make happens... someone knows what's make icons disappear? no iis reset works. only restoring previous database backup works. it seems make change db that icons disappears.... please check in top dnn panel => right side => dropdownlist control => select edit mode instead of view mode. make sure login host or admin login credential.

java - why do we have to fix the duration for each measurement iteration? -

what timing iterations means ? @measurement(iterations = 50, time = 2) should time of measurement fixed, if iteration of measurement takes longer 2 seconds, iteration stopped ? if true impact have on measurements. the straightforward answer question is: "we have provide iteration time (or rely on default iteration time), because otherwise iteration never stop". depending on benchmark mode, meaning iteration time may different. example, javadoc says : /** * <p>throughput: operations per unit of time.</p> * * <p>runs continuously calling {@link benchmark} methods, * counting total throughput on worker threads. * mode time-based, , run until iteration * time expires.</p> */ throughput("thrpt", "throughput, ops/time"), there no way stop uncooperative execution in java, short of killing vm. (interrupting thread needs cooperation: there should check interruption). therefore, if @benchmark call takes longer re...

c++ - Declare static functions as friend function? -

i have class myclass declaration in header file interface.h , static functions ( foo , bar , few more) in file1.cpp . static functions used inside file1.cpp need modify private/protected members of myclass`. // in "interface.h" class myclass { // maybe declare friend? // friend static void foo(myclass &ref); private: double someval; } // in "file1.cpp" static void foo(myclass &ref) { ref.someval = 41.0; } static void bar(myclass &ref) { ref.someval = 0.42; } // function uses foo/bar void dosomething(myclass &ref) { foo(ref); } idea 1 : somehow declare them friends of myclass ? why not good : static , in different compilation unit. besides expose them user of myclass not need know them. idea 2 : don't have idea 2. sort of linked: is possible declare friend function static? sort of linked: possible declare friend function static? personally find whole friend thing bit of hack breaks e...

c# - Generate a unique number that is formed from 2 numbers and vice versa? -

i not sure if possible but, i have 2 numbers, 32-bit int x , 64-bit long y. given 'y' unique. given these numbers, want generate unique identifier 32-bit int. should able construct individual numbers unique identifier. possible? apologize if wrong forum ask, related c# programming on project working on. basically, 'x' refers categoryid , 'y' refers unique 'categoryitemid' in database, single category can have million of catalogitems. thanks! to sum up: you have 96 (== 32 + 64 ) bits of possible inputs. you want unique 32 bit value regardless of input values. 32 < 96 it's not possible. entropy of inputs larger entropy of output.

javascript - jQuery click action stripped out by sorting function -

i have function, including following code: $(list).append(item); $(list).html( $(list).children("li").sort(function (a, b) { return $(a).val() - $(b).val(); })); $(item).click(this.listclick); (basically, creating <ul> <li> array of items, including listclick function fires when of list items clicked, , sorting list according li value ). if strip out sort function script, works fine (as in, list compiled, click-function working perfectly, albeit not in correct order). however, if sort list, strips out click-functionality (i..e. clicking items doesn't perform listclick function). why being stripped out? doesn't seem matter whether place sort function before or after listclick line added. that's because using html method replaces html content of element , has nothing sort method. old elements removed , attached event handlers too. should either use event delegation or better use appendto instead of html : $(...

c# - Why do changes made in foreach to a Linq grouping select get ignored unless I add ToList()? -

i have following method. public ienumerable<item> changevalueienumerable() { var items = new list<item>(){ new item("item1", 1), new item("item2", 1), new item("item3", 2), new item("item4", 2), new item("item5", 3) }; var groupeditems = items.groupby(i => i.value) .select(x => new item(x.first().name, x.key)); foreach (var item in groupeditems) { item.calculatedvalue = item.name + item.value; } return groupeditems; } into groupeditems collection calculatedvalue s null. if add tolist() select sentence after groupby calculatedvalue s has values. example: var groupeditems = items.groupby(i => i.value) .select(x => new item(x.first().name, x.key)).tolist(); so, question is. why this? want know reason this, solution me add tolist() update...

c# - Error: System.InvalidOperationException in ASP.NET WebAPI -

Image
i'm trying enter data database , access_token on end of successful call. when make call passing parameters: everything goes fine, user gets registered , saved database, , access_token returns user: but, when add signs +, = or \ in deviceid value exception , nothing saved in database: { "message": "an error has occurred.", "exceptionmessage": "error getting value 'readtimeout' on 'microsoft.owin.host.systemweb.callstreams.inputstream'.", "exceptiontype": "newtonsoft.json.jsonserializationexception", "stacktrace": " @ newtonsoft.json.serialization.dynamicvalueprovider.getvalue(object target)\r\n @ newtonsoft.json.serialization.jsonserializerinternalwriter.calculatepropertyvalues(jsonwriter writer, object value, jsoncontainercontract contract, jsonproperty member, jsonproperty property, jsoncontract& membercontract, object& membervalue)\r\n @ new...

python - Link MKL to an installed Numpy in Anaconda? -

>>> numpy.__config__.show() atlas_threads_info: not available blas_opt_info: libraries = ['f77blas', 'cblas', 'atlas'] library_dirs = ['/home/admin/anaconda/lib'] define_macros = [('atlas_info', '"\\"3.8.4\\""')] language = c atlas_blas_threads_info: not available openblas_info: not available lapack_opt_info: libraries = ['lapack', 'f77blas', 'cblas', 'atlas'] library_dirs = ['/home/admin/anaconda/lib'] define_macros = [('atlas_info', '"\\"3.8.4\\""')] language = f77 openblas_lapack_info: not available atlas_info: libraries = ['lapack', 'f77blas', 'cblas', 'atlas'] library_dirs = ['/home/admin/anaconda/lib'] define_macros = [('atlas_info', '"\\"3.8.4\\""')] language = f77 lapack_mkl_info: not availab...

laravel - Unit test ignore log level -

i have log level defined in config/app.php emergency . 'log' => 'syslog', 'log_level' => env('log_level','warning'), throughout applications have log::info('info') in several places. meaning info should ignore because log level set emergency. works great when run application, problem when run unit tests phpunit . log level ignored logs everything. anyone have idea why happen? in versions of monolog (i'm not seeing on master branch now), monology outputs stderr when no handler set: https://github.com/seldaek/monolog/blob/1.22.0/src/monolog/logger.php#l288-l290 pushing handler onto monolog, null one, supress logging: https://github.com/seldaek/monolog/blob/master/src/monolog/handler/nullhandler.php

ios - How to use NSPredicate with Multidimensional array (where the predicateFormat exists at valueForKeyPath) -

i have array 'id' on want filter array exists @ valueforkeypath 'objectid' of each of dictionaries. how compare predicates in valueforkeypath . currently.. predicate nspredicate * objidpredicate = [nspredicate predicatewithformat:@"objectid = %@",obj]; nsarray * oneorder = [array filteredarrayusingpredicate:objidpredicate]; is considering key , values of array elements, not ones @ valueforkeypath=@"objectid" use "self"in code array element's valueforkeypath nspredicate *objidpredicate =[nspredicate predicatewithformat:@"(self.objectid = %@)",obj]; `

html - How to increase the frame's width when the number of balls increases -

Image
here code .containerslave { display: inline-flex; flex-direction: column; flex-wrap: wrap; margin: 2px 2px 2px 2px; padding: 2px 2px 2px 2px; height: 220px; /*item height x 10*/ border: 2px solid red; } .containerslave .ball { width: 20px; height: 20px; border-radius: 50%; line-height: 20px; text-align: center; text-shadow: 0 1px 1px #000; font-size: 15px; color: #ffffff; margin: 2px 2px 2px 2px; background: radial-gradient(circle @ 20px 15px, #7fbbfc, #000); } when ball under status of limited height , automatically shift longitudinal direction, how make balls covered within frame. frame increase width number of ball increase. ok i'm using mozilla , seems work. original code set width fixed in containerslave 75px . this work , doesn't bad honest going need use outside code js (javascript). if you're open that, can show cool trick fix it. .containerslave { display: inline-fl...

jpa - Error associating dependecies betwen EJB and PersistenceUnity on JBoss 7 -

i having problems while starting ejb application on jboss 7 or on eap 6.1 jboss 7.2 while associating dependencies between ejb , persistenceunit. line log error: 10:07:04,857 error [org.jboss.as.deployment] (deploymentscanner-threads - 1) {"composite operation failed , rolled back. steps failed:" => {"operation step-2" => {"services missing/unavailable dependencies" => ["jboss.deployment.unit.\"crm.war\".component.clientedaobean.start missing [ jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao.clientedaobean/em\" ]","jboss.persistenceunit.\"crm.war#crmunity\" missing [ jboss.naming.context.java.jboss.datasources/crmds ]","jboss.deployment.unit.\"crm.war\".jndidependencyservice missing [ jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao.clientedaobean/em\", jboss.naming.context.java.module.crm.crm.\"env/br.com.crm.model.dao...