Posts

Showing posts from August, 2013

memory - Android OutOfMemory error ImageView -

java.lang.outofmemoryerror: failed allocate 14400012 byte allocation 5645520 free bytes , 5mb until oom @ dalvik.system.vmruntime.newnonmovablearray(native method) @ android.graphics.bitmapfactory.nativedecodeasset(native method) @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:726) @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:547) @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:1014) @ android.content.res.resources.loaddrawableforcookie(resources.java:3730) @ android.content.res.resources.loaddrawable(resources.java:3603) @ android.content.res.resources.getdrawable(resources.java:1852) @ android.content.context.getdrawable(context.java:408) @ android.view.view.setbackgroundresource(view.java:17228) @ alexcz.shapetest.test.nextq(test.java:89) @ alexcz.shapetest.test$1

Blueimp jQuery upload configuration -

i have configured blueimp upload progress bar , it's worked, message 'uploading' not changing 'upload finished'. thanks $(function () { $('#fileupload').fileupload({ datatype: 'json', add: function (e, data) { data.context = $('<button/>').text('upload') .appendto(document.body) .click(function () { data.context = $('<p/>').text('uploading...').replaceall($(this)); data.submit(); }); }, done: function (e, data) { data.context.text('upload finished.'); }, progressall: function (e, data) { var progress = parseint(data.loaded / data.total * 100, 10); $('#progress .bar').css('width',progress + '%'); } })

json - Handlebars each helper arguments -

i trying include object in {{each}} iteration in handlebars doesn't belong actual array object. myarrayobj <-- array of json objects include bunch of fields someotherobj <-- json object includes bunch of fields first attempt: {{#each myarrayobj}} {{#myhelper this.fieldinarrayobject someotherobj.somefield}} {{/myhelper}} {{/each}} helper: handlebars.registerhelper('myhelper', function (date, language) { console.log(json.stringify(language)); // <--- language undefined }); someotherobj.somefield coming out undefined in helper class? else working. another example: {{something.field}} // <--- works, displays wish {{#each sessions}} {{something.field}} // <--- not work {{/each}} when using object not belong current scope, you'll need use path try this {{#each myarrayobj}} {{#myhelper this.fieldinarrayobject ../someotherobj.somefield}} {{/myhelper}} {{/each}} for more on using paths - @ handl

javascript - establish send property for multiple webscoket connections -

in script below try open ten websocket connections server: var webscd=[]; function initweb(){ (var c=0; c <10; c++){ webscd[c]=new websocket(wsadress); webscd[c].onopen=function(evt){ var binary = new uint8array(2); binary[0]=1; binary[1]=2; webscd[c].send(binary.buffer); }; webscd[c].onclose=function(evt){}; webscd[c].onmessage=function(evt){}; webscd[c].onerror=function(evt){}; } } initweb(); but script throws following error 'uncaught typeerror: cannot read property 'send' of undefined' . should do? i figured out way without closure stuff. function create_ws() { var ws=new websocket("ws://127.0.0.1:1234"); ws.onopen=function(evt){ var binary = new uint8array(2); binary[0]=1; binary[1]=2; ws.send(binary.buffer); }; ws.onclose=function(evt){}; ws.onmessage=function(evt){}; ws.onerror=fu

ios - Swift - how do I pass the type through a method call? -

a realm object: class dog: object { dynamic var name = "" dynamic var age = 0 } calling results: let results = realm.objects(dog) or doing way: let type = dog.self let results = realm.objects(type) i want able passing method this: class someclass { func callrealm(type: anyobject) { let results = realm.objects(type) } } let someclass = someclass() let type = dog.self someclass.callrealm(type) how this? i've had no luck generics, although think might way go. your function callrealm should take input anyclass instead of anyobject . func callrealm(type: anyclass) { let results = realm.objects(type) }

javascript - d3.js / dc.js - How do I define a stacked bar graph's dimension and group when the data set has multiple variables? -

i have similar question 1 posted here: how create multiline chart using dc.js i new stackoverflow, means unable add comments or have asked additional information on post. so, apologize redundancy. i have data structured like: var data = { {"id": 'id_value1', ..., "dates": {"name": {"d1":" 0-91","d2":" 92-182","d3":"183-273","d4":"274-364","d5":"365+"}, "value": {"v1":'a',"v2":'a',"v3":'c',"v4":'d',"v5":'b'}}, {"id": 'id_value2', ..., "dates": {"name": {"d1":" 0-91","d2":" 92-182","d3":"183-273","d4":"274-364","d5":"365+"}, "value": {"v1":'a',"v2":'b',&quo

javascript - React Native: Opening URLs in Android (Equivalent to LinkingIOS.openURL) -

i'm aware when using react native develop ios, have access linkingios , webview modules work urls. there sort of equivalent android? i'm looking open url in device's browser. i know contributors working on implementing webview in android: https://facebook.github.io/react-native/docs/known-issues.html#views https://github.com/facebook/react-native/issues/2701 but there can use in meantime? again, need equivalent linkingios.openurl(url) android. with latest release of react native (0.21), provide module linking handle incoming outgoing web url. this can work both on android , ios without platform specific.

javascript - Intercept input entering -

is there way intercept value user inputs before ever appears in element? tried use object.defineproperty appears not work inputelement.value since var value; object.defineproperty($('input')[0], 'value', { get: function() {return value}, set: function(val) {console.log(val); value = val;} }); doesn't appear change behavior. or oninput/onchange option? since i'd rather have code executes before browser's. http://jsfiddle.net/zpmu1xcu/ if want detect input before text entered browser, can use element.onkeydown property. event fires key pressed down, before browser interprets action. var demo_i = document.getelementbyid('demo_i'); var demo_d = document.getelementbyid('demo_d'); demo_i.onkeydown = function(e) { demo_d.textcontent = e.which; // returning false stops event going further return false; } <input id="demo_i"><div id="demo_d"></div>

nested xml tag to xslt -

can me on this? have xml this <x:person> <x:name>angel</x:name> <x:education-info> <school>school abc</school> <address>address 123</address> <city>city 1</city> <year>2001</year> <remarks>12334</remarks> <school>school abc2</school> <address>address 456</address> <city>city 2</city> <year>2005</year> <remarks>test1233</remarks> </x:education-info> <x:age>22</x:age> </x:person> how can school , address tag inside education-info tag ? , format xslt this school abc - address 123 school abc2 - address 456 xslt 1.0 if first make xml valid xml, following, has effect elements in namespace urn:yourns , in no namespace: <x:person xmlns:x="urn:yourns"> <x:name>angel</x:name>

html - Equal Horizontal Menu in CSS (Legacy Support) -

i'm trying build equal horizontal menu in css still supported in older browsers ie9. (yes, know....) been testing in ff , chrome newer css3 techniques , working excellent! tried in ie9, still need support it.... , failed. i searched around, , found of these links did trick... http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/ horizontal menu auto width , same dimension of tabs ...however if number of menu items change need either change css or cater x number of menu items multiple declarations... is there simple 1 case covers support ie9 , still compatible newer browsers without affecting them? (ie: special stylesheet ie9) thanks. if understood question correctly, make use of display: table , display: cell , in: .menu { display: table; padding: 0; width: 100%; } .menu-item { display: table-cell; list-style: none; margin: 0; } <ul class="menu"> <li class="menu-item"&

c - How to convert a string to type int or float? -

i have problem putting value of creditos , nota in structure. i have file this, example: grade: 4.5 i'm using strtok , returns char pointer, , need int , float . #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char *nombre; int creditos; float nota; }curso; int conteo(file *_entrada); void semestre(file *_entrada,curso *_materias,int *_cantidad,int *_ganadas,int *_perdidas,float *_promedio); void imprimir(curso *_materias,int *_cantidad,int *_ganadas, int *_perdidas,float *_promedio); int main(int argc, char *argv[]){ int ganadas=0; int perdidas=0; float promedio=0.0; int cantidad=0; char archivoentrada[256]; curso *materias; printf("archivo de entrada \n"); scanf("%255s",archivoentrada); file *entrada; entrada=fopen(archivoentrada,"r"); if(entrada==null){ printf("no se logro abrir el archivo de entrada\n"); exit(exit_failure); } cantidad=conteo(entrada); materias=(curso *)

sql server - select all results from only certain tables Using SQL in C# from a stored procedure that returns multiple tables -

i have stored procedure returns 20 tables. i.e.: table 1 id|a 01|whatever table2 id|b 01|whatever table3 id|c 01|whatever 02|whatever2 03|whatever3 04|whatever4 i use following code grab result tables 1 column , 1 row: sqlreader.read(); rows = convert.tostring(sqlreader.getvalue(0)); sqlreader.nextresult(); when move next result, can use results of tables (would helpful grab columns no null values well)? edit: how table column 'c'

How do I change the number of ticks in matlab histogram and change axis numbers font size -

i want the x-axis display 1 2 3 4 5 6 the y-axis display 0 20 40 60 80 100 change numbers font size 14 i've tried setting different axis property (ref. commented lines of code in script below) none of them affect graph. %code generate dicesum dicesum = mydiceroller(1,500); figure(1) %create histogram hist(dicesum,ndice*6) %label axes xlabel('value of roll','fontsize',16) ylabel('number of times rolled','fontsize',16) %set(gca,'x','fontsize',14) %set(gca,'yticklabel',{'0' ;'100'}) %set('xtick','fontsize',14) %set('xlim',[0,6], 'ylim',[0 ,100]) %set('xtick',[0:1:6],'ytick',[0:20:100]) %set(gca,'xlim',[0 6]) %set(gca,'xtick',[0 1 2 3 4 5 6]) %set(gca,'xticklabel',str2mat{'0','1','2','3','4','5','6') %xlim([0 6]) this separate function i'm using creat

ractivejs - Update "progress bar" based on selection in Ractive -

i new ractive.js. trying achieve based on id selection(from combo box),update appropriate progress bar. in below sample, there 2 progress bars , 4 buttons(+25,+10,-25,-10).user can select progressbar(say "first") , press buttons +25 etc.when user performs action, appropriate progressbar should updated(in case "first" "25"). i have tried not sure how select context based on progressbar selection.in case,both progress bars updated irrespective of have selected in select box. please let me know how can resolve issue , tell me if there way clean code(something ng-repeat etc) please see code in see full code here.... .progress-bar { position: relative; width: 200px; height: 40px; border: 1px solid black; } .progress-bar-fill { height: inherit; background-color: orange; } .progress-bar-fill-red { height: inherit; background-color: red; } .progress-label { position: relative; top: 3px; left: 5px; color: #000; } input[type=range] { positi

PHP class doesn't recognize this->method() -

when trying access method i've defined in php class within method in same class, following error: parse error: syntax error, unexpected '->' (t_object_operator) in /var/www/ ... /toc.php on line 57 previously, i'd these functions sitting outside of class, including them needed them. having moved them one, @ first thought must having issue this user having, instance of class, can call render method file no problems. commenting out line this->printtreearray($sectionprojects); eliminates error. here's class: <?php class toc{ private function printtreearray($sectionprojects){ echo "var tocnodes = [\n"; //print each section, loop print each one's problems $i = 0; foreach($sectionprojects $sectionproject){ if($i != 0){ echo ",\n"; } $project = $sectionproject->getproject(); //get due date mouseover text $due

javascript - What does %%SOMETEXT%% Mean in PHP form -

today, came php form using variable/constant names or else(i don't know) in following manner <tr> <td align="left">email address<br> <input name="email" type="text" class="cartform" value="%%email%%" size="25"> %%emailrequired%% </td> </tr> <tr> <td align="left">first name<br> <input name="firstname" type="text" class="cartform" value="%%firstname%%" size="25" onchange="setshipping()"> %%firstnamerequired%% </td> </tr> can please explain meaning of value="%%email%%" it displays added email if session set, i.e behaves assigning value of variable in value attribute, can find variable/constant declared/defined ? in advance.

java - cannot find symbol...? -

this question has answer here: what “cannot find symbol” compilation error mean? 7 answers i have write code takes in string of 3 letters , converts give complement dna (a==t, c==g , reverse) string. although think code okay, keeps giving me same error "cannot find symbol" at string dna (main method), twice in method header of watsoncricktripletcompliment. know going wrong public class dnautilities { public static void main (string[] args) { string dna = "agt"; //cannot find symbol system.out.println (watsoncricktripletcomplement(dna)); } public static string watsoncricktripletcomplement (string dna) { /*cannot find symbol @ both string*/ stringbuilder builder = new stringbuilder(); if (dna.length() > 3 || dna.length() < 3 ) return ""; else { for(int

swift - iOS, Error when initializing GMSPlacesClient - unrecognized selector sent to instance -

i trying integrate google maps api's autocomplete feature on app. i trying instantiate gmsplacesclient on viewcontroller's viewdidload override, according documentation here. https://developers.google.com/places/ios-api/start var placesclient: gmsplacesclient? override func viewdidload() { placesclient = gmsplacesclient() super.viewdidload() } gmsservices has been instantiated on appdelegate using key. but i'm getting following error during instantiation. 2015-10-02 22:04:59.734 food2eat[93509:13849667] -[nsthread gtm_performblock:]: unrecognized selector sent instance 0x7ffc03f04f80 2015-10-02 22:04:59.766 food2eat[93509:13849667] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nsthread gtm_performblock:]: unrecognized selector sent instance 0x7ffc03f04f80' what doing wrong? faced same problem. error started after changed gms api key.

php - Increasing database field by specified percentage -

i have product information stored in mysql database. "price" column in database contains numeric price. i need write function in php can go through values , increase them specified percentage, not sure proper way go it. there function in mysql can it, or prices need read database, modified, , written database? the appropriate sql is: update t set price = price * (1 + $percentage / 100);

c++ - Simple Assembly Language doubts -

i had worked out code assignment , tells me i'm not doing correctly.. hope can take @ it. thank you! area reset, code, readonly entry ldr r1, = 0x13579ba0 mov r3, #0 mov r4, #0 mov r2, #8 loop cmp r2, #0 bge done ldr r5, [r1, r4] , r5, r5, #0x00000000 add r3, r3, r5 add r4, r4, #4 sub r2, r2, #1 b loop ldr r0, [r3] done b done end write arm assembly program add hexadecimal digits in register 1 , save sum in register 0. example, if r1 initialized follows: ldr r1, =0x120a760c when program has run completion, register 0 contain sum of 1+2+0+a+7+6+0+c. you need use following in solution: · 8-iteration loop · logical shift right instruction · , instruction (used force selected bits 0) i know did not use lsr. should put it? i'm getting started on assembly hope makes improvements on code..

Resizing listbox with Python Tkinter and grid layout manager -

i trying write simple app 2 side-by-side scrollable listboxes. want them each take half window irrespective of window size. while window resizable, listboxes remain same size , centered horizontally in respective halves. doing wrong? from tkinter import * import os import sys class scrollablelist(frame): def __init__(self, parent, vscroll=true, hscroll=false): frame.__init__(self, parent) self.grid(sticky=nsew) if vscroll: self.vscrollbar = scrollbar(self, orient=vertical) self.vscrollbar.grid(row=0, column=1, sticky=n+s) if hscroll: self.hscrollbar = scrollbar(self, orient=horizontal) self.hscrollbar.grid(row=1, column=0, sticky=e+w) self.listbox = listbox(self, selectmode=single) self.listbox.grid(row=0, column=0) if vscroll: self.listbox['yscrollcommand'] = self.vscrollbar.set self.vscrollbar['command'] = self.listbox.yview

virtual memory - Why is the size of stack segment much smaller than ulimit -s? -

i've noticed that, in ubuntu 12.04 x64, programs map stack segment virtual address range like: 7fff0f59b000-7fff0f5bc000 rw-p 00000000 00:00 0 [stack] since 0xbc000 - 0x9b000 = 0x21000 = 135168, size smaller value given ulimit -s (8192kb) could tell me why? stack segment grow automatically 8mb limit? thank in advance. i found reason. ulimit -s upper limit, not initial committed virtual memory stack. grow. sill don't know how achieve that. "sub rsp, size; mov [rsp], imm" not work.

Downloading multiple pdf's via wget into one output...issue -

i have issue wget i'm experiencing. i'm working on studio download multiple pdf's via wget , export them master file. code i'm utilizing is: wget -i wgeturl [which contains of urls] -o wgeturldownloads the problem i'm experiencing each iteration of download overwrites previous download. so, i'm expecting see multiple files, i'm seeing one. any suggestions? tl;dr: i'm using wget download multiple (60+) pdfs , outputting them 1 file. it's not working expected though. halp! download files individually , use pdftk merge them.

windows - cookies must be allowed error in microsoft edge? -

i have upgraded pc windows 10. getting "cookies must allowed" error while logging windows mail or gmail accounts using microsoft edge. working fine in other browsers edge giving me trouble. have set "don't block cookies " in browsers settings .

php - Not able to display data through ajax in codeigniter -

i want show restaurant after selecting area dropdown list. code did not show restaurant name , menu button of restaurant please tell me did mistake its model code function select_record($table, $where = null) { $this->db->select(); if ($where) $this->db->where($where); $this->db->from($table); $query = $this->db->get(); // echo $this->db->last_query(); return $query->result(); } controller code public function get_rests() { $cit_id = $this->input->post('cit_id'); $area = $this->input->post('areaid'); $where = array( 'city_id' => $cit_id, 'city_area_id' => $area ); $data = $this->bulk->select_record('restaurant', $where); $html = '<div class="container" id=""> <table align="centre" class="table table-condensed table-striped table-hover no-margi

How to handle routes in rails api -

i learning api on rails,and code below routes.rb require 'api_constraints' rails.application.routes.draw devise_for :users namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/' scope module: :v1, constraints: apiconstraints.new(version: 1, default: true) resources :users, :only => [:show] end end end users_controllers.rb class api::v1::userscontroller < applicationcontroller respond_to :json def show respond_with user.find(params[:id]) end end when run rails server localhost:3000/users/1 gives me error no route matches checked routes using rake routes , included in routes `api_user /users/:id(.:format) api/v1/users#show' but don't know why gives me error api_constraints.rb class apiconstraints def initialize(options) @version = options[:version] @default = options[:default] end def matches?(req) @default || req.headers[

Warning messages for running r script on 10-folds cross-validation classification model of customer churn -

i'm beginner in r, i'm tring customer churn data, built classification model, , tried use cross validation evaluate our model's performance, ther wrong code below: """ setwd("h:/r") source("cutoff-plot.r") source("classification-metrics.r") library(tree) negative.label <- "no" positive.label <- "yes" class.labels <- c(negative.label,positive.label) data.set <- read.csv("churn.csv") data.set$churn <- factor( as.numeric(data.set$churn==positive.label), levels=0:1, labels=class.labels) f <- churn ~ . n.folds <- 10 fold.idx <- sample(rep(1:n.folds, length=nrow(data.set))) p.linear <- rep(na, nrow(data.set)) p.tree <- rep(na,nrow(data.set)) (k in 1:n.folds) { fold <- (fold.idx == k) linear.model <- glm(f, data.set[-fold,],family=binomial) tree.model <- tree(f, data.set[-fold,]) p.linear[fold] <- predict(linear.model,data.set[fold, ]) p.tree[fold

python - NameError: name ... is not defined -

i trying make rpg game in python 2.7 but, run problem. try pygame draw starting_money , stam on screen.(i have them in init function in player_1.py.) when run it, says starting_money , stam not defined. (yes, have imported player_1 via player_1 import *.) here example of code: import pygame pygame.locals import * player_1 import * monster import * background_colour = (0,0,0) (width, height) = (800, 800) screen = pygame.display.set_mode((width, height)) pygame.display.set_caption('rpg game') screen.fill(background_colour) pygame.display(starting_money(500), stam(100)) pygame.display.flip() running = true while running: event in pygame.event.get(): if event.type == pygame.quit: running = false` and here example of player_1.py import pygame pygame.image.load('player1.png') class hero: def __init__(self, hp, alive, starting_money, stamina, player1_sprite, player1, run): self.starting_money = starting_money self.money = 500 se

c++ - Can a function return the same value inside a loop, and return different values outside of loops? -

it acts this. fun();//return 1; (int i=0;i++;i<100) fun();//return 2; fun();//return 3; i don't want manually, like: static int i=0; fun(){return i}; main() { i++; fun();//return 1; i++; (int i=0;i++;i<100) fun();//return 2; i++; fun();//return 3; } new classes , static variables allowed. i trying design cache replacement algorithm. of time use lru algorithm, but, if use lru algorithm inside loop cache thrashing. https://en.wikipedia.org/wiki/thrashing_(computer_science) i need know if inside loop. can use lfu algorithm avoid thrashing. an obvious way of doing using __line__ macro. return source code line number, different throughout function.

big o - Determining the time complexity of this portion of code -

//assume these 2 arrays given user , don't know // contents int a[5] = {1,0,2,1,0}; // (1) operation int y[5] = {0,0,1,1,2}; // (1) int n = 5; // (1) for(int i=0; i<n; i++){ // (n) operations if(a[i]!= y[i]){ // (n) operations in worst case..? cout << "hello" << endl; // (n) operations in worst case? } } i confused nested statements, know loop occurs "n" times , proportional input size. however, if statement proportional "n" in case well? cout statement proportional "n". mean piece of code has running time of o(n^3)..? confused constant operation , isn't in terms of proportionality input size.. assuming worst case here no items match.. you can calculate like: for(int i=0; i<n; i++){ if(a[i]!= y[i]){ cout << "hello" << endl } } you can if(a[i]!= y[i]) 1 operation complexity o(1) , in worst case executed n times, once in each iter

php code reuse. Is there a better way to do it? -

i have upgrade code. in old code had 2 functions: display_maker_success() , display_maker_fail() realised can combine 2 functions 1 display_maker_stat() putting more arguments function. much! is better way this? want more code reuse. function display_maker_success($link, $userid){ $status="closed"; $result="completed"; $sql = "select start, name wuuk tasker_id ='$userid' , status ='$status' , result ='$result' order id desc limit 6;"; $result = mysql_query($sql, $link); $isempty=mysql_num_rows($result); if ($isempty ==0) { echo "no record"; } else { echo "<table border=1>"; echo "<tr><th>date & time</th><th>name</th><th>status</th></tr>"; while ($row = mysql_fetch_array($result, mysql_num)) { echo "<tr><td>$row[0]</td><td>$row[1]</

javascript - Use a variable as name to access nested elements of another array -

i each-loop array build in helper: template.article.helpers({ section: function() { return [ {type: 'cars', sectiontitle: 'cars'}, {type: 'vegetables', sectiontitle: 'vegetables'} ]; }, }); the data articles comes router: router.route('/article/:_id', { name: 'article', data: function() { return { article: articles.findone({ _id: this.params._id }) } } }); but want access subelement of article type of helper. in example each loop done 2 times: first want use ../article.cars , ../article.vegetable . hope understand problem. want name of subelement helper type: <template name="article"> {{#each section}} <h1>{{this.sectiontitle}}</h1> <ul> {{#each ../article.type}} <!-- should '../article.cars' , '../article.vegetable' --> <li>{{thi

performance - SVG Images and CPU usage -

i have little question using svg "modern website". lately told using svg isn't idea because use cpu (is linked fact svg in fact vector graphic ?), might bad on mobile devices because of low cpu have. so "true" ? because i'haven't found article talking that. no it's not true. here's old out of date article microsoft . it's out of date because uas use gpus extensively these days (assuming device has gpu). microsoft has removed elves workshop test uas we're @ several hundred presents per minute time did so. having said can lots of powerful stuff svg if display graphic hundreds of animating objects, something's got process , processing must use battery.

jquery mobile - Jquerymobile Footer hiding and showing again with button -

i want add show , hide button fixed footer on jquerymobile. tried add close button did not do. <div data-role="footer" data-position="fixed"></div> thanks... i found solution. made collapsible block. this: <div data-role="main" class="ui-content"> <div data-role="collapsible"> <h1>click me - i'm collapsible!</h1> <p>i'm expanded content.</p> </div>

javascript - Js open devtools -

i using google chrome dev tools. know how open devtools, how open (devtools) js , html: <!doctype html> <html> <head> <title></title> </head> <body> <button onclick="function()">open dev tools</button> <script type="text/javascript"> function function() { "code open devtools ......" }; </script> </body> </html> but code code open devtools ...... ? simply press f12 on keyboard

android - RecyclerView show partial results -

i'm having strange problem filling recyclerview properly. have tablayout 4 tabs,in first tab want show list of contacts shows partial results ( 3 contacts or not @ all) while contacts list 250. have noticed @ first first 2 tabs instantiated , if example press third tab , first 1 shows expected results. this adapter: public class rvadapter extends recyclerview.adapter<rvadapter.customviewholder> { private static list<contact> contacts; // provide reference views each data item // complex data items may need more 1 view per item, , // provide access views data item in view holder public static class customviewholder extends recyclerview.viewholder { // each data item string in case public textview mtextviewname; public checkbox mcheckbox; public textview mtextviewnumber; public customviewholder(view view) { super(view); this.mtextviewname = (textview) view.findviewbyid(r.id.tv_

bundle - jspm preprocessing (injecting settings for the targeted environment) when bundling -

is there way preprocess .js files (i.e. inject environment specific settings) when bundling using buildstatic? i don't know way pre-process js files during bundling can have different files/modules different environments , use js api swap development version production one: gulp.task('jspm', function() { var builder = new jspm.builder(); function production(builder) { var systemnormalize = builder.loader.normalize; builder.loader.normalize = function(name, parentname, parentaddress) { if (name === 'ember') name = 'ember/ember.prod'; if (name === './app-config.dev') name = './app-config.prod'; return systemnormalize.call(this, name, parentname, parentaddress); }; } production(builder); return builder.loadconfig('./config.js') .then(function() { return builder.buildstatic('app/main', 'dist/app.min.js', { sourcemaps: false, minify: false, mangle: false})

How to compute sum of all the combinations of given list of numbers? -

suppose have list of numbers - a1,a2,a3,a4,a5,....,an. how can compute - (a1*a2)+(a1*a3)+(a1*a4)+(a1*a5)+(a1*a6)+.... ? ex-for 1,2,3 ,i need calculate 1*2+2*3+1*3=11 . also generalize solution combinations containing more 2 terms ex 3 terms- (a1*a2*a3)+(a1*a3*a4)+(a1*a4*a5)+(a2*a3*a4)+.... import itertools def sumofcombinations(l,s): return sum(prod(seq) seq in (itertools.combinations(l, s))) def prod(l): product = 1 x in l: product*=x return product #exemple mylist = [1,2,3] size = 2 print(sumofcombinations(mylist,size)) this job in python. there more pythonic ways accomplish this. results there.

mysql ST_WITHIN with POLYGON -

i not able return following test. mysql version: 5.6.16 (win32) select (st_within(geomfromtext('point(110.341903 1.558064)'), st_geomfromtext( "polygon((1.558467 110.341781 1.558081 110.342317 1.557764 110.34175 1.558467 110.341781 ))" ))) i want see point within polygon. map point within, did wrong? i did try on, doesn't work mysql> set @g1 = st_geomfromtext('point(110.341903 1.558064)'); query ok, 0 rows affected (0.00 sec) mysql> set @g2 = st_geomfromtext('polygon((1.558467 110.341781 1.558081 110.3423 17 1.557764 110.34175 1.558467 110.341781 ))'); query ok, 0 rows affected (0.00 sec) mysql> select st_within(@g1,@g2); +--------------------+ | st_within(@g1,@g2) | +--------------------+ | null | +--------------------+ 1 row in set (0.00 sec) you didn't add commas after each pair of values in definition of polygon. you have: polygon((1.558467 110.341781 1.558081 110.34231

jquery - AJAX call opens php URL instead of return to callback execution -

i have problem ajax callback: 1) in login.html page use: $.post("login.php", formdata, function(data) { } 2) in login.php: echo $data='pass'; 3) problem - on submit event: browser doesn't update login.html callback. instead, displays login.php - white screen 'pass' or 'fail' string, instead of updating login.html page you need use : preventdefault(); $(function () { var yourform = $('#yourform'); yourform.submit(function (e) { $.ajax({ type: yourform.attr('method'), url: yourform.attr('action'), data: yourform.serialize(), success: function (data) { alert('ok'); } }); e.preventdefault(); }); });

c - Pointer to a function that accepts both const and non-const arguments -

i want write wrapper read , write unix functions, read has const void pointer parameter, , write simple void pointer parameter. so, prototype this, fail 1 of functions: typedef ssize_t (*genericstreamhandler)(int, const void*, size); do not prototype function signature if code needs allow incompatible functions. the following compiles without warnings/errors. #include <stdio.h> ssize_t file_read(int h, const void* b, int sz) { if (b) return 0; return h + sz; } ssize_t file_write(int h, void* b, int sz) { if (b) return 0; return h + sz; } //typedef ssize_t (*genericstreamhandler)(int, void*, int); // v--- no function prototype typedef ssize_t (*genericstreamhandler)(); int main(void) { genericstreamhandler gfh1 = file_read; genericstreamhandler gfh2 = file_write; char buf[10]; return (*gfh1)(0, buf, 10) + (*gfh2)(0, buf, 10); } otoh, better answer may lie in taking approach not need common type variant

python - How do I calculate Pr(model|data) in Bayesian inference with extremely small numbers? -

i'm doing bayesian inference (manually, using grid search) in python. want calculate probability of each model given data. problem can calculate 'evidence' in log, otherwise 0. so, though between 0-1, can't results for: pr(data|model1) / (pr(data|model1) + pr(data|model2)) since each term 0 in non-log form. any ideas? thanks let logpr1 , logpr2 log(data|model1) , log(data|model2) , respectively, , suppose in [57]: logpr1 = -802 in [58]: logpr2 = -800 if try express probabilities (not logarithms of probabilities), 0: in [59]: np.exp(logpr2) out[59]: 0.0 now want compute log(pr(data|model1) / (pr(data|model1) + pr(data|model2))), which can write as log(pr(data|model1)) - log(pr(data|model1) + pr(data|model2)). for last term, can use function numpy.logaddexp (which essential tip in answer; see scipy.misc.logsumexp ). calculation is: in [60]: logp = logpr1 - np.logaddexp(logpr1, logpr2) in [61]: logp out[61]: -2.12692801104299

Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app -

i trying friend name , ids graph api v2.0, data returns empty: { "data": [ ] } when using v1.0, ok following request: fbrequest* friendsrequest = [fbrequest requestformyfriends]; [friendsrequest startwithcompletionhandler: ^(fbrequestconnection *connection, nsdictionary* result, nserror *error) { nsarray* friends = [result objectforkey:@"data"]; nslog(@"found: %i friends", friends.count); (nsdictionary<fbgraphuser>* friend in friends) { nslog(@"i have friend named %@ id %@", friend.name, friend.id); } }]; but cannot friends! in v2.0 of graph api, calling /me/friends returns person's friends use app. in addition, in v2.0, must request user_friends permission each user. user_friends no longer included default in every login. each user must grant user_friends permission in orde

udp - Forward Error Correction in rtp h264 -

i trying implement forward error correction , recovering lost packets in rtp h264 packetization mode 0 , mode 1.can me how works.i have found following libraries 1- https://github.com/catid/longhair 2- https://github.com/bulat-ziganshin/fastecc 3- https://github.com/arashpartow/schifra and following rfc https://tools.ietf.org/html/rfc5109 but no example implement.i free implement other methods because not targeting interoperability other voip devices. please if has experience using above libraries in networking please share.

modify content of flask page with another python script -

i have 2 python scripts: tnk_flask.py : creates flask webserver , 2 pages. pitoka.py : creates random number. my goal following: when run pitonka.py , generate random number i'd pass tnb_flask.py , but, after refreshing pages nothing changes. what can mistake? tnb_flask.py: from flask import flask # ezzel importáljuk ki pitonka import * app = flask(__name__) @app.route('/') def index(): denis = alma() return str(denis) @app.route('/tuna') def index__(): return str(numbi) if __name__ == "__main__": app.run(debug=true) pitonka.py: from flask import flask # import tnb_flask import random numbi = random.randint(10, 100) print(numbi) def alma(): return numbi + 17 in pitonka.py assigning random number variable. random variable once. instead return random number in function. def alma(): return random.randint(10, 100) + 17

javascript - can't get any file data, It shows file data empty -

this question has answer here: jquery ajax file upload php 4 answers i did uploading files via ajax. can't file data. shows file data empty. here ajax part . $("#personal_image").on('click',function(event) { event.preventdefault(); var datastring = $("#personal_image").serialize(); console.log(datastring); $.ajax({ type: "post", url: location.origin+"/user/parsonal_image_submit/", secureuri :false, fileelementid :'user_image', data: datastring, datatype: "json", success: function(data) { //success }, error: function() { //error } }); }) check below code. hope work you. please u

Pass generator 3.6 python blank screen -

when press f5(python idle) blank screen when follow press 1 go generator e.c.t #all imports used import random import time import re import sys import string def menu(): print("welcome password generator , checker") choice = int(input(""" 1) generate password 2) check password 3) quit """)) if choice == 1: gp(10) elif choice == 2: cf() elif choice == 3: print("goodbye") time.sleep(0.5) print("come next time") sys.exit() else: print("please select valid choice") def cf(): print("welcome password checker") #i think def underneath message maybe problem idk def gp(num): print("welcome password generator") time.sleep(0.5) print("this generator generates range of symbols,characters , numbers strongest , secure password") password = " " n in range(num): x =

Question regarding C#'s `List<>.ToString` -

why doesn't c# list<> 's tostring method provide sensible string representation prints contents? class name (which assume default object.tostring implementation) when try print list<> object. why so? the simple answer is: that's way is, i'm afraid. likewise list<t> doesn't override gethashcode or equals . note have little way of formatting pleasantly other call simple tostring itself, perhaps comma-separating values. you write own extension method perform appropriate formatting if want, or use newer overloads of string.join make pretty simple: string text = string.join(",", list);

c# - Hash files are different after taking same screen shot with Selenium -

i'm trying learn automated tests, using selenium. i'm working alone, , have docs, google , guys. using selenium in vs-2105, save screen shot of website image file location, , stop debugging @ point. file becomes 'expected' result. i comment line out, run again, taking screen shot saving different location. files, although of same size, have different hash values. to eyes identical. is there wrong approach? this code run create 'master' _webdriver.navigate().gotourl(url); var accept = _webdriver.switchto().alert(); accept.accept(); iwebelement menu = _webdriver.findelement(by.id("link")); menu.click(); system.threading.thread.sleep(500); var screenshot = _webdriver.getscreenshot(); var filename = "expandmenuinplan.png"; var origfile = _testimagespersistentpath + filename; screenshot.saveasfile(origfile, openqa.selenium.screenshotimageformat.png

swift - How is the name of the first item in the MacOS app menu localized? -

i found name of first menu dictated bundlename , $(product_name). wanted him support localization, , each region displayed name, didn't find it. are there relevant documents or cases can give me help, thank you?. in project, add strings file named infoplist.strings , add entry cfbundlename localize file , entry per supported language: cfbundlename = "¡mi aplicación!"; this allow name of app appear localized in app menu , in standard panel. other info.plist string entries can localized in infoplist.strings file (e.g., cfbundlegetinfostring , nshumanreadablecopyright , nscontactsusagedescription , etc.). see keys in xcode, open info.plist file , control-click in editor pane of plist see contextual menu , select show raw keys/values .

Issue with Apriori Function in R -

i new data mining. i've got assignment print association rules against confidence using apriori function (package : arules) in r. problem prints 1 item on rhs. below program used : a_list <- list( c("i1","i2","i5"), c("i2","i4"), c("i2","i3"), c("i1","i2","i4"), c("i1","i3"), c("i2","i3"), c("i1","i3"), c("i1","i2","i3","i5"), c("i1","i2","i3") ) names(a_list) <- paste("t",c(1:9), "00", sep = "") table5_1 <- as(a_list, "transactions") rules <- apriori(table5_1, parameter = list(supp = 0.21, conf = 0.7, target = "rules")) inspect(rules) output : lhs rhs support confidence lift count [1] {} => {i2} 0.7777778 0.7777778 1.000000 7 [2] {i4} => {i2} 0.

javascript - call static function in class in another helper function in the same file -

i have class in file contains static functions called in js files. module.export = class myclass{ static create(){ ... } } // helpers function callcreate(){ .. } i want call static function of myclass in callcreate helper function. how can this? the static members of class accessed like: class myclass { property() { console.log('i normal member'); } static func() { console.log('i static member'); } static functhis() { console.log('i static member'); console.log(this === myclass); // true this.func(); // run fine static member of class this.property(); // give error normal member of class } } (new myclass()).property(); myclass.func(); myclass.functhis(); static members directly accessed class name , not linked object. also, can use static member of class inside of static function. notice: pointed out @felixkling inside static function this refer d

sql server - SSIS Script - Export tables to files with metadata and import them using script task -

i have requirement export 100-150 tables sybase out .csv files on daily basis. need export metadata of each table (column names + data types) when import them, dont have guesstimate metadata. have gotten first part done using code here: welcome techbrothersit: c# - how export data sql server table or view text file in c sharp [^] however believe need metadata when importing these files back, otherwise how code know data type set column to? i still not sure code 2nd part, is, how import these files tables using code. assume need generated metadata figure out data types. 3rd party add-ons not option, hard requirement to use file based cdc hence option. can on this?

Displaying selectInput in sidebar based on tabsetPanel selection in R shiny -

i'm trying generate list in selectinput, dynamically. have sidebarpanel in have declared tabsetpanel. each tabsetpanel have different outputs, of want display in sidebar. output of first tab selectinput or perhaps 2 selectinputs, while same go second tab. here sidebarpanel code in ui.r ## ui.r sidebarpanel( tabsetpanel( tabpanel("az", uioutput("atozplayerlist")), tabpanel("byteam", uioutput("byteamplayerlist")) ), ),....... in server.r, have written following: ## server.r output$atozplayerlist <- renderui({ selectinput("alphabet", "players a-z", choices=atoz, selected=0) htmloutput("list") }) output$byteamplayerlist <- renderui({ selectinput("team", "teams", choices=teamlist, selected=0) htmloutput("list") }) but not work, nothing rendered in sidebarpanel. feel i'm missing som

Bit field structure arrays in C -

how can create bit-field array variable size? following code tried, didn't work. #include <stdio.h> int main() { int n=4; struct bite{ unsigned a1:2; unsigned a2:2; : : unsigned a(n-1):2; unsigned a(n):2; }bits; for(i=1;i<=n;i++) bits.a[i]=i; for(i=1;i<=n;i++) printf("%d ",bits.a[i]); return 0; } the members of struct cannot defined @ runtime. you simulate bit array using char array , macros. #define bitarray(array, bits) \ unsigned char array[bits / 8 + 1] #define setbit(array, n) \ { array[n / 8] |= (1 << (n % 8)) } while (0) #define getbit(array, n) \ ((array[n / 8] >> (n % 8)) & 1) int main(void) { bitarray(bits, 42); /* define 42 bits , init 0s (in fact allocates memory (42/8 + 1) * 8 bits). */ setbit(bits, 2); /* set bit 2. */ int bit2 = getbit(bits, 2); /* bit 2 */ ...