Posts

Showing posts from April, 2010

stomp - Does Spring @SubscribeMapping really subscribe the client to some topic? -

i using spring websocket stomp, simple message broker. in @controller use method-level @subscribemapping , should subscribe client topic client receive messages of topic afterwards. let say, client subscribes topic "chat" : stompclient.subscribe('/app/chat', ...); as client subscribed "/app/chat ", instead of "/topic/chat" , subscription go method mapped using @subscribemapping : @subscribemapping("/chat") public list getchatinit() { return chat.getusers(); } here spring ref. says: by default return value @subscribemapping method sent message directly connected client , not pass through broker. useful implementing request-reply message interactions; example, fetch application data when application ui being initialized. okay, want, partially !! sending init-data after subscribing, well. subscribing ? seems me thing happened here request-reply , service. subscription consumed. please clarify me if case. d...

javascript - How to iterate down an Array in chunks -

i'm trying build application takes text website (for app i'm using gutenburg.org's open ebook catalog) , displays story in bites of 10 indexes @ time in div make story easier read add. have working increment function i'm stuck how increment previous chunk. html: <input type="text" id="url" style="width: 400px"> <input type="button" id="btn" value="get json"> <button id="button">next</button> <button id="prev">previous</button> <div id="test"></div> javscript: $(function() { $( '#service' ).on( 'change', function(){ $( '#url' ).val( $( ).val() ); }); //angular.module('exampleapp') $( '#url' ).val( $( '#service' ).val() ); $( '#btn' ).click(function(){ var url = $( '#url' ).val() $.ajax(...

How to open python file in default editor from Python script -

when try on windows webbrowser.open(fname) or os.startfile(fname) or os.system ('cmd /c "start %s"' % fname) python script getting executed. how open edit in default editor (like sql script) tried import ctypes shell32 = ctypes.windll.shell32 fname = r'c:\scripts\delete_records.py' shell32.shellexecutea(0,"open",fname,0,0,5) it opens file explorer @ c:\program files\ibm\gsk8\lib64\c default open , edit actions handled shellexecute winapi function (actions defined in registry in hkey_classes_root subtree). there couple of way access winapi python script. using nicer wrapper pywin32 . safer ctypes, non-standard python module. i.e: import win32api win32api.shellexecute(none, "edit", "c:\\public\\calc.bat", none, "c:\\public\\", 1) using ctypes. trickier , doesn't control arguments, may cause fault (unless provide result type , arguments type manually). import ctypes shellexecutea ...

shell - add two letters from a variable in bash script -

im working make code take input (word) , output sum of letters in input, letters equal there numeric value- a=1 b=2 c=3 etc,here unfinished code far:- echo enter word read word let in $word echo $let *here should take input , calculate output (w+o+r+d = ??) here's solution uses associative array map (english) letters ordinal values. note associative arrays require bash 4.0 or higher . #!/usr/bin/env bash # declare variables. declare -i sum # -i declares integer variables declare -a lettervalues # -a declares associative arrays, requires bash 4+ declare letter # regular (string) variable # create mapping between letters , values # using associative array. # sequence brace expression {a..z} expands 'a b c ... z' # $((++i)) increments variable $i , returns new value. i=0 letter in {a..z}; lettervalues[$letter]=$((++i)) done # prompt word. read -p 'enter word: ' word # loop on chars. in word # , sum individual letter values. sum=0 (( = 0; ...

html - How can I make this so it becomes visible when hovered over -

i'm trying make paragraph becomes visible when hover on it. in html have paragraph inside body, , i've tried in div in body.my code in css just p{ position:absolute; visibility:hidden; } p:hover p{ visibility:visible; } first of cannot put <p> elements inside <p> , might problem. can use <div> or of these container. <div><p>paragraph</p></div> div p {} div:hover p {}

validation - Getting started with PHP/Laravel - Adding Http:// and Https:// on to URL Path -

i attempting have input field adding website/url. want require submit form www.domainname.com; however, after submission want add on http:// or https:// if not added person submitting form. the validation along lines of following, public function name($id) { $input = input::all(); $validator = validator::make( $input, array( 'website' => 'active_url', ) ); } for work if statement needed. have tried inserting along lines of code listed below, have not had luck. if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { $url = "http://" . $url; } i new php , starting use laravel, apologize in advance if there confusion or lack of information. appreciated. this should work: if (stripos($url, "http://") === false && stripos($url, "https://") === false) { $url = "http://" . $url; } stripos case-insensitive, shouldn't matter if user typed in lowercase letters or not in url prefix...

phpunit - Correctly setting date.timezone on Windows 7 for PHP 5.4.35 binary only install -

i writing unit tests series of php classes in netbeans (testing phpunit). these classes rely on nusoap script don't want mock. when run tests rely on nusoap dependency, seemingly common "it not safe rely on system's timezone" error method in nusoap script: function getmicrotime() { if (function_exists('gettimeofday')) { $tod = gettimeofday(); $sec = $tod['sec']; $usec = $tod['usec']; } else { $sec = time(); $usec = 0; } return strftime('%y-%m-%d %h:%m:%s', $sec) . '.' . sprintf('%06d', $usec); } so, have gone php.ini file , added: [date] ; defines default timezone used date functions ; ; http://php.net/date.timezone date.timezone = "america/new_york" i using php binaries. there no web instance there 1 ini file modify, far know. when rerun these tests errors phpunit right away , no tests run. if ...

Android Spinner OnLongClickListener or OnItemLongClickListener -

anyone have work around set up? have spinner in action bar i'd capture long click event, either onlongclicklistener, or individual item onitemlongclicklistener - user can edit value. i've read spinner doesn't support long clicks, hoping might have changed/someone might have workaround. it's ideal solution editing string - there's not enough space in action bar put dedicated button editing, , users intuitively try long press edit. here related questions (although quite old now): android spinner item long click/touch , how can use spinner setonitemlongclicklistener you should able "simulate" long click following code: final handler actionhandler = new handler(); final runnable runnable = new runnable() { @override public void run() { toast.maketext(activity.this, "long click performed", toast.length_short).show(); } }; spinner.setontouchlistener(new ...

sql - select multiple fields from most recent record from an oracle table -

i want this: select max(field1), field2 tbl1 group field1 but above query doesn't work (sqlplus throws error). how can achieve above in single query (for now, have split 2 queries result). you use inline view , analytic function ( max() over() ) in selecting row(s) largest timestamp: select field1, field2 (select field1, field2, max(field1) over() max_field1 tbl1) field1 = max_field1; note if there many records timestamp value of max_field1 , returned (in arbitrary order).

android - Problems of recording videos and pictures -

i'd create application record video or picture, process , display it. following instructions of official guide of how use camera , invoke existing applications recording videos , pictures. there 2 buttons switch main activity video capture or picture capture. of code copied guide (features , permissions have been added). however, doesn't work. code tested on samsung galaxy 3 mini, android 4.1.2. 1, when taking picture , press "save", shows "unfortunately ..." , quits. error in onactivityresult(int requestcode, int resultcode, intent data), data seems null; 2, when taking video, can open camera view there dialog "failed record". 3, deleted onactivityresult function , tested again, take photos cannot store sd card; take videos cannot return application activity. most code above mentioned guide, , added 2 buttons. suggestions helpful, thanks! public class mainactivity extends activity { private static final int capture_image_activity_r...

c - How Read File And Separate Values -

i'm trying read file this: ninp=20 nout=1 nlaye=3 hid=30 er=0.001 epo=100 eporep=100 pscpa=0 tip=aggr net=emi numprec=0.25 prec=nh3;nox;pm10;so2;voc rag=4 and must read values after = , , prec 's values, must separate every single value (delimited ; ) new line , write new file like: nh3 nox pm10 so2 voc to read after equals symbolt there no problems, can't separate price . this function: void settaggirete(char values[20][50]){ char line[50]; int = 0, j = 0; char str[10][20]; file *conf = fopen("conf.txt", "r"); if(conf == null){ printf("impossibile apripre il file conf\n"); exit(exit_failure); } //ciclo sulle linee del file di configurazione while(fgets(line, sizeof(line), configrete) != null){ // leggo valori contenuti dopo = if(i==10){ char * str = values[10]; sscanf(line, "%*[^=]=%s", values[i]); while ((token = strs...

mysql - How can I set COLLATION of a field to utf8_general_ci with GORM? -

i have string-type field in mysql database case-insenstive , unique. used following model: type user struct { id int64 `json:"id" sql:"auto_increment"` email string `json:"email" sql:"unique_index"` } which makes email unique, type user struct { id int64 `json:"id" sql:"auto_increment"` email string `json:"email" sql:"unique_index;collation(utf8_general_ci)"` } seems have no effect. how can set collation of field utf8_general_ci gorm? you can use sql tag in field want change, this: type user struct { gorm.model name `sql:"type:varchar(5) character set utf8 collate utf8_general_ci"` }

knockout.js - Select2 4.0 and Knockout 3.1 select not allowing selection -

i'm trying knockout (version 3.1) work select2 (version 4.0rc2). i unable select accept input , have initial selection. select seems read only. below fiddle demonstrating problem. tested on chrome (version 40.0.2214.115 m). http://jsfiddle.net/r8uf5/402/ javascript: ko.utils.setvalue = function (property, newvalue) { if (ko.isobservable(property)) property(newvalue); else property = newvalue; }; ko.bindinghandlers.select2 = { init: function (element, valueaccessor, allbindingsaccessor) { var obj = valueaccessor(), allbindings = allbindingsaccessor(), lookupkey = allbindings.lookupkey; $(element).select2(obj); ko.utils.registereventhandler(element, "select2-selected", function (data) { if ('selectedvalue' in allbindingsaccessor()) { ko.utils.setvalue(allbindingsaccessor().selectedvalue, data.choice); } }); ko.utils.domnodedisposal.adddisposecallback(element, function () { $(el...

How can I declare a structure in C++ without defining it? -

i have been following tutorial @ cplusplus.com/doc/tutorial . near end of functions page, discussed prototyping function. later on, read structures. thought looked little messy, , code blocks after main method. wondered if prototype data structure. tried this: #include <iostream> using namespace std; struct astruct; int main() { astruct structure; structure.a = 1; structure.b = 2; cout << structure.a << ", " << structure.b << "\n"; return 0; } struct astruct { int a; int b; }; but ide said "astruct not declared in scope". so, how prototype data structure bulk of can below main method? the tutorial pages: functions data strucutres generally reason pre-declaring structure avoiding circular references in defining structures. right solution use header, , hide structure definition in header instead: inside astruct.h : struct astruct { int a; int b; }; inside main.cpp ...

symfony - Symfony2 form: no empty choice -

building symfony2 form choices, there option "empty value", set text related empty choice. however, want set choice field mandatory, empty value should displayed no choosen. using empty or null constraints, there no error when user send "" value. how should done? you can add notblank() validation constraint appropriate property in form's underlying entity. how depends on whether using annotations or yaml validation definitions. there information validator here: http://symfony.com/doc/current/reference/constraints/notblank.html hope helps :)

c# - Retrieve column name from a gridcontrol in mvvm design -

hi working on wpf project in have grid control . itemssource property of grid control bound datatable in viewmodel. following mvvm pattern, question need bind selectedcell property of grid control property in view model class. possible determine name of column in cell resides binding property in view model class. know event handler can attached cell call function in code behind view, dont wish follow approach since not mvvm. kindly me suggestions. in xaml bind currentcell property datagridcellinfo in view model: <datagrid selectionunit="cell" selectionmode="single" itemssource="{binding mydatatable}" currentcell="{binding selectedcellinfo, mode=onewaytosource}"/> then in view model can access header bound object: public datagridcellinfo selectedcellinfo { { return _selectedcellinfo; } set { _selectedcellinfo = value; onpropertychanged("selectedcellinfo"...

Fortran performance when passing array slices as arguments -

i fortran's array-slicing notation ( array(1:n) ), wonder whether take performance hit if use them when it's not necessary. consider, example, simple quicksort code (it works, it's not taking care pick pivot): recursive subroutine quicksort(array, size) real, dimension(:), intent(inout) :: array integer, intent(in) :: size integer :: p if (size > 1) p = partition(array, size, 1) call quicksort(array(1:p-1), p-1) call quicksort(array(p+1:size), size-p) end if end subroutine quicksort function partition(array, size, pivotdex) result(p) real, dimension(:), intent(inout) :: array integer, intent(in) :: size, pivotdex real :: pivot integer :: i, p pivot = array(pivotdex) call swap(array(pivotdex), array(size)) p=1 i=1,size-1 if (array(i) < pivot) call swap(array(i), array(p)) p=p+1 end if end call swap(array(p), array(size)) end funct...

gradle error "Cannot convert the provided notation to a File or URI" -

i have defined 2 system properties in gradle.properties: systemprop.builddir=build systemprop.cfgdir=build\\cfg and have following task defined in build.gradle: task clean(group:'clean',description:'clean project') << { ant.sequential { delete(dir: system.properties.builddir) mkdir(dir: system.properties.builddir) delete(dir: system.properties.cfgdir) mkdir(dir: system.properties.cfgdir) } } this generates following error: execution failed task ':clean'. > cannot convert provided notation file or uri: {dir=build}. following types/formats supported: - string or charsequence path, e.g 'src/main/java' or '/usr/include' - string or charsequence uri, e.g 'file:/usr/include' - file instance. - uri or url instance. but equivalent block of code not generate error , works expected: task clean(group:'clean',description:'clean project') << { ...

apache - Understanding `mod_rewrite`: internally redirect `foo.txt` to `foo.txt.cgi` where `foo.txt` doesn't exist? -

my goal serve .txt files out of directory, particular .txt file not exist, want perform internal redirect named .txt.cgi script, if such script exists. question pertains why 1 approach seems work, 2 alternate approaches not work. i have following directory structure (i.e., subdirectory somewhere in /var/www or equivalent): % ls -arl rewritecgi total 0 drwxr-sr-x 2 posita posita 170 mar 16 14:36 test1 drwxr-sr-x 2 posita posita 170 mar 16 14:38 test2 drwxr-sr-x 2 posita posita 170 mar 16 14:38 test3 rewritecgi/test1: total 24 -rw-r--r-- 1 posita posita 288 mar 16 14:36 .htaccess -rw-r--r-- 1 posita posita 28 mar 16 14:34 other.txt -rwxr-xr-x 1 posita posita 143 mar 16 14:20 test.txt.cgi rewritecgi/test2: total 24 -rw-r--r-- 1 posita posita 301 mar 16 14:38 .htaccess -rw-r--r-- 1 posita posita 28 mar 16 14:34 other.txt -rwxr-xr-x 1 posita posita 143 mar 16 14:19 test.txt.cgi rewritecgi/test3: total 24 -rw-r--r-- 1 posita posita 288 mar 16 ...

Mongoose sum aggregation -

i have mongoose schema sum of sizes based on creator. creator: { type: schema.types.objectid, ref: 'user' }, archives: [{ archiveid: string, url: string, name: string, size: number, isset: { type: boolean, default: false }, timestamp: { type: date, default: date.now() } }] this have tried far, total keeps coming 0 var objectid = require('mongoose').types.objectid; archivemodel.aggregate( { $match: { 'creator': new objectid(creatorid), } }, { $group: { _id: null, total: {$sum: '$archives.size'} } }, { $project: { creator: 1, total: 1 } }, function(err, result) { console.log(err); console.log(result); } ); db.col.aggregate([ // match docs right creator {$match: {cr...

php - JSON data do not appear in jquery ui autocomplete -

i using jquery ui autocomplete display filtered data database. using browser's network utility confirm json data returned server correctly. nothing displayed in autocomplete menu , looking @ page's source "no search results". if use response body browser's network utility source jquery ui autocomplete, works fine. appreciated. the html <div class="col-lg-4 col-sm-4 col-xs-12 pull-right ui-widget"> <div class="input-group"> <input class="form-control" name="afm" id="autocomplete" /> <span class="input-group-addon"><i class="fa fa-search"></i></span> </div> </div> the javascript $( "#autocomplete" ).autocomplete({ delay:500, minlength:2, source: "getafmjson.php", select: function( event, ui ) { location.href="userpage.php?idx=22&q="+ui.item.id; } }); the php...

NODE.JS - OpenShift 503 Service is Temporarily Unavilable: Server.js and Package.json files are fine -

project running on node.js server: i'm going crazy on here. can't figure out why getting 503 error when have done open shift instructs do. server.js: var server_port = process.env.openshift_nodejs_port || 8080; var server_ip_address = process.env.openshift_nodejs_ip || '127.0.0.1'; server.listen(server_port, server_ip_address, function(){ console.log("listening on " + server_ip_address + ", server_port " +server_port); }); package.json: { "scripts": { "start": "supervisor server.js" }, "main": "server.js" } i have gone through logs , everything, , says there issue @ line 5 on server.js. how so? going crazy, or missing something? npm modules cleared, , application says fine. this not replica of post, because have done of those. server log trail error: referenceerror: server not defined @ object.<anonymous> (/var/lib/openshift/550764f6e0b8cd8a8a00007e/app-...

r - Why does combining two `data.frame` objects using the `data.frame` function cut off a long variable name? -

i have noticed if try combine 2 different data.frame objects larger data.frame using data.frame function, variable names cut off (i.e. see output of names(db) code below. i avoid situation combining variables using data.table function instead. my question is: why data.frame command cut off variable names? may quite simple question, , can solved using as.data.frame function on data.table object convert data.frame , curious why variable names cut off in first place if use data.frame function. have tried looking insight using in r, , on google, have found no success far. seeking answer more me better understand how r, , data.table , data.frame works (as relatively new r user, having switched stata). thanks in advance! > <- data.frame(rnorm(100)) > b <- data.frame(rnorm(100)) > names(a) <- "thisisaveryverylongvariablename-mean()" > names(b) <- "thisisanotherveryverylongvariablename-std()" > db <- data.frame(a, b) ...

sql server - Query hint for insert from stored procedure -

i'm running sql server 2014. in following code, have temp table (defined earlier in code) being filled stored procedure. of parameters stored procedure standard data types, @grouplayoutspecifications table variable accepts small heap table joined within stored procedure. insert #standardizedresponses exec rpt.usp_querybuilder_gatherstandardizedresponses @member, @orgunits, @groups, @measurename, @startdate, @enddate, @instrumenttypeids, @backgrounddataids, @grouplayoutspecifications; the problem i'm having query engine isn't able estimate number of rows stored procedure return. typical estimate return of 1 row, actual return of closer 200k rows. believe causing tempdb spillover later in plan. is table-type parameter causing query engine grief? if so, how might around that? similarly, there way hint sql server following query result in larger expected row count? i've researched quite bit through things msdn...

html - PHP converting URL string to ASCII characters -

i have string of characters passed in url. the string happens contain group of characters equivalent ascii code. when try use string on page using $_get command, converts part of string equivalent ascii code ascii code instead of passing actual string. for example url contains string name='%bert%' . when echo out $_get['name'] '3/4rt%' instead of '%bert%' . how can actual text? you're not escaping data properly. if want use %bert% in url, need encode % %25 , making query string value %25bert%25 . % in url means next 2 characters going encoded entity, if want use literally, must encoded way. you can read more information here: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

Sitecore 8 Multisite Experience Analytics -

i have multisite sitecore site working , have question regarding analytics , marketing tools. lets says have corporatesite, subsitea, , subsiteb ease of explanation. knowing that, content tree following: - corporatesite.com + content - subsitea.corporatesite.com + content - subsiteb.corporatesite.com + content now, lets have users correspond each site: corporatejoe = corporatesite admin, subsitea admin, subsiteb admin subsiteajoe = subsitea admin subsitebjoe - subsiteb admin corporatejoe have full access following: marketing control panel experience analytics experience profile corporatejoe create campaigns, view analytics, run reports, etc. subsiteajoe , subsitebjoe should have same rights site. i know can handle security content , nodes using roles, users, etc, how can allow administrators of each multisite utilize marketing tools , analytics site? possible? i don't believe possible. site name recorded field on xdb visits, , later on inc...

Could we prevent users' cursor turn into selection tool with css? -

with user-select: none able prevent user selecting text in undesired areas menu, browser cursor still turn selection tool, suggesting selectable. there way prevent behavior? better yet, can manipulate cursor link indicator? you can use pointer-events: none avoid having cursor turning selection tool. unaware if can turn cursor link indicator css.

twitter bootstrap - jQuery click events multiple times -

i know question has been asked several time haven't found answer works me. i have dynamic content being loaded via ajax , using bootstrap along masonry allow each post displayed in brick style. user scrolls page new post loaded. i have dropdown on each post listed actions user can perform such edit post. when user clicks edit post link modal poped allowing them edit there post. when user clicks update button first time well. if user clicks post edit , clicks update button both previous post , current post updated. happens in infinite state meaning each time update previous 1 updated. my code: modal $(document.body).on("click", ".editpost", function(){ // post id update var post_id = $(this).closest('.panel').attr('id'); // set modal title $('#mymodallabel').html('edit post'); // post text var panel_body = $('#'+post_id).children('.panel-body'); $('.modal-body').html(...

ios - Swift Function Error: 'Float' is not convertible to 'Void' -

i have following function, generates quick nsurlconnection request , returns contents of page. function gives me error on return line 'float' not convertible 'void' func getdji(year: int, month: int, day: int) -> float { let baseurl = "http://geo.crox.net/djia" var request = nsmutableurlrequest(url: nsurl(string: string(format:"%@/%02d/%02d/%02d",baseurl, year, month, day))!) httpget(request){ (data, error) -> void in if error != nil { println(error) } else { return (data nsstring).floatvalue } } } what going wrong? there 2 problems here. first, you've got closure supposed return void , you're trying return float it, , second, you've got function supposed return float , never return it. what might make sense outer function return void , , accept closure expects float , returns void : func getdji(year: int, month: int, day: int, complet...

python - Numpy Summation for Index in Boolean Array -

in numpy have boolean array of equal length of matrix. want run calculation on matrix elements correspond boolean array. how do this? a: [true, false, true] b: [[1,1,1],[2,2,2],[3,3,3]] say function sum elements of sub arrays index 0 true : add 3 summation (starts @ zero) index 1 false : summation remains @ 3 index 2 true : add 9 summation total of 12 how do (the boolean , summation part; don't need how add each individual sub array)? you can use boolean array a index rows of b , take sum of resulting (2, 3) array: import numpy np = np.array([true, false, true]) b = np.array([[1,1,1],[2,2,2],[3,3,3]]) # index rows of b true (i.e. first , third row of b) print(b[a]) # [[1 1 1] # [3 3 3]] # take sum on elements in these rows print(b[a].sum()) # 12 it sounds benefit reading the numpy documentation on array indexing .

javascript - How to get AJAX response before sending to template using DATATABLES? -

i implementing log tables in admin panel , used datatable plugin. created ajax in datatable don't know how response before sending table. i have in jquery: <script type="text/javscript"> $(document).ready(function() { $('#log-pageview') .on('xhr .dt', function(e, settings, json) { $('#status').html(json.status) }) .datatable({ "processing": true, "serverside": true, "ajax": "/secure/logs/visits.php?log_get=1" }); }); </script> in html have this: <table id="log-pageview" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>log id</th> <th>user id</th> <th>ip address</th> <th>date viewed</th> ...

ios - Can I apply the same animation to multiple text fields? -

i'm creating method shakes uitextfield , use pop heavy lifting. - (void)textfielderroranimation { popspringanimation *shake = [popspringanimation animationwithpropertynamed:kpoplayerpositionx]; shake.springbounciness = 10; shake.velocity = @(2000); [self.value.layer pop_addanimation:shake forkey:@"shakevalue"]; [self.year.layer pop_addanimation:shake forkey:@"shakeyear"]; } it seems working when apply animation object "value" not when it's applied "value" , "year" @ same time. i know can create shake2, shake3 etc 1 each textfield seems strange i'd need that. any ideas how can reuse animation? of course can. about, kind of reusing animations creating method returns animation , setting name , key values correctly. - (popspringanimation *)popshakeanimation { popspringanimation *shakeanimation = [popspringanimation animationwithpropertynamed:kpoplayerpositionx]; shakeanimation.vel...

android - how to check if user watched whole video using YouTube api -

is there way find out if user watched whole video or not..i want update database if user watches whole video. please this. ps: don't care if user skipped end or watched whole thing. i did find way using following listener, method looking onvideoended(). private playerstatechangelistener playerstatechangelistener = new playerstatechangelistener() { @override public void onadstarted() { } @override public void onerror(errorreason arg0) { } @override public void onloaded(string arg0) { } @override public void onloading() { } @override public void onvideoended() { } @override public void onvideostarted() { } }; and in method oninitializationsuccess(provider provider, youtubeplayer player, boolean wasrestored) add above listener player: player.setplayerstatechangelistener(playerstatechangelistener); i hope helps :)...

c# - Is there a way to terminate MVC Razor @: line? -

consider example: <input type="checkbox" @if (flag) { @: checked } /> the problem } /> conceived razor engine part of output string. i've tried use parenthesis no luck. is there way terminate @: operator in same line, or i'll have split other line / use ternary operator? update a common use-case of request can adding class if value true: <div class='container @(active ? "active")'/> so if : of ternary operator isn't present, treats treats unary if operator, that's wish... here 's suggestion on c# uservoice. for single attribute can use @value syntax, have special case checkbox (see razor quick reference ): <input type="checkbox" checked="@flag" /> you can use <text> syntax provides explicit (instead of "up end of line") closing tag: <input type="checkbox" @if (flag) { <text>checked</text> } />

Few Errors Using Swift -

Image
i trying build small random number guessing game using command line tool in xcode. i have added image of errors come xcode ide import foundation var randomnumber = 1 var userguess = 1 var continueguessing = true var keepplaying = true var input = "" while (keepplaying) { randomnumber = int(arc4random_uniform(101)) //to random number between 0-100 println(" random number guess is: \(randomnumber)" ); while (continueguessing) { println(" pick number between 0 , 100. ") input = nsstring(data: nsfilehandle.filehandlewithstandardinput(). availabledata,encoding:nsutf8stringencoding)! //get keyboard input input = input.stringbyreplacingoccurrencesofstring("\n", withstring: "", options:nsstringcompareoptions.literalsearch, range: nil)//strip off the/n userguess = input.toint()! if (userguess == randomnumber) { continueguessing = false println(...

javascript - why is jquery not loading -

for reason when try load jquery via cdn, works perfectly script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" however, when try load using local files, not work script type="text/javascript" src="javascripts/jquery-1.11.2.min.js" and displays error: uncaught syntaxerror: unexpected token < jquery-1.11.2.min.js:1 i must server running on node.js it seems have syntax error tag. try this. <script type="text/javascript" src="javascripts/jquery-1.11.2.min.js"></script>

winforms - C# - Windows Forms - Media Player -

i creating movie theater program blanks other screens , plays movie file on 3rd monitor (tv). have suggestion media player. media player giving activex error , not want border play pause , fast forward buttons etc. windows forms don't have media element. suggestions different media player. thanks! you can change media player uimode property none player.uimode = "none"; windows media player embedded without controls, , video or visualization window displayed.

java - cmd "Error: Could not find or load main class" error -

Image
i've read through other questions , have tried googling solutions, couldn't find solution looking for. this program compiles , runs on netbeans, complies on cmd. want running cmd. i'm not java - starting out , uni project. the program in package chess . move folder, c:\users\nihir\documents\chess> cd ..\ c:\users\nihir\documents> java -cp . chess.program

for loop - Python Document Comparison - returning ALL words NOT IN other document -

i'm trying create "translation comparison" program reads , compares 2 documents , returns all words in 1 document aren't in other document. right now, program returns first instance of word in 'file1' not being in 'file2'. beginner class, i'm trying avoid using obscure internal methods, if means less efficient code. have far... def translation_comparison(): import re file1 = open("desktop/file1.txt","r") file2 = open("desktop/file2.txt","r") text1 = file1.read() text2 = file2.read() text1 = re.findall(r'\w+',text1) text2 = re.findall(r'\w+',text2) item in text2: if item not in text1: return item you can this: def translation_comparison(): import re file1 = open("text1.txt","r") file2 = open("text2.txt","r") text1 = file1.read() text2 = file2.read() text1 = re.findall(r'\w...

ios - Point to Point Animation -

http://postimg.org/image/8bwxdp4bj/7124c28f/ want make animation shown in above image .i using code .they became move infinity , view not appear because involved in loop. newer in ios . please help.what stuck.any appreciated. for (i=0; i<3; i++) { if (i==0) { first.backgroundcolor=[uicolor blackcolor]; second.backgroundcolor=[uicolor yellowcolor]; third.backgroundcolor=[uicolor yellowcolor]; button.backgroundcolor=[uicolor yellowcolor]; i=1; } if (i==1) { first.backgroundcolor=[uicolor yellowcolor]; second.backgroundcolor=[uicolor blackcolor]; third.backgroundcolor=[uicolor yellowcolor]; button.backgroundcolor=[uicolor yellowcolor]; i=2; } if (i==2) { first.backgroundcolor=[uicolor yellowcolor]; second.backgroundcolor=[uicolor yellowcolor]; third.backgroundcolor=[uicolor blackcolor]...

jquery on each bind text for parent attribute name values -

i trying own tooltip, should show value of parent element name value: i appending new div after anchor tag, , try bind text value of parent anchor name value... but getting last name value(tooltip 3333333333333) in (.tooltipcontainer) div ? can 1 resolve? html: <!-- tooltip - begin --> <ul> <li><a name="tooltip 1111111111111" class="customtooltip">tool tip 1111</a></li> <li><a name="tooltip 2222222222222" class="customtooltip">tool tip 222</a></li> <li><a name="tooltip 3333333333333" class="customtooltip">tool tip 333333</a></li> </ul> <!-- tooltip end --> js: $(document).ready( function() { $(".customtooltip").each(function(i){ var customtooltipname = $(this).attr('name'); ...

html - Is possible change css inline <div id="feedback_xxx" -

is possible change css inline <div id="feedback_xxx" css? id variable example: <div id="feedback_0gj0ftyrmdv0nl50j" <div id="feedback_0gj0ftyrmdv0nl55l" <div id="feedback_00j0ftyrmdv0nl50j" rules css? you can't in css. but can using jquery here's how assign id programmatically $('#oldid').attr("id","#newid");

How to use IN in SQL Server with Select -

select category pea_template temp_id = 000001 , temp_version = 2 this query returns '000001','000002' saved in category column in format. select * hr_category cat_code in ('000001', '000002') this select working fine row string select * hr_category cat_code in (select category pea_template temp_id = 000001 , temp_version = 2) but when use query inside in not return value. what reason this? way fix this? if category can have concatenated strings apostrophe e.g. '000001' or '000001','000002' , better use join construction, this: select * hr_category inner join (select category pea_template temp_id = 000001 , temp_version = 2) pea on pea.category '%'''+cat_code+'''%'

How to Create Password validation in iOS? -

this question has answer here: password validation in uitextfield in ios 10 answers i new ios, how create password validation in ios. in uitextfield allows numbers,one uppercase,lowercase , special characters. password length 8 characters. advance thank, examples. if want validate password, in button click, mean after have typed password, , click button , want validation work---- how --- create ibaction button--- -(void)validatewithbuttonclick:(id)sender{ nsstring *textfrompassword = _mypasswordtextfield.text; bool hasoneupper = no; bool hasonelower = no; bool hasonespecial = no; bool is8digit = no; if(pass.length >=8){ is8digit = yes; } (int =0; i<pass.length; i++) { char c1 = [pass characteratindex:i]; if([[nscharacterset uppercaselettercharacterset] characterismember:c1]){ hasoneupper = yes; continue; } else i...