Posts

Showing posts from January, 2012

php - Taking a manual RSS feed from a Facebook page - am I missing something? -

i trying take rss feed client's facebook page, rework contents (posts), edit , present resulting data on website. don't want use widget 3rd party , neither want use facebook api's not give me access raw data. i have taken feeds before , code have provided works nbc, google etc. nothing facebook. url using works fine in browser not in code , hoping here can point no doubt obvious error. $xml=("<http://www.facebook.com/feeds/page.php?id=xxxxxxxxxxxxxx&format=rss20>") $xmldoc = new domdocument(); $xmldoc->load($xml); //get elements "<channel>" $channel=$xmldoc->getelementsbytagname('channel')->item(0); $channel_title = $channel->getelementsbytagname('title') ->item(0)->childnodes->item(0)->nodevalue; $channel_link = $channel->getelementsbytagname('link') ->item(0)->childnodes->item(0)->nodevalue; $channel_desc = $channel->getelementsbytagname('descriptio...

Building Rails Nested Form Within Nested Form -

i have rails form includes parent, child, , child of child. i'm using nested_form gem , rails version 4.1. issue i'm encountering nested form nested field within it. don't want have user add nested resource button, want nested object instantiated when view loads. parent model class loanapplication < activerecord::base # associations has_many :business_contacts, :dependent => :destroy # nested object accepts_nested_attributes_for :business_contacts, :allow_destroy => true end child of parent class businesscontact < activerecord::base # associations belongs_to :loan_application has_one :personal_guarantee # nested objects accepts_nested_attributes_for :personal_guarantee, :allow_destroy => true end child of child (grandchild parent) class personalguarantee < activerecord::base # associations belongs_to :business_contact end view <%= f.fields_for :business_contacts, :wrapper => true |contact_form| %> ...

facebook - Tried accessing nonexisting field (fql) on node type (User) -

fql requests fail since wednesday. have no clue why since fql supposed deprecated @ end of april. basically, here type of requests worked until wednesday : https://graph.facebook.com/89240001803405/fql?access_token=<access_code>&q=select+is_published%2c+talking_about_count%2c+access_token%2c+description%2c+emails%2c+fan_count%2c+general_info%2c+location%2c+page_url%2c+pic_square%2c+username%2c+page_id%2cname+from+page+where+page_id+in+%28select+page_id+from+page_admin+where+uid+%3d+89240001803405%29 and here current response : { "error": { "message": "(#100) tried accessing nonexisting field (fql) on node type (user)", "type": "oauthexception", "code": 100 } } any idea how can fix before migrate de non fql ? thanks the user id have in there before fql part wrong, far know. if has worked before, rather accident, guess. fql calls via api endpoint should of form https://graph.faceb...

c++ - Attaching to Gtk::Grid the same image -

** edit: have tried below (compiles strangly not work)** class nibblerwindow : public gtk::window { private: gtk::grid grid; gtk::image tmp; gtk::image gridelem[5]; public: bool initimgarray(); nibblerwindow(); ~nibblerwindow(){} }; bool mywindow::initimgarray() { int = 0; while (i != 5) { this->gridelem[i].set("someimage.gif"); ++i; } return true; } mywindow::mywindow() { this->set_title("work in progress"); this->set_default_size(512, 512); this->add(grid); this->grid.add(gridelem[0]); this->grid.add(gridelem[1]); this->grid.show(); this->grid.show_all_children(); } hello everybody, i trying build game grid (like draughts or checkers), each child widget containing same image pattern. functional method found create each child widget individually, , build them in constructor list of class, this: class mainwindow { private: gtk::grid gamegrid; ...

javascript - How to display angular js bar graph in modal popups -

hi trying display angular js bar chart in modal popup (jquery modal), not working. have tried below code. <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="mylargemodallabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content widg_larg"> <div class="title">modal title <span class="pull-right cursor_pointer"> <i class="fa fa-times" data-dismiss="modal" aria-label="close"></i> </span> <div ng-controller="testconrtoller"> <canvas class="chart chart-bar" data="data" ...

Java Applet Blocked -

i'm trying make applet work on website whenever load it, following message: security settings have blocked untrusted application running. have added site exception list, still won't work. should make work? you need sign applet using official certificate company involved in code signing can provide. if not option you, there nothing can oracle has removed possibility run unsigned applets in sandbox of browser.

dependency injection - Dagger and Android context qualifiers -

i've been using dagger in projects while using these examples guides: https://github.com/square/dagger/tree/master/examples but there's thing can't comprehend in them. use @foractivity , @forapplication qualifiers explicitly differentiate between types of context , never @inject them in dependency? that? overlook in example?. if quite misleading. how go injecting them in dependency then? @inject dependency dependency suffice , resolve correct type own? to inject context in @foractivity case have to: @inject @foractivity context context; here post explains it: https://stackoverflow.com/a/27343567/3929577 it's same result @named annotation. you can use in module: @provides @singleton @named("foractivity") context provideactivitycontext() { return activity; } and use that: @inject @named("foractivity") context context;

c# - streaming XElements oddity when there's no whitespace -

this question has answer here: xmlreader skips elements 1 answer i've run problem streaming xelements , when there's no whitespace. given following code msdn documentation streaming xelements, public static ienumerable<xelement> streamelements(stream source, string elementname) { using (xmlreader reader = xmlreader.create(source)) { xelement item = null; reader.movetocontent(); // parse file, save header information when encountered, , yield // item xelement objects created. // loop through codefile elements while (reader.read()) { if (reader.nodetype == xmlnodetype.element && reader.name == elementname) { item = xelement.readfrom(reader) xelement; if (item != ...

javascript - Accessing handlebars variable inside client js file -

i'm generating handlebars view hbs express js framework, , need access variables pass view inside separate javascript file. for example: var foo = {{user.name}} obviously code throws error, preferred way of getting hbs variables inside javascript? currently i'm running ajax request same data. think not wise make request same data... found solution, seems had put handlebars variable inside string work. in order pass , object variable created hbs helper: hbs.registerhelper('json', function(context) { return json.stringify(context); }); and in view: var currentuser = json.parse('{{{json user}}}'); and can access data on client side js.

java - display new row at first row inside dataGrid or focus on the newly added row -

my requirement add new row @ first row of grid inside datagrid on click of add row button. can able add new row inside grid, want add/display new row in first row of grid each time when user click add row button. when user want add new row , been displayed after existing rows can seen in fiddle : http://jsfiddle.net/q9gyv/59/ . please suggest how can display the new added row in first row of existing data grid or if added @ last row shown in fiddle, focus on newly added row user . below sample code: require(['dojo/_base/lang', 'dojox/grid/datagrid', 'dojo/data/itemfilewritestore', 'dijit/form/button', 'dojo/dom', 'dojo/domready!'], function (lang, datagrid, itemfilewritestore, button, dom) { /*set data store*/ var data = { identifier: "id", items: [{ id : 1, col2 : "aa", col3 : "bb", col4 : "cc" }] }; ...

c# - Unity Vectors Equality -

{ hi guys, here's problem, pretty new on programming in unity , i've made first game android. it's pretty simple 2d game infinite down scrolling , have dodge fallings blocks. have made little c# script should make player go opposite side of screen when goes out of it. thing is working pretty when use in unity when port apk file doesn't work @ :(. here's code: thanks helping me :) if (player.transform.position == new vector3 (8, -7, 0)) { transform.translate (-15, 0, 0); } if (player.transform.position == new vector3 (-8, -7, 0)) { transform.translate (15, 0, 0); } you shouldn't use == vector3 variables... they're based on floating point numbers can close each other still not equal. instead try checking whether player.transform.position.x greater 8 or less -8. game should work more consistently way.

c++ - std::bind-like function returning a std::function -

i need bind function behaves std::bind , returns appropriate specialization of std::function . i think std::function template arguments can extracted using placeholder number function's parameter. doesn't trivial though. there implementation available already? why need this i want implement waterfall function semantics similar this javascript one . here how imagine in c++: std::function<void(const std::string &)> f = waterfall( []( const std::function<void(int)> &cb, const std::string & ) { ...; cb( 1 ); }, []( const std::function<void(double, double)> &cb, int ) { ...; cb(0.5, 10); }, []( double, double ) { } ); in other words, waterfall take bunch of functions, each of (but last one) takes function first parameter. waterfall bind every function previous 1 (starting last one, of course), , return single function. basically waterfall should this: // recursion termination: `waterfall` called...

spring integration - How do I use the StompSubProtocolHandler with the int-websocket:client-container -

i have basic setup websocket stomp client. problem stompsubprotocolhandler, websocketinboundchanneladapter , websocketoutboundmessagehandler treat messages if application server. the messages special treatment depending on whether inbound or outbound. for example, send message through outbound-channel-adapter simpmessagetype="connect" , stompsubprotocolhandler's handlemessagetoclient [thankfully] not supposed connect message because not expect such message sent. then connected [connect_act] message comes , handled stompsubprotcolhandler's handlemessagefromclient function. function doesn't know connected frame , instead of publishevent attempts send message outputchannel. ok except websocketinboundchanneladapter aware of simpmessagetypes , ignores message because not "message" type. i feel there must kind of client side websocket channel adapters don't know about. feel there must kind of stompsubprotocolhandler designed client in mind well...

javascript Date timezone issue -

i need js date object specified values date , year. expect new date("2000-01-01") give me date object 2000 value getfullyear() , if computer's time settings set chicago timezone, i'm getting fri dec 31 1999 18:00:00 gmt-0600 (cst) , , buenos aires: fri dec 31 1999 22:00:00 gmt-0200 (arst) . is there way create date object, .getfullyear() returning date set in constructor, no matter timezone set on user's machine? update: need date object used in library (which calls .getfullyear() method, using utc getters doesn't help. when parsing string date in javascript, value in yyyy-mm-dd format interpreted utc value, rather local-time value. the key parts separated hyphens, , there no time zone information in string. ecmascript 5.1 spec says in §15.9.1.15 : ... value of absent time zone offset “z”. that means, if don't specify offset, assume meant utc. note since opposite of iso-8601 says, behavior has been changed in ecmascript...

javascript - getFeatureFromEvent from multiple layers simultaneously in OpenLayers -

i'm trying return multiple features 2 layers user click (one feature on each layer)? i'm using openlayers 2.12. have 2 vector layers containing polygons, , container layer containing both. when clicking both layers contain feature, layer2 feature returned. how feature @ layer1 of same position? is there away feature specific layer @ viewport position? explanation: selectfeature -control uses layers getfeaturefromevent() method find one feature click, hover, touch etc. event. if selectfeature controls more 1 layer, glues layers virtual single layer, therefore @ max 1 feature in case, too. your 1st question: if want select more 1 feature, can use selectfeature's selectbox(openlayers.bounds) method: if create small bounds position , call selectbox(), all features all layers controlled sc intersecting bounds selected. your 2nd question: may make openlayer.event viewport position , call getfeaturefromevent() specific layer. of course return 1 feature...

html - vertically centering bootstrap buttons -

i using bootstrap buttons in menu bar @ top of page. of buttons have short link names, while others have long link names. want split long link names 2 lines, doing makes short buttons half size of resulting link link buttons. , if put break tags after short link titles, short link titles on top of lines instead of in middle. when remove break tags , force height each button, short link titles still @ top of button. how can vertically center-justify names of links in buttons below? <spring:url value="/" var="homeurl"></spring:url> <a href="${fn:escapexml(homeurl)}" class="btn btn-info btn-lg" style="vertical-align:middle; min-height:45px">home</a> <spring:url value="/start-simple" var="simpleurl"></spring:url> <a href="${fn:escapexml(simpleurl)}" class="btn btn-info" style="vertical-align:middle; min-height:45px">start<br>simpl...

javascript - php - background process of a jar file, how can i get asyncronously notified when process finishes? -

scenario: have php vagrant virtualbox server , runnable jar takes minutes run. ideally, when user goes route in application, server start running said jar in background user wont have wait looking @ blank page, and, when jar finishes executing, page automatically refresh(or data in it) giving user information got output of jar. problem: far, managed run jar in background using exec() function. can process id , check if still running or not. problem have how can php(per say) notified when jar stops running without blocking normal execution? there way this? i've searched everywhere laravel queues forking running process nothing(as understood) suits needs. edit: think may have found solution ask community anyway. use javascript loop (with setinterval) after page loads, , ,inside loop, make ajax async request server asking if process has ended, and, if so, bringing output of jar , updating web page new data. make "pull" solution instead of preferable "push" ...

eclipse - Accessing an object from another class C++ -

this question has answer here: what undefined reference/unresolved external symbol error , how fix it? 27 answers i trying create library system. have source file called 3.cpp, several classes called game.h, dvd.h, book.h, library.h , media.h. i creating object called lib in 3.cpp , trying access lib object game class. how can this? using eclipse onmac os. the 3.cpp source file is: #include <stdlib.h> #include <iostream> #include <fstream> #include <string> #include "library.h" // include header of library class #include "game.h" // include header of game class #include "dvd.h" // include header of dvd class #include "book.h" // include header of book class using namespace std; int main(){ library lib; while( 1 ){ char mainselect; char gameoption, name[30], platform[30],...

Laplace transform in Matlab -

i trying graph frequency response of transfer function h(s). circuit have been given x(t), voltage in, goes threw inductor , threw parallel placed resistor , capacitor. y(t) across parallel placed capacitor , resistor. impedance of l(inductor) zl = sl(where s = alpha + jwt), zr = r, zc = 1/sc , zrc = src/r+sc(it sum of 2 impedance in parallel, capacitor , inductor). have got equation transfer function h(s), below: i(s) = x(s)/zl+zrc //which total current in circuit y(s) = i(s)*zrc(voltage across capacitor , resistor) h(s) = y(s)/x(s) => zrc/zrc+zl=> r/(r*c*l*s^2 + l*s + r) did transfer function h(s) right? because when try graph frequency response f = 0:0.001:2 , s = j2pf, don't desired output in db, should negative values instead of positive. finally, impulse response of system t = 0:0.001:1, thought h(s) impulse response. thank you the current in circuit given i(s) = x(s)/(zl(s) + z_rc(s)) not x(s)/zl(s) + z_rc(s) take care of parenthesis. the co...

javascript - JSX not creating files -

i have file src/post.jsx following content var react = require('react'); var post = react.createclass({ render: function() { return ( <h1>i t!!!</h1> ); } }); module.exports = post; react.render( <post />, document.getelementbyid('post') ); when run jsx --watch src/ build/\ only build directory gets created no post.js file. do have run other command first? jsx seems consider *.js files by default : -x, --extension <js | coffee | ...> file extension assume when resolving module identifiers (default: js) so, add -x jsx .

matlab - Simultaneous differential equations with conditional change of a coefficient -

i want model chemostat (a kind of bioreactor). setup following system can solved ode45 method: %chemostat model, based on: %dcc=-v0*cc/v + umax*cs*cc/(ks+cs)-rd -->change of cell concentration on time %dcs=(v0/v)*(cs0-cs) - cc*(ys*umax*cs/(ks+cs)-m) -->change of substrate concentration on time function dydt=sys(t,y,v0,v,umax,ks,rd,cs0,ys,m) dydt=[-(v0/v)*y(1)+(umax*y(1)*y(2))/(ks+y(2))-rd; (v0/v)*(cs0-y(2))-(ys*umax*y(2)*y(1))/(ks+y(2))]; i call function with: [t,y]=ode45(@systemequations, [0 40],[1 100],[],**v0**, v,umax,ks,rd,cs0,ys,m); the values of additional coefficients set before running calculation. far works. v0 dependent on system state. e.g. v0 = 0 , when cell concentration surpasses value want change. the problem is, absolutely have no idea how implement this. matlab of ode solver wasn't of either... thanks or suggestions! cheers, dahlai use differential system function take care of you! first formulate v0 funct...

c# - Get a list of referenced Types within a project with Roslyn -

i want list of used types in project, example: var x = 1; var y = x.tostring().gettype(); the code should return system.int32 , system.string , system.type . what have freaking slow... each file (syntax tree), following: var root = await syntaxtree.getrootasync(); var nodes = root.descendantnodes(n => true); if (nodes != null) { var syntaxnodes = nodes syntaxnode[] ?? nodes.toarray(); // identifiernamesyntax: // - var keyword // - identifiers of kind (including type names) var namedtypes = syntaxnodes .oftype<identifiernamesyntax>() .select(id => this.compilation .getsemanticmodel(id.syntaxtree) .getsymbolinfo(id) .symbol) .oftype<inamedtypesymbol>() .toarray(); // add found types list this.addrange(namedtypes); // expressionsyntax: // - method calls // - property uses // - field uses // - kinds of composite expres...

AngularJS XMPP Get Roster -

i use xmpp jsjac library , angularjs programming chat application. can connect server, not list roster. app.js var app = angular.module("app", ["ngroute"]).config(["$routeprovider", function($routeprovider) { $routeprovider .when("/login", { templateurl: "view/login.html", controller: "logincontroller" }) .when("/main", { templateurl: "view/main.html", controller: "maincontroller" }) .otherwise({ redirectto: "/login" }); }]); xmppservice.js app.service("xmppservice", function() { return { conparams: null, auth: function (userid, password) { this.conparams = { httpbase: connectionconfig.httpbase, timerval: connectionconfig.timerval }; con = new jsjachttpbindingconnection...

java - Smart JScrollPane follows output text -

i have smart jscrollpane unlike every other solution out there know if view port can follow (scrolling with) viewed component (jtextarea) if scroll pane not @ bottom , if text buffer full. functional code snippet included. thanks. public class scrollingjtextareaexample extends jframe { // worker thread periodically append example messages jtextarea timer timer = new timer(); // merely informative counter, displayed example messages int messagecounter = 0; // gui components jscrollpane jscrollpane; myjtextarea jtextarea; public scrollingjtextareaexample() { initcomponents(); // boiler plate gui construction , layout // configure jtextarea not update cursor position after // inserting or appending text jtextarea. disables // jtextarea's usual behavior of scrolling automatically whenever // inserting or appending text jtextarea: want scrolling // occur @ our discretion, not blindly. note ...

android - Set onItemClickListener on only a particular card in CardScrollView? -

i making quiz app in google glass. after clicking main activity (which question) user taken list of cards, in mcardscrollview (which answers question in main activity), want user taken next question after correct option (i.e card in cardscrollview) clicked. currently using following itemclicklistener turns every card clickable item, public void onitemclick(adapterview<?> parent, view view, int position, long id) { // plays disallowed sound indicate tap actions not supported. audiomanager = (audiomanager) getsystemservice(context.audio_service); am.playsoundeffect(sounds.disallowed); toast.maketext(questionactivity.this, "this selected : " + position, toast.length_short).show(); //mcardscrollview.deactivate(); intent gotoquestion; gotoquestion = new intent(questionactivity.this, mainactivity.class); startactivity(gotoquestion); finish(); and trying fo...

Selecting Range by Database Attribute for Rails Form -

is possible select range maximum number option pulled database? have code below gives 1 option. i'd give options 1 through @item.quantity. <%= f.select(:quantity_requested, [1..@item.quantity], {}, { class: 'item-quantity form-control' }) %> all other examples see of hard coded numbers. appreciate understanding why doesn't work. thanks! i've never seen ruby's range dynamic numbers. tried doing in irb , didn't work correctly. alternative use (not tested, idea is): <%= f.select(:quantity_requested, 1.upto(quantity.times).to_a, {}, { class: 'item-quantity form-control' }) %> edit: tried in irb console , started @ 0 based, you'll want use upto instead of times, see output below: a = 100 a.times.to_a => [0, 1, ... 99] 1.upto(a).to_a => [1, 2, 3,.. 99, 100]

html - Get the name of ONE element when it is clicked in PHP -

i'm wondering how can name of element when clicked in php, elements have same name instance... php: <?php $playlist_names = array("chill", "groovy", "pastasauce", "dank songs", "katy perry"); ($i = 0; $i < count($playlist_names); $i++) { echo "<a href=\"\" class=\"playlist-name\" name=\"$x\">$playlist_names[$i]<img src=\"http://i.imgur.com/pllny9d.png\" class=\"gear-icon\" /></a>"; } ?> what i'm trying when "playlist-name" clicked - return playlist name in different div text "editing [name of playlist here]" this seem simple problem, helping out! use $(this).text(); text inside html element for case retrive first element text can use selector : $("div p:nth-child(1)").text(); and 1 other ones .

javascript - Injecting JQuery into Android Webview -

i working on project translate webpage , displaying in android app. have done injecting javascript webview android using following code: @override public void onpagefinished(webview view, string url) { string jap = "お問い合わせ"; string eng = "contact us"; mwebview.loadurl("javascript:(function(){" + "var jpf = '"+jap+"';" + "var jp = new regexp(jpf,'g');" + "var en = '"+eng+"';" + "document.body.innerhtml = " + "document.body.innerhtml.replace(jp,en);" + "})()"); } however, ineffective method, because search each term , replace it. because of this, tried similar jquery's dictionary: @override public void onpagefinished(webview view, string url) { mwebview.loadurl("javascript (function(){" + "var mydictionary = {...

php - Require user login to submit form -

how can require user logged in, in order submit input? i found piece of code, not sure how can modify suit needs: add_action('login_head','ref_access'); function ref_access() { global $error; if( !empty($_get['ref']) && 'access' == $_get['ref'] ) $error = 'restricted area, please login continue.'; } this input posted mysql database. this input code stands in plugin: <input type="text" maxlength="4" name="' . $quanid . '" value="" class="input" /> as of right now, can submit this, regardless of login status. you can use wordpress's built in function that: is_user_logged_in() . example: function ref_access() { global $error; if (is_user_logged_in()) { // process form here. }else { $error = "hey, out of here"; return ; } }

printing - Use Python to output bold text in .doc -

i trying print statement: a= 'hi %s, \n meeting scheduled %s %sth \n if have questions please contact %s' % (cfname, meetingmonth, meetingday, cleadfname) print i'm trying bold every variable insert (i.e. cfname, meetingmonth etc.). basically, have script asking enduser input writes statement .doc format. there simple way bold things when writing in python? i've tried bold brackets around word , doesn't seem work. great! print produces plain text, not microsoft word documents. if add html formatting tags ( <html> , <body> , <strong> , <br /> , etc.) necessary, give resulting text file .doc extension, open word, - assuming have reasonably recent version understands html - parse html , display result you're looking for. sample: a= '<html><head></head><body>hi %s, </br> meeting scheduled <strong>%s %sth</strong> <br /> if have questions please contact %s</body...

c# object reference not set to an instance of an object For my c# -

this question has answer here: what nullreferenceexception, , how fix it? 33 answers can me? keep getting error "object reference not set instance of object" on line 2150 in coding here: ln 2148 if (session.characterinfo.timer > 0) ln 2149 { ln 2150 session.senddata(roomchatcomposer.compose(actor.id, "you have " + session.characterinfo.timer + " minutes left until you're paid", 0, chattype.whisper)); 2151 } one of following: session null session.characterinfo null actor null roomchatcomposer null (this calling static method, if discard) chattype null (this enum? if discard this) introduction debugging

php - Codeigniter Update Record - Unable to update in database -

i'm trying update record in ci project. can deal form validation later. right i'm trying address inability update record in database. i'm using template pages , placing content. appreciated. model updating record public function up_ct_acct($id, $sus) { $this->db->where('user_id',$id); $this->db->update('users',$sus); } controller form view , action //for page view public function update_profile($id, $datum) { //the username on url. $id = $this->uri->segment(3); $datum['user_profile'] = $this->user_model->get_da_profile($id); //using template pages $content['main_content'] = $this->load->view('users/update_profile',$datum); $this->load->view('main',$content); } //action update public function up_sup_acct() { $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name...

parse.com - PFFile security -

does know if possible set security pffile? url pffile public , can access knows url. need urls have access control, not public access. can done in parse? thank you you need wrap access file in proxy own security checks. look parse hosting, create web end-point takes file id , user token input check security , return file data in response stream. if need implementing after reading docs please post question you've tried far.

javascript - Angular dynamically adding directive -

i want dynamically use angular-slimscroll in webpage. directive looks this: <div id="scroll" slimscroll="{slimscrolloption: value}"> scroll content </div> how can dynamically add slimscroll="{slimscrolloption: value}" #scroll div , have functioning angular-slimscroll? you can create directive, thing that: js angular.module('myapp',[]) .controller('myctrl', function ($scope) {}) .directive('myscroll', ['$compile', function($compile) { return { scope: true, link: function(scope, element, attrs) { element.attr('slimscroll', '{slimscrolloption: value}'); element.removeattr('my-scroll'); $compile(element)(scope); } }; }]); html <div id="scroll" my-scroll> scroll content </div> the key need $compile element again dynamically add angular-slimscroll. , removing attribu...

Java Generics Wildcard bounding cannot set -

i have following classes. public class basket<e> { private e element; public void setelement(e x) { element = x; } public e getelement() { return element; } } class fruit {} class apple extends fruit {} class orange extends fruit {} my confusion comes when consider following cases. basket<? extends fruit> basket = new basket<>(); basket.setelement(new apple()); // cannot set and basket<fruit> basket = new basket<>(); basket.setelement(new apple()); // okay! if ? extends fruit means can pass @ least fruit (or implements or extends), why cannot pass in apple type? cannot see difference between 2 cases if passing apple type in second case works because apple descendant of fruit ... basket<? extends fruit> not mean basket can hold object long subtype of fruit . means basket of unknown type t extending fruit . example basket<apple> , basket<orange> or basket<fruit...

mysql - How to Link PHP Sub Categories(Pages) Dynamically -

Image
i have there php file getting data mysql database called: clubs.php club.php player.php the clubs.php list clubs tbleclubs table , looks like: clubs.php $database = new database(); $res = $db->query("select * tblclubs"); foreach ($res $datarow): ?> <span><?php echo $datarow['id']; ?></span> <span><a hrer=""><?php echo $datarow['name']; ?> </a></span> <?php endforeach; ?> and club.php listing players in club tblclub table club.php $database = new database(); $res = $db->query("select * tblpclub"); foreach ($res $datarow): ?> <span><?php echo $datarow['id']; ?></span> <span><a hrer=""><?php echo $datarow['name']; ?> </a></span> <?php endforeach; ?> and player.php tbleplayer : player.php $database = new database(); $res = $db->query("select * tblpl...

javascript - Shift + Enter » Multiple Line -

firstly english isn't native language, sorry if have mistakes. there message sending problem in function, i've played jquery codes couldn't fix it. when press enter, message reach receiver, that's good. when press shift enter, message reach receiver again, want create new line when press both keys. jquery codes: $(document).ready(function() { $('input#chat').bind('keydown', function(e) { if(e.keycode==13) { // store message var var message = $('input#chat').val(); var id = $('#chat').attr('class'); if(message) { // remove chat errors if $('.chat-error').remove(); // show progress animation $('.message-loader').show(); // reset chat input area document.getelementbyid("chat").style.height = "25px"; $('input#chat').val(''); did try ? if(e.shiftkey && e.keycode==13){ //...

Android Studio creating ViewPager -

i have button on mainactivity opens secondactivity. secondactivity viewpager , , have 2 fragment classes ( fragment1 , fragment2 ) , 2 fragment xml, each textview inside. cannot work out how put 2 fragment inside viewpage using fragmentpageradapter can slide 1 fragment another. can please show/help me? mainactivity button button1 = (button) findviewbyid(r.id.buttoncreateworkout); button1.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { startactivity(new intent(mainactivity.this, secondactivity.class)); } second_activity.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" ...

string - Android Studio Saving Data to Phone -

string mystring = "hello world"; how save contents of mystring .txt file within phone/android, there after application ends , can edit value in future? use method: public void writetofile(string str) try { outputstreamwriter outputstreamwriter = new outputstreamwriter(context.openfileoutput("config.txt", context.mode_private)); outputstreamwriter.write(data); outputstreamwriter.close(); } catch (ioexception e) { log.e("exception", "file write failed: " + e.tostring()); } private string readfromfile() { string ret = ""; try { inputstream inputstream = openfileinput("config.txt"); if ( inputstream != null ) { inputstreamreader inputstreamreader = new inputstreamreader(inputstream); bufferedreader bufferedreader = new bufferedreader(inputstreamreader); string receivestring =...

office365 - How can i revoke the access granted to web application to my organization's azure AD? -

i have office 365 developer account & tenant in windows azure manage office 365 users. using consent framework "prompt=admin_consent", granted access rights 1 of web application registered in azure ad (which managed me) use office 365 api services, after granting access using admin consent, azure ad users able authenticate against azure ad. able see applications granted access using http://myapps.microsoft.com not able revoke access granted applications using url. how can revoke access granted or third party application organization's azure ad? let me check our azure folks, believe if granted admin consent can remove azure management portal. when navigate apps, see apps you've consented along apps you've developed. can remove there.

java - Populating dropdown in Play framework -

i fetching list of client names database , need populate list drop down in play framework. when do, getting error: not found type name . doing wrong? my application.java code is: package controllers; import java.awt.list; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import play.mvc.*; import play.twirl.api.content; public class application extends controller { static list l = new list(); public static <list> result index() throws instantiationexception, illegalaccessexception, classnotfoundexception, sqlexception{ class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver").newinstance(); connection conn = drivermanager.getconnection("jdbc:sqlserver://localhost:1433","sumeet","sumeet"); system.out.println(conn); statement sta = conn.createstatement(); string sql = "select * clie...

Can I rely on % (modulo) operator in C for negative numbers? -

using gcc: printf("%i \n", -1 % (int)4); printf("%u \n", -1 % (unsigned int)4); -1 3 can rely on behaviour across platforms? should explicitly define mod , rem macros sure isn't altered? the c99 standard says: 6.5.5 multiplicative operators : when integers divided, result of / operator algebraic quotient fractional part discarded 87) . if quotient a/b representable, expression (a/b)*b + a%b shall equal a . : 87) called ‘‘truncation toward zero’’ this implies divide rounds towards 0, can rely on it. note different c++03 standard. your second line unsigned divide, converting value -1 unsigned int before divide. 1 less power of 2, defined.

ruby on rails - data is not saved in joins table -

i working on website, user can have multiple projects , multpile users can contribute single project. have project model class project < activerecord::base #associations has_and_belongs_to_many :users end and users model class user < activerecord::base #associations has_and_belongs_to_many :projects end and have created joins table name - :projects_users works fine when run code on rails console. when try save thing in controller, data not being saved in joins table. code controller please help class projectscontroller < applicationcontroller def new @project = project.new end def create @user = user.find(session[:user_id]) @project = project.new(project_params) if @project.save @project.users << @user redirect_to @project else flash[:error] = "project has not been created due error" render 'new' end end private def project_params params.require(:project).per...

Android Studio 1.1 Gradle 2.2.1 Gradle version 2.1 required current version is 2.2.1 -

Image
i trying compile latest version of u2020-daggr2 in android stu![e imported gradle project. error complaining gradle! did edit gradle-wrapper.properties. rebuilding did not work. did see: gradle 2.1 required migrate gradle wrapper , sync project seems same issue on studio did not find: settings -> gradle , click use default gradle wrapper (recommended). i did not find in studio. first off there no menu says setting. there : file->other setting->default setting. nothing gradle vm parameters etc. nothing using default gradle wrapper. need have local copy of gradle 2.1 work? ![enter image description here][4] gradle wrapper.properties edited such: distributionurl=https://services.gradle.org/distributions/gradle-2.1-all.zip error:(20) problem occurred evaluating root project 'u2020-dagger2'. failed apply plugin [id 'com.android.application'] gradle version 2.1 required. current version 2.2.1. if using gradlewrapper, try editing ...