Posts

php - Why does Instagram's pagination return the same page over and over? -

the code i've created php class communicate instagram's api. using private function called api_request (shown below) communicate instagram's api: private function api_request( $request = null ) { if ( is_null( $request ) ) { $request = $this->request["httprequest"]; } $body = wp_remote_retrieve_body( wp_remote_get( $request, array( "timeout" => 10, "content-type" => "application/json" ) ) ); try { $response = json_decode( $body, true ); $this->data["pagination"] = $response["pagination"]["next_url"]; $this->data["response"] = $response["data"]; $this->setup_data( $this->data ); } catch ( exception $ex ) { $this->data = null; } } these 2 lines of code... $this->data["pagination"] = $response["pagination...

django-autocomplete-light django 1.8 custom modelform for admin -

i want add autocomplete onetoone field django-admin class banner(models.model): product = models.onetoonefield(product, null=true) class banneradmin(admin.modeladmin): form = bannerform stucked on https://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/tutorial.html?highlight=tutorial#tutorial - anything changed after following steps (same list widget 'product' ...): what have done: installed :d added 'autocomplete_light', installed_apps overrided admin/base_site.html (using custom loader) url(r'^autocomplete/', include('autocomplete_light.urls')), urlpatterns autocomplete_light_registry.py model banner , search_fields=['product'], updated modelform: class bannerform(autocomplete_light.modelform): class meta: model = banner fields = ['product', 'priority', 'image'] autocomplete_fields = ['product'] what i've missed? following re...

apache spark - SparkMLlib MultiClassMetrics.confusionMatrix() and precision() seems giving contradictory results -

hi new machine learning , spark mllib. have created randomforest classifier model using randomforest.trainclassifier() training data set categorical in nature , have response/target variables actionable/noactionable. have created predictionandlables rdd using test data , model.predict() trying following validate model accuracy. multiclassmetrics metrics = new multiclassmetrics(predictionandlables.rdd()) system.out.println(metrics.precision()); //prints 0.94334140435 system.out.println(metrics.confusionmatrix()); //prints following 1948.0 0.0 117.0 0.0 now if see model accuracy printed using precision() method seems around 94% if see above confusion matrix seems wrong have 1948 nonactionable target variables , 117 actionable target variable in test data set. according confusion matrix predict nonactionable correctly , not predict @ actionable variables. please me understanding confusion matrix , why precision 94% . results contradicting. please guide in advance...

Multidimensional array calculations in PHP -

i have 2 arrays: array ( [0] => stdclass object ( [id] => 1 [values] => array ( [0] => stdclass object ( [id] => 2 [field_value] => green [ordering] => 0 [count] => 0 ) [1] => stdclass object ( [id] => 1 [field_value] => red [ordering] => 1 [count] => 0 ) ... ) ) [1] => stdclass object ( [id] => 2 [values] => array ( [0] => stdclass object ( [id] => 2 ...

c++ - Singleton class and thread safety -

class numberstorage { public: static numberstorage& instance(); double getnumber(); void setnumber(double d); private: numberstorage() { number = 0.0; }; double number; }; colorramps& colorramps::instance() { static colorramps instance; return instance; } i think have read somewhere instance() method implemented way thread safe. correct? guess must lock member variable number in getnumber() , setnumber()? how do (c++11)? c++11 compiler makes thread safe. static variables can created 1 single thread. other questions locks both depend on how threads should work methods. if have multiple threads can 1 same piece of memory - use locks. simple lock can used std::unique_lock , std::mutex : void setnumber(double number) { static std::mutex _setnumberlock; std::unique_lock _lock(&_setnumberlock); // code }

jquery - Bootstrap modal and multiple vimeo videos -

i have page has multiple videos embedded. each link opens video in bootstraps modal. problem have if close modal video still playing. i found script force stop next issue page has multiple videos. have tried capture id of each video variable when clicked. independently 2 scripts have work, bit missing them combined? html <ul> <li><a class="video" href="#" data-toggle="modal" data-target="#video1">video 1</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video2">video 2</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video3">video 3</a></li> <li><a class="video" href="#" data-toggle="modal" data-target="#video4">video 4</a></li> </ul> this jquery ...

javascript - How to call the function, if the count reaches the limit -

i using google maps , placing map markers using array locations , want call function clearmarkers() if i==26 how can this? code: var markers = []; var map; var india = new google.maps.latlng(21.9200,77.9000); var image = 'images/pushpins/set1.png'; function initialize() { var mapoptions = { zoom: 5, center: india }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); drop(); } function drop() { clearmarkers(); (var = 0; < locations.length; i++) { var city = locations[i][0]; var pro_cat = locations[i][1]; addmarkerwithtimeout(locations[i][2], * 500); getcity(city,pro_cat, * 500); } if (i==26){ clearmarkers(); } } function addmarkerwithtimeout(position, timeout) { window.settimeout(function() { markers.push(new google.maps.marker({ position: position, map: map, icon: image, optimized: false, //animation: google.maps.animation.bounce })...