Posts

Showing posts from June, 2011

html - Cycle 2 Prev and Next -

good evening, i'm using cycle2 prev , next function, cannot centre prev , next function under images. i've looked around , know going stupid, cannot see it. frustrating. gary <script src="../../respond.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="http://malsup.github.com/jquery.cycle2.js"></script> <script src="http://malsup.github.io/jquery.cycle2.center.js"></script> @charset "utf-8"; /* simple fluid media note: fluid media requires remove media's height , width attributes html http://www.alistapart.com/articles/fluid-images/ */ img, object, embed, video { max-width: 100%; } /* ie 6 not support max-width default width 100% */ .ie6 img { width:100%; } /* dreamweaver fluid grid properties ---------------------------------- dw-num-cols-mobile: 4; dw-num-cols-tab...

c++ - Accessing a class member in an if statement using std::is_same -

i'm trying tackle following problem: if statement depending on whether argument of template specific object or not - , if is, call object's member function. let's want std::string the snippet: #include <iostream> #include <string> template <typename t> void is_string(const t& arg) { if (std::is_same<t, const std::string&>::value) std::cout << arg.length() << std::endl; else std::cout << "the argument not string" << std::endl; } int main() { is_string(0); return 0; } it doesn't compile, following error: types.cpp: in instantiation of ‘void is_string(const t&) [with t = int]’: types.cpp:13:13: required here types.cpp:7:13: error: request member ‘length’ in ‘arg’, of non-class type ‘const int’ std::cout << arg.length() << std::endl; i reckon i'm trying achieve might not possible in c++11, appreciate suggestions on how able such thing ...

vb.net - Could not find any resources appropriate for the specified culture or the neutral culture. -

i'm trying use resources .dll file, whatever can't working. spent hours researching, , realized there no way 'figure out' until gives me example. my main project called test 1 rootname test_1 have simple form 1 textbox. .dll file called classlibrary1 rootname classlibrary1 .dll resources.resx unchanged. added 1 string called test value asd . i'm trying call string when loading form1 of test1 . -i have set resources.resx embedded resource. -i added project & .dll reference enter code here -i have set resources public. private sub form1_load(sender object, e eventargs) handles mybase.load dim pathx string pathx = "t:\classlibrary1.dll" ' visual basic .net ' gets reference same assembly ' contains type creating resourcemanager. dim myassembly system.reflection.assembly myassembly = me.gettype.assembly ' gets reference different assembly. dim myotherassembly system.reflection...

shell - PHP Exec - How to only display the result of the last command -

i'm using exec php function run script grabs youtube video in mp3 format (with youtube-dl ). at end of script made echo , result want. but when launch php page, output composed of youtbe-dl did. that: [youtube] ztks9svhhui: downloading webpage [youtube] ztks9svhhui: downloading video info webpage [youtube] ztks9svhhui: extracting video information [youtube] ztks9svhhui: downloading js player en_us-vflgfv_kx [youtube] ztks9svhhui: downloading js player en_us-vflgfv_kx [download] destination: /var/www/xxx/mp3dl/kaskade - whatever ft kolaj (neus remix).webm [download] 0.0% of 3.84mib @ 10.17kib/s eta 06:26 [download] 0.1% of 3.84mib @ 30.44kib/s eta 02:09 [. . .] [download] 100.0% of 3.84mib @ 4.01mib/s eta 00:00 [download] 100% of 3.84mib in 00:00 [ffmpeg] destination: /var/www/xxx/mp3dl/kaskade - whatever ft kolaj (neus remix).mp3 deleting original file /var/www/xxx/mp3dl/kaskade - whatever ft kolaj (neus remix).we...

java - How to establish peer to peer connection on top of client server app? -

i have client server application several clients connect single server. know need establish peer peer connection between 2 online clients can chat together. lost on how implement this. in how server send ip address clients? , how can implement chatting if clients not listening connections , connecting server?

pandas - Combine Sklearn TFIDF with Additional Data -

i trying prepare data supervised learning. have tfidf data, generated column in dataframe called "merged" vect = tfidfvectorizer(stop_words='english', use_idf=true, min_df=50, ngram_range=(1,2)) x = vect.fit_transform(merged['kws_name_desc']) print x.shape print type(x) (57629, 11947) <class 'scipy.sparse.csr.csr_matrix'> but need add additional columns matrix. each document in tfidf matrix, have list of additional numeric features. each list length 40 , it's comprised of floats. so clarify, have 57,629 lists of length 40 i'd append on tdidf result. currently, have in dataframe, example data: merged["other_data"]. below example row merged["other_data"] 0.4329597715,0.3637511039,0.4893141843,0.35840... how can append 57,629 rows of dataframe column tf-idf matrix? don't know begin , appreciate pointers/guidance. i figured out: first: iterate on pandas column , create list of lists for...

ruby - Should this Chef recipe be refactored? -

i've written recipe installs windows desktop apps databag: workstation_apps = data_bag_item('winapps','desktop_apps') package in workstation_apps['apps'] chocolatey_package "#{package}" action :install end end running foodcritic error: fc002: avoid string interpolation not required: ./recipes/default.rb:23 as can see, added double quotes around #{package} expands variable , not function comment. is there better way this? two things: first use of for loops in ruby discouraged in favor of each loops. second, chocolatey package provider support multi-package operations can rewrite recipe this: workstation_apps = data_bag_item('winapps','desktop_apps') chocolatey_package workstation_apps['apps'] (remember :install default action don't need write out)

python - OrderingFilter has no attribute 'filter_queryset' -

i have been trying orderingfilter work. example in django-rest-framework's page, seems should straightforward: class userlistview(generics.listapiview): queryset = user.objects.all() serializer_class = userserializer filter_backends = (filters.orderingfilter,) ordering_fields = ('username', 'email') however, when try that: from django_filters.rest_framework import djangofilterbackend, filterset, orderingfilter ... class listingviewset(viewsets.modelviewset): queryset = listing.objects.all() serializer_class = listingserializer filter_backends = (djangofilterbackend, orderingfilter,) filter_class = listfilter ordering_fields = ('price', 'views') ordering = ('price',) i error orderingfilter not having filter_queryset attribute: error 2016-11-13 03:14:57,304 log 25913 123145338523648 (<class 'attributeerror'>, attributeerror("'orderingfilter' object has no attr...

amazon web services - AWS s3:ListBucket action results in access denied using conditional StringLike statement on s3:prefix -

i have items in "folder" in s3 bucket. "path" file contains identity id of user uploaded file , appears in s3 managment console "all buckets/[my_bucket]/us-east-1:080ffd35-c00e-4e33-877f-3ec57be4b128" have iam policy attached cognito authenticated users includes following conditional statement: "condition": { "stringlike": { "s3:prefix": [ "us-east-1:080ffd35-c00e-4e33-877f-3ec57be4b128/*" ] } } i've hard-coded in identity id troubleshooting step since wasn't sure if "${cognito-identity.amazonaws.com:sub}" contained correct string. specific identity id encoded, still not work , receive access denied error when trying list contents of bucket. correct in thinking stringlike looks given string inside prefix? there else i'm missing? i've included full iam policy below: { "version": ...

javascript - Trying to open a php file in background using ajax on link click -

i want open php file in background on link click instead of showing user link php file. i realize way ajax. but not working, instead of opening new php page in background instead nothing happens, php code not execute. my javascript <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <script type="text/javascript"> $('a#run-php-script').click(function(e){ e.preventdefault(); $.ajax({ type: 'post', url: 'http://mywebsiteaa.com/myfile.php?addid=<?php echo $add->id); ?>' }); return false; }); </script> my html <a id="run-php-script" href="#">clickit</a> please note php script works when put php link html href tag. problem reveals user php file url , won't want user see nor want open in new tab if @ possible instead in background. i tried get instead of post ,...

eclipse - java query not passing test case -

this question: a dosod number divisor of sum of digits. example, if take number 12, sum of digits 1 + 2 = 3. 12 divisible 3 , hence dosod number. same reasoning, 11 not dosod number, closest dosod number 11 12. write program take integer n input , print dosod number closest not less n. sample input-1 16 expected output 18 sample input-2 20 expected output 20 this code: class dosod{ public static void main(string args[]){ scanner s=new scanner(system.in); int n=s.nextint(); int temp=0,x; x=n; int y=n; while(n>0){ x=n%10; temp+=x; n=n/10; } if(y%temp==0){ system.out.print(y); }else if(y%temp!=0){ y=y+2; system.out.println(y); } } } but not passing test case .can ? you need update else branch. closest number forward or backward current number. since problem statement explicitly says closest...

android - Failing to compile forked Github Repo with Jitpack -

i forked repo on github , wanted build project. figured jitpack easiest way this. followed instructions , still cannot compile. i noticed in android studio when expand "external libraries" section in left pane can see repo there. however, when expand it, not of classes there. there seem obfuscated. see java package name expect, see a, b, c, d, e, f, g, h, i, j, classes. in world going on here? i think know might happening here. android library forked had proguard enabled. think trying compile against binary built proguard via jitpack, don't think work. when build against github source through jcenter, guessing building source, , not compiled binaries why problem did not exist until started using jitpack , forked repo. not 100% sure however. i won't mark answer accepted until sure issue.

sqlite - Phone gap desktop apps with offline database -

i new phone gap. created small application using phone gap desktop save form data online mysql database , working fine. want save these form data in local database offline system , save online database when connected internet. how can integrate local sqlite database phone gap desktop.

angular2 routing - Angular 2.1.2 (SystemJS) Can't resolve all parameters for AppComponent -

i getting error @ app startup error: (systemjs) can't resolve parameters appcomponent: (?, ?, ?). error: can't resolve parameters appcomponent: (?, ?, ?). @ compilemetadataresolver.getdependenciesmetadata (https://npmcdn.com/@angular/compiler@2.1.2:14598:21) @ compilemetadataresolver.gettypemetadata (https://npmcdn.com/@angular/compiler@2.1.2:14499:28) @ compilemetadataresolver.getdirectivemetadata (https://npmcdn.com/@angular/compiler@2.1.2:14274:30) @ eval (https://npmcdn.com/@angular/compiler@2.1.2:14678:35) @ array.foreach (native) @ compilemetadataresolver._getentrycomponentsfromprovider (https://npmcdn.com/@angular/compiler@2.1.2:14677:32) @ eval (https://npmcdn.com/@angular/compiler@2.1.2:14635:85) @ array.foreach (native) @ compilemetadataresolver.getprovidersmetadata (https://npmcdn.com/@angular/compiler@2.1.2:14622:21) @ eval (https://npmcdn.com/@angular/compiler@2.1.2:14629:43) ...

delphi - Client Application Name in DataSnap -

i have client-server system uses datasnap. want log client application data use tdsserver - onconnect event. in event can access want following code: ip:= dsconnecteventobject.channelinfo.clientinfo.ipaddress clientport:= dsconnecteventobject.channelinfo.clientinfo.clientport protocol:= dsconnecteventobject.channelinfo.clientinfo.protocol appname:= dsconnecteventobject.channelinfo.clientinfo.appname first 3 lines ok appname empty!!! (i run server , client on same computer i.e. localhost) i have been unable find online information how specify appname when client connects via tcp/ip. if @ code procedure tdstcpchannel.open; var clientinfo: tdbxclientinfo; begin inherited; freeandnil(fchannelinfo); fchannelinfo := tdbxsocketchannelinfo.create(intptr(fcontext.connection), fcontext.connection.socket.binding.peerip); clientinfo := fchannelinfo.clientinfo; clientinfo.ipaddress := fcontext.connection.socket.binding.peerip; clientinfo.clientport := i...

Limits on Python Lists? -

i'm trying assimilate bunch of information usable array this: for (dirpath, dirnames, filenames) in walk('e:/machin lerning/econ/full_set'): ndata.extend(filenames) in ndata: currfile = open('e:/machin lerning/econ/full_set/' + str(i),'r') rawdata.append(currfile.read().splitlines()) currfile.close() rawdata = numpy.array(rawdata) order,file in enumerate(rawdata[:10]): in rawdata[order]: r = i.split(',') pdata.append(r) fdata.append(pdata) pdata = [] fdata = numpy.array(fdata) plt.figure(1) plt.plot(fdata[:,1,3]) edit: after printing ftada.shape when using first 10 txt files for order,file in enumerate(rawdata[:10]): i see (10, 500, 7). if not limit size of this, , instead for order,file in enumerate(rawdata): then fdata.shape (447,) seems happens whenever increase number of elements through in rawdata array above 13... it's not specific location either - changed for order,file in enu...

What is the difference between Forever-frame and server sent events? -

this question similar question: what difference between web sockets, long polling, server-sent events , forever frame? however, question's answer doesn't mention difference between sse , forever-frame. let me give brief explanation them. regarding sse, system resembles comet, point different comet not breaking connection after data being sent. so, connection server client long-alive , client receives series of fragments of whole data. on other hand, forever frame seems similar me. in forever frame, first client receives page including iframe tag, establishing long-lived connection inside hidden iframe. , client receives chunked datas server , manipulates dom functions on first document client has. i assume difference forever-frame uses iframe tag in mechanism, sse doesn't , sse can realized more ways. right? i'd not heard of forever-frame name before! (it covered in ch.7 of book, data push apps html5 sse, in "iframe" section). long-pol...

php - json - Value <br of type java.lang.String cannot be converted to JSONObject -

i trying log in on app, access online database , check if inputs registered i'm getting error: value < br of type java.lang.string cannot converted jsonobject . i don't know why php code returns < br />. (i added space between < , br show) here's code. import android.app.activity; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.os.asynctask; import android.support.v7.app.actionbar; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.widget.button; import android.widget.edittext; import android.view.view; import android.widget.toast; import org.json.jsonobject; import java.util.arraylist; import java.util.hashmap; public class login extends activity { button btnlogin; intent intent; jsonobject jsonobject; button btnsignup; edittext txtusername, txtpassword; @override protected void oncreate(...

django rest framework model foreign key -

i have 2 models class order(models.model): fields... class orderitem(models.model): fiels... order = models.foreignkey(order, related_name='items') and have 2 serializers: class createorderitemserializer(serializers.modelserializer): class meta: model = orderitem resource_name = 'order-item' fields = ('order', 'count') ..... class orderserializer(serializers.modelserializer): items = createorderitemserializer(many=true) class meta: model = order resource_name = 'order' fields = ('id','items') i posted order items array this: { 'ordername': 'foo', 'items': [{ 'name': 'foo1', },{ 'name': 'foo2', }, ] } but have error: "order":["this field required."] how can first create order later create items orderid? ...

css - Overlaping many imgs in html -

Image
i have 7 transparent images same width , same height. have background image same width , height well. did (and want do) place background image in main div , place other 7 imgs on top see in code below. result imgs flow out of main div , bigger. tried changing css similar behaviour alway occurs. in addition, background image not in center of page specified in css. can mistake? so got following html: <div class="row wrapper"> <div class="col container"><img ng-src="{{data.firstdisplay.src}}"></div> <div class="col container"><img ng-src="{{data.seconddisplay.src}}"></div> <div class="col container"><img ng-src="{{data.thirddisplay.src}}"></div> <div class="col container"><img ng-src="{{data.forthdisplay.src}}"></div> <div class="col container"><img ng-src="{{d...

javascript - How do I return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback ca...

IOS. How to get coordinates using maps? -

i have label coordinates (lat, lng eg). want choose custom location on map , return coordinates label. solution use google maps placepicker https://developers.google.com/places/ios-api/placepicker i don't want use google maps framework, how implement similar functionality using native ios (core location, mapkit)?

Excel VBA for opening a file with changing in the file name every month -

i want vba code open file name changing every month chdir "s:\credit_risk\mis\consolidated customer profile macro\securities" workbooks.open filename:= _ "s:\credit_risk\mis\consolidated customer profile macro\securities\enterprise pending cases @ end of oct.2016.xls" any 1 can help workbooks.open filename:= _ "s:\credit_risk\mis\consolidated customer profile macro\securities\enterprise pending cases @ end of " & format(date, "mmm.yyyy") & ".xls"

forms - Send data to PayPal; submit with PHP -

this code: <form action="" method="post"> <input class="payment_input" type="text" name="name" placeholder="name"> <input class="payment_input" type="text" name="address" placeholder="address"> <input class="payment_input" type="text" name="email" placeholder="e-mail"><br> <input class="payment_input" type="submit" name="submit_paypal" value="go paypal"> </form> <?php $order_token = md5(uniqid($_post['name'], true)); if (isset($_post["submit_paypal"])) { $statement = $pdo->prepare("insert customers (name, address, email, order_token) values (:name, :address, :email, :order_token)"); $statement->execute(array(':name' => $_post['name'], ':address' => $_post['address'], ':email' ...

Handling FaceBook API Tokens (limit and permission) -

i'm crawlers massive collections facebook pages , groups. main problem lots of "unsupported request(100)" , " user request limit reached(17). i'm using 2 kind of tokens: application-tokens , user-tokens (that service connect facebook , token source of page). need ideas how handle tokens, wan't reach limit. i'm trying switch token when limit error, since have services , each of them have threads , doesn't help. help,

php - Restart RabbitMQ After Loading Server From Snapshot -

i running server on gce (ubuntu 14.04). used rabbitmq on machine managing 4 queues run tasks. the code written in php access rabbitmq. i did snapshot server , moved new stronger server , hell breaks loose rabbit. no queues, no users / passwords, , after there no rabbitmq connection , following error: php fatal error: uncaught phpamqplib\exception\amqpruntimeexception: broken pipe or closed connection i tried - rabbitmqctl stop , reset , start , create users/pass , error still there. is there resetting can in order reconnect service?

c++ - SOLID: Does DIP mean that composition/aggreation to an object is forbidden? -

Image
i trying understand , apply solid principles. regarding dependency inversion principle, means composition/aggregation object forbidden? interface must used access class method? i mean that: class serviceclass { void serviceclasshelper(); } class mainclass { void mainclass(serviceclass service); // use serviceclasshelper } must changed to: class serviceinterface { virtual void interfacehelper() =0; } class serviceclass : public serviceinterface { void serviceclasshelper(); void interfacehelper() { serviceclasshelper(); }; } class mainclass { void mainclass(serviceinterface service); // uses interfacehelper } i think (or @ least hope) understand principle. wonder if can rephrased that. indeed, stuff read dip suggest use interfaces. thanks! basically, main idea of dip is: high-level modules should not depend on low-level modules. both should depend on abstractions. abstractions should not depend on details. details should depend on ...

C# - Servicestack MongoDB JSON Objects Unescape -

Image
i have got 2 problems. i have local mongodb several collections. a database object looks this: my configuration looks this: ​using funq; using servicestack; using servicestack.text; namespace protocol.server.api { public class apihost : appselfhostbase { public apihost() : base("api rest service", typeof(apihost).assembly) { } public override void configure(container container) { plugins.add(new corsfeature()); setconfig(new hostconfig { defaultcontenttype = mimetypes.json, enablefeatures = feature.all.remove(feature.html) }); jsconfig.convertobjecttypesintostringdictionary = true; } } } my request definition this: public async task get(getobjects request) { var collection = connect. database.getcollection("cylinders"); var aggregate = colle...

android - Picasso image in Collapsing Toolbar layout ONLY shows in landscape mode -

an image loaded picasso appears in landscape mode of app, never in portrait. i have coordinatorlayout appbar , collapsingtoolbarlayout set in 1 of activities. setup 1 of androidstudio's auto-generated ones. i have added imageview collapsingtoolbarlayout , loading image in oncreate. can see image in view if phone in landscape mode. code: xml <android.support.design.widget.appbarlayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:fitssystemwindows="true" android:theme="@style/apptheme.appbaroverlay"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary...

javascript - Sorting row values in orbjs pivot table -

below code project file: { name: '3', caption: 'career level', aggregatefunc: 'sumtext', sort: { order: 'desc' } } instead of 'desc' sort custom sort based on predetermined array. as per code orbjs on github how customfunc can added: name: '4', caption: 'category', sort: { customfunc: function(a, b) { if(a.trim() == 'touch screen phones'){ return -1; } if(a < b) return -1; if(a > b) return 1; return 0; } } } i have customfunc sort career levels column project contains values ["p1", "ex", "m4"] (length of array varies). if have sort elements per below array. how create customfunc in github issue link ["ex", "m4", "m3", "m2", "m1", "p6", "p5"] kindly obser...

java - How to edit default render behaviour of ComboBoxTableCell in JavaFX 2? -

by default comboboxtablecell rendered label when not being edited. want change behaviour rendered combobox time. couldn't find out how. basically have tableview. of columns of type combobox. want combobox node shown always. vartypecol.setcellvaluefactory(new propertyvaluefactory<globalvariable, string>("vartype")); vartypecol.setcellfactory(new callback<tablecolumn<globalvariable, string>, tablecell<globalvariable, string>>() { @override public tablecell<globalvariable, string> call(tablecolumn<globalvariable, string> p) { return new comboboxtablecell<globalvariable, string>(fxcollections.observablearraylist("string", "integer")); } }); you need implement own tablecell . like public class livecomboboxtablecell<s,t> extends tablecell<s, t> { private final combobox<t> combobox ; public livecomboboxtablecell(observablelist<t> items...

wiredep - Bower dependency per html -

using wiredep bower great, don't want link javascript files on every page. although building app single page app, there may html pages require large, distinct javascript libraries not used in main page. the questions is, can specify in bower html page dependency for? if so, can on install? bower install bootstrap --save --all dependency pages, , bower install largejslibrary --save "complex.html" 1 off dependencies? or creating multiple bower.json files, wiredep entry each in gulp file work? whats best practice in situation?

python - PHP array with datetime function to get time in seconds -

i have wrote function in python (as have solid knowledge there), need use function in php (on codeigniter project - model). question how fallowing function on php: import datetime datetime import timedelta def getmaxvalverify(mylist): intervaltime = mylist[len(mylist) -1][1] - mylist[0][1] seconds=timedelta.total_seconds(intervaltime) return seconds now explain does, list(array) looks : list = [(41740, datetime.datetime(2016, 6, 20, 18, 00, 00)), (41280, datetime.datetime(2016, 6, 20, 18, 00, 30)), (40500, datetime.datetime(2016, 6, 20, 18, 02, 00))] it return difference in seconds first datetime element last, in our case 18:00:00 18:02:00 return: print getmaxvalverify(list) 120.0 you should use datetime class in php, gives access dateintervals. example 2 dates : <?php $datestart = new datetime('2016-06-20 18:00:00'); $interval= $datestart->diff(new datetime('2016-06-20 18:30:00')); echo...