Posts

Showing posts from April, 2013

class - c++ how to call function with subclass, having superclass pointer -

i have 3 classes, a, b , c: class { public: virtual bool sm(b b) = 0; virtual bool sm(c c) = 0; }; class b : public { bool sm(b b) { //code } bool sm(c c) { //code } }; class c : public { bool sm(b b) { //code } bool sm(c c) { //code } }; and vector<a*> objects , stores b or c objects. (for example generates randomly) can call somehow for(int = 0; < objects.size(); i++) { for(int j = i; j < objects.size(); j++) { objects[i].sm(objects[j]); } } without dynamic cast or something? because there can bit more of b-c classes , bag thing, , may there better way it? solution odelande said , understood, solution problem #include <iostream> #include <vector> class b; class c; class { public: virtual bool sm(a* a) = 0; virtual bool sm(b* b) = 0; virtual bool sm(c* c) = 0; }; class b : public { public: bool sm(a* a) { return a->sm(this); } bool sm(b* b) { std::cout &l

ruby on rails - How to pass parameters to the controller with the proper key -

i'm trying figure out how store id on controller side delete store. currently code params on controller side sends store.id(1) value key format. need retrieve store_id: instead. {..."controller"=>"home", "action"=>"delete_store", "format"=>"1"} what need: {..."controller"=>"home", "action"=>"delete_store", "store_id"=>"1"} html/erb: <h4>your stores:</h4> <% @my_stores.each |store| %> <p><%= store.name %><%= link_to "x", delete_store_path(store.id), method: :delete %></p> <% end %> controller: class homecontroller < applicationcontroller ... def delete_store # current code, have # current_user.stores.where(store_id: params[:format] ) # make proper need # current_user.stores.where(store_id: params[:store_id] ) end end you can in

listview - android exendable list on screen's foreground -

:d i got exependable listview on top of layout, controlled fragment , below imageview. what want : when expend list, image don't move goes in background what happen : image go down as list expends. i tryed use linear layout weight param. same results any idea? <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:background="@color/colorbackground" android:fillviewport="false" android:id="@+id/container" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/linearlayout2"> <fragment android:id="@+id/pl

tensorflow - distributed data reader across multiple machines -

is there distributed data reader tensorflow? if not, suggested way handling big datasets on multiple machines? the distributed inception example here pre-segments data on multiple machines , each workers grabs subset of data available subsets. supported method? also seems of data readers described in here thread safe couldn't find distributed solution. we don't have general solution distributed data reading in tensorflow, , it's bit of hard problem since there many different possible requirements around latency, size, , sharding. i'd interested in proposals or patches though!

javascript - Node js post data is undefined -

this in app.js file... var routes = require('./routes'); var user = require('./routes/user'); var reg = require('./routes/register'); var bodyparser = require('body-parser'); app.use(bodyparser.json()); app.use(bodyparser.urlencoded({ extended: true })); ... ... app.get('/', routes.index); app.get('/users', user.list); app.get('/register', reg.register); app.post('/signup', reg.postregister); in register.js file rendering new page using get , , trying access post data page using post function... exports.register = function (req, res){ res.render('register.jade', { title: 'register' }); } exports.postregister = function (req, res) { console.log(req.body.reg_name); } the get works, , post function called console logs undefined , cannot figure out why. html file register.js trying access... form(name="login", method="post", action='/signup', enc

meteor - Flow Router not working with google maps? -

for strange reason whenever try route google maps flow router layout never renders. google maps template i'm using looks this: <template name="map"> {{> googlemap name="map" options=mapoptions}} </template> is glitch flowrouter?

c++ - Compilation of x264 project -

i had downloaded source of x264 library site http://www.videolan.org/developers/x264.html the version of x264 148. for compilation of shared dlls using following command under msys environment: ./configure --disable-cli --enable-shared --prefix=. the result following: platform: x86_64 byte order: little-endian system: windows cli: no libx264: internal shared: yes static: no asm: yes interlaced: yes avs: no lavf: no ffms: no mp4: no gpl: yes thread: win32 opencl: yes filters: crop select_every debug: no gprof: no strip: no pic: yes bit depth: 8 chroma format: after execution of make have following error: common/win32thread.o:win32thread.c:(.text+0x60): undefined reference `_beginthreadex' common/win32thread.o:win32thread.c:(.text+0x60): relocation truncated fit: r_x86_64_pc32 against undefined symbol `

image - Game Maker - Mouse Click image_index Checking -

i have sprite: spr_meteoritelv3 , has 2 sub-images index image_index 0 , 1 respectively. i have these objects: obj_meteoritelv3 , obj_tempmeteoritelv3 , , obj_score . object obj_meteoritelv3 spawns above random position, random amount, , random sub-image. object obj_tempmeteoritelv3 makes obj_meteoritelv3 s spawn. when player clicks on meteorite, program checks value of image_index object. obj_meteoritelv3 has these events: create event : change sprite_index spr_meteoritelv3 , , start moving downwards. left-pressed mouse event : destroy self instance, , check image_index : if image_index == 0 score += 5 ; else score -= 5 ). obj_tempmeteoritelv3 has these events: create event : set alarm 0 3600, set variable exist 1, , set variable add 1. alarm 0 : set variable add 0, , destroy obj_meteoritelv3 instance. alarm 1 : set variable exist 1. step event : if (exist == 1) then, if (add == 1) create instance of obj_meteoritelv3 , set variable exist 0, , set

google spreadsheet - How can I use IMPORTRANGE to populate my create calendar event sheet without affecting the script? -

this formula in a2 , populates data in booking sheet =query( importrange("sheet_key","sheet1!a7:z"), "select col7,col2,col8,col9,col12,col19" ) the calendar event script https://stackoverflow.com/a/15790894/6400958 works , takes 5-10 seconds run when data entered directly creates duplicates , exceeds run time when import range formula used same amount of data. here demo file . note there 3 rows of event data. below script: /** * adds custom menu active spreadsheet, containing single menu item * invoking exportevents() function. * onopen() function, when defined, automatically invoked whenever * spreadsheet opened. * more information on using spreadsheet api, see * https://developers.google.com/apps-script/service_spreadsheet */ function onopen() { var sheet = spreadsheetapp.getactivespreadsheet(); var entries = [{ name : "export events", functionname : "exportevents" }]; sheet.addmen

javascript - disable links, form submit action and modal popups in a cloned object jquery -

i creating site walk-trough on first signup users. chose use live elements on landing view appear more customized each user pictures. using jquery clone drawing live objects walk-through modal. $(".dashboard_content").clone().appendto( ".t_dashboard_content" ); i need disable links, form submit action , modal popups in cloned object.solutions here resulting in target elements on original elements being disabled undesirable. leads attaining welcome. you try everwrite link onclick event: $('a').click(function(ev){ // global variable use enable/disable following links if(islinkdisabled) { ev.preventdefault(); return false; } return true; });

css - Text won't display in Bootstrap Jumbotron w/ image -

i trying add background image twitter bootstrap jumbotron class. i using bootstrap3. i tried alpha'd text , did not restrict image jumbotron: .jumbotron:after { background: url("img/island.png") repeat scroll center center transparent; bottom: 0; content: ""; display: block; left: 0; opacity: 0.4; position: absolute; right: 0; top: 0; } here html: <!-- main jumbotron primary marketing message or call action --> <div class="jumbotron"> <div class="container"> <h1>hello, world!</h1> <p>this template simple marketing or informational website.</p> <p><a class="btn btn-primary btn-lg">learn more &raquo;</a></p> </div> </div> this got me 90% of way text not show: <link href="css/bootstrap.css" rel="styleshe

c++ - why my main function couldn't return at last? -

i build win32 console application program, here source code: #include <iostream> #include <fstream> #include <vector> #include <string> using namespace std; struct cpassenger { string name; string id; string seat; }; struct cflight { string flnum; string destination; int amount; int booking; string departuretime; string falltime; vector<cpassenger> list; }; class cflightsystem { public: cflightsystem(); ~cflightsystem(); private: vector<cflight> flight; }; cflightsystem::cflightsystem() { ifstream infile("flight.txt"); if(!infile) { cerr<<"no input file!"<<endl; exit(1); } while(!infile.eof()) { cflight plane; infile>>plane.flnum>>plane.destination >>plane.amount>>plane.booking >>plane.departuretime>>plane.falltime; for(int i=0;i

javascript - How to setup php in my Angular project? -

i trying setup angular project has php backend. project setup followed: project -app -api -test.php -scripts -app.js -test.controller.js -css -images ...others in test.controller.js angular.module('myapp') .controller('mainctrl', function ($http) { $http.get('api/test.php').then(function(res) { console.log(res) }) ...more }); inside test.php <?php ..php codes ..calculate stuff. ..generate $result echo json_encode($result); for reason, when load page, can see request entire test.php code instead of data need. for example: return i've got "<?php↵header("content-type: application/json", true);...more... i have virtual host setup , not sure went wrong. me it?

Implementing the difference between two sorted Lists of comparable items in java -

implement method in java compute difference () between l1 , l2. l1 \ l2 = { x | x ∈ l1 , x ∉ l2 }. this implementation far: public static <anytype extends comparable<? super anytype>> void difference(list<anytype> l1, list<anytype> l2, list<anytype> difference){ if(l1 == null){ difference = null; } else if(l2 == null){ difference = l1; } else if(l1.size()==0 || l2.size()==0){ difference = l1; } else{ iterator<anytype> it1 =l1.listiterator(); iterator<anytype> it2 =l2.listiterator(); anytype = it1.next(); anytype b = it2.next(); while(true){ if(a.compareto(b)>0){ if(it2.hasnext()){ b = it2.next(); } else{ difference.add(a); while(it

vb.net - Is this code is prone to sql injection attacks? -

sql= "select * book pubname = '" & mypubname & "'" mypubname encapsulated. yes. if taking "mypubname" variable user input , not checking properly. to inject sql needs write value of "mypubname" variable "'sometext' or 1=1" then query select * book pubname = 'sometext' or 1=1 which return rows book table.

c# - Linq to SQL type mismatch -

i have type mismatch error when reading contents of table 'imagehighlight'. in designer.cs table is: public system.data.linq.table<imagehighlight>imagehighlights { { return this.gettable<imagehighlight>(); } } in code trying cache small table in method loadstaticcache() @ applicationstart can access contents later via gethighlightimages() . public class staticcache { private static imagehighlight _images = null; public static void loadstaticcache() { // images - cache using static member variable using (var datacontext = new mhrdatacontext()) { _images = datacontext.imagehighlights; } } public static imagehighlight gethighlightimages() { return _images; } } at code line _images = datacontext.imagehighlights; error cannot implicitly convert type system.data.linq.table<holidayrentals.core.domain.linqtosql.imagehighlight> holidayrental

PHP Regex prefix with image file extension -

i want display files prefix: 7ws9xfd1rhvaupxh37nb_ must have file extension of .jpg, .png, .gif these sample strings: 7ws9xfd1rhvaupxh37nb_magnifying_glass_icon.png 7ws9xfd1rhvaupxh37nb_url.gif 54a8sx555a4rrgsabwzq_korea.jpg 7ws9xfd1rhvaupxh37nb_6780969-cool-abstract-wallpaper.png 7ws9xfd1rhvaupxh37nb_wall_1409747331_multicolor-geometric-shapes.jpg i've used regex no luck: $key "7ws9xfd1rhvaupxh37nb"; $regex = '~^'.$key.'-.*\.((jpg)|(png)|(gif))$~'; $files = $files = preg_grep($regex, scandir("../temp/")); there difference between - , _. check regex , modify slightly: $regex = '~^'.$key.'_.*\.((jpg)|(png)|(gif))$~';

php - DateTime Class not support the years before 1960? -

i have following situation: $birth = new datetime('1960'); echo $birth->diff( new datetime() )->format('%y'); the output 56 - ok, when set argument 1959 or less value got result 0. example: $birth = new datetime('1959'); echo $birth->diff( new datetime() )->format('%y'); the output 0. the test environment is: php 5.5.9-1ubuntu4.17 apache/2.4.10 (ubuntu) thanks! you need specify valid datetime input new datetime(). i guess 1960 can interpreted year, while 1959 time. printing out difference in years between time , time @ 19:59 0. you better off specifying full date, 1959-01-01.

angularjs - angular slow select input -

in controller, set 2 scope variables "otherscope" , "options". otherscope: {"id":"1", "val1":"x", "val2":"y", ...} othersope.id value, should selected one. contains 1 object options: [{"id":"1", "text":"sometext"}, {"id":"2":"sometext2"}, ...] options.id available options compare otherscope.id. contains 50 objects. it works, take 10 seconds render. correct way set selected value? <label class="item item-input item-select"> <div class="input-label"> options </div> <select ng-model="otherscope.id"> <option ng-repeat="option in options track option.id" value="{{option.id}}">{{option.text}}</option> </select> </label> change options opti

Ruby: Confused about how to make sense of this code -

i'm little confused 1 part of code. in line 7 have commented below. 01:states_file = file.open("states_abbrev.txt") 02:states = {} 03:while ! states_file.eof? 04: first = states_file.gets.chomp 05: #"alabama,al" 06: data = first.split(",") 07: states[ data[0] ] = data[1] #this line here. 08:end 09:puts states.inspect 10: 11:states_file.close line 5 , example of each line in states_abbrev.txt file. state, comma, abbreviation, , carriage return. 50 states in file. as can see on line 7 data[0] key seems overwritten data[1] . why when run code data[0] still key, , data[1] becomes value? after line 6 data[0] alabama, data[1] al after line 7 states { 'alabama' => 'al' } its not overwriting data[0].. data[0] key , data[1] value. one thing can try ruby's irb

apache spark - how to filter () a pairRDD according to two conditions -

how can filter pair rdd if have 2 conditions filter , 1 test key , other 1 test value (wanna portion of code) bcz used portion , didnt work saddly javapairrdd filtering = pairrdd1.filter((x,y) -> (x._1.equals(y._1))&&(x._2.equals(y._2))))); you can't use regular filter this, because checks 1 item @ time. have compare multiple items each other, , check 1 keep. here's example keeps items repeated: val items = list(1, 2, 5, 6, 6, 7, 8, 10, 12, 13, 15, 16, 16, 19, 20) val rdd = sc.parallelize(items) // create rdd possible combinations of pairs val mapped = rdd.map { case (x) => (x, 1)} val reduced = mapped.reducebykey{ case (x, y) => x + y } val filtered = reduced.filter { case (item, count) => count > 1 } // print out results: filtered.collect().foreach { case (item, count) => println(s"keeping $item because occurred $count times.")} it's not performant code this, should give idea approach.

php - How to activate Gii Code Generator in Yii 2.0.6? -

Image
i have updated yii version using composer 2.0.6. when try locate gii, yii through 404 not found error. screen shot: composer.json file: { "name": "yiisoft/yii2-app-advanced", "description": "yii 2 advanced project template", "keywords": ["yii2", "framework", "advanced", "project template"], "homepage": "http://www.yiiframework.com/", "type": "project", "license": "bsd-3-clause", "support": { "issues": "https://github.com/yiisoft/yii2/issues?state=open", "forum": "http://www.yiiframework.com/forum/", "wiki": "http://www.yiiframework.com/wiki/", "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, "minimum-stability": "stable", "require": {

java - Create unit tests in android studio -

i'm following this tutorial. want create unit tests androidjunitrunner . my directory in app/src looks this: androidtest debug main release android docs suggests create test/java unit tests. problem in android studio can't create new directory if i'm on android project mode. , should find directory manually , create manually. there way automatically create these directories , tests 1 flavor? i've read this question, doesn't relate problem. it's easiest create folder manually in directory. android studio notice pretty , show in android view. you need create packages in test/java folder too. if package name com.foo.bar need create following dir structure in app/src folder: test/java/com/foo/bar as aside in latest versions of android studio don't need use androidjunitrunner anymore. studio supports junit4 tests out of box. to make tests particular flavor need append flavor name end of test folder. if flavor dev fol

How to properly do importing during development of a python package? -

this question has answer here: python relative import causes syntaxerror exception 2 answers i first year computer science student working on small project save dropbox school. i apologize in advance potentially trivial question. having little no experience , after trying debugging techniques have been taught, im stuck! it has following file structure school_project/ __init__.py #(empty) main_functions/ __init__.py #(empty) render.py filter.py helper_functions/ __init__.py #(empty) string.py utility.py currently, need use functions founded in utility.py in file render.py . first attempt @ solving problem import ..helper_functions.utility in file render.py . unfortunately, met following error message. import ..helper_functions.utility ^ syntaxerror: invalid syntax fir

python - Ignore nested structures in numpy's array creation -

i want write vlen hdf5 dataset, using h5py.dataset.write_direct speed process. suppose have list of numpy arrays (e.g. given cv2.findcontours ), , dataset: dataset = h5file.create_dataset('dataset', \ shape=..., \ dtype=h5py.special_type(vlen='int32')) contours = [numpy array, ...] for writing contours destination given slice dest , must first convert contours numpy array of numpy arrays: contours = numpy.array(contours) # shape=(len(contours),); dtype=object dataset.write_direct(contours, none, dest) but works, if numpy arrays in contours have different shapes, e.g.: contours = [np.zeros((10,), 'int32'), np.zeros((10,), 'int32')] contours = numpy.array(contours) # shape=(2,10); dtype='int32' the question is: how can tell numpy create array of objects? possible solutions: manual creation: contours_np = np.empty((len(contours),), dtype=object) i, contour in

php - Posting Values of select box and hidden fields With Ajax on select box change -

i having form in table select box in each row carrying different information hidden field in each row obtained database in php, while selecting of option of select box should redirected page hidden field in row , selected value of select box <table border="1px solid black"> <tr><th>id</th><th>name</th><th>sub</th><th>action</th></tr> <tr><td>1</td><td>mamta</td><td>php</td><td><form method="post" action="form.php"> <select name="workno"> <option value="">--select---</option><option value="1">1</option> <option value="2">2</option></select> <input type="text" name="counter" placeholder="hidden field"> <input type="text" name="counter" placeholder="hidden field"> <i

javascript - How to update input value without clicking on input field? -

so have problem input value updated when clicked on input field ("total" input field, below "suma" ("kiekis" * "kaina" = "suma") column , readonly), want automatically update "totals" field (which @ bottom near "bendra suma"). js code: $(document).on('keyup change', '.quantity, .price', function() { var row = $(this).closest('tr').get(0); var rowprice = $(row).find('.price').val(); var rowquantity = $(row).find('.quantity').val(); $(row).find('.total').val((rowprice * rowquantity).tofixed(2)); $('.total').blur(function () { var sum = 0; $('.total').each(function() { sum += parsefloat($(this).val()); }); $('#totals').val((sum).tofixed(2)); }); }); you can test how works in jsfiddle: https://jsfiddle.net/xqy6qafk/ thanks in advance help! you don't ne

android - Can't work with findViewById -

i'm having problem findviewbyid() . whenever use in code shows me error. android studio suggest me textview dateview = null; , dateview = (textview)dateview.findviewbyid(r.id.dateview); but gives error. can me work out code. public class operationfragment extends fragment { public operationfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment return inflater.inflate(r.layout.fragment_operation, container, false); } public void oncreate (bundle savedinstabcestate){ super.oncreate(savedinstabcestate); calendar c = calendar.getinstance(); simpledateformat dd = new simpledateformat("dd-mm-yyyy"); simpledateformat dt = new simpledateformat("hh:mm a"); string formatteddate = dd.format(c.gettime());

c++ - Template class with operator overload -

here question template class aclass<int> a{1,2}; aclass<float> b{3.0,4.0}; aclass<int> c; int main() { c=a+b; //how overload operator in simple way? b=a; //and this? return 0; } how can overload operator handle template class different types? (sorry poor english) you can have member function templates inside class template: template <typename t> struct aclass { aclass(aclass const &) = default; aclass & operator=(const aclass &) = default; template <typename u> aclass(aclass<u> const & rhs) : a_(rhs.a_), b_(rhs.b_) {} template <typename u> aclass & operator=(aclass<u> const & rhs) { a_ = rhs.a_; b_ = rhs.b_; return *this; } t a_, b_; };

javascript - Not return HTML back in C# -

i've got chathub this public class chathub : hub { public void send(string message) { if(message.length > 0) { string name = context.user.identity.name; clients.all.broadcastmessage(name, message); } } } problem if user enters message <strong>hello</strong> it returned chat like hello how can make return <strong>hello</strong> ? where display (js) chat.client.broadcastmessage = function (name, message) { $('#chat-table').append(name + ': ' + message); }; use .text $('#chat-table').text(name + ': ' + message);

string - How to extract a substring depending on a specified char using Groovy -

i need extract part of name of folder. have code each of folders import groovy.io.filetype def dirs = [] def currentdir = new file('c:\\compilationstaging') currentdir.eachfile filetype.directories, { dirs.add( 'c:\\compilationstaging\\'+it.name) println( it.name) } dirs.sort() def list = dirs.reverse() this gets me list of folders, in specific format: 2013.28.08.14.08.16_debug_value1 2013.28.08.14.08.16_release_value2 2013.28.08.14.18.36_debug_value3 i need each it.name last part of name (value1, value2, value3) thanks.... try println( it.name.split( '_' )[ -1 ].tolowercase() )

css - Bootstrap grid layout issue - does not work as intended -

Image
all items in grid layout set same height, still have problem: <!-- featured-box --> <div class="featured-box"> <div class="col-md-4 col-sm-4 col-xs-6"> <div class="video-box featured-event-box"> <div class="row"> <div class="col-md-4"> <div class="featured-event-image-box"> <a href="#"><img src="images/featured-event-01.jpg" class="img-responsive transparent-onhover" /></a> </div> </div> <div class="col-md-8"> <p>20th jan 2016</p> <h4 class="featured-event-heading truncate"><a href="#" title="lorem ipsum dolor sit amet">lorem ipsum dolor sit amet</a></h4>

javascript - Nodejs is reloading app.get every 2 minute -

i using node.js first time , have problem because refreshing 1 of methods( app.get('/addtohistory' ) every 2 minutes without iteraction side or browser. problem somewhere in server.js configuration cannot found it. i trying build spa angularjs, nodejs , mysql. there 3 pages: home page (with images), image page (user can click on image home page see details image) , history (all images user saw). there wouldn't login functionality. app recognizing user session id, saved db. i using routing of angular navigate between different pages. here configuration of server.js var mysql = require('mysql'); var cookieparser = require('cookie-parser'); var express = require('express'); var app = module.exports = express(); var session = require('express-session'); var mysqlstore = require('express-mysql-session')(session); app.use(cookieparser()); var db_options = { host: 'localhost', //port: 3306, user: 'user&#

whisper - Ethereum - does not exist/is not available error with web3 -

i'm trying simple whisper example running web3 on geth console: var f = web3.shh.filter({topics: ["qwerty"]}) f.get() web3.shh.getmessages("qwerty") web3.shh.post({topics: ["qwerty"], payload: "0x847a786376", ttl: "0x1e", worktoprove: "0x9" }) but i'm getting these errors: > f.get() filter id error: filter().get() can't chained synchronous, please provide callback get() method. @ web3.js:3602:23 @ <anonymous>:1:1 > web3.shh.getmessages("qwerty") typeerror: 'getmessages' not function @ <anonymous>:1:1 > web3.shh.post({topics: ["qwerty"], payload: "0x847a786376", ttl: "0x1e", worktoprove: "0x9" }) method shh_post not exist/is not available @ web3.js:3119:20 @ web3.js:6023:15 @ web3.js:4995:36 @ <anonymous>:1:1 is documentation not date or not run geth version (tried 1.4.5 , 1.5)? "does n

ESI within a varnish cascade? -

we want set varnish cascade have level 1 , level 2 caching. means on request - varnish level 1 processes , routes - varnish level 2 routes - application question: if application adds esi within content, possible define namespaces esi handled within level 2 varnish , other ones within level 1 varnish? thanks for varnish process esi 1 needs add set beresp.do_esi = true; to "vcl_backend_response" ("vcl_fetch" in varnish 3) in ones vcl. as can done conditionally, e.g. sub vcl_backend_response { if (bereq.url == "/test.html") { set beresp.do_esi = true; // esi processing } } you control if esi processed in 1 or other varnish instance. see: https://www.varnish-cache.org/docs/4.0/users-guide/esi.html

javascript - Buttons to Activities -

i'm new android studio doing best learn it. case came , unfortunately can't find answer though seems basics. my app starts 3 buttons (workouts, results, info) f.e when click on "workouts" want activity called workoutsactivity.java has 12 buttons . when click on "results" want activity activityresults.java etc... what code link these different 3 buttons different 3 activities? do need create 12 new activities buttons in workoutsactivity.java? (is how android works?) i appreciate help. thanks. ok, here few concepts need understand before publish source code : layouts , views , activities , intents , events . views visible ui elements such texts, images, buttons, progress bars, rating bars, etc. layouts invisible ui elements displays views in defined order such row, column or position relative other views (torightof, toleftof, etc.) called containers. activities 'page' handle single task. contains views , layouts (and m

java - Hosting a runnable jar file (Discord bot) on a web server (Heroku) -

i finished creating simple discord bot in runnable jar. (as disclaimer, when comes web, i'm noob.) looking way freely run online , read these vps sites, none of them offered unlimited free plans. stumbled site called heroku, allows me run portion of month. i've figured out, there 1 error i've been unable fix: error r10 (boot timeout) -> web process failed bind $port within 90 seconds of launch my discord bot not connect heroku's server , think thats problem, have no clue how fix it. has encountered similar problem? going hosting bot right way? thanks. edit: here full logs: 2016-06-11t17:00:56.792783+00:00 app[web.1]: 17:00:56.792 [main] debug d.btobastian.javacord.impldiscordapi - requested gateway wss://gateway.discord.gg (token: **************************************************ndxxxw0oq) 2016-06-11t17:00:56.765456+00:00 app[web.1]: 17:00:56.765 [main] debug d.btobastian.javacord.impldiscordapi - requesting gateway (token: ******************************

http - Java okhttp issues in redirect count and domain cert -

i have 3 issues when use okhttp content these web sites: http://www.wp.com has error with: javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target http://www.macys.com has error with: java.net.protocolexception: many follow-up requests: 21 http://www.vk.me has error with: javax.net.ssl.sslpeerunverifiedexception: hostname www.vk.me not verified: certificate: sha256/sx09combybyu6gdls0e6dayldvlydbmjjfnktanfsg4= dn: cn= .vk.com, ou=domain control validated subjectaltnames: [ .vk.com, vk.com] updated @ 2016/06/12: http://www.wordpress.com has error with: javax.net.ssl.sslhandshakeexception: remote host closed connection during handshake how fix above issues 1-4? all! given sites have not been compromised: (1) missing root-ca certificate in trusted store. can happen, if ca used website not delive

angular - Form Validation for Dynamically added and removed form Elements -

i have form element in can add , remove value dynamically. for example in below code domain can added , removed using adddomain , removedomain <div *ngfor="let item of company.domains"> <div class="row"> <div class="col-lg-9"> <input type="text" class="form-control" ngcontrol="domainc" [(ngmodel)]="company.domains[i]"> </div> <div class="col-lg-3 pull-left"> <a (click)="removedomain(i)"> <i class="fa fa-times"></i></a> <a (click)="adddomain()"> <i class="fa fa-plus"></i></a> </div> </div> </div> i need validate these on

Convert a sparse matrix to a full matrix - R -

i looking efficient way convert huge sparse matrix full matrix (not dataframe) in r? any idea? thanks. we can use as.matrix m1 <- as.matrix(sm) where sm sparse matrix. we can check methods grep("as.matrix", methods(class = "sparsematrix"), value = true) #[1] "as.matrix,matrix-method"

javascript - How can I change chrome://flags using chrome API? -

i started using chrome extensions api , there 1 settings page experimental features , need change of them. how can change these settings api? chrome://flags <= experimental features thanks! you can check documentation *chrome.experimental. api . it includes here steps on how use api. to enable api in browser, can in either of 2 ways: go chrome://flags , find "experimental extension apis", click "enable" link, , restart chrome. on, unless return page , disable experimental apis, you'll able run extensions , apps use experimental apis. specify --enable-experimental-extension-apis flag each time launch browser. on windows, can modifying properties of shortcut use launch google chrome. example: path_to_chrome.exe --enable-experimental-extension-apis caution: don't depend on these experimental apis. might disappear, , change. also, chrome web store doesn't allow upload items use experimental apis.

bash - Execute another script inside heredoc Doc That expect user input in shell -

i have script based upon user input need call script run pbrun admin made menu ps3 , select , based upon input call function inside i'm running pbrun , pass here doc input this. function calls { pbrun -l /bin/su - admin <<'inner_eof' /home/ankur/testwithout.ksh inner_eof } now every thing runs fine if call script uses ps3 , select give menu , needs user input command line proceed i'm not able provide calling script input provided input taken script not 1 call admin any idea how can achieve this.? ps: cannot use expect cannot install it. not have access install on systems. admin script written using ksh shell seems me want pipe output: /home/ankur/testwithout.ksh | pbrun -l /bin/su - admin or use process substitution : pbrun -l /bin/su - admin < <(/home/ankur/testwithout.ksh) command <(...) process substitution , creates temporary "file" in /proc/self/fd/ ... write to, , temporary file's name returned

c# - Empty Array in Unity? -

i'm working on bit of brute force workaround bug in program, because there doesn't seem way refresh values assigned in editor. anyway, i'm trying load images (sprites) array script can use. however, doesn't seem working , i'm not sure why. i've not done stuff before made simple mistake. error saying pics1[i] out of range. here code below: using unityengine; using system.collections; public class imageblock : monobehaviour { public sprite[] pics1; public static sprite[,] allpics; // use initialization void start () { pics1 = resources.loadall<sprite> ("dock pics"); allpics = new sprite[100,100]; (int = 0; pics1 [i] != null; i++) { allpics [1,i] = pics1 [i]; } } } change for-loop this: for(int = 0; < pics1.length; i++) that might trick. if check pics1[900] not return null, throw indexoutofrangeexception, why want check existing indices beforehand. of course within valid range pic1[i] may return nul

java - how to dismiss popupWindow? -

i have popupwindow on activity. however, popupwindow not dismissed after interacting activity. i want dismiss popup when i'm touching/scrolling/clicking/etc on screen not popupwindow . public class listviewfordeletecontact extends appcompatactivity { listview mylistview; protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.listviewfordeletecontactlayout_main); mylistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { layoutinflater layoutinflater=(layoutinflater)listviewfordeletecontact.this.getsystemservice(context.layout_inflater_service); view dfg= layoutinflater.inflate(r.layout.popupwindowfordeletelayout_main,(viewgroup)findviewbyid(r.id.popupid)); popupwindow popupwindow=new popupwindow(dfg,

java - Writing Excel using maps in groovy -

i trying write excel file using maps in groovy. in java entering values in map given below //writing data in map map < string, object[] > empinfo = new treemap < string, object[] >(); empinfo.put( "1", new object[] {"emp id", "emp name", "designation" }); empinfo.put( "2", new object[] {"", "gopal", "technical manager" }); empinfo.put( "7", new object[] {"tp02", "manisha", "proof reader" }); empinfo.put( "4", new object[] {"tp03", "", "technical writer" }); empinfo.put( "5", new object[] {"tp04", "satish", "technical writer" }); empinfo.put( "6", new object[] {"tp05", "krishna", "" }); //iterate on data , write sheet set < string > keyid = empinfo.keyset(); int rowid = 0; (string key : keyid) {

c# - When is a directory actually classed as been "accessed" on Windows? -

Image
i have console application gets directory , prints out last time written , last time time accessed. using following code checking when written to: directory.getlastwritetime(path) , following code checking when last accessed to: directory.getlastaccesstime(path) . don't need of programmer see that, using correct methods. now problem when pass in top level c:\ (or directory) path , access time always matches write time. when have opened few files in top level c, not written it. see here: however, when run code supplied @ top this: this not time opened file. leads me believe "accessing" file not think. true, or bug somewhere? in default configuration, windows doesn't keep track of last access times directories. you can turn on using: fsutil behavior set disablelastaccess 0 however, may affect system performance.

unity3d - The name `CrossPlatformInput' does not exist in the current context -

this first time using unity please bear me. created basic setup game. ground plane, third person controller main camera, material ground plane, obstacles , lightning source. last thing wanted add before working on actual gameplay skybox. please note @ point, play , working flawlessly. i searched asset store free skybox , found one: https://www.assetstore.unity3d.com/en/#!/content/18353 upon adding it, got compiler error: the name `crossplatforminput' not exist in current context", , "the type or namespace name 'crossplatforminput' not exist in namespace 'unitysampleassets', missing assembly reference?. at lines in scripts there before added skybox. figured must wrong skybox, deleted project, errors did not go it, in fact still persist! i've tried reimporting of assets (as suggested similiar posts on forum), including standard assets folder houses crossplatforminput, did nothing solve problem. does know have caused this? since de

Android custom ViewPager is not allowing me to click on the View components -

i using fragmentstatepageradapter custom viewpager. using standard viewpager , able swipe fragments correctly , interact edittexts/buttons , other components on different views, had create custom viewpager when restricting swipe direction. once used custom viewpager, displays correctly etc unable click of edittexts/buttons etc. can see problem this? assuming signuppager not overriding method or incorrectly handling motionevent.... none of attempts have worked. signuppager.java: import android.content.context; import android.support.v4.view.viewpager; import android.util.attributeset; import android.view.motionevent; public class signuppager extends viewpager{ public signuppager(context context){ super(context); } public signuppager(context context, attributeset attrs) { super(context, attrs); } private float initialxvalue; public swipedirection direction = swipedirection.all; @override public boolean ontouchevent(motioneven

Javascript reading .txt file and displaying in HTML -

i'm trying have javascript on html page read .txt file (status.txt) in same directory , display contents in 2 different font colors based on information in .txt file. have displaying text on page fine, wanted make bit more noticeable. here current code display text basic #ccc hex. <script type="text/javascript"> loadxmldoc(); </script> <script type="text/javascript"> function loadxmldoc() { var xmlhttp; if (window.xmlhttprequest) { xmlhttp = new xmlhttprequest(); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("status").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get", "status.txt", true); xmlhttp.send(); } </script> <h3 id="status" style="padding-right: 7px; padding-left: 7px; margin-top: 2px; font-size: 11px; color: #cccccc">