Posts

Showing posts from July, 2015

javascript - d3 Line Chart animations from left to right -

Image
i interested create line chart -- draws left right -- connecting dots in x-axis. http://bl.ocks.org/markmarkoh/8700606 http://bl.ocks.org/duopixel/4063326 this jsfiddle i've made start creating chart. http://jsfiddle.net/nyeax/1512/ //__invoke line $('[data-role="line"]').each(function(index) { createline(this); }); function createline(el){ var w = $(el).data("width"); var h = $(el).data("height"); var svg = d3.select($(el)[0]) .append("svg") .attr("width", w) .attr("height", h); var data = d3.range(11).map(function(){return math.random()*10}) var x = d3.scale.linear().domain([0, 10]).range([0, 700]); var y = d3.scale.linear().domain([0, 10]).range([10, 290]); var line = d3.svg.line() .interpolate("cardinal") .x(function(d,i) {return x(i);}) .y(function(d) {return y(d);}) var path = svg.append("path") ...

Php array error with sendgrid -

this script sending newsletter users. code below has limit 5 testing. i'm having error: catchable fatal error: argument 1 passed sendgrid\email::settos() must of type array, string given, called in /var/www/web/web/sengrid.php on line 44 , defined in /var/www/web/web/sendgrid-php/lib/sendgrid/email.php on line 90** <?php ini_set("display_errors", "1"); error_reporting(e_all); require_once ('inc/db.php'); require("sendgrid-php/sendgrid-php.php"); $sendgrid = new sendgrid('myapikey'); $email = new sendgrid\email(); $resultado = mysqli_query($dbc,"select email, hash newsletter enviado = '0' , newsletter = '1' limit 5"); $totalrows = mysqli_num_rows($resultado); if ($totalrows == 0){ echo "<p>no results</p>"; } $rss = ""; if(!$xml = simplexml_load_file('http://www.test.com.ar/rss.php') ) { echo 'unable load xml file'; } else { for...

java - How to Iteratre over Future<List> Object? -

the return value of call() method list<person> . mycallable class looks this: public class mycallable implements callable <list<person>>{ public list<person> call() throws exception { ... return list } public mycallable(list<account> accountlist) { super(); } } below code im writing in callablefuture class executorservice executor = executors.newfixedthreadpool(nthreds); list<future<list<person>>> list = new arraylist<future<list<person>>>(); (int = 0; < 20; i++) { callable<list<person>> worker = new mycallable(accountlist); future<list<person>> submit = executor.submit(worker); for(future<list<person>> :list){ //list.add(submit); } } i don't k...

r - Using geom_abline() and ggplot -

Image
i beginner in ggplot2 --it's been 4 days since have started experimenting it. so, apologize if question sounds basic. i'd appreciate guidance--i've been struggling issue hour. i experimenting using geom_abline() below: p <- ggplot(mpg, aes(cty, hwy)) + geom_point() p + geom_abline() + facet_wrap(~cyl) this works in can see reference line in 4 faceted graphs below: later, using related dataset mtcars see happens geom_abline() p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() p + geom_abline() + facet_wrap(~cyl) however, when ran command, couldn't see geom_abline(). quite surprisingly, found similar version of above command in file, , says " geom_abline() out of range " while know "out of range" means, how know whether in particular dataset, abline() out of range? can override forcing use specific slope , intercept, i'd consider bit of hacking--i.e. modifying code after seeing output. there way can know happen...

javascript - Bootstrap radio select through Jquery not working -

i have created jquery quiz. answer choices radio buttons. whenever answer choice clicked, code determines whether right or wrong , sends message dom. however, clicking right answer sends message wrong. think must due bootstrap or way set code. pls help. (var = 0; < choices.length; i++) { $(document.createelement('label')).addclass( 'c-input c-radio').appendto('#choice-block') .attr('id', i); $(document.createelement('input')).appendto('#' + i) .attr('type', 'radio').attr('id', * 100); $(document.createelement('span')).addclass( 'c-indicator').appendto('#' + i); $(document.createelement('span')).appendto('#' + i) .text(choices[i]); $(document.createelement('hr')).appendto( ...

syntax highlighting - In emacs, how to colorize a row in a CSV based on value in a column? -

i have created major-mode emacs use data analysis. mode works great me it's drab , don't take advantage of color way should. data being analyzed in csv format , i'd colorize rows within based on values in columns. let's have following file in csv format: one,1,2,3 two,4,5,6 three,7,8,9 the rows in csv should colored red based on value in 4th column , intensity of red should increase same value. in case last column should intense red , first should least red. i've read on search based fontification , i'm bit confused how write (matcher . facespec) sets facespec properly. facespec expression evaluates to (face face prop1 val1 prop2 val2…) but how make depend on values in fourth column of csv? guess value in fourth column gets matched how tie face used magnitude of value matched? suppose need generate face on fly based on value matched not sure how so. any ideas? simple example best.

python 2.7 - Dynamic filter on Django query -

i want search in field given user. i have far: def search_engine(model, given_field, text): # stuff result = model.objects.filter(given_field__icontains=text) return result the "given_field" inside filter parameter given in function, variable. create dict dynamic key generated given_field , unpack using ** generate keywords arguments. def search_engine(model, given_field, text): # stuff filters = { given_field+'__icontains': text } result = model.objects.filter(**filters) return result

ios - UITableViewCell reusability issue. Modifying one cell is affecting others -

whenever cell section 3 selected. i'm updating datasource array, , cell's background color changing correctly. however, whenever scroll start seeing random cells modified background color, knowing don't mention in cellforrowatindexpath method , each section in tableview populated separate datasource array/dictionary ! (i'm using storyboard handle ui setup) here's code (focus on section 3) - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { ectextfieldtableviewcell *cell = [tableview dequeuereusablecellwithidentifier:ksettingstextfieldcellreuseidentifier forindexpath:indexpath]; if (indexpath.section == 0) { cell.celltextfield.text = [self.personalinfodatasource valueforkey:kuservalueskey][indexpath.row]; } else if (indexpath.section == 1) { cell.celltextfield.text = [self.contactinfodatasource valueforkey:kuservalueske...

sql server - design deduplication sql statement using NULLS vs MAX VALUE -

i'm trying sculpt sql statement de-dupicate table. the table has 3 keys: key1, key2, key3 used business key. date being used. the rules (assuming matches in key1, key2, key3): if rows have dates, retain max(date) if 1 row has date, , others null, retain row date if rows has date = null, keep rows. i've been using code basis: with cte as( select [key1], [key2], [key3], [date], rn = row_number()over(partition [key1], [key2], [key3], [date] order [date] desc) dbo.table1 ) delete cte rn > 1 i not educated on how apply rules on sql statement. wisdom appreciated. example deduplications: case 1: before dedupication: key1 key2 key3 date 1 1 null 1 1 null 1 1 null after deduplication: key1 key2 key3 date 1 1 null 1 1 null 1 1 null case 2: before dedupication: key1 key2 key3 date 1 1 1/1/2016 1 1 1/1/2016 1 1 1/1/2016 after deduplica...

Subset dataset with time condition in R -

i have dataset in example.txt "09/jan/2016" "05:00:22" "304" 449 "09/jan/2016" "07:00:12" "304" 449 "09/jan/2016" "10:00:02" "200" 10575 "09/jan/2016" "11:00:03" "304" 449 "09/jan/2016" "13:00:03" "304" 449 "09/jan/2016" "20:00:03" "304" 449 "09/jan/2016" "23:00:03" "304" 450 "10/jan/2016" "00:00:03" "304" 449 "10/jan/2016" "03:00:03" "304" 449 "10/jan/2016" "04:00:03" "304" 449 can subset dataset range 6 hour before run code in r? example, open , run code in january 10th, @ 4:15, want subset dataset, like "09/jan/2016" "23:00:03" "304" 450 "10/jan/2016" "00:00:03" "304" 449 "10/jan/2016" "03:00:03...

How to send NSDate in JSON Format through AFNetworking in iOS? -

how send nsdate in json format through afnetworking in ios ? json request - { "from_date" : "11/11/2014", "to_date" : "11/11/2017" } code - // formats date chosen date picker. - (nsstring *)formatdate:(nsdate *)date { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdatestyle:nsdateformattershortstyle]; [dateformatter setdateformat:@"dd'/'mm'/'yyyy"]; nsstring *formatteddate = [dateformatter stringfromdate:date]; return formatteddate; } - (void)updatetodatefield:(id)sender { uidatepicker *picker = (uidatepicker*)todatefield.inputview; todatefield.text = [self formatdate:picker.date]; } // storing date in nsstring dashboard.todatestring = todatefield.text; convert nsdate in string , send it, send other parameters.

Dropdown menu in R plotly? -

i saw on blog using plotly in r possible insert dropdown menu, great ! however, seems new feature included in 4.0 release of plotly, haven't found information. do know if it's possible developpment version ? have information on date of release plotly 4.0 ? you can create dropdown menus plotly r library 2.0. here see example .

angularjs - Changing Tab using Button Click -

<div ng-cloak> <md-content> <md-tabs md-dynamic-height md-border-bottom> <md-tab label="one"> <md-content class="md-padding"> <h1 class="md-display-2">tab one</h1> <md-button class="md-raised">save & next</md-button> </md-content> </md-tab> <md-tab label="two" ng-disabled="true"> <md-content class="md-padding"> <h1 class="md-display-2">tab two</h1> <md-button class="md-raised">save & </md-button> </md-content> </md-tab> </md-tabs> i using angular + angular material , there 2 tab menu "one" , "two" when clicked on "save & next" button next tab should enabled , foucs goes next tab , reverse things should happen when clicked on second tab ...

ios - UISearchController makes content of the UITableView black -

i have problem uisearchcontroller in combination uitabbarcontroller. have 3 tabs. in every tab, have uitableviewcontroller search bar uisearchcontroller set header view of table view follows. searchcontroller = uisearchcontroller(searchresultscontroller: nil) searchcontroller.searchresultsupdater = self searchcontroller.dimsbackgroundduringpresentation = false searchcontroller.hidesnavigationbarduringpresentation = true tableview.tableheaderview = searchcontroller.searchbar tableview.contentoffset = cgpointmake(0, cgrectgetheight(searchcontroller.searchbar.frame)) if start searching , switch other tab without canceling search , return previous tab, content of uitableview become black. have read multiple postings such uisearchcontroller makes controller black or uisearchcontroller causes black screen swift 2.0 . these solutions not work me. if setting definespresentationcontext = true then problem first occur. if omit line content of table view not becomming black search ba...

c# - NumericUpDown Control is not in my list of available controls in Visual Studio 2015 (Community) -

i'm learning c# , following tutorial. the tutorial written vs2013, doing in vs15 (community). says drag numericupdown object in toolbox in designer window not listed. i've tried right clicking , looking in "choose items" dialog and, in fact, numericupdown listed , checked doesn't show in toolbox list. google searches i've found have people saying shows grayed out, mine isn't there, let alone grayed out. i'm working in wpf project. any suggestions? since wpf doesn't have standart numericupdown element have create 1 ourselfs: below posted sample, original here: codeproject <grid margin="1"> <grid.columndefinitions> <columndefinition width="*" /> <columndefinition width="20" /> </grid.columndefinitions> <textbox name="textboxvalue" textalignment="right" grid.column="0"/> <st...

How to add set text bold, italic, super script and sub script in comment text in Word VBA? -

Image
i want format comment text in word template using vba. can add simple text using following code. don't know how format text commenttext = "test bold: bold text & vbnewline & test italic: italic text & vbnewline & test bold italic: bold italic text & vbnewline & test superscript: brandtm & vbnewline & test subscript: h2o" selection.comments.add range:=selection.range selection .typetext (commenttext) 'add comment text end output should following image: the code below add formatted comment selected text. tested in word 2007, , functioning expected. by way, in case need similar in future, start recording macro, add comment, stop recording. resulting macro code should of way there. public sub addcomment() selection.comments.add range:=selection.range selection .typeparagraph .typetext text:="test bold: bold text" .moveleft unit:=wdcharacter, count:=9, extend:...

Android studio gradle - avoid rebuilding of modules -

can somehow tell android studio never build submodules? split apps many modules , reuse modules between apps. have 10+ modules app... so sake of speed want tell android studio, check dependencies of main project , build main project , never check modules or them if not force via clean build. is possible? if include moduels via compiled jar, android studio act that. want same behaviour if don't include jars add modules project. question can desired behaviour if compile modules myself , add jars project or can somehow have same behaviour modules possibility make changes modules main project , force recompilation of modules via clean build or similar?

amazon ec2 - how to get ec2 instances public dns name by ansible playbook -

i playing ansible automate ec2 instances. created ec2 instance , m trying public dns name via ec2_remote_facts module. giving variable not defined in output. playbook: - hosts: localhost connection: local tasks: - name: ec2 instance facts ec2_remote_facts: region: ap-southeast-2 filters: instance-state-name: running register: ec2 - debug: var=ec2.instances.public_name output:play [localhost] *************************************************************** task [setup] ******************************************************************* ok: [localhost] task [create ec2 instance] ***************************************************** ok: [localhost] task [debug] ******************************************************************* ok: [localhost] => { "ec2.instances.public_name": "variable not defined!" } play recap ********************************************************************* localhost ...

recursion - 2D array Maze solve in C -

i have maze represented square array of integers. have find least-cost path (sum of integers) through maze, moving orthogonally. 12323 12323 11232 21111 for instance, track through maze above 1's: x2323 x2323 xx232 2xxxx i wrote recursive function find path, return 0 instead of number of steps. i set breakpoint , find out line below executes (comparison true ) when array location matches num . if(*((int*)table)!=num) return 0; i think have problems int** code: case 3:// main. arrtask3 initialized get2darray. printf("enter size of array\n"); scanf("%d",&arrtask3size); arrtask3size=getarrsize(arrtask3size); get2darr((int**)arrtask3, arrtask3size, 0, 0); num=*((int*)arrtask3); start=(int**)arrtask3; finish=(int**)(arrtask3)+arrtask3size*arrtask3size; task3he(num, arrtask3size, arrtask3, finish, start, 0,...

java - Unable to find a WebElement when invoking an ant job in Jenkins -

Image
i trying invoke ant job in jenkins , failed since web elements not found (i find these elements id). however, can build ant in eclipse without issue. using jenkins-1.651.3 in window7. public class sendemail webdriver browser = new firefoxdriver(); @parameters("url") @test public void openhomepage(string url) throws exception { browser.get("https://exmail.qq.com/"); } @test(dependsonmethods = "openhomepage" ) public void openloginpage() throws exception { webelement loginbutton = browser.findelement(by.linktext("登录")); loginbutton.click(); } @parameters({"username","password"}) @test(dependsonmethods = "openloginpage" ) public void authentication(string username, string password) throws exception { webelement usernamefield = browser.findelement(by.id("inputuin")); webelement passwordfield = browser.findelement(by.id("pp")); webelement checkbox = browser.findelement(by.i...

sql - Insert from one table to another (different databases) -

auth2.dbo.accounts : account_id, login_name , password , other columns... auth.dbo.account : account_id , account , password , other columns... i want insert accounts(account_id,account,password) " auth.dbo.account " " auth2.dbo.accounts " (account_id,login_name , password) , giving other columns values want. i hoping work , once wrote in sql management studio , got error syntax error near " select account_id auth.dbo.account" insert [dbo].[accounts] ([account_id], [login_name], [password], [referral_id], [referral_code], [pcbang], [block], [withdraw_remain_time], [age], [auth_ok], [last_login_server_idx], [event_code], [server_list_mask], [result], [ip], [game_code], [gamecode], [login_event], [email], [security_a_1], [security_a_2], [security_a_3], [security_a_4], [security_q_1], [security_q_2], [security_q_3], [security_q_4], [votepoints], [cash], [country]) values (select account_id auth...

jsonix properties - ogc-schemas .js aren't same -

the manual on jsonix properties @ https://github.com/highsource/jsonix/wiki/properties shows properties being like: name: 'mymodule', typeinfos: [{ type: 'classinfo', localname: 'inputtype', propertyinfos: [{ type: 'attribute', typeinfo: 'boolean', name: 'checked' }] }], but (after npm install ogc-schemas ) seeing is: ln: 'timeclockpropertytype', ps: [{ n: 'timeclock', rq: true, en: 'timeclock', ti: '.timeclocktype' }, with abbreviated names. which should , why doesn't matter if doesn't? disclaimer: i'm author of jsonix . this what's called compact naming . option of jsonix schema compiler generates shorter names in mappings, n instead of name or dens instead of defaultelementnamespaceuri . goal make mappings smaller , since ogc-schemas pr...

python - What the right way to analyse a text for adult content identification? -

i want filter out adult content tweets (or text matter). for spam detection, have datasets check whether particular text spam or ham. for adult content, found dataset want use (extract below): arrbad = [ 'acrotomophilia', 'anal', 'anilingus', 'anus', . . etc. . 'zoophilia'] question how can use dataset filter text instances? i approach text classification problem, because using blacklists of words typically not work classify full texts. main reason why blacklists don't work have lot of false positives (one example: list contains word 'sexy', alone isn't enough flag document being adults). need training set documents tagged being "adult content" , others "safe work". here do: check whether existing labelled dataset can used. need several thousands of documents of each class. if don't find any, create one. instance can create scraper , download reddit content. read instance text cl...

In Android, how to get default focus on Back/Home button on ActionBar -

i have fragment extending preferencefragment, how default focus on back/home button in actionbar. at present default focus on first entry in list. tried below code in main activity well, gave null pointer exception, view home = findviewbyid(android.r.id.home); home.requestfocus(); can try following? (it's more of hack, underlying assumption home button first child) private void requestbackbuttonfocus() { if (toolbar != null) { int childrencount = toolbar.getchildcount(); (int = 0; < childrencount; i++) { if (toolbar.getchildat(i) instanceof imagebutton) { toolbar.getchildat(i).requestfocus(); break; } } } }

javascript - Name automatically an alt tag -

in script how add alt tag value same "nikeair 32" in example? <script> function test_options_rendered(){ $('.test_option_value').each(function(){ if( !$(this).parent().hasclass("conditional")){ $(this).find('input:radio').first().prop("checked", true); // $(".test_radio_option :input:first").prop("checked", true); } }); $('.test_radio_option:contains("nike air32")').append('<img class="option_img" src="https://image.png">'); } </script> if want add alt tag img can this: $('.test_radio_option:contains("nike air32")') .append('<img class="option_img" alt="nike air32" src="https://image.png">') if want more dynamically can this: $('.test_radio_option:contains("nike air32")').each(function() { $(...

c# - Can't send mail from server -

we built asp.net app deployed on client's server, using smtp server. i'm trying have elmah send error emails using erroremailmodule . uses smtp settings configured in web.config, somehow sending emails not working (nothing being sent). the smtp settings configured this: <system.net> <mailsettings> <smtp from="support@xxxxxx.nl"> <network host="xxxxxxx.management.local" port="25" enablessl="true" defaultcredentials="true"/> </smtp> </mailsettings> </system.net> to test if problem elmah or config created little test application uses same setting , tries send email: string = "support@xxxxxxxx.nl"; string = configurationmanager.appsettings["errorreportingemail"]; var message = new mailmessage(from, to, "test", "test"); var smtpclient = new smtpclient(); smtpclient.send(message); this doesn't work eit...

geospatial - Mariadb: geography -

i need check if distance between 2 geographic point less n km . i'm trying execute query: select st_distance( st_geomfromtext('point(45.764043 4.835658999999964)', 4326), st_geomfromtext('point(45.750371 5.053963)', 4326) ) < :n but doesn't work because: so far srid property dummy in mysql, stored part of geometries meta data actual calculations ignore , calculations done assuming euclidean (planar) geometry. ( https://mariadb.com/kb/en/mariadb/st_transform-missing/ ) my goal convert distance metric distance or convert n degrees. how can it? maybe, know better solution? p.s. need solution based on spatial methods (or more better performance). i don't think "distance" function available (yet) in spatial . there regular function in https://mariadb.com/kb/en/latitudelongitude-indexing/ work. however, args , output scaled lat/lng (10000*degrees). code altered avoid scaling, needed in context of blog page. ...

node.js - Safari 9 unable to play HTML5 Video with binary source? -

i'm working on web project using nodejs have video upload , player. video uploaded stored in mongodb in binary form, , when retrive via api localhost/api/media/:id : /*getting media db in binary format*/ res.setheader('accept-ranges', 'bytes'); res.setheader('content-range', 'bytes=0-1/' + media.length); res.setheader('content-type', 'video/mp4'); res.setheader('cache-control', 'public,max-age=0'); res.send(media); this work fine on chrome , firefox, using api give me html5 page video tag this: <video controls="" autoplay="" name="media"> <source src="localhost/api/media/abcde" type="video/mp4"> </video> which run fine on older safari 7. on safari 9 in particular it's not working , show media controller text "loading" , can never play video. try put same video file in localhost , access via localhost/test.mp4 , run ok in s...

linux - Sum numbers in lines grouped in blocks with headers (with Bash and AWK) -

assuming have following example output: node hostabc foofoofoo 1 foo 1 ... 1 ... 1 ... 1 ... 5 ... node hostcde ... 1 ... 10 ... how can sum of numbers each host (without using temporary files, , using bash , awk only)? for example: hostabc 10 hostcde 11 you can use following awk command: awk '/^node/{n=$2;next}{t[n]+=$1}end{for(n in t){print n,t[n]}}' file better explained multiline script: # if line starts 'node' /^node/ { # set n(ame) value of second field n=$2 # no further actions on line next } { # add value of first field t(otals)[n(name)] t[n]+=$1 } # once end of input has been reached end{ # iterate trough t(otals) keys for(n in t) { # print total along name print n,t[n] } }

javascript - Difference between sort(), sort(function(a,b){return a-b;}); and sort(function(a,b){...}) -

Image
i trying understand how sort() works , how supposed use it. i did research (google) , went through similar questions here on stackoverflow, there still few things not 100% clear me. so understanding far following: there are: sort() without parameters : sorts simple arrays of string values alphabetically , in ascending order e.g. // sort alphabetically , ascending: var myarr=["bob", "bully", "amy"] myarr.sort() // array becomes ["amy", "bob", "bully"] sort() function parameter : sorts objects in arrays according properties; items are, however, compared numbers myarr.sort(function(a,b) { return - b; }); sort() function parameter : sorts objects in arrays according properties; items can numbers or strings myarr.sort(function(a, b) { if (a.sortnumber < b.sortnumber) return -1; else if (a.sortnumber > b.sortnumber) return 1; return 0; }); tried sorting following array the...

javascript - Center position of current screen position -

is there option find center position (top , left) of actual screen position? my main goal show div in center of screen no matter scroll or click you can use window attributes center coordinates in pure javascript: var x = window.innerwidth / 2; var y = window.innerheight / 2;

split the statement in a excel file column using a specific keyword -

Image
i have excel file data in multiple columns. need select 1 column file , separate data in each cell of column using specific keyword in cell. keyword same each cell now want is, want separate each alphabet cell , give them title 1 in image below the following vba code should trick: option explicit public sub mainsub() dim arr variant dim srcrow long, destrow long dim wssrc worksheet, wsdest worksheet set wssrc = thisworkbook.worksheets("sheet1") set wsdest = thisworkbook.worksheets.add(before:=wssrc) wsdest.cells(1, 1).value2 = "letter" wsdest.cells(1, 2).value2 = "value" destrow = 2 srcrow = 1 wssrc.cells(wssrc.rows.count, "a").end(xlup).row if instr(1, wssrc.cells(srcrow, 1).value2, "half:", vbtextcompare) arr = split(wssrc.cells(srcrow, 1).value2, "half:")(0) arr = split(arr, "/") destrow = writetodest(arr, "full", destrow, wsdest) arr = spli...

MATLAB: Use variables (defined outside) inside parfor loop -

i need know how work variables defined outside parfor loops. want speed code takes time when using higher number of elements. i try explain example. let's suppose have series of elements move randomly inside loop , calculations take place according position of elements. here example of code: % variables nelements = 5000; ly = 2; vmax = 1; time = 0.1:0.1:20; x = -0.5+rand(nelements,1); y = -ly + ly*rand(nelements,1); zx = []; zy = []; rate = zeros(1,length(time)); vel = zeros(nelements,1); vz = []; % loop parfor ii=1:length(time) ntimes = ii; % counter vel = vmax.*(1-(y./ly).^2) % elements move according velocity profile x = x + vel + randn(nelements,1); y = y + vel + randn(nelements,1); nz = length(zx); if ~isempty(zx) && ~isempty(zy) vz = vmax.*(1-(zy./ly).^2) zx = zx + vz + randn(nz,1); zy = zy + vz + randn(nz,1); end [x,y,zx,zy] = f(x,y,zx,zy); % function uses variables x , y; , if conditions met, creates z element rate(ii)...

android - Blur Mask Filters are not supported -

Image
i have 1 custom class extends view class , in drawing custom bitmaps. problem whenever using class in xml, creates rendering problem. here xml code : <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.custom.drawingview android:layout_width="wrap_content" android:layout_height="wrap_content"/> </relativelayout> there nothing else using in xml still error there, sharing screenshot it, check below. in custom view class have used blurmaskfilter also blurmaskfilter blurmaskfilter = new blurmaskfilter(5, blurmaskfilter.blur.normal); as can see, not able see preview of layout , not component tree . configuration : android studio : 2.1.3 classpath 'com.android.tools.build:gradle:2.1.3' compilesdkversion 24 buildtoolsversion "24.0.0" ...

javascript - jQuery hide appended div items -

i have following code , trying hide/show inner/appended items, such text1, text2 , text3: html: <div id="div1"> <a href="#" id="clickitem">link</a> <br /> text1 <br /> text2 <br /> text3 </div> jquery: var hide = false; $("#clickitem").click(function (e) { if (hide == false) { $("#div1").hide(); hide = true; return; } else { $("#div1").show(); hide = false; return; } }); you can wrap inner text in div , toggle inner div onclick of link. please check below snippet more idea. var hide = false; $("#clickitem").click(function (e) { $("#innerpart").toggle(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="div1"> <a href="#...

java - Saving hash map into SharedPreferences -

this question has answer here: saving hash map shared preferences 6 answers how can save , hashmap in android using below format in sharedpreference hashmap<string, list<string>> mchildmap = new hashmap<>(); the easiest way use google's gson save hashmap json. create wrapper class hashmap the getter , setter methods. refer below answer. https://stackoverflow.com/a/11931812/5425930

JavaScript regex on textarea input -

i trying extract ip addresses apache log file input in textarea field. using regular expressions extracting ip addresses. want see ip addresses printed on screen. cannot understand doing wrong. kindly help <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>regex_example</title> </head> <body style = "background-color: lightgrey"> <center> <h3><u>log miner</u></h3> <br /><hr /> <h5>paste apache log file in box below , click on mine!</h5> <textarea rows="25" cols="200" form="mine_log" id = "logs"> </textarea> <form id = "mine_log" method = "" onsubmit="parselogs(document.getelementbyid('logs').value)"> <input type = "submit" value = "mine!!" /> </form> <script language="javascript" type...

meteor - Angular2 render app 2 times -

i have problem, can`t routing in angular 2. mb fased similar? so, app renders in weird way: <my-app><div> <app-nav-bar _nghost-ile-2=""><ul _ngcontent-ile-2=""> <!--template bindings={ "ng-reflect-ng-for-of": "[object object],[object object],[object object],[object object]" }--><li _ngcontent-ile-2="" ng-reflect-raw-style="[object object]" style="float: left;"> <a _ngcontent-ile-2="" ng-reflect-raw-class="[object object]" ng-reflect-href="/" href="/">home</a> </li><li _ngcontent-ile-2="" ng-reflect-raw-style="[object object]" style="float: left;"> <a _ngcontent-ile-2="" ng-reflect-raw-class="[object object]" ng-reflect-href="/index/books" href="/index/books">books</a> </li><li _ngcontent-ile-2="" ng-reflect-ra...

python - How to initialize OpenGL with glXChooseFBConfig and ctypes module? -

i want make simple opengl animation on tkinter window. dont want include needless dependencies i'm writing scratch ctypes. far have this: #!/usr/bin/env python3 import tkinter import ctypes ctypes import cdll glx_pixmap_bit = 0x00000002 glx_window_bit = 0x00000001 glx_pbuffer_bit = 0x00000004 glx_rgba_bit = 0x00000001 glx_color_index_bit = 0x00000002 glx_pbuffer_clobber_mask = 0x08000000 glx_front_left_buffer_bit = 0x00000001 glx_front_right_buffer_bit = 0x00000002 glx_back_left_buffer_bit = 0x00000004 glx_back_right_buffer_bit = 0x00000008 glx_aux_buffers_bit = 0x00000010 glx_depth_buffer_bit = 0x00000020 glx_stencil_buffer_bit = 0x00000040 glx_accum_buffer_bit = 0x00000080 glx_config_caveat = 0x20 glx_x_visual_type = 0x22 glx_transparent_type = 0x23 glx_transparent_index_value = 0x24 glx_transparent_red_value = 0x25 glx_transparent_green_value = 0x26 glx_transparent_blue_value = 0x27 glx_transparent_alpha_value = 0x28 glx_dont_care = 0xffffffff glx_none = 0x8000 glx_slow_...

java - CSS files doesn't download in JSP page -

this question has answer here: browser can't access/find relative resources css, images , links when calling servlet forwards jsp 7 answers i have simple html page. css files doesn't download in page. have error 404 when try show image in <style> tags in page. nothing works. catalog structure here. home.jsp <%@ page contenttype="text/html;charset=utf-8" language="java" %> <html> <meta charset="utf-8"> <title>title</title> <link href="../../assets/css/style.css" rel="stylesheet"> <link href="../../assets/css/bootstrap.css" rel="stylesheet"> <style> /*h2{*/ /*color: red;*/ /*}*/ body { background: url(../../assets/img/javarush.jpg); } </style> ...

r - Remove unwanted hyphen from variable -

i have data below 0-0098-45.3a-22 0-0104-44.0a-23 0-0983-29.1-22 0-1757-42.5a-22 0-4968-37.3a2-23 000000-44.0a-23 000000-45.3a-42 is there way remove initial unwanted hypen , make below in r 00098-45.3a-22 00104-44.0a-23 00983-29.1-22 01757-42.5a-22 04968-37.3a2-23 000000-44.0a-23 000000-45.3a-42 any helpful. we can use sub remove unwanted - @ 2nd position of string. use ^ specify start of string, capture first character group ( (.) - . metacharacter refers character element) followed - , in replacement use backreference ( \\1 ) captured group. df$v1 <- sub('^(.)-', '\\1', df$v1) df$v1 #[1] "00098-45.3a-22" "00104-44.0a-23" "00983-29.1-22" #[4] "01757-42.5a-22" "04968-37.3a2-23" "000000-44.0a-23" "000000-45.3a-42" data df <- structure(list(v1 = c("0-0098-45.3a-22", "0-0104-44.0a-23", "0-0983-29.1-22", "0-1757-42.5a-22...

ruby - rails devise undefined method username when I want to use it with cancancan -

i want achieve role based authorisation in rails. login use gem devise, works perfect. after including code of cancancan in tutorial error undefined method username , when remove username error undefined method email... here code: ability.rb (to manage user specific role can do) class ability include cancan::ability def initialize(user) user ||= user.new if user.role?(:admin) can :manage, :all elsif user.role?(:mitarbeiter) can :manage, :documents can :manage, :entries end end end a part of user.rb roles = {0 => :admin, 1 => :mitarbeiter} attr_reader :role : def initialize(role_id = 0) @role = roles.has_key?(role_id) ? roles[role_id] : roles[0] end def role?(role_name) role == role_name end a part of application_controller.rb protect_from_forgery with: :exception check_authorization rescue_from cancan::accessdenied |exception| flash[:warning] = exception.message ...

Dominant colors with Image package in python -

Image
i have transparent image , trying extract major colors out of using image module's getcolor() method y = image.open('img.png') y.getcolors() [out]: [(21841, 0), (13328, 1), (8171, 2), (2673, 3), (1337, 4), (1010, 5), (892, 6), (519, 7), (379, 8), (234, 9)] how actual color values (or names) corresponding these indexes? i not sure whether following code snippet finding. convert image object rgba object , use getcolors() follows. from pil import image im = image.open('img.png') rgba_im = im.convert('rgba') print ( rgba_im.getcolors() ) """ <output> [(2673, (218, 215, 209, 255)), (379, (195, 29, 54, 255)), (21841, (208, 208, 209, 0)), (234, (206, 198, 185, 255)), (519, (201, 178, 176, 255)), (1337, (193, 188, 186, 0)), (8171, (182, 176, 174, 0)), (892, (178, 170, 165, 255)), (13328, (168, 26, 41, 255)), (1010, (107, 18, 19, 255))] """

GitLab omnibus Sidekiq refusing to start due to missing Gemfile (8.11) -

a few days ago, 1 of servers hosting community edition of gitlab rebooted (because of hosting provider maintenance). since moment, gitlab instance partially broken : sidekiq refuses start. it restarts in endless loop, following trace in logs (from gitlac-ctl tail ): ==> /var/log/gitlab/ci-sidekiq/current <== 2016-08-29_11:07:56.79639 bundler: failed load command: sidekiq (/opt/gitlab/embedded/bin/sidekiq) 2016-08-29_11:07:56.79654 bundler::gemfilenotfound: /opt/gitlab/embedded/service/gitlab-ci/gemfile not found 2016-08-29_11:07:56.79655 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/definition.rb:23:in `build' 2016-08-29_11:07:56.79655 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:123:in `definition' 2016-08-29_11:07:56.79655 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:91:in `setup' 2016-08-29_11:07:56.79656 /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/bundler-1.1...

Nested ListView in wicket throwing IndexOutOfBoundsException -

i have nested listview in wicket reason throwing indexoutofboundsexception. here relevant markup: <table> <tr wicket:id="datarow"> <td wicket:id="datacell"><span wicket:id="datacontent"></span></td> </tr> <table> and relevant code: listview<user> datarow = new listview<user>("datarow", new abstractreadonlymodel<list<user>>() { private static final long serialversionuid = 1l; @override public list<user> getobject() { ... return getusers(itemoffset, c, filter, sc, isdescending ); // returns list<user> of row objects } }) { private static final long serialversionuid = 1l; @override protected void populateitem(listitem<user> item) { // list of <td>s listview<string> datacell = new listview<string>(...