Posts

Showing posts from April, 2012

ios - How do I move UIView to front of ViewController Swift 3? -

Image
i trying build sign page option use phone or email. in order able send server of views have in 1 view controller. trying figure out how can move 1 view front of controller when pressing button. screenshot 1: screenshot 2: this because trying call on class signupview , rather instance of class. bringsubview(tofront:) instance method. it looks have changed type of view controller's view property signupview, can still access using view , this: view.bringsubview(tofront: youremailviewinstance) note have changed use of emailview in method call. need using property names have assigned instances of views, not class names.

c# - creating a dynamic page in asp.net mvc -

i'm new asp.net mvc , i'm trying create dynamic page using following code.... `@using musicstore.models; @{ viewbag.title = "songs"; ienumerable<songs> songs = viewbag.songslist; } <section id="main" class="container"> <div class="jumbotron"> <h1> tony's music store</h1> <h2>@viewbag.title.</h2> </div> <table class="table"> <thead> <tr> <th><h3>song list</h3></th> </tr> </thead> @foreach (var list in songs) { <tbody> <tr> *<td><a href=" ">@list.songname</a></td>* </tr> </tbody> ...

Why "Use same selection" option is missing in Android Studio 3.0 and later? -

Image
in android studio 2.x, looks this: android studio 2.x but in android studio 3.0, option "use same selection" missing. android studio 3.0 why convenience option deprecated? there move other places didn't find? android studio 3.0 still beta version, if correct. can't assume deprecated. maybe there release version. as current problem, same option in run/debug configurations . select usb device target , select checkbox underneath. should it.

reactjs - React Mobx Firebase.onAuthStateChanged listener -

i have put auth.onauthstatechange().then(user => ... inside componentdidmount() of top level react component. then remove listener inside of componentwillunmount() my question how mobx-ify this? idea this: class store { @observable user = null @action killfirebaselistener = this.removelistener() constructor() { this.removelistener = firebase.auth().onauthstatechange(user => { if (user) this.user = user }) } } i call killfirebaselistener action componentwillunmount of top level container-component... , use user observable necessary. understanding when user observable updates upon successful login or logout, listeners update , trigger re-render accordingly... wrong this? does have experience sort of "user listener" mobx? have pointers or maybe resources can pass along. ok. looks idea works fine. added class store { @observable user = null constructor() { firebase.auth().onauthstatechanged(user => { if (u...

javascript - how to pass promise to map -

i have blog , i've posts on it. in post table inserted posts authorid . , want convert authorid authorname table called user . convert, use function getpostauthor returns promise main function. can't collect returned value getpostauthor map function problem? var db = require('../controllers/db'); var mongo = require('mongodb').mongoclient(); var url = "mongodb://localhost:27017/blog"; var objectid = require('mongodb').objectid; //#1: function lists posts in blog const list = function(req, res){ db.find('post', {}, 10, {timecreated: 1}) .then(posts => { var promises = posts.map(post => getpostauthor(post.author) .then(author => author /* value doesn't go promises*/) ); console.log(promises); //printed [promise {<pending>}, ...] }) } //#2: function gets authorid , gives authorname const getpostauthor = function(authorid){ return db.findo...

C++, OpenCv: Member function not updating member variables -

i have class mainwindow contains function saveimagefile(). reads image, puts canvas object, class stores list of layer objects, each layer containing 2 opencv mats, pre-effects mat , post-effects mat. in saveimagefile(), apply image effect lumatoalpha() on layer[1] of canvas. lumatoalpha() takes layer's pre-effects mat, performs operation on it, , stores in layer's post-effects mat. function tested. works. however, when attempt post-effect mat, original mat. if lumatoalpha() did nothing @ all, or performed on totally different layer object. i believe may have pointers, not confident. going wrong? mainwindow class... //member variables of mainwindow... canvas mcanvas; void mainwindow::saveimagefile() { mat mat = imread("c://picture.jpg), cv_load_image_grayscale); mcanvas.startcanvas(mat, canvas::bgra); mcanvas.getlayer(1).lumatoalpha(); mat canvasmat = mcanvas.getlayer(1).getposteffectmat(); imwrite("c://picture-result.png...

nginx - WebSocket connection to 'ws://<ip>..failed: Error during WebSocket handshake: Unexpected response code: 502 -

i'm using node,socket.io,nginx socket connections http based simple application. below nginx.conf configured websockets, socket io present in socket/socket.io. strange thing same config works when run node application in localhost , nginx port 80. not sure why failing in linux real ip addresses. http { upstream io_nodes { ip_hash; server ip:port; --> application's ip , port server ip:port; } include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 1000; # http server server { listen 80; server_name ip; server_tokens off; #proxy_ssl_verify off; # prevents 502 bad gateway error large_client_header_buffers 8 32k; location /dummy/ { root html; index dummy/index.html; } location /socket/socket.io { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; p...

html - Place image to the right of multiple lines of text -

i have 2 divs: 1 div multi-line text , image right of first div. the width of image not fixed - controlled user defined parameter. <div> <div class="inline_div"> multi line text... </div> <div class="picture"> image... </div> </div> inline_div { display: inline-block; } . picture { display: inline-block; vertical-align: top; } this works great single line of text. when text goes multiple lines, image gets placed below text. you can float both div 's left, , assign appropriate widths required. .container { clear: both; width: 100%; } .inline_div { float: left; width: 70%; } .picture { float: left; width: 30%; } <div class="container"> <div class="inline_div"> multi line text... multi line text... multi line text... multi line text... multi line text... multi line text... ...

java - Search text file for matching integer -

i'm struggling program read through text file , find match number num wrkid , can print out relevant information. the text file looks this. numbers 455 , 367 wrkid , i'm trying number input match: corner street^3^455^collin^sydney david street^2^367^spence^sydney public class work { public static void main(string[] args) throws ioexception { scanner keyboard = new scanner(system.in); system.out.print("enter filename >> "); string response = keyboard.nextline(); file infile = new file(response); scanner wrk = new scanner(infile); system.out.print("enter job id >> "); int num = keyboard.nextint(); while (route.hasnextline()) { string street = wrk.nextline(); int stopnum = wrk.nextint(); int wrkid = wrk.nextint(); string road = wrk.nextline(); string town = wrk.nextline(); if(wrkid == num) { sys...

javascript - Can't detect Click on cross-domain iframe when change it's src via jquery -

i've list of items on click update iframe src accordingly. , iframe src cross-domain url (amazon link). i'm using jquery plugin detect first time when src of iframe changed via jquery doesn't detect. think there document ready issue. here snippet of code $('iframe').iframetracker({ blurcallback: function(){ alert('sd'); $('.play').val(1); var dt = new date(); var time = dt.gethours() + ":" + dt.getminutes() + ":" + dt.getseconds(); $('.playtime').val(time); // data save alert(); $.post('save_link',{link:$('iframe').prop('src'),type:$('iframe').data('type')},function(result){ alert(result); }); } });

android - Turn on speaker during ongoing call -

i'm trying turn on loudspeaker during incoming/outgoing call button click, have tried: how turn speaker on/off programatically in android 4.0 , how turn on speaker incoming call programmatically in android l? , how turn speaker on during call but of same result: com.example not have using speaker authority in call i have checked permissions error none.. edit: added of permissions: <uses-permission-sdk-23 android:name="android.permission.modify_audio_settings"/> <uses-permission android:name="android.permission.read_phone_state" /> <uses-permission android:name="android.permission.call_phone" /> <uses-permission android:name="android.permission.modify_audio_settings" /> <uses-permission android:name="android.permission.process_outgoing_calls" /> and function activate speaker: public void speaker(view view) { try { thread.sleep(500); // delay 0,5 seconds handle better tur...

c# - How to make window form application run in background? -

this question has answer here: what architecture server service , gui? 2 answers c#: gui display realtime messages windows service 7 answers 2 parts windows application: “windows service” + gui configure it 2 answers gui , windows service communication 2 answers i want create gui application run when window start windows service. windows service have no gui. when window start winform hide , when user press specific key winform show. know required keyboard hook. create winform application work accurately want work in background , after window start when user press specific key winform show...

Outlook : auto reply after processing the body content -

i want send email when email particular subject. not want send static content. need process (create table content depends on received email body) received 1 , send. how can this? have created simple html page , copying body text field , process using javascript function. send using mailto option.

python - "List index out of range" for list of lists -

this code: import random fixed_set = random.sample(range(1, 11), 6) test = [[random.sample(range(1, 11), 6)] x in range(5)] x in range(5): j in range(6): print (test[x][j]) in line 7 "print (test[x][j])" error "indexerror: list index out of range" , don't understand why happening , how fix it. appreciated. random.sample(range(1, 11), 6) returns list , no need use [] around that. try this: import random test = [random.sample(range(1, 11), 6) x in range(5)] x in range(5): j in range(6): print (test[x][j])

javascript - Why does the regex stop working when constructed as a string? -

this question has answer here: why javascript regex doesn't work? 1 answer javascript regex not working 1 answer why regex constructors need double escaped? 4 answers i have regular expression works when constructed via native regex primitive: var regex = /^(?:533-)?\d{3}-\d{4}$/; '533-123-4567'.match(regex) ["533-123-4567", index: 0, input: "533-123-4567"] but fails when constructed via string: var regex = new regexp('/^(?:533-)?\d{3}-\d{4}$/'); '533-123-4567'.match(regex) null i have tried escaping slashes no avail. documentation on characters must escaped? when use constructed new regexp () not need escape or enclosing ...

Get the column number by propertyName from Grid using Vaadin 7.4.9 -

i want column number grid. how can ? grid grid = new grid(); indexedcontainer container = new indexedcontainer(); grid.setcontainerdatasource(container); container.addcontainerproperty("name", string.class, ""); container.addcontainerproperty("surname", string.class, ""); container.addcontainerproperty("age", integer.class, 0); i solution: list list = grid.getcolumns(); for(int = 0; < list.size(); i++) system.out.println(list.get(i) + " on position: " + i); solution is: list list = grid.getcolumns(); for(int = 0; < list.size(); i++) system.out.println(list.get(i) + " on position: " + i);

sql - ORA-01810: format code appears twice : jdbctemplate -

i playing around dates , query's jdbctemplate , getting below error. // creating localdate object specific date & time localdate date = localdate.of(localdate.now().getyear(), localdate.now().getmonth(), localdate.now().getdayofmonth()); system.out.println("date $$$$$$$$$$$" +date); localdatetime datetime = date.attime(localtime.max); system.out.println("datetime " +datetime); // not required since above steps same. datetime.withhour(23).withminute(59).withsecond(59); system.out.println("datetime " +datetime); datetimeformatter formatter = datetimeformatter.ofpattern("yyyy-mm-dd hh24:mm:ss"); system.out.println("formatter" +datetime.format(formatter)); return jdbctemplate.queryforobject("select count(*) test status in ('active','active_p') , created<to_date('"+datetime.format(formatter)+"','yyyy-mm-dd hh24:mm:ss')",integer.class); this output date $$$$$...

backbone.js - my Backbone Collection does not display the change in model -

i have collection of items(books). each item displays button updates attribute (due date) of corresponding item. item-list: [button] item 1 [monday] [button] item 2 [monday] [button] item 3 [tuesday] for example, if click button on item 2, maybe server answers 'tuesday' , models attribute 'tuesday'. the problem see change if press refresh button on browser. var itemview = new bookcollectionview({collection: items}); itemview.listento(items,'change',itemview.render); self.$el.append(itemview.render().el); that how initialize list in main window. set of collection looks this: var bookcollection = backbone.collection.extend({ defaults: { user:null, token:null }, initialize: function(options){ this.user = options.user; this.token = options.token; }, comparator: 'item', model: bookmodel, parse: function(data) { return dat...

ssh - How to connect/open to Couchbase web interface of remote machine -

i trying connect couchbase web interface of remote machine through ssh. can open web interface of couchbase of remote machine in ubuntu os. i try , doesn't work me ssh -l 8091:robi:80 robi@xxx.xx.xx.xx can me how achieve this. grateful 8091 not port need forward. maybe configure vpn? full list of ports can find in docs https://developer.couchbase.com/documentation/server/current/security/security-iptables.html

Assign a factor level when constraints are met in R -

this question has answer here: convert continuous numeric values discrete categories defined intervals 2 answers i think i'm half way want doing using (just need little doing second part): clients[which(clients$age >= 18 & clients$age <= 24),] this groups 18 years of age 24 years of age (inclusive) , lists rows match in data frame. i want go 1 step further , assign every row matches constraint level of factor variable; 'i'. , 25 - 34 can part of 'ii', 35 - 44 part of 'iii', etc, etc. the ultimate goal make easy me plot frequency different age groups next 1 - feel making them each unique levels in factor variable start. any ideas? you use cut specify multiple levels @ once: cut( clients$age, breaks = c( 18, 25, 35, 45 ), include.lowest = true, labels = c( "i", "ii", "ii...

c++ - Copying values to struct pointer fails at second call -

i'm trying code client-server program(tcp) , code used (down below) works fine. have 1 major issue it, when call initialize() first time works, sends comamnd , data server , server sends reponse. found out when call second time values aren't assigned struct pointer of request. tried adding zeromemory @ end clean values. didn't change anything. of may know why this? appreciated! typedef struct auth_request { dword version; dword game; byte key1[0x10]; byte key2[0x10]; byte secret[0x14]; } request, *arequest; typedef struct auth_response { dword status; } response, *aresponse; bool initialize() { // init poiters arequest request = (arequest)xphysicalalloc(sizeof(request), maxulong_ptr, 0x00, page_readwrite); response response; // assigning values request->version = fileversion; request->game = utils::getgameid(); memcpy(request->key1, utils::getkey1(), 0x10); memcpy(request->key2, utils::getkey2(), 0...

entity framework - Use 'Average()' On EF CORE (C# .NET CORE) -

i use .net core while , noticed queries run strange, did profiling , noticed queries , running in parts on database, instead of getting in 1 shot. turned off option 'queryclientevaluation' ef core , keep getting error linq expression 'average()' not translated , evaluated locally. which strange because used average function in ef6 till no issue, why should need use queryclientevaluation?? here simple sample _context.reviews.select(r => r.rating).average() which version using? it bug #7190 has been fixed @ version 2.0.0-preview1 . can have latest released version 2.0.0 .

mysql - Select query returns different timezone for datetime column -

Image
i using nodejs , express framework , mysql database i have set default-time-zone in [mysqld] section in file c:\programdata\mysql\mysql server 5.7\my.ini as follows default-time-zone='+05:00' here global time zone , session time zone the column name registration_date .. datetime column here result of select statement in mysql workbench i using database query in function getparentrecord: function (mobilenumber, callback) { db.query('select parent_id , name , cnic ,mobilenumber ,email ,parent_type ,convert_tz(registration_date,\'+05:00\',@@global.time_zone) registration_date,is_registered,is_active,source_id parentslist mobilenumber=?', mobilenumber, function (err, result) { if (err) { var parent_record_dberror = { status: "fail", message: "there problem connecting our website please try again" } callback(parent_record_dberror, null); ...

strange exception in keyboard library << python -

i want wait until button 'q' pressed this code: import keyboard while true: if keyboard.is_pressed('q'): print('q pressed') break #finishing loop and exception got: exception in thread thread-1: traceback (most recent call last): file "c:\python27\lib\threading.py", line 810, in __bootstrap_inner self.run() file "c:\python27\lib\threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) file "c:\python27\lib\site-packages\keyboard\__init__.py", line 134, in listen _os_keyboard.listen(self.queue, _key_table.is_allowed) file "c:\python27\lib\site-packages\keyboard\_winkeyboard.py", line 423, in listen keyboard_hook = setwindowshookex(wh_keyboard_ll, keyboard_callback, null, null) argumenterror: argument 2: <type 'exceptions.typeerror'>: expected cfunctiontype instance instead of cfunctiontype what problem?

database - Alter variable format using SQR programming language -

i new peoplesoft , peoplecode/sqr in general , want ask question. what wish do, try , output large (clob) string variable on pdf file using sqr programming language, on 3 columns on page, can change layout of text in microsoft word going layout -> columns -> 3 what have until this: begin-select txt.u_po_txt &txt.po_txt ps_u_po_disc_txt txt txt.business_unit = &po.business_unit , txt.po_id = &po.po_id end-select so, txt.u_po_txt is clob stored in database of 10000 characters , want output &txt.po_txt on pdf using layout described above. i have tried using columns , next-column sqr commands no avail. find documentation of sqr on oracle website poorly written. this example have found, applied case: columns 10 50 110 move 55 #bottom_line begin-select txt.u_po_txt &txt.po_txt if #current-line >= #bottom_line next-column goto-top=1 at-end=newpage else position (+1,1) !what even, throws me error "unknown comma...

javascript - NodeJS: How to handle promise rejection properly & best way to create logs -

i'm pretty new coding , node.js trying learn... first big difficulties found node.js think in async way when building code, i'm facing monster: promises. up until now, i've tried build code work , not minding @ error handling (i know that's dumb, helps me learn) while running code errors time time. since " my program " (for now) bunch of requests (using request-promise ) being made through infinite loops. manipulation of info ( {objects} ) being received , sending mongodb (via mongoose ), know errors coming from: the servers (being requested) returning error ( statuscode !== 200 ). too many requests made (which specific statuscode ) and code runs smoothly, until 1 of these errors. objective code handle these errors , create logs once occur. ideal function restart loop yielded error (request) once occur (maybe after settimeout or something). my questions are: could recommend great material on promiserejection handling dig into? i'm us...

html - trying to replace a div with jquery slideDown click method -

i trying replace div 1 once element has been clicked, cant seem working. have included html , jquery code below. element trying slide in has css property of display: none. html: <div class="meal-details"> <h4>heading</h4> <h5 class="optiontabs meal-description">description</h5> <h5 class="optiontabs nutrition-description">nutritional info</h5> <div class="nutrition-breakdown"> <p>text one</p> </div> <div class="meal-breakdown"> <p>text two</p> </div> </div> jquery: $(".nutrition-description").click(function(){ $(this).find(".nutrition-breakdown").slidedown("fast...

Using both AppCompat and Youtube API in one activity with firebase and RecyclerView in Android -

Image
i working on application in both appcompatactivity , youtube api should used, reasons unable use both in same activity when use appcompatacticity toolbar youtube api stops working , if extends youtubebaseactivity toolbar not work , using recyclerview , firebase database in applcation, can me , tell me how can implement appcompatactivity , youtubeapi both work, have researched many forums did not provide useful information on doing so, please help. i using android studio youtube class file : public class homepage extends youtubebaseactivity{ private recyclerviewpager mrecyclerview; private databasereference mdatabasereference; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home_page); mdatabasereference = firebasedatabase.getinstance().getreference().child("holla"); mrecyclerview = (recyclerviewpager) findviewbyid(r....

ios - Any can not be used with dictionary literal -

i trying use segue context on watchkit, , ran issue: contextual type '[any]' cannot used dictionary literal here code using: override func contextsforsegue(withidentifier segueidentifier: string) -> [any]? { if segueidentifier == "one" { return ["scenename" : "one"] } else if segueidentifier == "two" { return ["scenename": "two"] } else { return ["scenename": "three"] } } on segue destination there's code, produces no errors: @iboutlet var thename: wkinterfacelabel! override func awake(withcontext context: any?) { super.awake(withcontext: context) // configure interface objects here. self.settitle("") let dict = context as? nsdictionary if dict != nil { let seguecontext = dict![["scenename"]] as! string thename.settext(seguecontext) } } hope can help! the return ...

c# - Xamarin Forms Android NoSupportedException while UWP works -

i updated solution latest nuget packages of xamarin.forms (2.3.4.267). receive exception while run program in android emulator (x86) unhandled exception: system.platformnotsupportedexception: operation not supported on platform. with piece of code: public virtual void addrange(ienumerable<t> collection) { if (collection == null) throw new argumentnullexception(nameof(collection)); foreach (var in collection) items.add(i); oncollectionchanged(new notifycollectionchangedeventargs(notifycollectionchangedaction.reset)); } and in particular, line foreach (var in collection) items.add(i); here github link test problem https://github.com/hugoterelle/posexclusive-droid-notsupported this similar an issue i've encountered while working on xamarin android. issue has been fixed on release 15.3.2 of xamarin . try updating xamarin version , try again

css - firefox height does not grow up but works in chrome -

i have 2 display: table-cell columns. left 1 has button , adds content left column when clicked. , right 1 has text box should grow height height of left column. so, gave fixed height value right column: #step-right { height: 10px; } . this works fine in chrome still having issue in firefox. found firefox have issue regarding height: 100% not same problem. want solve using no js tricks. any appreciated. thanks function step() { var stepleft = document.getelementbyid('step-left'); stepleft.innerhtml = 'step <br/>' + stepleft.innerhtml; } * { box-sizing: border-box; } .step-content { display: table; background-color: blue; } .step-bar { display: table-cell; height: 100%; } #step-left { background-color: yellow; } #step-right { height: 10px; background-color: green; } .input-group { height: 95%; display: table; } .input-group textarea { height: 100%; } <div class=...

php - wp-admin - spins for a while then blank page -

ok - created wordpress site someone. hosting company moved site without telling anyone. issues created move. now, week or 2 later, realise cant wp-admin. spins on white screen while gives up. just eliminate theme or plugins i've renamed both dirs didnt help. the hosting guys have given me credentials mysql , ftp. is there need changing or updating following server move allow me access wp-admin? thanks, nick

javascript - Using passport.socketio with express and passport-local-mongoose -

i'm trying make easy chat room using passport , socket.io , need know has emit message using socket.io , use passport.socketio this, , use module passport-local-mongoose simplify using passport . however, when add io.use(passportsocketio.authorize({ cookieparser: cookieparser, secret: 'lqcbfu1wfjagklfzng4x', store: sessionstore })); in app.js caused client-side socket not connected server (if commented block, message server's console ) i thought may due misusing of passport.socketio or module passport-local-mongoose , don't know what's wrong qaq. app.js: var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieparser = require('cookie-parser'); var bodyparser = require('body-parser'); var session = require('express-session'); var flash = require('req-flash'); var helmet = require...

python - How to draw a Spiral & Arc Shape Curves using pygame? -

i trying draw spiral & arc shapes using pygame. data want draw of opendrive maps. has 2 types of curves. arc has same starting , ending curvatures, however, spiral has different start , ending curvatures. see sample map data here: http://www.opendrive.org/tools/culdesac.xodr . ( map image) pygame allows 1 function draw curves requires boundary rectangle , start/end angles draw arcs. see http://www.pygame.org/docs/ref/draw.html#pygame.draw.arc . i want know how draw both type of curves(arc & spiral) using pygame.

javascript - Excel - json data - return certain elements to adjacent cells formula/macro -

Image
i have lot of json data in rows , need extract pieces of data in excel, there way this? have provided sample of typical cell, keep simple, how extract "lat" , "lng" values , place them in adjacent cells. let's json in cell d2, need 'lat' in e3 , 'lng' in f3: projectid:'5571511970726f3903000000', lat:13.737738, lng:100.566147, destinations:[{"id":"57bc75550ce0fe28af001609","name":"browneyesrestaurant","category_name":"restaurant","category_class_name":"restaurants","lat":13.737875,"lng":100.566806,"travel_time":"lessthanaminutebyfoot","distance_human":"39m","distance_in_meters":39},{"id":"57bc75550ce0fe28af00160a","name":"hanahana","category_name":"restaurant","category_class_name":"restaurants","lat...

angular - C# errors in TypeScript files VS2017 -

i'm learning aspnetcore mvc angular2 , wrote model follows: import { supplier } './supplier.model'; import { rating } './rating.model'; export class product { constructor( public productid?: number, public name?: string, public category?: string, public description?: string, public price?: number, public supplier?: supplier, public ratings?: rating[]) { } } which shows no errors, , there shouldn't be. if try build project get: error cs0116 namespace cannot directly contain members such fields or methods sportsstore f:\projects\mvcng2\sportsstore\clientapp\app\models\product.model.ts error cs1026 ) expected sportsstore f:\projects\mvcng2\sportsstore\clientapp\app\models\product.model.ts error cs1002 ; expected sportsstore f:\projects\mvcng2\sportsstore\clientapp\app\models\product.model.ts error cs1519 invalid token ',' in class, struct, or interface member de...

java - Get generic type of class at runtime -

how can achieve this? public class genericclass<t> { public type getmytype() { //how return type of t? } } everything have tried far returns type object rather specific type used. as others mentioned, it's possible via reflection in circumstances. if need type, usual (type-safe) workaround pattern: public class genericclass<t> { private final class<t> type; public genericclass(class<t> type) { this.type = type; } public class<t> getmytype() { return this.type; } }

web scraping - Can't get the certain item using selector -

how can article , nothing else using css selector elements available in below link. use selector in parser written in python. i tried like: div.user-review p using above selector other things don't want. want article. here link leading elements containing article: " https://www.dropbox.com/s/readzjpl0bca3zr/elements.txt?dl=0 " try below css selector , let me know if doesn't fetch desired output: div.user-review p.lnhgt ~p

Standard names for "stacked" versus "hanging" layered graph drawing algorithms? -

Image
here 2 different ways of drawing same hierarchy. notice in "stacked" layout, nodes 1 layer higher highest "child" node. ( important: see edit @ bottom of question example) do these 2 types of layered drawing methods have specific names? i'm trying find existing algorithms "stacked" one, can't seem surface info because don't know it's called. if don't have names distinguish them because rely on same algorithm, there known sets of parameters attaining "stacked" version of graph existing algorithms? thanks! edit: although above graphs strict " trees ", algorithm i'm looking should able handle cases nodes have more 1 parent, , cases there more 1 path root leaf. here's example , , here's another . edit2: in case it's useful anyone, hacky (and slow) force-directed approach pre-computed node layers (y-axis contraints) seems work right. here's looks like . example uses cytoscape.js , cola...

algorithm - Quick Sort 3-way Partitiion -

i'm trying implement quick sort algorithm 3-way partition technique, using "m1" , "m2" indexes delimitate zone elements equal pivot. here code: public class sorting { private static random random = new random(); private static int[] partition3(long[] a, int l, int r) { long x = a[l]; int m1 = l; int m2 = l; (int = l + 1; <= r; i++) { if (a[i] < x) { m1++; m2++; swap(a, m1, m2); } if (a[i] == x) { m2++; swap(a, i, m1); } } swap(a, l, m1); int[] m = {m1, m2}; return m; } private static void swap(long[] a, int i, int j) { long temp = a[i]; a[i] = a[j]; a[j] = temp; } private static void randomizedquicksort(long[] a, int l, int r) { if (l >= r) { return; } int k = random.nextint(r - l + 1) + l; long t = a[l]; a[l] = a[k]; a[k] = t; int m[] = partition3(a, l, r); randomiz...

c - basic, about specifier -

#include<stdio.h> int main(){ double n1,n2; float n3; printf("input 2 flt:"); scanf("%lf %lf",&n1,&n2); n3 = n1 * n2; printf("n1 * n2 = %.2lf",n3); } when set n1,n2 float, n3 cannot correctly calculated ,why? code a online tutorial , modified test function of %lf. you must use %f . #include <stdio.h> int main(){ float n1,n2; float n3; printf("input 2 flt:"); scanf("%f %f",&n1,&n2); n3 = n1 * n2; printf("n1 * n2 = %.2f",n3); }

Is it good to create Spark batch job for every new Use cases -

i run 100s of computer in network , 100s of user access machines. every day, thousands or more syslogs are generated machines. syslog log including system failures , network, firewall , application errors etc. sample log below may 11 11:32:40 scrooge sg_child[1829]: [id 748625 user.info] m:wr-sg-block-111- 00 c:y th:block , no allow rule matched request entryurl:http:url on mapping:bali [ rid:t6zcuh8aaaeaagxyaqyaaaaq sid:a6bbd3447766384f3bccc3ca31dbd50n ip:192.24.61.1] from logs, extract fields timestamp, loghost, msg, process, facility etc , store them in hdfs . logs are stored in json format . now, want build system can type query in web application , analysis on logs . able queries like get logs message contains "firewall blocked" keywords. get logs generated user jason get logs containing "access denied" msg. get log count grouped user, process, loghost etc. there thousands of different types of analytics want do. add more, want combined res...

android - Disable rotation animation on clicking 'navigation drawer indicator' ( hamburger icon) -

how disable rotation animation on clicking 'navigation drawer indicator' ( hamburger icon) ? i'm using htc model on geny motion emulator(1 gb ram). on clicking navigation drawer icon, there slight lag on nav panel sliding (opening , closing). so,i think, disabling animation make sliding smoother. (i'm using navigation drawer default template) you can use setdrawerslideanimationenabled(boolean) enable or disable drawer arrow animation when drawer position changes. example of be: // installs drawer toggle drawertoggle = new actionbardrawertoggle(this, drawerlayout, r.string.drawer_open, r.string.drawer_close); // disables animation drawertoggle.setdrawerslideanimationenabled(false);