Posts

Featured post

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):