Posts

javascript - Regular expression for excluding file types .exe and .js -

i using jquery file upload plugin, giving value option accept files need regular expression tells file types restricted. need restrict both exe , js achieved using below expression (\.|\/)(!exe|!js)$ but expression not allowing other files tried adding 1 extension below (\.|\/)(!exe|!js|pdf)$ with above regular expression accepting pdf , not accepting exe , js. need enable file extentions except exe , js. difficult add extensions expression. can mention how in expression accept other filetypes except exe , js in similar format above. regular expression js. thanks, vinay this exclude .js , .exe @ end of string, allow else: /^[^.]+$|\.(?!(js|exe)$)([^.]+$)/ broken down: ^[^.]+$ matches string no dots \.(?!(js|exe)$)([^.]+$) matches dot if not followed js or exe @ end of string. the following allowed: something.js.notjs somethingelse.exee /something.js/foo the following not allowed: jquery.js outlook.exe note: excluding file extens...

post - Yii postback value for dropdownlist -

like described in title, i' trying use dropdownlist post page. post receive in controller value selected empty. here dropdownlist <?php echo chtml::dropdownlist('groupe',$groupe, array("a"=>"a","b"=>"b","c"=>"c","d"=>"d","e"=>"e","f"=>"f","g"=>"g","h"=>"h"), array( 'prompt'=>'--choisir un groupe--', 'submit'=>ccontroller::createurl('classement'), //'data'=>array('groupe'=>'js:this.value'), )); ?> and here controller public function actionclassement($groupe="") {echo $groupe; if(isset($_post['groupe'])){echo $_post['groupe']."ici=".$groupe; $groupe = $_post['groupe']; }echo 'test'; $model = team::model()...

ios - How to format the layout of an NSDate without converting to NSString -

i'm looking change way date object being put nsdictionary currently, date object being entered in following format: 2014-04-22 17:28:47 +0000 however i'd entered as 22-04-2014 i tried using nsdateformatter i've used it's put string nsdateformatter *formatter = [[nsdateformatter alloc]init]; [formatter setdateformat:@"dd-mm-yyyy"]; nsstring *thedate = [formatter stringfromdate:date]; how achieve changing layout yyyy-mm-dd hh:m:ss ???? dd-mm-yyy maintain date object? after having discussion op, been concluded following go long way in achieving desired result. create new class looks this //fooditem . h nsstring *fooditemname; nsstring *fooditemdate; //you can add more stuff calorie intake etc //have custom init method -(id)initnewfooditemname:(nsstring*)name withdate:(nsstring*)dateinput; //then in //fooditem.m //make sure synthesise properties above. -(id)initnewfooditemname:(nsstring*)name withdate:(nsstring*)dateinput{ ...

java - How to avoid HTTP Status 415 when sending ajax request to the server? -

i have ajax call should return json document function getdata() { $.ajax({ url: '/x', type: 'get', data: "json", success: function (data) { // code omitted } }); } my server side simple. @requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() { return employeeservice.getemployees(); } but request can't controller. error is: http status 415 - server refused request because request entity in format not supported requested resource requested method. how can fix it? add @consumes("text/html") before code in server side, @consumes("text/html") @requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() { return employeeservice.getemployees(); }

node.js - angularjs ng-include not showing file -

i'm trying implement basic node-express angular app includes ng-include directive. this structure of app: app: server.js package.json public: js css index.html partials: header.html partial-about.html partial-homt.html the content of server.js following: var express = require("express"); var app = express(); var port = process.env.port || 8080; app.configure(function () { app.use(express.static(__dirname + "/public")); app.use(express.logger("dev")); }); app.listen(port); console.log("app listening on port: " + port); this content of index.html: <html lang="en"> <head> <meta charset="utf-8"> <title>angularjs uirouter demo</title> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <link rel="stylesheet" href="./css/style.css"> <script s...

ios - Where does filterContentForSearchText:scope: method come from? -

recently, noticed filtercontentforsearchtext:scope: appeared in multiple tutorials regarding how implement search bar. however, looked references of both uisearchdisplaydelegate , uisearchbardelegate . found filtercontentforsearchtext:scope: neither required nor optional method. i wondered if filtercontentforsearchtext:scope: conventional method name filtering search results? yes, convention common method called uisearchdisplaydelegate methods - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring; - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchscope:(nsinteger)searchoption; the current "simple uisearchbar state restoration" sample project apple not use convention: - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring { nsstring *scope; nsi...

django - Success variable message is assigned referenced before assignment -

i'm trying show success message after posting data on form. def addcostumer(request): form = costumerform(request.post or none) if form.is_valid(): save_it = form.save(commit=false) save_it.save() message = "data sent!" return render_to_response('nuevocliente.html', {'message': message}, context_instance=requestcontext(request),) you need check if request indeed post , show message if form submitted indeed valid. also, looks forgot send actual form in context. def addcostumer(request): form = costumerform() message = none #set message none default if request.method == 'post': form = customerform(request.post) if form.is_valid(): save_it = form.save(commit=false) save_it.save() message = "data sent!" #set message if object saved successfully. return render_to_response('nuevocliente.html', {'message...