Posts

Showing posts from June, 2012

c# - How to display checkboxes in MVC with Razor -

i trying create view viewmodel includes many checkboxes. can list checkboxes couldnt figure out labels. @for (int = 0; < model.colors.count; i++) { @html.editorfor(x => x.colors[i].checked) @html.labelfor(x => x.colors[i].color) } the second line in loop displays "color" next every checkbox. proper way display value in x.color[i].color? the first parameter of labelfor() should same used editorfor() the label associated controls (clicking on label toggles checked state of checkbox). second parameter can provided 'display text'. refer documentation @for (int = 0; < model.colors.count; i++) { @html.editorfor(x => x.colors[i].checked) @html.labelfor(x => x.colors[i].checked, model.colors[i].color) }

c# - How can I fetch non-english column names from a table in SQL Server 2008? -

i have created items_table. columns' name of table ਸੋਯਾਬੀਨ , ਕਨ੍ਨੀ , in language other english. created columns using alter table item_table add "+item.text+" nvarchar(50); where non-english column name entered in textbox on ui. in next step want fetch column names table , add them item in combobox in c# app. want know query can fetch non-english column names. using query-->> select * information_schema.columns table_name=n'item_table' and returns name of database. based on little info posted, assume you're looking information_schema . select * information_schema.columns or select * information_schema.columns table_name=n'mytable'

apache - Where's that "index.php" coming from after rewrite? -

i added following code htaccess: rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(?:.+/)?(\d+)/?$ ?id=$1 [l,qsa] the "l"-flag should prevent forthcoming rules apply, don't why url www.domain.com/a/b/c/d/123 is rewritten to www.domain.com/index.php?id=123 i'm sure of can enlighten me! your pattern is: ^(?:.+/)?(\d+)/?$ which matching /a/b/c/d in first non-capturing group , capturing 123 in captured group #1. target ?id=$1 rewriting above url ?id=123 . now index.php default directory index due directoryindex directive hence invoking index.php?id=123 .

python - NumPy/Scipy locks PyQt event loops -

i want call time-consuming scipy functinons dedicated pyqt qthread. afaik, when calling scipy functions, release gil , qt event should work. cannot tell me, how can cope it? # -*- coding: utf-8 -*- import numpy np import scipy sp import scipy.interpolate import os import sys import time pyqt4 import qtcore, qtgui class longrunningworker(qtcore.qobject): result_ready = qtcore.pyqtsignal(tuple) @qtcore.pyqtslot() def generate_uber_mega_data(self): print "oy!" # time.sleep(5) r_ticks = np.linspace(0, 1000, 5000) phi_ticks = np.linspace(0, 2 * np.pi, 5000) r_grid, phi_grid = np.meshgrid(r_ticks, phi_ticks) print u"starting interpolation" spline = sp.interpolate.rectbivariatespline(r_ticks, phi_ticks, r_grid * phi_grid) print u"Интерполяция всё / interpolation complete" time.sleep(5) print "vey!" self.result_ready.emit((7, 40)) @qtcor

java - Find multiple matches using Regex -

i trying find occurrences (there 0 or more) of anchor( <a> ) html tags specific attributes/text (to captured groups). regex : <a\s+.*attr1="myattr".*attr2="(.+)".*attr3="(.+)".*>(.+)</a> input string : first <a attr1="myattr" attr2="value12" attr3="value13">text1</a> second <a attr1="myattr" attr2="value12" attr3="value13">text1</ a> third <a attr1="myattr" attr2="value12" attr3="value13">text1</a> outcome: says 1 occurrence found. returning first occurrence of " <a " starting index (of match) correct, says last occurrence of " </a> " end index. expected outcome: 3 matches , in each match 3 groups (specified parentheses in regex). regex default greedy, .* match many characters possible. should instead use .*? non-greedy mode.

php - Inserting multiple rows mysql in codeigniter -

i trying insert multiple rows @ once using codeigniter my html code codeigniter view <?= form_open(base_url() . 'home/create') ?> <tbody> <tr> <td class="col-md-1 center-block"> <input type="text" name="id[]" value="1" class="form-control" /> </td> <td> <input type="text" placeholder="enter descreption" class="form-control" name="desc[]" /> </td> <td class="col-md-2 center-block"> <input id="space" onkeyup="sumprice()" type="number" class="form-control" name="space[]" /> </td> <td>

javascript - ng-repeat angular adding two elements to a div as opposed to one when iterating through array -

i using angular make request return live data. wish display data on home page. the code in controller follows: $scope.holder = []; $http.get('url').success(function(data){ $scope.lines = data.lines; $.each($scope.lines, function(name){ $scope.holder.push(this.friendly_name); $scope.holder.push(this.status); }); }); }); the $scope.holder array looks after data has been called: ["bakerloo", "good service", "central", "part closure", "circle", "good service", "district", "part closure", "hammersmith & city", "good service"] my html looks this: <body ng-controller="tubecontroller"> <div ng-repeat="item in holder track $index"> {{item}} </div> </body> when display on html page each element of array put separate div looks this: <div>bakerloo</div> <di

Can't get my build to use the unirest-java-version of org-apache.http.client instead of the one shipped with Android (I'm at API 16) -

i'm having trouble unirest-java on api level 16, namely have compiled jar ( unirest-java-1.4.6-snapshot-withdependency-shadedforandroid ) dependencies , apache-libs shaded - i'm still getting errors app not finding org.apache.http.client.methods.httprequestbase.releaseconnection . which have concluded due using built-in apache-libs (which didn't have httprequestbase.releaseconnection implemented @ api 16, later on) instead of ones i've compiled in unirest-jar. tried building project both using android studio (1.0) , gradle same result. logcat http://pastebin.com/5mcsa7eg unirest-java/pom.xml http://pastebin.com/thhzn3sn app/build.gradle http://pastebin.com/vnuguhcy any in direction appreciated!

javascript - Want to add string to HTML from AJAX request in AngularJS -

Image
i want make weather app ajax request , not strong in angularjs. have : http://jsfiddle.net/6458vz1s/1/ and can't add locationhtml html ng-bind-html . causes errors this: screenshot of console when add ng-bind-html-unsafe , there no errors , still no html when print through console.log , looks perfect. can't add html add 'ngsanitize' module's dependencies check documentation here : https://docs.angularjs.org/api/ng/directive/ngbindhtml weatherapp=angular.module('weatherapp',['ngsanitize']); weatherapp.controller('weathercontroller', function($scope,$http){ $http.get('http://api.wunderground.com/api/key/forecast/geolookup/conditions/q/ca/san_francisco.json').success(function(response){ $scope.weather = response; $scope.locationhtml = "in next 2 boxes see weather conditions in <b>" + $scope.weather.location.city + "</b> city"; }) .error(function(response){

YouTube Android API seekToMillis() not working accurately -

while using youtubeplayer.seektomillis() function, there seek delay of 2 seconds. not 2 seconds, so. if try seek between 10,000 milliseconds , 12,000 milliseconds (eg: 11,000 11,500, 11,550). video started 10,000 itself. if give value between 12,000 , 14,000 goes 12,000 point.. , on... we developing app youtube has start accurate time specified. hence function quite crucial us. youtubeplayer.seektomillis(10000); youtubeplayer.play(); please show hints how can start video youtube player precise starting time, if possible precisely millisecond. this not bug, this standard behavior of seekable-compressed video file . short , super-simplified explanation a compressed video file composed sequence of frames. there 2 macro-types of frame, full frames ( f ) , partial frames (p*): full frame : contains full real frame @ specific time (like full jpeg image) partial frame set of differences in relation previous frame, expressed motion vectors. raw video sequence

jpa - GlassFish can't find my datasource -

i created java ee web application in netbeans connected derby db. i generated entity bean via "create entity database" did. there menu had fill in datasource called "wwhy source". after generated session beans entity user. the problem each time try deploy application gives me exception. initially during deployment. in-place deployment @ c:\users\nam\documents\programming\netbeansprojects\wwhy\build\web glassfish server 4.1, deploy, null, false c:\users\nam\documents\programming\netbeansprojects\wwhy\nbproject\build-impl.xml:1045: module has not been deployed. in glassfish log exception while preparing app : invalid resource : wwhy source__pm honestly don't have single clue why doesn't work. can give rest of glassfish log output kinda same. tried clean , build, restarting netbeans nothing helps. stopped working tried use jpa. please me :) edit when created entity bean via "entity class databases", automatically create pers

PHP Use of undefined constant -

so i'm getting bunch of errors of undefined constants , i'm not sure why. i'm running on windows wamp server if makes difference. i'm writing code in dreamweaver cs6 , not showing errors. here code: <!doctype html> <?php $services = array( "website" => array ( title => "web site design", price => "vaires contact free quote", blurb => "we make websites" ), "nas" => array ( title => "nas storage", price => "vaires contact free quote", blurb =>" make make servers" ), "localserver" => array ( title => "local sever setup", price => "vaires contact free quote",

javascript - Unable to load textured Collada exported from blender using Three.js -

Image
i using three.js, version 71 . i'm using blender, version 2.73 . i created textured collada object (.dae file) using blender, , want load three.js scene. far, can load models exported blender have no textures on them. here how create textured collada object: in blender, use default cube. using settings on right, add texture cube. here texture putting onto cube (note: 2048 x 2048, it's power of 2): here image of cube in render mode prove texture on it: here export settings used when exported cube collada blender: here code used try load textured collada: var loader = new three.colladaloader(); var localobject; loader.options.convertupaxis = true; loader.load( './models/test_texture.dae', function ( collada ) { localobject = collada.scene; localobject.scale.x = localobject.scale.y = localobject.scale.z = 32; localobject.updatematrix(); game.scene.add(localobject); } ); here error got: [.webglrenderingcontext]gl error :gl_invalid_operation : gl

Why can my code not find the AngularJS $interval? -

my angularjs code trying call $interval , there's problem in vs2013 saying not found. here's code: var apprun = [ '$rootscope', function ( $rootscope ) { // not work $interval(userservice.isauthenticated(), 5000); // works $rootscope.$interval(userservice.isauthenticated(), 5000); }] app.run(apprun); can tell me why call $interval. ... not work. why need put $rootscope before ? $interval angular service need inject inject $rootscope : var apprun = [ '$rootscope', '$interval', function ($rootscope, $interval) { $interval(userservice.isauthenticated(), 5000); }] app.run(apprun); regarding why $rootscope.$interval seems work - may have attached $interval service $rootscope on other part of application. it's not built-in on $rootscope . in case, should used via injection.

javascript - URL Pattern Matching issue, .+ matches all after -

Image
i matching stored urls current url , having little bit of issue - regex works fine when being matched against url itself, reason sub-directories match (when want direct match of course). say user stores www.facebook.com , should match both http://www.facebook.com , https://www.facebook.com , does the problem is matching sub-directories such https://www.facebook.com/events/upcoming etc. the regex example: /.+:\/\/www\.facebook\.com/ matches following: https://www.facebook.com/events/upcoming when should matching http://www.facebook.com/ https://www.facebook.com/ how can fix seemingly broken regex? if you're being specific want match, why not reflect in regexp ? /^https?:\/\/(?:(?:www|m)\.)?facebook\.com\/?$/ http or https www., m. or no subdomain facebook.com demo edit include optional trailing backslash

javascript - Accessing KO component fields in viewmodel -

i have created first ko component : components.js ko.components.register('team-dropdown', { viewmodel: function (params) { var self = this; self.teamnames = ko.observablearray([]); $.ajax({ url: 'http://footballcomps.cloudapp.net/teams', type: 'get', contenttype: 'application/json', success: function (data) { $.each(data['value'], function (key, value) { self.teamnames.push(value.teamname); }); console.dir(self.teamnames); }, error: function (err) { console.log(err); } }); self.selectedteam = ko.observable(); }, template: { require: 'text!components/team-dropdown.html' } }); team-dropdown.html <div id="teams" class="inputblock form-group&q

java - How to set JavaFX password field echo char -

this question has answer here: bullet asterisk in passwordfield 1 answer in swing, can set echo char setechochar : new jpasswordfield().setechochar('*'); how can same in javafx? it kind of ugly, but... password mask character hardcoded default skin. what need create own skin , implement own masking function. there existing feature request more flexible password masking functionality: rt-39954 option set custom bullet/mask/placeholder in passwordfield . if interested in contributing the open-jfx project javafx development, nice simple way start... as background, here making code javafx 8 com.sun.javafx.scene.control.skin.textfieldskin.java : // use passwordfield public static final char bullet = '\u2022'; . . . @override protected string masktext(string txt) { if (getskinnable() instanceof passwordfield) { int n

AJAX Raw Javascript Basic -

i wonder why open , send method when using ajax comes @ end. not before responsetext method function loadxmldoc() { if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("mydiv").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","xmlhttp_info.txt",true); xmlhttp.send(); } i'm bit confused open method take url of our data/file. , how xmlhttp.responsetext method file we're working with, since code @ bottom – basically need construct request @ first , bind necessary event handlers process response. need fire request. that's reason why it's @ end. if fire request @ first, might not have event handlers registered handle response. so that

Unable to clone app engine project in pycharm -

Image
i trying clone app engine project written in python, pycharm. my version of git 1.9 have latest version of pycharm. i have run gcloud auth login can authenticate using google account. when try clone repository @ https://source.developers.google.com/p/app-engine-project i dialog box similar 1 below, request me enter username , password. i enter gmail account can't login. tells me can't connect repository. please help. do following: create directory want local git repository located , navigate it. $mkdir directory $cd directory run gcloud auth login command. command gets credentials required access cloud repository google cloud platform. $ gcloud auth login run gcloud init command. command creates local git repository , adds cloud repository git origin remote. $ gcloud init project_id the gcloud init command creates directory named project_id/default in current directory. default directory contains local git repository. run pycharm , 1

Get the App Namespace in Laravel 5 -

i developing package laravel 5, if user change default namespace of application package command php artisan app:name test won't work properly. package needs know app's namespace work properly. based on understanding laravel 5 doesn't provide namespace of app in of core classes so decided either namespace composer.json file "psr-4": { "appnamespace\\": "app/" } or ask user provide namespace of application in kind of config file. question: please let me know if presumption laravel doesn't provide correct , if correct please let me know way best way namespace or if have better suggestion? you can app's namespace using below trait included core of laravel: illuminate\console\appnamespacedetectortrait laravel uses trait in appnamecommand current namespace before updated. an example: class myclass { use \illuminate\console\appnamespacedetectortrait; public function getnamespace()

c# - Inconsistent accessibility errors -

i writing program , have come across 2 errors believe related , unsure how solve. errors read... 1) error 1 inconsistent accessibility: parameter type 'ref programmingassignment2.avltree' less accessible method 'programmingassignment2.editcountryform.editcountryform(ref programmingassignment2.avltree, system.windows.forms.datagridview)' c:\users\adam\documents\visual studio 2010\projects\programmingassignment2\programmingassignment2\editcountryform.cs 17 16 programmingassignment2 2) error 2 inconsistent accessibility: property type 'programmingassignment2.avltree' less accessible property 'programmingassignment2.editcountryform.stuffs' c:\users\adam\documents\visual studio 2010\projects\programmingassignment2\programmingassignment2\editcountryform.cs 60 33 programmingassignment2 the errors in edit form follows... public partial class editcountryform : form { public country toedit; public editcountryform(ref avlt

css - Change color of Font Awesome icons when they selected -

can change color of font awesome icon using ::selection pseudo-element? i used that .icon i::selection { color: #fff; } or that: .icon i:before::selection { color: #fff; } and other variations. nothing worked. font awesome icons added using :before / :after pseudo-elements. .fa-stack-overflow:before { content: "\f16c"; } since pseudo-elements don't exist in dom , it's not possible select them: 5.10 pseudo-elements , pseudo-classes neither pseudo-elements nor pseudo-classes appear in document source or document tree. to work around this, have avoid pseudo-elements , add icon html directly, isn't ideal. (example here) therefore content: "\f16c" become &#xf16c; , have wrapped in .fa element correct font-family applied: <i class="fa">&#xf16c;</i> . for example: ::selection { color: #fff; } <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/

git reset <file> versus git reset -- <file> -

i need add several files group them single commit, have exclude 1 of them. in this answer , code given is: git add -u git reset -- file_to_ignore.dat i'm not sure dashes in last command. difference following? git reset file_to_ignore.dat which how it's shown in this tutorial . i mentioned double hyphen (or double dash) notation in " deleting badly named git branch ". it helps separating options of commands actual arguments (filename) it conventional recognize double hyphen signal stop option interpretation , treat following arguments literally. in case, there no difference... unless file name ' master '! (in case, -- important)

javascript - Fabric.js geometric shapes -

i want use different geometric shapes (like hexagon, star...) apart rect, triangle, ellipse.what else can do? how can do? var canvas = new fabric.canvas('c'); var rect = new fabric.rect({ left: 50, top: 50, fill: 'green', width: 40, height: 80 }); var circle = new fabric.circle({ radius: 20, fill: 'red', left: 100, top: 100 }); you can polygon function: var pol = new fabric.polygon([ {x: 200, y: 0}, {x: 250, y: 50}, {x: 250, y: 100}, {x: 150, y: 100}, {x: 150, y: 50} ], { left: 250, top: 150, angle: 0, fill: 'green' } ); for more complex shapes should load svgs

html - Jquery Match Value to Array -

i have navigation bar , divs want show when nav bar link clicked on. instead of having divs descendants of nav bar links, separate (i know shouldn't done). so, created data label each nav bar link matches data label of div should shown on click. so, want click nav link, find data label (which i've done jquery), match data label against different divs , display div (while hiding others). think need create array of divs, have jquery code create array , go through find matching data type, show div...thanks help! <div id="nav"> <ul> <li><a href="#" class="navselection" data-type="1">1</a></li> <li><a href="#" class="navselection" data-type="2">2</a></li> <li><a href="#" class="navselection" data-type="3">3</a></li> <li><a href="#" class="nav

javascript - Hiding div on button click -

i have script has 3 buttons shows div when clicked, question how hide div's let's div 1 opened , click open div 2, make show div 2 hide div 1 can have div's in same position, show if supposed to. my script: <!-- support contact form start--> <div class="contactsupportbutton"><input type="button" src=".png" alt="contact support button" style="height: 40px; width: 120px" onclick="showsupform()"/> <div id="contactsupportform"> test </div> </div> <script type="text/javascript"> function showsupform() { document.getelementbyid('contactsupportform').style.display = "block"; } </script> <!-- support contact form ending--> <!-- busin

php - Android app and login to my database -

i'm developing android app similar social network. have created signup form, login form , other asynctask send data database. send data using post request receipt php page execute query database e send json result application. for example, when user log in app, send post "login.php" page check if there user in database. then, if user exist in database, php page send json application read , open home activity. now, if close app (without logout) or reboot phone when open again application have login everytime. how can maintain connection open in app? user must log off if press logout button. also there better way send data such username , password server? sorry english you can use sharedpreferences storing credentials. save data when exit app , when return app data sharedpreferences , check see if login succeeded or not.if login succeeded start home page activity or start login activity. can use database store credentials, if want , can use encrypt

rotation - Matlab angle2dcm different definition -

i using matlab function angle2dcm gives me different results expected. digging code (angle2dcm.m) found definition of forming rotation matrix different standard one. for example, rotation rx ry rz (i.e. 'xyz' order) defined as: % [ cy*cz, sz*cx+sy*sx*cz, sz*sx-sy*cx*cz] % [ -cy*sz, cz*cx-sy*sx*sz, cz*sx+sy*cx*sz] % [ sy, -cy*sx, cy*cx] while should (please refer link): http://inside.mines.edu/fs_home/gmurray/arbitraryaxisrotation/ is different definition of direction cosine matrix , rotation matrix? thanks! it's issue notation conventions, since 2 cases (matlab versus link posted) refer opposite orders of rotation. if want use matlab function , continue use convention link posted, possible workaround can call function 'zyx' , invert signs of angles, i.e. dcm = angle2dcm( -r1, -r2, -r3,'xyz'); *edited* which uses following rotation matrix (see matlab documentation)

format as link to email address, ruby on rails -

the <%= @post.source_account %> email address. want display link says "email me" , when click open users mail client <% if @post.source_account.present? %> <h4>email seller: <small> <%= @post.source_account %><br></h4> <% end %> you can use mail_to , creates mailto link tag specified email address: <%= mail_to @post.source_account, "email me" %>

In delphi, how do you embed Excel in a form and show excel components on the component pallette? -

Image
years ago remember installing excel , office components onto component palette in delphi 5. either through activex or com, or typelib, there way install components. components think drag , drop onto form , spreadsheet embedded app (or microsoft word, etc.). the information can find on internet using olecontainers... component in system tab of delphi 5. not remember being olecontainer when used components embedding excel, rather remember installing actual excel , office components onto component palette somehow... components may have been generated ocx file or typelib, not remember. 1 find or obtain files generate excel , office components on component palette? ocx , come copy of ms office have on computer? are there excel com or activex components 1 can install? remembering correctly, or way use excel through olecontainer component? edit: may have been automation server component excel or office you can this: in formcreate (or onactivate ..) olecontainer1.

html - Upload a file in folder using PHP script -

i trying upload , save image using php scripting, image not getting saved in specified folder. please help here's code: <?php if(isset($_post['button'])){ $name= "product_name.jpg"; move_uploaded_file($_files["filefield"]["tmp_name"],"student_images/$name"); header("location: tryupload.php"); } ?> <html> <body> <form action="tryupload.php" enctype="multiple/form-data" name="myform" id="myform" method="post"> <table> <tr> <td align="right">product image</td> <td><label> <input type="file" name="filefield" id="filefield" /> </label></td> </tr> <tr> <td>&nbsp;</td> <td><label> <input type="submit" name="button" id="button&q

geolocation - Android.Location.toString() interpretation of `et` -

when use .tostring() method on location object have results this: location[gps 01.234567,12.234567 acc=14 et=+2d23h36m34s870ms alt=123.0 vel=0.0 {bundle[mparcelleddata.datasize=40]} ] (i added newlines better readability) i guess (after research here: link ): acc=14 accurracy in meters vel=0 velocity in meters/second alt=123 altitude above wgs reference ellipsoid in meters but et=+2d23h36m34s870ms ? according javadocs: /** * return time of fix, in elapsed real-time since system boot. * * this value can reliably compared * {@link android.os.systemclock#elapsedrealtimenanos}, * calculate age of fix , compare location fixes. * reliable because elapsed real-time guaranteed monotonic * each system boot , continues increment when system * in deep sleep (unlike {@link #gettime}. * * all locations generated {@link locationmanager

Facebook login always comes back as cancelled. (iOS Swift) -

Image
i'm trying implement facebook login using 4.0 version of sdk, happens 3.+ version. when call loginwithreadpermissions (4.0 version) or openactivesessionwithreadpermissions (3.+ version). closure/block called iscancelled (4.0 version) , closedfailedlogin (3.+ version) before user can make selection ( cancel or ok ). thought may problem url scheme in plist settings i've checked on , on , seems right. wondering if may have ideas on solving problem. bundle id right, single signin on, native app enabled, in facebook dev console. see sample code , configurations below (4.0 version). login call: appdelegate: plist: i had problem found workaround. can set login behaviour of login manager use facebook details on phone. default behaviour fbsdkloginbehaviorsystemnative , tries use facebook app first , if not there, uses web modal. instead of doing way , passing around urls don't seem work can set login behaviour fbsdkloginbehaviorsystemaccount . long sto

sql - MySQL: left join exclusion -

Image
i'm struggling mysql request cannot seem find right syntax. design of database pretty simple: have table applicant , table internship , table application . when applicant applies internship, insert row application table containing 2 foreign keys linking applicant , internship. question : how can list of internships applicant has not applied already, knowing applicant's id? so far : came query, that's not it: select internship.* internship left join application on application.id_internship = internship.id_internship application.id_applicant null or application.id_applicant <> 42 group application.id_internship any appreciated. have day. you should use condition applicant id in join , use = operator, joined records ones connected applicant, filter out internships join has match: select internship.* internship left join application on application.id_internship = internship.id_internship , application.id_applicant = 42 application.id_app

c - How to get the GCD of command line argument integers entered by the user after './a.out' in any order? -

this program returns gcd of command line args inputed user least greastest. example: user input: './a.out 5 10 15 20 25 ' this program returns: "the gcd of command line args 5" however, problem running if user types example: user input: './a.out 15 10 5 25 20' this program returns: 15 can tell me how fix issue? this aiming for: if user input: './a.out 15 10 5 25 20' this program should return: 5 //header files #include<stdio.h> #include<string.h> //main method int main(int argc, char *argv[]){ //declared variables here , print statements int i,x,y,min; printf("number of command line args %d\n", argc); printf("the gcd is:\t"); //this main while loop while( x !=0 && y !=0 && y != x){ if(x<y){ y=y-x; }//end first if statement if(y<x){ x-x-y; }//end second if statement }//end while loop //this function returns converted integral number int value x=atoi(argv

java.util.scanner - Java with Sublime Text - Scanner not working? -

i trying learn java, , i've started. i want run code found online: import java.util.scanner; // needed scanner /** java program demonstrates console based input , output. */ public class myconsoleio { // create single shared scanner keyboard input private static scanner scanner = new scanner( system.in ); // program execution starts here public static void main ( string [] args ) { // prompt user system.out.print( "type data program: " ); // read line of text user. string input = scanner.nextline(); // display input user. system.out.println( "input = " + input ); } // end main method } // end myconsoleio class however error: type data program: exception in thread "main" java.util.nosuchelementexception: no line found @ java.util.scanner.nextline(scanner.java:1540) @ myconsoleio.main(myconsoleio.java:17) [finished in 0.9s exit code 1] i running code in

android - Java Websocket chat on mochahost vps 404 error -

i bought vps online , i've installed apache tomcat 8.0.20 on it. server , running. websocket app running on localhost apache tomcat 8.0.3 keeps giving status 404: (not found) error. i need know if there additional configuration need do. or perhaps mochahost not support websockets. or perhaps tomcat server needs run without apache. not know how configure i'm new vps systems. please need urgently. use autobahn websocket library android on client side.my connection url of format: ws://domain.com/appserver/endpointvalue everything works on localhost. though, wonder if need add port numbers online server address, too. it fault. had include port number in websocket url. once included it, began work expected. thanks: path became: ws://yourdomain.com:port_number/serverappname/endpointvalue .

jquery - Validating a form with ajax json response -

i sending form server before sending form make ajax request returns json response. problem is, if condition valid ask user if still want send form, sends form if user says no. this code $("#form-alta-servicios").submit(function(){ if( confirm('desea enviar la informacion ahora?') ) { //entonces validamos datos if( $('#tel').val()=='') { alert('ingresa el numero de telefono'); $('#tel').focus() return false; } else { if( $('#dir').val()== '' ) { alert('la direccion es un dato requerido'); $("#dir").focus(); return false; } else { if( $("#taxi_id option:selected").val()=='0' ) { alert('seleccione un taxi por favor'); return false; } else { $.ajax( { type: 'get', url: '/verifica-si/'+$("#taxi_id option:selecte

For loop in R through data.frame -

i have following data.frame name<-c("jack","jerry","emma","andy","jayde","lynn","liam") education<-c("master","master","master","bach","bach","phd","phd") salary<-c(20000,20000,20000,30000,10000,70000,70000) people<-data.frame(name,education,salary) i have use loop (silly, know) loop through frame, find "education" level, , add salary increase. how can done? even though better mentioned in comments, can ugly way: for (i in 1:nrow(people)) { if (people$education[i] == "bach") { people$salary[i] <- people$salary[i]+1000 } else if (people$education[i] == "master") { people$salary[i] <- people$salary[i]+2000 } else { people$salary[i] <- people$salary[i]+3000 } }

php - Google Static Map not loading -

i retrieving values sql table displayed, , want display static map using latitude , longitude co-ordinates taken in. <?php if(isset($row["address"])) { echo"<b>address: </b>"; echo $row["address"]; echo "<br>"; } $latitude = $row["latitude"]; $longitude = $row["longitude"]; $map = "https://maps.googleapis.com/maps/api/staticmap?center=".$latitude.",".$longitude."&zoom=13&size=300x300&key=[my key goes here]"; ?> <img src="$map"> i have renewed key , tested link seperately, , loads fine in chrome browser tab. however, when try load through webpage, address section loads fine, instead of map there usual icon shows picture hasn't loaded. (not enough rep post picture of actual output). this first time using api welcome! the problem trying reference $map variable outside php code you can try this <?php if(is

python - Find longest substring of text and pattern -

is there a function in python, returns index of longest common substring of text , given pattern in case pattern has start substring? text = lorem ipsum dolor sit amet, consectetur adipisici elit pattern = amegt 22 you looking "suffix tree" algorithm: http://en.wikipedia.org/wiki/longest_common_substring_problem your solution should this: https://github.com/kvh/python-suffix-tree there example there on how use library. need far understand requirements. let me know if need additional help. cheers, alex

Ansible vsphere_guest error -

i try auto create vm can code working ... able create 20 vm on fly! upgrade ansible ansible 1.8.4 configured module search path = none to ansible 1.9.0.1 configured module search path = none as upgrade pysphere 0.1.7 0.1.8 (pysphere-0.1.8-py2.7.egg-info) reason upgrade relocate() function in 0.1.8. so try run ansible code , error failed: [host1] => {"failed": true} msg: unsupported parameter module: username tasks: - debug: var=vm - name: gather vm facts vsphere_guest: vcenter_hostname: vcenter name password: pass username: user guest: ansible vmware_guest_facts: yes   remote_module vsphere_guest vcenter_hostname=xxxxxxxxx guest=ansible password=value_hidden username= <------ missing !!!! why ?? i install new server , go old version: same issue … how can more detail log? what missing? thanks noam ok fix ! yes idiot ! 50% :) by default ansible try find folder named libra

linux - Limit memory bandwidth cgroups without NUMA -

i trying limit bandwidth of process memory. have 2 cgroups (cgroup1 , cgroup2) processes in them. can limit amount of memory used each cgroup. if keep calling malloc() , free() , saturating memory bus, influence each other. how limit this? don't have 2 different memory nodes, , no numa. this not possible. supported subsystems are: blkio — subsystem sets limits on input/output access , block devices such physical drives (disk, solid state, usb, etc.). cpu — subsystem uses scheduler provide cgroup tasks access cpu. cpuacct — subsystem generates automatic reports on cpu resources used tasks in cgroup. cpuset — subsystem assigns individual cpus (on multicore system) , memory nodes tasks in cgroup. devices — subsystem allows or denies access devices tasks in cgroup. freezer — subsystem suspends or resumes tasks in cgroup. memory — subsystem sets limits on memory use tasks in cgroup, , generates automatic reports on memory resources used tasks. net_cls — subs

c - stat function returns empty struct -

this question has answer here: issue s_isdir() result in c (maybe because stat() isn't setting struct properly?) 1 answer studentsdir = opendir(linevalues); while ((entry = readdir(studentsdir)) != null) { stat(path, &dirdata); if (s_isdir(dirdata.st_mode) && (entry->d_name[0] != '.') && (entry->d_name[1] != '.')) { im searching in directory folders. problem stat returns dirdata empty values of folders the code needs: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> the prototype function is: int stat(const char *path, struct stat *buf); so need: struct stat dirdata; and *path variable needs actual path (can relative or absolute), file name, target file. nothing in posted code indicates of above has been included in code. and 'en

nginx - How can I see a dynamically assigned port from within a docker container? -

i have server application takes few minutes startup , ready process requests. want have container register nginx load-balancer when knows has started, don't know how determine port docker assigned container (i'm starting lots of these docker run -p). ideas? thanks, ian you cannot talk docker daemon default inside container , shouldn't try to. containers perspective, running process on port 80 or whatever default of webapp. to determine port assigned container, can either use docker port or docker inspect command host running container. docker port my_webapp_1 returns list of mapped ports of container. docker inspect my_webapp_1 this returns json in can find networksettings lists ports of containers , ports of host mapped to. you can run additional process reads data docker port or docker inspect , updates nginx config.

Processing eclipse android resource file papplet -

when create pimage in papplet android activity, want locate image location. read online need store in /assets folder in root directory of project, isn't being recognized reason, there other steps needed include folder in build path or something?? to locate resource in android put in "assets" directory , load with: "file:///android_asset/[name of file.extension]"

ios - How can I make a slider move in steps of 0.25? -

i have slider have min of 0 , max of 8. move between 0 , 8 in steps of 0.25. ex. 0 - 0.25 - 0.5 - 0.75 etc. can please me? appreciated. https://developer.apple.com/library/ios/documentation/uikit/reference/uislider_class/#//apple_ref/occ/instm/uislider/setvalue:animated : supports float well... float roundedvalue = roundf(value / 0.2f) * 0.2f; (use round....) see here similar problem increment uislider 0.2 in range 0 2.0

python - Virtualenv, Django and PyCharm. File structure -

i newbie using virtualenv , try create 1 using pycharm. during process, pycharm ask me specify project location, application name , virtualenv name , location. doubt is, after specify name , location of virtualenv location of django project files must inside virtualenv? or it's possible have virtualenv files in different location django project files? maybe not understanding purpose of virtualenv. perhaps, virtualenv it's list of dependencies of project, python version, django version, pip version, jinja2 version , other required files, not django application files (the website being developed). thanks in advance. ya, think misunderstand virtualenv does: https://virtualenv.pypa.io/en/latest/ the basic problem being addressed 1 of dependencies , versions, , indirectly permissions. imagine have application needs version 1 of libfoo, application requires version 2. how can use both these applications? if install /usr/lib/python2.7/site-packages (or whateve

Cordova cannot release application to Windows Phone Store -

thorough search of site did find question (from different user) there no answers ask myself: background : using apache cordova 4.x , visual studio 2013 (all latest updates). made apps - work fine on android , other platforms - deployed windows phone 8.1. uploaded bundle phone store , there problem packaged application id not matching store expects. details : problem store named app (reserved previously) "12345myname.appname" in config.xml app id "com.myname.appname". renaming widget id or appid or package id 12345myname.appname" fails because of this: error 48 file content not conform specified schema. 'id' attribute invalid ... ' http://schemas.microsoft.com/appx/2010/manifest:st_applicationid ' ... i know error i've exhausted possible means around (create.js cordova has right regex - no need change it, dropping appx manifests in res/native/windows, directly editing appx manifests, using additional config files, etc...) nothing

jquery - Javascript Not Sorting Prices Correctly -

i'm sorting list of prices code: var $divs = $("div.machinebox"); var numericallyordereddivs = $divs.sort(function (a, b) { return $(a).find("p.price").text() < $(b).find("p.price").text() ? 1 : -1; }); $("#machinewrapper").html(numericallyordereddivs); i want sort list of prices highest lowest, this: $549.00 $387.00 $248.99 $242.91 $97.01 $32.04 the problem it's sorting them this: $97.01 $549.00 $387.00 $32.04 $248.99 $242.91 any ideas how sort properly? thanks! for quick fix recommend storing unformatted value in attribute on element. problem it's sorting characters, not numerically. try instead: var $divs = $("div.machinebox"); var numericallyordereddivs = $divs.sort(function (a, b) { return parsefloat($(a).attr('data-sort')) < parsefloat($(b).attr('data-sort')) ? 1 : -1; }); $("#machinewrapper").html(numerical

Android Recyclerview, want to know how it determines the data list for listing -

so trying figure out how use recyclerview listing items. unlike listview has adapter passes list constructor internal working, recyclerview not seem have one, example, in class extending recyclerview.adapter provide contructor set list declared. public customadapter(data[] mydataset) { this.mdataset = mydataset; } but how recyclerview.adapter know use? example, since constructor provided us, possible make contructor put 2 parameters 2 different data type lists/arrays. how adapter know list use?? add: or use according how use lists on onbingviewholder method? if so, how position parameter work? take @ this post. has simple example pretty overview/explanation of recyclerview , how works.