Posts

Showing posts from March, 2012

php - Laravel and Xdebug - I can't debug because of Fatal error: Can't find Controller class that all controllers extend it -

so managed configure xdebug (2.4.0) php 7 (7.0.4). can't use in laravel project. trying debug block of code inside cartcontroller. says there error because can't find controller cartcontroller extends. in phpstorm console: c:\xampp\php\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 c:\users\nikolay\dropbox\store\app\http\controllers\cartcontroller.php php fatal error: class 'app\http\controllers\controller' not found in c:\users\nikolay\dropbox\store\app\http\controllers\cartcontroller.php on line 14 php stack trace: php 1. {main}() c:\users\nikolay\dropbox\store\app\http\controllers\cartcontroller.php:0 fatal error: class 'app\http\controllers\controller' not found in c:\users\nikolay\dropbox\store\app\http\controllers\cartcontroller.php on line 14 call stack: 2.1491 376944 1. {main}() c:\users\nikolay\dropbox\store\app\http\controllers\cartcont...

How to export images to local folder using php -

how export images local folder using php, data in server system. how export uploaded images in client system ? please give me solution. using php. all. either keep zipped file images. , request url directly. no role of php, if images folder static. in case image folder not static, , images added/deleted, can create zip using php zip library. best option in order download multiple images @ clients machine. you can use code below. code below stack overflow post @ how zip whole folder using php // real path our folder $rootpath = realpath('folder-to-zip'); // initialize archive object $zip = new ziparchive(); $zip->open('file.zip', ziparchive::create | ziparchive::overwrite); // create recursive directory iterator /** @var splfileinfo[] $files */ $files = new recursiveiteratoriterator( new recursivedirectoryiterator($rootpath), recursiveiteratoriterator::leaves_only ); foreach ($files $name => $file) { // skip directories (they adde...

python - Apply formula with two different lists -

i have 2 lists this: lista = [51, 988, 1336, 2067, 1857, 3160] listb = [1, 2, 3, 4, 5, 6] i have apply formula in lists: n / pi * ((x*0.1)+1)**2 - pi * (x*0.1)**2 the 'n' elements of lista, 'x' elements correspond same index of 'n' in listb. i need apply formula elements in both list. when loop runs first time needs this: 51/pi*((1*0.1)+1)**2 - pi *(1*0.1)**2 for second this, needs this: 988/pi*((2*0.1)+1)**2 - pi*(2*0.1)**2 and repeats until end of both lists. i know have use 'for' loop, problem don't know how elements second list. i'm trying this: for n in lista: n/pi*((......)) inside thhe brackets should elements listb don't know how them, , need have same index element lista. output should third list result of each formula applied. i have tried explained myself best way possible, if don't understand question feel free ask question. thanks in advance. i assume both lists have same size time,...

java - I want to set a thread inside getView method how should i do it? -

the code of getview method this: public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub layoutinflater inf = getlayoutinflater(); view v; v = inf.inflate(r.layout.rowdetails, parent, false); textview _tvname = (textview)v.findviewbyid(r.id.tvname); imageview _ivimg = (imageview)v.findviewbyid(r.id.ivimg); car_setget c = new car_setget(); c = arrlist.get(position); _tvname.settext(c.getname()); //loader.displayimage(c.getimg(), _ivimg, op, null); imagedownloader task = new imagedownloader(); try { bitmap image = task.execute(c.getimg()).get(); _ivimg.setimagebitmap(image); } catch(exception e) { e.printstacktrace(); } return v; } } //imagedownloader.java public...

java - how to enable https with org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer? -

i have encounter problem when try stepup https server resteasy-netty4 (http service ok) ----> resteasy version 3.0.16.final, java version 1.8) by searching stackoverflow , google, got solutions, such as, simple java https server yeah, original demo running successful, unfortunately, didn't work after integrated nettyjaxrsserver. i creted sslcontext below: public sslcontext getsslcontext1() throws exception { sslcontext sslcontext = sslcontext.getinstance("tls"); // initialise keystore char[] password = "password".tochararray(); keystore ks = keystore.getinstance("jks"); fileinputstream fis = new fileinputstream("{parent_path}\\testkey.jks"); ks.load(fis, password); // setup key manager factory keymanagerfactory kmf = keymanagerfactory.getinstance("sunx509"); kmf.init(ks, password); // setup trust manager factory trustmanagerfactory tmf = trustmanagerfactory.getinstance...

io - How to determine whether the computer has an XT/AT keyboard in assembly? -

Image
i finished writing 16 bit operating system used int 0x16 tell key user pressed. want write own keyboard driver , don't want use interrupts. (so can enter long mode). realized there 2 scan codes, @ , xt. how can determine keyboard computer use in nasm x86 assembly? should ask user press key , determine using scan code in port 0x60 when os boots? eg: key - 0x1c(make) @ , 0x1e(make) xt linux not that....... i used following code , discovered virtual box uses xt keyboard.... [org 0x2e00] mov bx, 0x1000 mov ds, bx ;the program loaded @ 0x12e00 or 1000:2e00 operating system xor ax, ax ;set ax 0 mov bl, 0x0e ;set text color loop: ;main loop in al, 0x60 ;read ports , display them mov cx, ax call hex_print ;print content of port in hex in al, 0x61 mov cx, ax call hex_print in al, 0x62 mov cx, ax call hex_print in al, 0x63 mov cx, ax call hex_print in al, 0x64 call hex_print call com_cls ...

javascript - Two overlapping images via CSS and JS -

i trying enable user drag image (e.g. face) on image (e.g. map square). implemented drag&drop angular directive , kinda work. not working position of dropped image (the face): not overlaying, being placed below map square. the starting html code generated via ng-repeat, resulting element this: <span style="display: inline-block;position:relative;"> <img src="map_square.jpg" class="map-image"> </span> when dropping, becomes: <span style="display: inline-block"> <img src="map_square.jpg" class="map-image"> <img src="face.jpg" class="face-image-on-map"> </span> this css code: .map-image { position: relative; max-width: 42px; z-index: 0; } .face-image-on-map { position: absolute; width: 100%; max-width: 42px; z-index: 100; opacity: .8; } as result of this, expect face image on map square, both being inside span-de...

java - How to recursively flatMap a stream? -

this question has answer here: in java, how efficiently , elegantly stream tree node's descendants? 4 answers i asked retrieve every leaf node descandant of tree node. got idea job in 1 line! public set<treenode<e>> getleaves() { return getchildrenstream().flatmap(n -> n.getchildrenstream()).collect(toset()); } it @ first glance, ran stackoverflowexcepetion if tree depth reaches ~10, can't accept. later developed implementation without recursion , stream (but brain roasted ), i'm still wondering if there way recursive flatmap s stream, because found impossible without touching stream internals. it'll need new op, recursiveops that, or have collect results set every step, , operate on set later: set<treenode<e>> prev = new hashset<>(); prev.add(this); while (!prev.isempty()) { prev = prev.stream().flatm...

Loading resources from another maven module with mvn exec:java doesn't work -

i have maven project structure: parent -----module1 --------src ------------main -----------------java ----------------------loader.java -----------------resources -------------------------file1.txt -----module2 --------src ------------main -----------------java -------------------------callloader.java so loader.java , loads files1.txt . call class callloader.java module2. code used in loader.java , private static file getresourcefile(string filename){ try { url resource = graphutil.class.getclassloader().getresource(filename); return new file(resource.getpath()); } catch (throwable e) { throw new runtimeexception("couldn't load resource: "+filename, e); } } where filename="file1.txt" . i error because file absolute path looks this: file:/home/moha/.m2/repository/my/package/name/%7bproject.version%7d/base-%7bproject.version%7d.jar!/file1.txt what doing wrong? get content of...

Linux bash : find out from which zip file the file comes -

if unzip f.i. zipfile1.zip zipfile2.zip zipfile3.zip i these files: script1.txt script2.txt script3.txt script4.txt ... script10.txt is there way know zip-file each file unzipped? for example: zipfile1.zip : script1.txt zipfile2.zip : script2.txt ... you can write simple bash script that, instance : #!/bin/bash in zipfile*.zip; unzip -l $i done the option -l command unzip allows list content of zip archive in short format.

angular2 routing - Issue with building an Angular 2 RC router link with a route parameter -

i in reference angular 2 documentation rc router route parameters : here mentioned in documentation constructing router link route parameter: ['herodetail', { id: hero.id }] // {id: 15} this supposed produce following link: localhost:3000/hero/15 i have following link: <a [routerlink]="['/dashboard/messageconversation/', {otherid: getother(message).id}]"> and produces following link (notice semicolon query parameter instead of route parameter ): http://localhost:8080/dashboard/messageconversation;otherid=2 here @routes definition: {path: '/messageconversation/:otherid', component: messageconversationcomponent} can please tell me getting wrong? it turns out proper way add route parameter (as opposed query parameter ) pass parameter second element of array follows: <a [routerlink]="['/dashboard/messageconversation', getother(message).id]"> credits go stuntbaboon directing me relevan...

java - reading excel file using XMLStreamReader ( read number as string, not as a number ) -

i reading excel file using xmlstreamreader object. initialization of object : opcpkg = opcpackage.open(excelpath, packageaccess.read); xssfreader = new xssfreader(opcpkg); factory = xmlinputfactory.newinstance(); iterator = xssfreader.getsheetsdata(); inputstream = iterator.next(); xmlreader = factory.createxmlstreamreader(inputstream); the contents of cell read using statement, xmlreader.getelementtext(); the problem simple number string 10.2 contained in cell being read 10.199999999999999. want read 10.2 only. there way solve ? when read string, parse double.parsedouble(...gettext() ); that surest way number out of line of text

ruby on rails - RoR Enum "Unable to autoload constant" error -

i getting basic enum error in active admin: unable autoload constant school_user i have defined enums in model: class schooluser < activerecord::base belongs_to :user has_one :school enum user_type: [:school, :student, :guardian, :teacher] end and in admin/school_user.rb trying dropdown list: activeadmin.register schooluser permit_params [:user_type] form |f| f.inputs "school_user" f.input :user_type, :as => :select, :collection => school_user::user_type.keys end f.actions end end user_type integer. i don't know i'm doing wrong here bet it's simple oversight. help? unable autoload constant school_user i believe error in below line f.input :user_type, :as => :select, :collection => school_user::user_type.keys where school_user should schooluser f.input :user_type, :as => :select, :collection => schooluser::user_types.keys

php - Strange behavior Of foreach -

<?php $a = array('a', 'b', 'c', 'd'); foreach ($a &$v) { } foreach ($a $v) { } print_r($a); ?> i think it's normal program output getting: array ( [0] => [1] => b [2] => c [3] => c ) can please explain me? this well-documented php behaviour see warning on foreach page of php.net warning reference of $value , last array element remain after foreach loop. recommended destroy unset(). $a = array('a', 'b', 'c', 'd'); foreach ($a &$v) { } unset($v); foreach ($a $v) { } print_r($a); edit attempt @ step-by-step guide happening here $a = array('a', 'b', 'c', 'd'); foreach ($a &$v) { } // 1st iteration $v reference $a[0] ('a') foreach ($a &$v) { } // 2nd iteration $v reference $a[1] ('b') foreach ($a &$v) { } // 3rd iteration $v reference $a[2] ('c') foreach ($...

Contact form on website not working when we hosted our email on google apps -

hi grapich designer temporary asked working check emails problem. we using drupal our website. when using google apps our email server, contact form on our webpage (which our customer used use sending question) stop sending emails seems mail fuction not working anymore. because hosted our emails google apps? there anyway make work? need contact form on our webpage send mail if using webform can set email address few places: this default webform email set: yoursite.com/admin/config/content/webform and default can overridden in individual webform e-mail tab: yoursite.com/node/1234/webform/emails (1234 node id of webform) drupal has global email address site used default also, worth checking here: yoursite.com/admin/config/system/site-information

css - HTML background image with 100% height preserving aspect ratio -

i trying image fill page using bootstrap css template , additional custom css. html: <head> <link rel="stylesheet" href="bootstrap.min.css" /> <link rel="stylesheet" href="cover.css" /> </head> <body> <div class="my_banner"> <div class="col-lg-8"> <h3>title</h3> </div> <div class="col-lg-4 "> <a class="btn btn-success">ok</a> </div> </div> </body> cover.css: .my_banner { padding-top: 50px; text-align: left; color: #f8f8f8; background: url(image.png); max-width: 100%; height: auto; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; background-repeat: no-repeat; } however image fills 1/3 of height of page when browser width small , 1/10th of page when br...

ios - Trouble adding files to Xcode project -

Image
i trying add 2 swift files xcode project. located on desktop currently. when open them up, this: however, when add them xcode project, this: how can add these files without text messing up? thanks! that looks suspiciously kind of png file, not text file. ("png" followed "ihdr", specifically.) sure that's swift file , not screenshot of swift file or something? that's strange title in titlebar of screenshot. perhaps related. either way, seems pretty clear these allegedly swift files format not plain text. copy text out of new file created scratch xcode, , fix whatever problem is.

xml - select whole node with its attribute value too with xpath -

hello have strange question (for me strange). have xml file below: <?xml version="1.0" encoding="iso-8859-1"?> <studentslist> <student> <student_id email="test@yahoo.com">18700</student_id> <firstname>jhon</firstname> <lastname>smith</lastname> <address>dragon vally china</address> </student> <student> <student_id email="leesin@gmail.com">18701</student_id> <firstname>lee</firstname> <lastname>sin</lastname> <address>league of legend uk</address> </student> </studentslist> when search file using xpath in php $allstudents = $xml->xpath("//studentslist/student"); it give me students in array child node , values below: array ( [0] => simplexmlelement object ( [student_id] => 18700 [firstname] => jhon [lastname] => smith [address] => dragon vally china ) [1] => simplexml...

vba - Register database using a macro -

i trying register new database in openoffice calc, need make using script (macro). is there way it? if not, can work on unregistered database in calc macros? if yes, how it? i porting vba macro calc , have problem connecting dbase file. got no working code @ moment, can provide vba script show need in calc. i don't know if can create dsn dbase file should doable? dsn might easier work when doing this.

java - JSF adding object to arrayList -

i have been trying add student object arraylist using java server faces, can figure out how it, here hat got far. method need use, , put it? index <h:body> <h:form > <h:panelgrid columns="2" > <h:outputtext value="name"/> <p:inputtext value="#{student.name}" required="true"> <h:outputtext value="age"/> <p:inputtext value="#{student.age}" required="true"> <p:commandbutton value="add" action="#{student.showgo()}"><!--go jsf page--> <!-- actionlistener needed--> </p:commandbutton> </h:panelgrid> </h:form> </h:body> student bean @named(value = "student") @requestscoped public class studentbean { private string name; private int age; public studentbean(string name, int a...

javascript - Trying to swap the title attribute of a paragraph with the content of the paragraph -

for example want change html : <p title="title text">content text</p> into this: <p title="content text">title text</p> so far have code make title value equal in <p> window.addeventlistener("load",init); function init(){ var b = document.queryselector("p"); b.setattribute("title",b.textcontent); console.log(b); } swap them using variable holds value while updating window.addeventlistener("load", init); function init() { var b = document.queryselector("p"); var temp = b.textcontent; b.textcontent = b.getattribute("title"); b.setattribute("title", temp); console.log(b); } <p title="title text">content text</p>

python - Stop retrying periodic celery task on error -

imagine task in celery schedule , runs each minute , sends email on errors. if there error, it's more persistent, database unavailability, mail box get's spammed similar emails. what's possible workarounds? you use flag program knows whether has sent alarm email, gets set false once database comes online the code example of concept.. it's unrelated celery, i'm sure can work fit needs database_flag = false database = get_database() while true: if not database.is_faulted(): database_flag = false elif database.is_faulted() , not database_flag: send_email() database_flag = true time.sleep(60)

java - Position Actor Bottom Right Of Viewport -

i using scene2d, , want position custom actor created, extends image , allows me play animations. having problems keeping actor in bottom right of screen. when shrink window out of 16:9 ratio, actor goes side (up on y axis) instead of staying in bottom. actor animactor (i created), work same image. trying make loading symbol. resize view port correctly. here's code : stage = new stage(viewport); animation anim = main.loadingsymbol; anim.setframesize(new vector2(camera.viewportwidth / 10, camera.viewportwidth / 10)); loadingsymbolactor = new animactor(anim); table = new table(new skin()); table.setbounds(0, 0, stage.getwidth(), stage.getheight()); table.add(loadingsymbolactor); table.pack(); table.align(align.bottomright); stage.addactor(table); table s static ui layout, since not easy add/remove or move actors once laid out. there isn't can tell libgdx wiki doesn't, has explanation on table s here . but if issue resiz...

java - How to create a collection of different types objects to use it with polymorphis -

i have problem different type of objects in collection, in case arraylist, here there example: public interface customobject {} public class customobjecta implements customobjects {} public class customobjectb implements customobjects {} in main call mymethod: arraylist<customobject> list = new arraylist<>(); for(int i=0; < list.size(); i++) { mymethod(list.get(i)); } mymethod defined overloading written below: public void mymethod(customobjecta a) { ... } public void mymethod(customobjectb b) { ... } there compile-error. how can solve? what's right way (collections, generics, wildcard ?) one way work around use of visitor pattern, allows attach functionality, without touching domain objects // visitor, can 'visit' types interface customobjectvisitor { void visita(customobjecta a); void visitb(customobjectb b); } // make customobject visitee public interface customobject { void accept(customobjectvisitor visitor); }...

c++ - Handling List in Rcpp -

i trying take rcpp::charactermatrix , convert each row own element within rcpp::list . however, function have written has odd behavior every entry of list corresponds last row of matrix. why so? pointer related concept? please explain. function: #include <rcpp.h> using namespace rcpp; // [[rcpp::export]] list char_expand_list(charactermatrix a) { charactervector b(a.ncol()); list output; for(int i=0;i<a.nrow();i++) { for(int j=0;j<a.ncol();j++) { b[j] = a(i,j); } output.push_back(b); } return output; } test matrix: this matrix a passed above function. mat = structure(c("a", "b", "c", "a", "b", "c", "a", "b", "c"), .dim = c(3l, 3l)) > mat [,1] [,2] [,3] [1,] "a" "a" "a" [2,] "b" "b" "b" [3,] "c" "c" "c" o...

vb.net - Remove first 7 chars from every items in a listbox -

an example of item be: title1=hello! i need remove first 7 characters make it: hello! i have tried code, not working: listbox.items.item(1).remove(0, 7) each in listbox1.items = (strreverse(strreverse(i).remove(7))) next

regex - How to extract the content between two brackets by using grep? -

1:failed + *1 0 (8328832,ar,undeclared) this expect : 8328832,ar,undeclared i trying find general regex expression allows take content between 2 brackets out. attempt is. grep -o '\[(.*?)\]' test.txt > output.txt but cannot match =( thanks still using grep , regex grep -op '\(\k[^\)]+' file \k means use look around regex advanced feature. more precisely, it's positive look-behind assertion , can : grep -op '(?<=\()[^\)]+' file if lack -p option, can perl : perl -lne '/\(\k[^\)]+/ , print $&' file another simpler approach using awk awk -f'[()]' '{print $2}' file

javascript - how to display products using Repeater control ASP.NET -

Image
i using repeater control display results e commerce website shows, mean horizontaly , vertically well, repeater displaying results in list want show 4 items per row second row third row, showing items top bottom straight line list, please tell me , how can display items want them to,i have seen answers here not working that's why posting question <asp:repeater id="repeater1" runat="server"> <itemtemplate> <div class="span4" style="width:187px" runat="server"> <div class="products"> <a href="='<%# eval("id") %>'"> <img alt="" src='<%# eval("imagelink") %>' height="195" width=""></a> <br/> <h3 class="tit...

Python async TCP server: cannot get sockets from it -

i'm trying simulate network using asychronious tcp servers , sockets. used example documentation starting point task. here's code of server class: import asyncio import socket import node class serverprotocol(asyncio.protocol): def __init__(self, hostnode): self.hostnode = hostnode def connection_made(self, transport): peername = transport.get_extra_info('peername') print('connection {}'.format(peername)) self.transport = transport def data_received(self, data): print('data received: {!r}'.format(data)) self.hostnode.processincomingmessage(data) class nodeserver: def __init__(self, hostnode): self.loop = asyncio.get_event_loop() self.hostnode = hostnode def startlistening(self): self.coro = self.loop.create_server(serverprotocol(self.hostnode), '', 0, family=socket.af_inet) server = self.loop.run_until_complete(self.coro) def getpo...

Eloquent JavaScript Recursion Return? -

i having hard time understanding recursion in eloquent javascript, easy know happening cannot understand why.. function power(base, exponent) { if (exponent == 0) return 1; else return base * power(base, exponent - 1); /* 2*2*2, returns base? thought @ first was, 2*(2,3-1) return 2*(2,2)? calling until reach 0, why exponent out?*/ } console.log(power(2, 3)); // → 8 recursive functions can expressed loop. see adaptation: function power(base, exponent) { var result = 1; (var = 0; < exponent; i++) result *= base; return result; } as can see, exponent doesn't play role @ in output, represents number of loops make. in world of recursion, exponent represents number of times function has yet call before can return. this youtube video visualizes recursion nicely: computerphile

is it possible to inherit using in ASP.NET C# -

Image
have project has solution , class library made baseclass called managerclass.cs inherits system.web.ui.page make class baseclass every thing, in class library have class called alertmessage.cs want use class directly inherited class example: default class inherited manager class: using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace custommodalmessages { public partial class default : managerclass { protected void page_load(object sender, eventargs e) { } protected void btnpopup_click(object sender, eventargs e) { alertmessage.show("", false, page, gettype()); } } } also manager class looks this: using system; using system.collections.generic; using system.linq; using system.web; using sharedcomponent; namespace custommodalmessages { public class managerclass : system.web.ui.page { ...

java - Serializing an anonymous class's function does not work correctly -

summary when try serialize anonymous function (which includes method) - doesn't seem serialize correctly. problem i have interface: program implements serializable , contains function void run(); main method creates variable: p , makes type program . to "initialize" this, create anonymous class interface. in there run() method. type this: system.out.println("hello world, test"); i have class programio uses objectoutput , objectinput streams read , write these files. writing works, reading - until start reading programio ( from: program p = new program {...} program p = programio.readprogram(...) } when it's - reading , writing doesn't work. (writing shouldn't reading should) this error: java.lang.classnotfoundexception: main$2 hypotheses i believe problem occuring because it's looking code inside main class. why want know how can fix this. code import java.io.fileinputstream; import java.io.fileoutputstream; imp...

android - cursor.moveToFirst() always returns false -

i using following code retrieve values db table. public list<string> getprocedure() { list<string> labels = new arraylist<string>(); string selectquery = "select * " + tablename; sqlitedatabase db = this.getreadabledatabase(); cursor cursor = db.rawquery(selectquery, null); log.d("before", "if"); if (cursor.movetofirst()) { log.d("inside", "if"); while (cursor.movetonext()) { log.d("inside", "while"); labels.add(cursor.getstring(1)); } } cursor.close(); db.close(); return labels; } and never log message "inside if" in logcat. mean? i have data inside table , hence not able retrieve it! how rectify it?? please help!! my stack trace: e/sensormanager(6951): thread start d/sensormanager(6951): registerlistener :: handle = 4 name= mpl accel delay= 200000 listener= a...

ElasticSearch parent/child on different indexes -

have 2 objects: humans , belongings. want specify _parent of belonging specific human. elasticsearch provides ability via _parent mapping. documentation , examples i've found doing within same index. but if had humans index, , belongings index, i'm wondering if able specify parent relationship across indexes. preliminary tests seem point no. furthermore, theory cannot because result in human being on different shard belonging (different indexes, different shards). know documentation human id used route child (upon indexing) same shard human. efficiency purposes (in memory joins, round trips, etc). cannot occur since we're talking different shards altogether. question #1: know if _parent can specified across indexes? and if so, question #2: how routing issues mentioned resolved internally? you correct in saying "different index, different shard" - meaning answer question #1 no. that, #2 cannot answered.

algorithm - Interview stumper: friends of friends of friends -

suppose have social network billion users. on each user's page, want display number of users friends, friends of friends, , on, out 5 degrees. friendships reciprocal. counts don't need update right away, should precise. i read on graphs, didn't find suggested scalable approach problem. think of take way time, way space, or both. driving me nuts! one interesting approach translate friend graph adjacency matrix, , raise matrix 5th power. gives adjacency matrix containing counts of number of paths-of-length-5 between each node. note you'll want matrix multiplication algorithm can take advantage of sparse matrices, since friends adjacency matrix sparse first couple levels. lucky you, people have done lot of work on how multiply huge matrices (especially sparse ones) efficiently. here's video twitter's oscar boykin mentions approach computing followers of followers @ twitter.

arrays - Split a string within a list python -

i have list in python, text document split @ new line characters. end of data indicated # in text document. need count each of element of list , split strings in list @ tab characters, creating 2 dimensional list. i thought simple, however, i'm not getting result code. strings in list not splitting @ all, nevermind @ \t . with open('names.txt') names: records = names.read().split('\n') recordcount = 0 item in records: if item != '#': recordcount += 1 item = item.split('\t') print (records) print (recordcount) has got tab characters being troublesome? or can not replace elements of list in-place? should creating new list split records? you're reassigning local variable. doesn't affect contents of list. try this: for i, item in enumerate(records): if item != '#': recordcount += 1 records[i] = item.split('\t')

ruby on rails 4 - Paperclip fails to upload mp3 files -

i'm trying upload audio files website. however, paperclip unable upload mp3 files try upload. reason though able upload wav files. have found similar problems none of answers have worked me. advice appreciated. audio.rb has_attached_file :audio validates_attachment_content_type :audio, content_type: ['application/mp3','application/x-mp3', 'audio/mpeg', ['audio/mpeg'], 'audio/mp3'] validates_attachment_size :audio, :less_than => 35.megabytes error [paperclip] content type spoof: filename test.mp3 (binary/octet-stream headers, ["audio/mpeg"] extension), content type discovered file command: audio/mpeg. see documentation allow combination. [paperclip] content type spoof: filename test.mp3 (binary/octet-stream headers, ["audio/mpeg"] extension), content type discovered file command: audio/mpeg. see documentation allow combination. (0.1ms) rollback (0.1ms) rollback

How To Make Twitter Photo Card To Display In Image Original Size -

how display image in twitter card in original dimension? for example have tweet using twitter card (in indonesian language) https://twitter.com/urban_indo/status/367219691174903808 screenshot: http://i.imgur.com/zptrylw.png the image displayed smaller original image. but upload original image using twitter ( http://pic.twitter.com ), image displayed larger , readable. https://twitter.com/feliciadj/status/367185164603883522 screenshot: http://i.imgur.com/klxrhfl.png here's meta in html <meta property="twitter:card" content="photo" /> <meta property="twitter:site" content="urban_indo" /> <meta property="twitter:title" content="ampera lt/lb 1000/1000 siap huni" /> <meta property="twitter:image:src" content="http://www.urbanindo.com/widget/property/539192592.jpg" /> <meta property="twitter:image:width" content="652" /> <meta property=...

makefile - Building an out-of-tree linux kernel module with separate output directory -

i want build out of tree kernel module output directory being separate source directory? how this? i'm willing go route. i'm okay minimal changes kernel build system, i'm okay copying source files (however not want rebuild if haven't made changes source files , doesn't work if copy source files normally), , i'm okay setting parameter or something.

r - lapply function with RSelenium -

my session this: startserver() remdir <- remotedriver() remdir$open() source <- paste0("https://www.example.com") remdir$navigate(source) i parsing link: html <- remdir$getpagesource() tmp <- xpathsapply(htmlparse(html[[1]]), ' //a/@href') and want parse each tmp link: srcpartone <- paste0(source, as.list(tmp)[185:199],"/") htmls <- lapply(srcpartone, geturl) but in point, geturl function not usage me. because links contains dynamic page. so, need use rselenium in lapply function this: htmls <- lapply(srcpartone, remdir$navigate,remdir$pagesource) i gave example, know doesn't work. how can parse each link using rselenium? edit : library(rselenium) library(rcurl) library(rdrop2) library(pbapply) #start rselenium drop_auth() #dropbox authentication startserver() remdir <- remotedriver() remdir$open(silent = true) #set 'vitrin' sources mobil number: ...

asp classic - ASP select option, if else syntax -

how add attribute use if else statement in asp? have list shown below. <select> <option value="100">$100</option> <option value="200">$200</option> <option value="300">$300</option> </select> how can write way using asp, if (num = 100){ add attr selected="selected" <option value="100"> //read <option value="100" selected="selected"$100</option> }if (num = 200){ add attr selected="selected" <option value="200"> //read <option value="200" selected="selected"$200</option> }else{ add attr selected="selected" <option value="300"> //read <option value="300" selected="selected"$300</option> } i don't know asp syntax, know php! thanks in classic asp like: <% dim num num = 200 %> <select> ...

How to submit an HTML form so that it triggers a route in Backbone.js? -

i building tabbed wizard ui in backbone.js , use html form submission trigger route displays view next tab. however, usual submit button doesn't seem cause route fire. index.html: <form id="statesearch"> <fieldset> <legend>select state:</legend> <select name="statesearchname"> <option value="nd">north dakota</option> <option value="ok">oklahoma</option> <option value="tx">texas</option> <option value="wy">wyoming</option> </select> <button type="reset" name="submitstatename" onclick="window.location.href='index.html/#searchbystate'">search </button> </fieldset> </form> app.js: window.tabexrouter = backbone.router.extend({ routes: { ...

javascript - Close Electron frameless window not working -

i'm building app using electron 1.0 , unfortunately everywhere guides , tutorials it, no 1 uses electron 1 because it's new. i trying close frameless window through click of button made. know button works because have check make sure can simple things (i.e. change text or whatever) that's when use internal javascript trying use external javascript. when use external function never gets called... const {remote} = require('electron'); const {browserwindow} = require('electron').remote; document.getelementbyid("close-button").addeventlistener("click", function (e) { var window = remote.getcurrentwindow(); window.close(); }); that javascript file. know linking file because can use document.write() , works. what doing wrong here? any appreciated thanks! edit: added remote line. although there reason why event handler isn't working button. question closed , answer has been accepted. ...

java - Casting List<String> to a String return type -

the method (below) list<string> type , class i'm using parameter string . wondering if way i'm casting work: return (list<string>) sublist; this method: public list<string> getwords(string phrase) { lettercounter sublist = new lettercounter(phrase); if (phrase == null) throw new illegalargumentexception(); (string element : dict) { if (sublist.contains(element)) sublist.add(element); } return (list<string>) sublist; }// end of getwords this url points lettercounter class: http://pastebin.com/xbeusvpx i put in paste bin because class long. better creating new instance of list<string> , adding string element like, public list<string> getwords(string phrase) { lettercounter sublist = new lettercounter(phrase); if (phrase == null) throw new illegalargumentexception(); list<string> str = new list<>(); (string element : dict) { if (sublist.con...

asp.net mvc - Define Custom View From Controller -

Image
i've been exploring asp.net mvc 5 these days , got stuck basics. example, create controller called ' homecontroller ' , in regard, view created called ' index ' in ' home ' folder. suppose create folder ' home ' folder named ' data ' , again has view called ' viewdata ' . in 'homecontroller' , i've method named ' viewdata ' follows (i want method referred view ' viewdata '): public actionresult viewdata() { maindbcontext db = new maindbcontext(); var con = (from c in db.lists c. public == "no" select c). tolist(); return view("data/viewdata", con); } when run project, works desired mean giving me output , url looks this: http://localhost:2361/home/viewnodata but want show this: http://localhost:2361/home/data/viewnodata under ' home ' folder. 1 more thing - when right click on 'viewdata()' match view, shows ' unable fi...

ruby on rails - No SQL database or Graph database for data intensive application -

i building rails application have huge amount of user , activities , tasks , dynamic attributes. using postgresql know not choice kind of application. i confused between graph databases , 'nosql databases` 1 choose. a graph database is nosql database, document database, column-store database, , key/value database. regarding 1 choose: unfortunately cannot answered simply, lot depend on specific application. but... why choose one ? each type of nosql data store has specific advantages. can build system based on multiple data stores, each 1 used specific advantage(s). concept known polyglot persistence . the microsoft patterns & practices team published guidance around topic, , i'd suggest reading through it. can check out book nosql distilled goes topic , specifics of each data store classification. if want see example of app built on several data stores, check out cloud ninja polyglot persistence . members of team (including myself) got , built lear...

checkbox textview just work in emulator android -

i have problem , checkboxed textview work checked when click in emulator , if try on device , checkboxed textview not checked when click , blank . my adapter : import java.util.arraylist; import android.content.context; import android.support.v4.app.fragmentmanager; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.adapterview.onitemselectedlistener; import android.widget.arrayadapter; import android.widget.checkbox; import android.widget.spinner; import android.widget.textview; import com.id.nirwana.r; import com.nirwana.app.models.amenities; public class amenitiesadapter extends arrayadapter<amenities> implements onitemselectedlistener { private context context; private int itemlayoutresource; spinner spinner; string[] menus; fragmentmanager fragmentmanager; public amenitiesadapter(context context, int itemlayoutresource, ...

ios - Simulator places images with constant CGPoint to the right of screen -

using: os 10.11.5, xcode 7.3.1 , simulator 9.3 2 images , 2 labels (none constraint) appear shifted right on simulator, no vertical change. setting positioning constraints doesn't help. inspite of this, project work. after working on project, image should near centre appears right when simulating. i've commented out has image leaving @ constant cgpoint(x: 375.0, y: 333.0) , still appears on right margin. please, can do?

controller - access to database from private function in cakephp -

i'm writing private function in cakephp see error: using $this when not in object context think because havent access model , find data private function me please { public function blah(){ ... } public function call_remember_me(){ $remembered = remember_me($user_id); } } function remember_me($user_id) { $user = $this->user->findbyid($user_id); .... } assuming using cakephp version 3.x , have connected database in config/app.php , here answer: if have followed cakephp models , database conventions can use orm (object-relational mapping) table registry method use cake\orm\tableregistry; // before class declaration $userstable = tableregistry::get('users'); // in function $userdetails = $usertable->get($user_id); // in function in case have not yet configured config/app.php file establish database connection, kindly [click here][2] more information on how this.

select - MySQL Join three table if one table no record -

$numquery1 = " select d.* , r.* , avg(c.on_time)+avg(c.friendly)+avg(c.language_skills)+avg(c.professional) ranking comment c left join driver d on d.userid = c.driver_id left join driver_rental r on r.email = d.email ( $driver_rental not null , $driver_rental != '' , car_type_1 >= $_session[car_type_1] ) or car_type_2>=$_session[car_type_1]); "; if comment table have no driver_id record, result null, can ignore comment table in select statement cannot without it? $numquery1 = "select driver.*, driver_rental.*, avg(comment.on_time)+avg(comment.friendly)+avg(comment.language_skills)+avg(comment.professional) ranking comment left join driver on driver.userid = comment.driver_id right join driver_rental on driver.email = driver_rental.email ($driver_rental not null , $driver_rental != '') , (car_type_1>=$_session[car_type_1] or car_type_...

api - Kinvey one-to-many relationship -

i have 2 collections - categories , products. category have array of products. how can create needed relation objects? have products column content 1 category: { "_type":"kinveyref" "_id":"574a889c0ee767ef41d9a3d7" "_collection":"products" } how can create one-to-many relationship? artem, assuming have maintained array of product ids in category collection, can expand product information, querying individual product ids, in postfetch hook category collection. following link implementing collecion hooks: http://devcenter.kinvey.com/ios/guides/business-logic#collection-hooks thanks, pranav kinvey support

java - Should I declare an unchecked exception? -

i've got method invokes method this: public void m1() { m2(10); } public void m2(int v) { if(v < 10) throw new myexception(); } public class myexception extends runtimeexception{ } now, i'd notify clients going use m1() might throw myexception . ok if declare this: public void m1() throws myexception{ m2(10); } i'm not sure used use throws declaration checked exceptions. common unchecked ones? you can - , it'll show in javadoc, believe. won't force callers handle exception, you're still relying on users (developers calling code) diligent enough check documentation. if that's sufficient you, go - otherwise, change myexception checked exception. as whether it's common declare unchecked exceptions might thrown - i've seen enough not particularly surprising, it's not widely-used practice.