Posts

Showing posts from 2013

c# - Asp.net visible button when 2 parameters match -

hello want make button visibile when userid stored in database match current userid. string clientid = context.user.identity.getuserid(); jobdescriptions job = new jobdescriptions(); if (job.postedby == clientid) { button2.visible = true; else { button2.visible = false; } postedby id of user posted on website saved on jobs table. problem button not visibile when statement should work. the solution if (!string.isnullorwhitespace(request.querystring["id"])) { int id = convert.toint32(request.querystring["id"]); jobreqmodel model = new jobreqmodel(); jobdescriptions job = model.getjob(id); string clientid = context.user.identity.getuserid(); if (job.postedby == clientid) { button2.visible = true; ...

Simple PHP If Statement Not Acting As Expected -

this simple year validation should check if year between 1900 , current year. if year valid should displayed input's value. if(!empty($year) && $year >= 1900 || !empty($year) && $year <= date('y')){ $yearholder = 'value="'.$year.'"'; }else{ $yearholder = 'placeholder="year"'; } the problem i'm having statement not work, , passes numbers through. you can try this. if(!empty($year) && $year >= 1900 && $year <= date('y')){ $yearholder = 'value="'.$year.'"'; }else{ $yearholder = 'placeholder="year"'; }

Spark saving RDD[(Int, Array[Double])] to text file got strange result -

i trying save userfeature of matrixfactorizationmodel textfile, according doc rdd of type [(int, array[double])]. called model.userfeature.saveastextfile("feature") however, results got like: (1,[d@4b7707f1) (5,[d@513e9aca) (9,[d@7d09bcab) (13,[d@31058458) (17,[d@2a5df2a7) (21,[d@5372efd7) (25,[d@59d1c59a) (29,[d@53ee5e25) (33,[d@498f5a34) (37,[d@4f9967eb) (41,[d@5560afb) (45,[d@2dc7f659) (49,[d@b46fcc) (53,[d@38098dd1) (57,[d@77090fb5) (61,[d@64769e18) what expecting like: (1, [1.1, 2.3, 0.4, ...]) (2, [0.1, 0.3, 0.4, ...]) ... so what's wrong? the behavior of saveastextfile use tostring method. so, array , merely hashcode . have 2 options if stick saveastextfile : .mapvalues(x=>/*turn array data string*/).saveastextfile... or can use map wrap data in custom object custom tostring , or in case list , tostring might work .mapvalues(_.tolist).saveastextfile

jquery - disable all the radio button with same name -

i have 2 set of radio button, if 1 of option selected other radio in same group have disabled. <div class="question_container"> <p class="questions">question stuff?</p> <span class="group" style="inline-block;"> <label> <input id="id_radio1" class="incorrect" type="radio" name="group1" value="answer 1" />answer 1 </label> <label> <input id="id_radio2" class="correct" type="radio" name="group1" value="answer 2" />answer 2 </label> <label> <input id="id_radio3" class="incorrect" type="radio" name="group1" value="answer 3" />answer 3 </label> <label> <input id="id_radio4" class="incorrect" type="radio" name="group1" value=...

ios - read the specific data from the JSON file and load on tableView in swift -

have text file in project put json data read data problem occur when specific field read program crash fatal error andy 1 me code let path = nsbundle.mainbundle().pathforresource("days", oftype:"json") let jsondata = nsdata(contentsoffile:path!) // println(jsondata) var jsonresult: nsdictionary = nsjsonserialization.jsonobjectwithdata(jsondata!, options: nsjsonreadingoptions.mutablecontainers, error: nil) as! nsdictionary // println(jsonresult) var = 0 ; < jsonresult .valueforkey("monday")!.count ; i++ { arrdic!.addobject((jsonresult.valueforkey("monday") as! nsarray).objectatindex(i)) println( arrdic!.addobject((jsonresult.valueforkey("monday") as! nsarray).objectatindex(i)) func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("ahmad") ...

java - Amazon DynamoDB table w/ Elastic Beanstalk not setting up correct parameters -

Image
i have example dynamodb project amazon when uploaded instance of elastic beanstalk environment, generates dynamodb table. howevever, after generating table missing few parameters. here code elastic beanstalk instance: /* * copyright 2010-2013 amazon.com, inc. or affiliates. rights reserved. * * licensed under apache license, version 2.0 (the "license"). * may not use file except in compliance license. * copy of license located @ * * http://aws.amazon.com/apache2.0 * * or in "license" file accompanying file. file distributed * on "as is" basis, without warranties or conditions of kind, either * express or implied. see license specific language governing * permissions , limitations under license. */ package com.amazonaws.geo.util; import com.amazonaws.geo.geodatamanagerconfiguration; import com.amazonaws.services.dynamodbv2.model.attributedefinition; import com.amazonaws.services.dynamodbv2.model.createtablerequest; import com....

c# - Recoloring TabControl -

Image
i have tab control want customize. more specific, want change color of tab page header, color of white line around tab page (check first picture). i thought of using custom renderer (similar recoloring menu strip, example), i'm not sure how this. i've read setting drawmode ownerdrawfixed may this, using option makes the tab control if program made in '90s (check second picture). what want keep tabs simple , flat and change color. check way tabs in visual studio example (check third picture). any ideas? edit: picture of tab page it's more clear "white line" is. when use ownerdrawfixed means you supply drawing code. if did not hook , use drawitem event, nothing gets drawn. same yours @ design time, because event not firing. design time painting, you'd have subclass control , use ondrawitem . // colors use private color[] tcolors = {color.salmon, color.white, color.lightblue}; private void tabcontrol1_drawitem(ob...

latest length, latitude and position on openstreetmap -

i need show latest position , length, latitude on openstreetmap link, http://tools.geofabrik.de/map/#10/54.5536/9.3658&type=geofabrik_standard&mlat=54.50582&mlon=9.23807 someone coded or have guide this?

html - How to write a custom form helper template for dynamically generated content? -

Image
i have sort of quiz system, user gets shown question , several answer-options radio-buttons. but using helper inputradiogroup gets filled via list, not pretty anymore (like twitter bootstrap). radiobuttons inline, while should underneath each other. , change icon prettier button. this how looks @ moment: therefore tried write own custom form helper, keep getting stuck. find frustratingly hard understand documentation this: https://www.playframework.com/documentation/2.3.x/javaformhelpers first created new template named myfieldconstructortemplate.scala.html @(elements: helper.fieldelements) <div class="@if(elements.haserrors) {error}"> <label for="@elements.id">@elements.label</label> <div class="input"> @elements.input <span class="errors">@elements.errors.mkstring(", ")</span> <span class="help">@elements.infos.mkstring(", ")</span> </d...

database - Storing a String in an Enum object in java -

this question has answer here: how can lookup java enum string value? 9 answers i have enum category ,a question class, database question ,option, category,etc stored. question class has getter() , setter() question how can store string type data database in category type? rs.getstring("cateogory") returns string want store string in category type obj. how can so? public enum category { geography,history,gk,science; } public class question { private int srno; private string question; private string option1; private string option2; private string option3; private string option4; private string correctans; private category category; private complexity complexity; public question() { } class x{ resultset rs=null; statement stmt=null; list<question> queslist=new arraylist<question>(); question q=new question(); catego...

jQuery variable undefined with php include -

i trying use variable in jquery wich included php, attr rel of img in footer. i try use change attr src in same img in footer. if use without include, works. include doesn't. i ../img/undefined.svg result. how can ../img/facebook.svg or ../img/twitter.svg ? in php-file use: <?php include '../include/header.php';?> <?php include '../include/footer.php';?> in header.php javascript, jquery , html: <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="../css/stijl.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("footer img").hover( function(){ var src = $(this).attr('rel'); $(this).attr('s...

How to move a UIView programmatically in Swift -

Image
the issue move "infoview" (uiview) programmatically in swift. the following constraints exist in storyboard (see image): now, move "infoview" inside "myview" or down. i tried: @iboutlet weak var infotextlabel: uilabel! @iboutlet weak var infotextlabelview: uiview! // set infotextlabel color self.infotextlabel.textcolor = uicolor.blackcolor() // set infotextlabel text self.infotextlabel.text = "hello" // unhide infotextlabel self.infotextlabel.hidden = false // moving in y-direction, tried - not work !!!!!!! self.infotextlabelview.frame.origin.y += 200 could autolayout-constraints play role. how overcome programmatically. or frame.origin.y method wrong 1 ?? appreciate on ! when using constraints, never want set view's frame directly. instead, reconfigure constraints , let auto layout engine set view's frame you. create iboutlet in view controller store reference "center y alignment constraint". make s...

list of test step results in groovy script -

i'm trying figure out way list of (names) of failed test steps, below code giving me names def testcase = testrunner.gettestcase() def steplist = testcase.getteststeplist() steplist.each { log.info (it.name) } now i'm not sure how move on here , failed status of each step in list you can use follow approach: assertion status of teststeps, , check if status failed, unknown or valid. can use follow groovy code so: import com.eviware.soapui.model.testsuite.assertable.assertionstatus def testcase = testrunner.gettestcase() def steplist = testcase.getteststeplist() steplist.each{ // check teststep has assertionstatus // (for example groovy teststeps hasn't property since // there no asserts on its) if(it.metaclass.hasproperty(it,'assertionstatus')){ if(it.assertionstatus == assertionstatus.failed){ log.info "${it.name} fail..." }else if(it.assertionstatus == assertionstatus.valid){ ...

wordpress - Calculate distance between two address php -

i've situation clients ask me calculate distance between main address , customer address. , based on distance i've add additional charge cart , validation , showing customer address out of service. below description; main address; 2801 florida ave, miami fl, 33133. if user's address entered 25 miles or more main address, pop "we sorry. address falls outside of our service area , unable deliver/pick equipment @ time." if user's address 5 miles away or less, no charge. if user's address 5-10 miles away, $20 charge. if user's address 10-25 mils away, $30 charge. order $500 or more, no matter distance (0-25 miles), no charge. i've came below answer , thinking, solution problem? distance point b using google maps, php , mysql how can make sure correct addresses? alternate highly appreciated. thanks the requirement doesn't specify whether distance should straight line base address user's address, or...

struct - Conflicting types for "function" error (C) -

i keep getting error: [error] conflicting types 'average_grade' , cant find mistake.. new in c need here. struct card { char on[20]; char ep[20]; float b; int ap; struct card *next; }; struct card *first,*last,*t; int ch; int main() { float mo; { printf("\n1.initialize\n2.add end\n3.show list\n4.average grade\n0.exit\nchoice:"); scanf("%d",&ch); switch(ch) { case 1: init_list(&first,&last); break; case 2: t=create_node(); add_to_end(t,&first,&last); break; case 3: show_list(first); break; case 4: mo=average_grade(&first); printf("%f",&mo); break; case 0: printf("bye!\n"); break; default:printf("try again.\n"); ...

python - Decoding an IEEE double precision float (8 byte) -

i'm decoding amf0 format file. data i'm looking timestamp, encoded array. [hh, mm, ss]. since data amf0, can locate start of data reading in file bytes, converting each byte hex, , looking signal 08 00 00 00 03, array of length 3. my problem don't know how decode 8-byte integer in each element of array. have data in same, hex-encoded format, e.g.: 08 00 00 00 03 *signals array length 3* 00 01 30 00 00 00 00 00 00 00 00 00 *signals integer* 00 01 31 00 00 00 00 00 00 00 00 00 *signals integer* 00 01 32 00 40 3c 00 00 00 00 00 00 *signals integer* 00 00 09 *signals object end* this should decoded [0, 0, 28] (if minerva believed). i've been trying use struct.unpack, examples see 4-byte (little endian) values. the format specifier looking ">9xd4xd4xd3x" : >>> import struct >>> binascii import unhexlify >>> struct.unpack(">9xd4xd4xd3x", unhexlify("0800000003000130000000000000000000000131000000...

c# - How to prevent 'System.FormatException' occurred in mscorlib.dll' with an empty textbox? -

i have programmed simple program me work out amount of carbohydrate per meal (i have diabetes) , issue system.formatexception when 1 of textboxes empty. how may prevent please ? my code (using form consisting of 3 textboxes; 2 of require input me , third shows result of simple equation). public partial class form1 : form { public form1() { initializecomponent(); } private void form() { tbccg.textchanged += textboxchanged; tbctg.textchanged += textboxchanged; } private void textboxchanged(object sender, eventargs e) { decimal carbst; decimal carbsperc = convert.todecimal(tbccg.text); decimal totcarbs = convert.todecimal(tbctg.text); carbst = carbsperc / 100 * totcarbs; tbtc.text = carbst.tostring("###,###.00"); } } you can verify text in text boxes if (string.isnullorwhitespace(tbccg.text)) tbccg.text = "0"; if (string.isnullorwhites...

ios - how can i save the high score? -

before want clarify im not expert you'll see. i'm complete beginner in programming. said. how can manage save high score after game ends? in following code i'm using nsuserdefaults i'm having problem in can't fix. once run game , score of 30 once countdown hits 0 example , try play again , 12 example automatically 12 new high score 12 totatly wrong can't fix it. class game: skscene, skphysicscontactdelegate { let ball = skspritenode(imagenamed: "red.png") var quitoption = sklabelnode() var scorelabel = sklabelnode() var timesecond = int(60) var locked = false var loseoption = sklabelnode() var scorepoints = sklabelnode() var score = int() let whiteball = skspritenode(imagenamed: "fingerpointingdown.png") var caseforscoreone = sklabelnode() var caseforscoretwo = sklabelnode() struct physicscategory { static let ball: uint32 = 0b1 static let whiteball: uint32 = ...

c - Processes synchronization with message queues and signals -

i have create 3 processes: reading expression 1+3+5+12 checking if expression has correct syntax adding numbers , displaying them data between processes shared using pipes mechanism. processes synchronization uses message queues , signals.i should able manually send signals each process through console. the problem running processes seem run randomly. why that, what's wrong here? should work... this whole code compiles correctly: #include <stdio.h> #include <unistd.h> #include <signal.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #define sizebuff 256 // signal handling each process void h_sig1(int signo); void h_sig2(int signo); void h_sig3(int signo); void h_s4(int signo); // processes functions void process1(void); void process2(void); void process3(void); // helper functions bool isinteger(double val); static pid_t p...

jquery - How to pass updated input value? -

i have input field value. trying capture new text added input , pass value input. each time pass however, old value passed. realise simple error making, can't seem working although have tried many times different approaches. trying using zurb joyride plugin. so, first input within step on walkthrough , passed input on page itself. any appreciated. here stripped down code: html <input type="text" id="egtext" value="stuff" /> <a href="#" onclick="addtext()" class="btn">button</a> <input type="text" id="searchbox" placeholder="a placeholder" /> js function addtext() { var text = $("#egtext").val(); $("#searchbox").val(text); } jsfiddle http://jsfiddle.net/figlen/zyapmc7h/ $('.btn').on('click', function(){ var text = $("#egtext").val(); $("#searchbox").val(text); }); h...

Redefining C++ function using a struct -

let's say, have following in "foo.hpp". have function same name struct . int foo(int i); struct foo{ foo(int i){ value = i;} operator int() {return value;} int value; }; if call in main so: int main() { std::cout << foo(1) << std::endl; // function called, not struct, why?? } why compiler link function , not struct? if possible, how change struct linked, not function? ultimately, overwrite function in library adding header file , overwriting function struct. way, hoping change 1 specific function, continue using other library functions , not alter library code @ same time. justification according c++ standard n4431 § 3.3.10/2 name hiding [basic.scope.hiding] ( emphasis mine ): a class name (9.1) or enumeration name (7.2) can hidden name of a variable, data member, function, or enumerator declared in same scope. if class or enumeration name , variable, data member, function, or enumerator declared in same scope (in order) ...

javascript - react.js dynamically grabbing object resulting in undefined -

i learning react.js. have object literal , trying dynamically select object within object based upon chosen select input. getting undefined, however. have tried both dot , bracket notation. grabbing value of selected option , storing within variable. ideas? here object: var horolist = { aries: { title: "jerkface", }, cancer: { title: "cancerous", }, gemini : { title: "goofball" } } ; here of jsx within render method: <select name="pick-sign" onchange={this.handlechange}> <option></option> <option value="aries" >aries</option> <option value="cancer" >cancer</option> <option value="gemini" >gemini</option> <option value="taurus" >taurus</option> </select> ...

java - Eclipse error: "The import XXX cannot be resolved" -

i'm trying work hibernate in eclipse. i'm creating new simple project , i've downloaded collegue project too, via cvs. both don't work, while on collegue's eclipse do. problem that, each import of hibernate class, eclipse says: the import org.hibernate cannot resolved but hibernate jars in build path, is: antlr-2.7.6.jar cglib-2.2.jar commons-collections-3.1.jar dom4j-1.6.1.jar hibernate3.jar hibernate-jpa-2.0-api-1.0.0.final.jar javassist-3.12.0.ga.jar jta-1.1.jar slf4j-api-1.6.1.jar try cleaning project going following menu item: project > clean... if doesn't work, try removing jars build path , adding them again.

python - --extract-audio equivalent for YoutubeDL class? -

i want extract audio in mp3 format youtube links, can't figure out how without calling youtube-dl command line --extract-audio option. there way within youtubedl class similar examples given here ? here's have far, still creates mp4 file. import youtube_dl # download using optimal audio settings ydl_opts = { 'format': 'bestaudio/best', 'postprocessors': [{ 'key': 'ffmpegextractaudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], 'quiet': true, 'restrictfilenames': true} ydl = youtube_dl.youtubedl(ydl_opts) ydl.download(['https://www.youtube.com/watch?v=pnt2cy5mwyw']) clarification: above code generate mp3 file, generates mp4 video file. only want generate mp3. update : here sample of output when quiet set false: [youtube] et6sslen8le: downloading webpage [youtube] et6sslen8le: extracting video information [yo...

What is the difference between Ruby open class and JavaScript prototype object? -

in ruby can use openclass add properties this: class string attr_accessor :ruby def open ruby = 'open' end def close ruby = 'close' end end then can use x = string.new x.open # set ruby 'open' 'open' x.close # set ruby 'close' 'close' in javascript can use prototype add properties this: string.prototype.ruby = {} string.prototype.open = function () { this.ruby = "open"; } string.prototype.close = function () { this.ruby = "close"; } then can invoke these prototype methods this: var x = new string() console.log(['ruby', x.ruby].join(':')) /* when invoke open */ x.open() console.log(['ruby', x.ruby].join(':')) /* when invoke close */ x.close() console.log(['ruby', x.ruby].join(':')) are same thing?

ios - How to take Permissions to retrive uploadimage through url in S3bucket -

i uploaded image s3 bucket , requirement display uploaded image through url in uiimageview. when browsing url image displaying when using url in following code, url printing in console. when converting url in data contains nil value. i tried following code. can 1 tell me if problem permissions in s3 bucket or coding? let url = nsurl(string: imageurl) let responsedata = nsdata(contentsofurl: url!,options: nil,error:nil) print("the data \(responsedata)") changeimgvc.image = uiimage(data:responsedataenter!) you need change policy of bucket in aws s3 console: - http://www.jppinto.com/2011/12/access-denied-to-file-amazon-s3-bucket/ - http://awspolicygen.s3.amazonaws.com/policygen.html - add bucket>properties>permissions>bucket policy

android - Placing Button on top of ImageView that stretches with different screen sizes -

i have image (match_parent) 2 rectangles in containing options. trying place 2 transparent buttons on top of image clicking on image results in action. however, trying support multiple screen sizes, while able play around layout margins line rectangles in buttons specific resolution smartphone, testing tablet failed. how place buttons consistently line image stretches fill varying screen sizes. pretty simple layout code right using dp doesn't work <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/banner" android:background="@drawable/banner" android:contentdescription="@string/banner" /> <button android:layout_width="120dp" android:layout_height="90dp" android:id="@+id/vs_computer" android:layout_margintop="135dp" android:layout_marginleft="135dp" android:alpha=...

javascript - Purpose of Static Methods in ECMAScript 6 Classes -

what sort of issues es5 static class methods in es6 supposed deal with? the babel documentation has following example in its section regarding es6 classes , though not state pattern accomplishes. classes support prototype-based inheritance, super calls, instance , static methods , constructors class skinnedmesh extends three.mesh { constructor(geometry, materials) { super(geometry, materials); this.idmatrix = skinnedmesh.defaultmatrix(); this.bones = []; this.bonematrices = []; //... } update(camera) { //... super.update(); } static defaultmatrix() { return new three.matrix4(); } } if compile es6 code babel, , class contains static method, es5-generated code adding static function constructor function. so, es6 code: class { static dostuff() {} } ...equals (in es5): function a() { } a.dostuff = function() { }; why need static functions? well, transpiled code won't support statics @ all, since functions...

Bluemix Push Notifications service returns error "502 Bad Gateway" -

i'm using push notifications service provided bluemix, few days ago push service became unavailable, @ least configuration purposes. the hint i've got trial expired , had enter credit card, maybe caused problem. here's exception thrown: exception thrown application class 'com.ibm.mbaas.ui.backendutility.getjsonresponse:-1' javax.servlet.servletexception: uiback108e: got unsuccessful response 'https://mccp.ng.bluemix.net/login/rolecheck?role=developers&space_guid=568581a0-9bbd-4fbf-9fb0-243c0d7febc3'. response status 502 bad gateway. response body was: "502 bad gateway: registered endpoint failed handle request. ". @ com.ibm.mbaas.ui.backendutility.getjsonresponse(unknown source) @ com.ibm.mbaas.ui.backendutility.checkrole(unknown source) @ com.ibm.mbaas.ui.security.uaacallbackservlet.doget(unknown source) @ javax.servlet.http.httpservlet.service(httpservlet.java:575) @ javax.servlet.http.httpservlet.service(httpservlet.java:668) @ com...

ios - how to do cancel requests in GCD without operation queue -

i'm implementing ios app make requests using rest service. , want cancel previous rest calls when make new call. can in global queue in gcd without operation queue? thanks gcd not provide api cancel blocks. have implement cancellation yourself. the easiest way set global flag 'canceled' , check inside of blocks. if flag set, return block. after blocks have finished can reset flag , enqueue new block. even though sounds simple, requires nontrivial code. easier use nsoperationqueue instead of reimplementing features on top of plain gcd.

ember.js - ember build Parse error on line 1: {{#each messages as |message|}} -

hi attempting update ember cli project ember 1.8.1 -> 1.9.1 & handlebar 1.3.0 -> 2.0.0 following error, when use command ember build : build failed. file: ui/templates/components/ember-notify.hbs parse error on line 1: {{#each messages |message|}} {{#vie --------------------^ expecting 'close_raw_block', 'close', 'close_unescaped', 'string', 'number', 'boolean', 'open_sexpr', 'close_sexpr', 'id', 'equals', 'data', 'sep', got 'invalid' error: parse error on line 1: {{#each messages |message|}} {{#vie --------------------^ expecting 'close_raw_block', 'close', 'close_unescaped', 'string', 'number', 'boolean', 'open_sexpr', 'close_sexpr', 'id', 'equals', 'data', 'sep', got 'invalid' @ object.parseerror (/users/shivamsinha/desktop/programming/workspace/feedserver...

python - How to change arrow head width and length of CurveB in matplotlib? -

i trying create annotations arrow code given below: import matplotlib.pyplot plt figure = plt.figure(figsize=(5.15, 5.15)) figure.clf() plot = plt.subplot(111) plot.set_xlabel(r'\textit{x}', labelpad=6) plot.set_ylabel(r'\textit{y}', labelpad=6) plt.annotate(r'\textit{p}', xy = (0.5, 0.5), \ xycoords = 'data', xytext = (0.4, 0.4), \ textcoords = 'data', fontsize = 7, arrowprops=dict(arrowstyle = "->")) plt.show() i tried change head width , head length follows: arrowprops=dict(arrowstyle = "->", head_width = 0.2, head_length = 0.1) but gives me following error: attributeerror: 'fancyarrowpatch' object has no attribute 'set_head_width' how change head length, head width , body width in matplotlib? use headwidth , frac specify width , length of arrowhead. frac the headlength written fraction total arrow length. plt.annotate(r'\textit{p}', xy = (0.5, 0.5), \ ...