Posts

Showing posts from September, 2015

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

cakephp - Cake php multiply Find Conditions OR /AND -

hey guys have been struggling .i trying select table using cakephp find e.g want select table (a == 1 , b == 2) or (a == 2 , b == 1) on query here code far $conditions = array("or"=> array("message.to_to"=>$daddy["user"]["id"], "message.from_from"=>$this->auth->user("id")), array("message.to_to"=>$this->auth->user("id"), "message.from_from"=>$daddy["user"]["id"]) ); to expected result (a == 1 , b == 2) or (a == 2 , b == 1), try nesting 'and' conditions missing code. you need specify conditions parameter. try following: $conditions = array( 'conditions' => array( "or"=> array( "and" => array( "message.to_to"=>$daddy["user"]["id"],

sql server - SQL replace occurrances based on a table -

hi i've sql issue solve; i've these tables: table varchar column tst tst '2','5','8' '2','6' '4','12' table b int column rep rep 2 6 i'm looking query (without cycle while) update table in following way: tst 'r','5','8' 'r','r' '4','12' using char 'r' replace occurrances of table b in table a thanks in advance sqlfiddle demo update t1 set tst = stuff(z,1,1,'') --remove leading comma final result ( select --convert original string xml tst ,cast('<a>'+replace(tst ,',','</a><a>')+'</a>' xml) x tst ) t1 cross apply ( select --replace value 'r' when matched in rep ','+case when rep null y.value('.','varchar(max)') else '''r''' end x.nodes('a') t2(y) --explode xml separate values

Android - Application crashes with Out Of Memory when selecting very large image -

this question has answer here: strange out of memory issue while loading image bitmap object 39 answers in below code, getting exception "out of memory on byte allocation" large size images in function "getscaledbitmap" when processing decodefile second time in code. below function being called 4 times, processing 4 different images on screen. please guide on this. private bitmap processimage(string picturepath){ bitmap thumbnail =null; thumbnail=getscaledbitmap(picturepath,500,500); matrix matrix = null; try { exifinterface exif = new exifinterface(picturepath); int rotation = exif.getattributeint(exifinterface.tag_orientation, exifinterface.orientation_normal); int rotationindegrees = bal.exiftodegrees(rotation); matrix = new matrix(); if (rotation != 0f) {

What to import to use Facebook Graph API in iOS? -

Image
i need user friends list. understood how login fb app button. can not come across on line: which header file should import use graph api? /* make api call */ [fbrequestconnection startwithgraphpath:@"/{friendlist-id}" completionhandler:^( fbrequestconnection *connection, id result, nserror *error i installed frameworks see below, , included header. can not see graph stuff. #import <fbsdkcorekit/fbsdkcorekit.h> #import <fbsdkcorekit/fbsdkcorekit.h> #import <fbsdkloginkit/fbsdkloginkit.h> try using in way updated in sdk 4.0 [[[fbsdkgraphrequest alloc] initwithgraphpath:@"/me/friends" parameters:nil] startwithcompletionhandler:^(fbsdkgraphrequestconnection *connection, id result, nserror *error) { if (!error) { nslog(@”fetched user:%@”, result); } }]; refer : https://developers.facebook.com/docs/ios/

.net - Windows 8 application works on computer but not on windows tablet -

i having weird problem windows 8 application, coded in vb.net, works fine on computer when install on tablet not work. here did in visual studio : project -> windows store -> create application packages. here did on tablet : transfered files created tablet ran powershell , installed application successfully. tried run white square "x" inside of (default application icon) shows , brought start menu. the application seems running open in task bar . however, does not show in task manager . i tried running powershell install application on computer , works fine . to make sure tablet wasn't problem created empty application , worked fine on tablet i tried proposed here , still doesn't work : http://answers.microsoft.com/en-us/windows/forum/windows8_1-windows_store/all-modern-apps-fail-to-start-after-windows-81/a80793c7-c214-43ec-9ca9-5c758f9ad840 any ideas causing problem ? can't seem find fix it this windows tablet : dell venue 11 pro (5

security - Java jersey importing packages -

i'm trying remake solution found here basic http authentication jersey / grizzly i've included these imports far import javax.ws.rs.webapplicationexception; import javax.ws.rs.container.containerrequestfilter; import javax.ws.rs.core.response; import javax.ws.rs.core.httpheaders; import javax.ws.rs.core.response.status; and after search included one import org.glassfish.jersey.server.containerrequest; my problem these errors ... authfilter not abstract , not override abstract method filter(containerrequestcontext) in containerrequestfilter ... method not override or implement method supertype ... cannot find symbol [error] symbol: method getheadervalue(string) [error] location: variable containerrequest of type containerrequest and code if don't want switch tabs here @override public containerrequest filter(containerrequest containerrequest) throws webapplicationexception { // automatically allow requests. string

domain driven design - Entity Framework Fluent API and MultiBoundedContext -

i have applied multi bounded context principle of domain driven design , have 3 different objects (in 3 different domain contexts) pointing same table in database. julie lerman suggested, have shared database model has objects. shared database model used code-first migrations. have fluent api configurations represent foreign key relationships , column constraints on shared database model. question is, should let 3 domain specific contexts know of these fluent api configurations. validate object graph in each of these contexts. should worry string lengths, required etc etc on these separate domain contexts? necessary/good practice configure these relationships on each of 3 separate domain contexts? yes, have repeat fluent api configurations in smaller domain specific models.

javascript - document.frame is not working in ie11 -

i getting undefined object error while executing in ie 11 without compatible mode. works fine in ie 11 compatible mode. sample code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script> function test() { var parent = document.getelementbyid("tabpanemain"); var doc = document; var html = '<div class="tab-page" id="tabcust" style="width: 100%; height: 95%">' + '<h2 class="tab">customer</h2>' + '<table cellpadding=2 cellspacing=0 width="100%" height="100%">' + '<tr><td valign=top id=iframeparent_tabcust>' + '<iframe name="iframe_tabcust" id="iframe_tabcust" src="overview.html" style="width=100%; height: 100%;" scrolling="no" fram

excel - Make a cell scroll/marquee text right to left? -

i have cell m2 in excel contains large amount of text. trying figure out way of making text scroll right left continuously. i have done lot of looking on web can find codes don't make sense me , want try , make simple possible. please show me simple way of getting want. sub startmarquee() dim smarquee string dim iposition integer smarquee = "this scrolling marquee" me .tbmarquee .text = "" iposition = 1 len(smarquee) .text = .text & mid(smarquee, iposition, 1) application.wait timeserial(hour(now()), minute(now()), second(now()) + 1) next iposition end end 'beep 'application.ontime + timeserial(hour(now()), minute(now()), second(now()) + 2), "startmarquee" end sub while done inside of loop in subroutine, entire application going locked while loop executing, make extremely unhelpful. instead think of 1 run of subroutine single iteration. when sub runs want detect in message marquee @ in cell m13, , push message 1 more

What is the equivalent of Python's list[:x] in C++? -

in python, if have list l , want first x elements of it, call l[:x]. in c++, use vectors instead, don't know of easy way invoke first x elements of vector. there several ways: 1) create vector v consisting of first x elements as: std::vector<t> v { begin(l), begin(l) + x }; 2) pass first x elements function, pair of iterators: f(begin(l), begin(l) + x); where f accepts 2 iterators arguments — explore standard algorithms <algorithm> , of them work on pair of iterators. depending on use case, use of them.

java - How to start file browser app from Android application? -

i have app started "share via" menu , list of selected files input. now, let user able run file browsing app app , results. i know example can start phonebook , obtain choosen contact(s) following code: intent intent = new intent(intent.action_pick, contactscontract.contacts.content_uri); startactivityforresult(intent, pick_contact); so question is: there similar way run file browser , in return list of files selected? edit: "possible duplicated post" partially similar, ask how start file manager inside specific path, , way hasn't accepted answer. need, if possible, start file manager (if there one) specific path , in return selected files. thank much cristiano ok, found answer here on , combining davidjohns comment i've got need. thank cristiano

Create Dictionary in Javascript / PHP -

i'm trying create dictionary .txt file in shape of tree. on every line of text file there's word, extract words in array. now regarding tree, each node contains letter, if it's last letter of word, contains definition, , each node have array children contains letters others words starting same way. so have nodes defined way: function node(letter,definition,children) { this.letter = letter, this.definition = "", this.children = [] }; i have array dictionary contain nodes. every node organized (so know 'a' in dictionary[0] , 'b' in dictionary[1] , on). i defined functions build dictionary: check if dictionary contains first letter of word have (c character, dictio dictionary array , ascii ascii-97 value of character) function checkchar(c,dictio,ascii){ if(dictio[ascii].letter == c ){ return true; } return false; }; create node given character function createchar(c){ var noeud = { let

html - Facebook Page Plugin width doesn't apply -

Image
i'm trying implement facebook page plugin . set width 500, stays @ 280px. <div id="facebook-feed" style="text-align: center"> <div class="fb-page zdepth-1" data-width="400" data-href="https://www.facebook.com/facebook" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"></div> </div> what doing wrong? the page plugin tries fit in smaller containers/screens the plugin renders @ smaller width (to fit in smaller screens) automatically, if container of slimmer configured width. it tries render nicely on smaller screens assuming container squeezes mobile. so probably, in case container holding plugin smaller configured width i.e. 500px .

Simple AngularJS scope issue (newbie) -

i'm trying figure out how user's email passed controller i'm getting undefined $scope.user.email . $scope defined there's no user object in there. there wrong code? html <label class="item item-input"> <span class="input-label">email</span> <input ng-model="user.email" type="text"> </label> <button ng-click="signinclick()" class="button button-full button-positive"> sign in </button> controller .controller('welcomectrl', function($scope) { $scope.signinclick = function() { console.log($scope.user.email); } }) edits the controller linked via js/apps.js , runs when button clicked know it's linked welcomectrl . because $scope.user undefined. .controller('welcomectrl', function($scope) { $scope.user = {}; $scope.signinclick = function() { console.log($scope.user.email); } })

python - Connection with boto to AWS hangs when running with crond -

i have basic python script uses boto query state of ec2 instances. when run console, works fine , i'm happy. problem when want add automation , run script via crond . notices script hangs , waits indefinitely connection. saw boto has problem , people suggested add timeout value boto config file. couldn't understand how , where, added manually /etc/boto.cfg file suggested timeout value (5) didn't help. strace can see configuration file never being accessed. suggestions how resolve issue? there chance cron environment not close enough interactive shell of login prompt. paths , things .boto or boto.cfg files not found or in same place in cron's environment. also, on systems (ubuntu) cron runs dash , not bash, things different. if croning script, try source /etc/boto.cfg file or set aws environment variables make sure it's using proper settings better yet - read them in python script making portable , not reliant on env. vars. from configpars

ios - MPMoviePlayerController not staying within bounds of UIView -

Image
i trying add video uiview container within modal window. when add video not stay within bounds of uiview bounded to. here picture of looks like: the grey container can see right edge of container , here view controller adds video. import foundation import mediaplayer class evalinstructionsvc: uiviewcontroller { private var movieplayer : mpmovieplayercontroller? @iboutlet weak var video: uiview! func playvideo() { let path = nsbundle.mainbundle().pathforresource("time rotate demo", oftype:"mp4") let url = nsurl.fileurlwithpath(path!) movieplayer = mpmovieplayercontroller(contenturl: url) if let player = movieplayer { player.view.frame = video.bounds player.view.center = cgpointmake(cgrectgetmidx(video.bounds), cgrectgetmidy(video.bounds)) player.preparetoplay() player.scalingmode = mpmoviescalingmode.aspectfill video.addsubview(player.view) }

javascript - How can you check if an input (email) field contains a special character using JQuery -

currently, i'm using following code doesn't seem work. throw error if user fails enter "@" symbol in input field. please bear me. thanks my following code is: var emailaddressval = $("input[name='emailaddress']").val().split('@').slice(1)[0].trim(); if(emailaddressval .match(/@/) !== null) { alert('an @ symbol not entered'); } looks you're doing lot more work need to. split() call searches bad character, stop there , see if string split or not. that's not clear way of expressing intent. if you're looking specific character, don't need regex. why not if ( $("input[name='emailaddress']").val().indexof('@') > -1 ) { /* found '@' character; handle */ } else { /* not found, handle appropriate */ alert("missing required '@' character"); } indexof returns non-negative value if finds string. see https://developer.mozilla.org/e