Posts

Showing posts from January, 2012

java - Libgdx Project crashing after exporting -

i'm trying create game libgdx. game works when i'm testing inside eclipse when try export either android or desktop game starts , crashes immediately. the problem game cannot find assets , throws unhandled exception. use following way load of assets. mainmenu = new sprite(new texture(gdx.files.internal("images/screens/mainmenu.png"))); i have searched exported jar , assets located inside it, yet reason game cannot find them. on desktop work fine when place .jar file assets folder. when create new libgdx project , export it, works fine, add java classes stops working. i have tried searching similar questions here, none of answers solved problem. it can file inside assets folder not wanted. i had similar problem, in assets folder .xcf file gimp file. deleted .xcf file , problem solved.

xamarin.forms - TailTruncation when the label meets the limit of word wrap in Xamarin Forms -

in xamarin.forms tailtruncation mode labels works fine single lines of text. we can force tailtruncation happen @ 2nd or 3rd or nth line, if know in advance lenght of text, using custom renderer one: depechie multilinelabel . but need tailtruncation works when don't know in advance how many lines of text fit in label. if height of label changes, , number of lines of text can fit in it, want tailtruncation happens @ end of available space. not @ line before , neither @ line after. how can tailtruncation happens when text meets limit of available word wrap space inside label bounds? is there custom renderer trick allows calculate number of lines fit inside bounds , set tailtruncation line number accordingly (on both ios , android)? thanks in advance.

vb.net - Font dispose - How to: Implement the Dispose Finalize Pattern (Visual Basic) -

first thing program use 3 5 fonts , when create pdf. i think there's no need dispose fonts objects point of view of resources learning , create habit good. i try do if myfont1 isnot nothing myfont1.dispose() end if or if myfont1 isnot nothing myfont1.idisposable.dispose() end if and "dispose or idisposable not member of font" to implement dispose option need work? https://msdn.microsoft.com/en-us/library/s9bwddyx(v=vs.90).aspx your code should suggested: if myfont1 isnot nothing myfont1.dispose() end if since font type implement idisposable interface explained here .

web services - Java JAX WS generated WSDL vs wsgen -

i have jax ws web service in java, , change type document rpc following line: @soapbinding(style = style.rpc) the problem when try use wsgen.exe (version 2.2.9) jdk 1.8.0_91: "c:\program files\java\jdk1.8.0_91\bin\wsgen.exe" -verbose -cp . com.ws.serviceimpl -wsdl -inlineschemas the wsdl generated method insertdevolutions following: <xs:schema version="1.0" targetnamespace="..." xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:complextype name="arraylist"> <xs:complexcontent> <xs:extension base="tns:abstractlist"> <xs:sequence/> </xs:extension> </xs:complexcontent> </xs:complextype> <xs:complextype name="abstractlist" abstract="true"> <xs:complexcontent> <xs:extension base="tns:abstractcollection"> <xs:se...

javascript - Sticky Nav with Header -

i've made nav sticky header shrinks little scroll i'd have large image above nav user have scroll down, nav rise , stick in place. i'm having trouble finding tutorial. can point me in right direction? function myscroll() { var header = document.getelementbyid("header"); var title = document.getelementbyid("title"); var ypos = window.pageyoffset; var nav = document.getelementbyid("mynav") if(ypos > 300) { header.style.height = "80px"; title.classlist.add("shrink"); nav.style.margintop = "25px"; } else { header.style.height = "150px"; title.classlist.remove("shrink"); nav.style.margintop = "90px"; } }; window.addeventlistener("scroll", myscroll); * { margin: 0; padding:0; } #header { height: 150px; width: 100%; position: fixed; background-color: #f6f6f6; transitio...

encoding - How to print a list of all ascii characters with php? -

Image
i'm traying print ascii characters when index arrives extended characters appears question mark �. see image for example, if echo chr(160); oa== when supposed á how can correct value without change header charset or file encoding? im doing follow: for ($i=0; $i < 255; $i++) { echo chr($i) . " - "; } my file encoded utf-8. when set header iso-8859-1 appears good. see image header("content-type: text/html; charset=iso-8859-1"); i tried print 1 character. see happen: why variable strange value. you convert characters utf-8: for ($i=0; $i < 255; $i++) { echo mb_convert_encoding (chr($i), 'utf-8', 'iso-8859-1') . " - "; }

Gradle flavors in Java / Kotlin Project? -

so come android world, , gradle android plugin has concept allowing developers split sources around called flavors . useful flavors contain source in ./src/main/java/ dir, flavor1 contain source code ./src/flavor1/java/ dir , flavor2 contain source code ./src/flavor2/java/ dir. does such feature exist gradle / java plugin? if not, there equivalent?

r - Include rgl interactive plot in .Rnw (pdf output) -

Image
description of problem i'd include interactive (rotating) rgl 3-d scatterplot in .pdf knitted .rnw file. know there hook including rgl maybe html output only. can't seem include plot rotates. here minimal example. plot appears there lines rather points , no rotation available. question(s) is including interactive rgl in pdf possible? if so...how can knitr?; doing incorrectly? mwe \documentclass{article} \begin{document} <<setup, include=false, cache=false>>= library(knitr) library(rgl) knit_hooks$set(rgl = hook_rgl) @ <<fancy-rgl, rgl=true>>= x <- sort(rnorm(1000)) y <- rnorm(1000) z <- rnorm(1000) + atan2(x,y) # open3d() plot3d(x, y, z, col = 'black') @ \end{document} what see in pdf: it's possible, barely. need install asymptote, , use rgl::writeasy() write program it. include program in document, run latex, asymptote, latex again. there examples of including asymptote in latex here: ht...

python - How to set active tab using crispy form? -

i have following code snippet show tabs using crispy form in modelform. possible set active tab when page loads? put css_class='active" in second tab, seems not working. in advance self.helper.layout = layout( common_layout, tabholder( tab( 'tab1', field('name', readonly=true), field('age', readonly=true), ), tab( 'class', field('grade 1'), css_class="active", ), ) ) active should lowercase # ... tab( 'class', field('grade 1'), css_class="active", ), #...

python - TypeError: unsupported operand type(s) for +=: 'int' and 'str' -

i'm getting error when reading file: line 70 in main: score += points typeerror: unsupported operand type(s) +=: 'int' , 'str' i'm taking integer in file , adding variable score . reading file done in next_line function called in next_block function. i have tried converting both score , points integer doesn't seem work. here's program code: # trivia challenge # trivia game reads plain text file import sys def open_file(file_name, mode): """open file.""" try: the_file = open(file_name, mode) except ioerror e: print("unable open file", file_name, "ending program.\n",e) input("\n\npress enter key exit.") sys.exit() else: return the_file def next_line(the_file): """return next line trivia file, formatted.""" line = the_file.readline() line = line.replace("/", "\n...

asp.net mvc - Microsoft.Owin.Security.Facebook C# MVC - Sign in with different account or second account -

during first time user tries login facebook, dialog appears, user signs in , social account created in application. problem when same user wants link second/different facebook account, login dialog not appear able sign in different account. i've tried solution: facebook popup login owin , no luck. redirection automatically assumes same/first account , continues linklogincallback. how can show login dialog everytime user tries linking user account other facebook account(s) through application? your appreciated. thanks.

angularjs - Angular 2 digest fails at executing a function, or finding a change at an object's property -

i have absolutely no idea on what's going on; 2 theories in title. thing is, should working, somehow 1 of core parts of angular, digest cycle, failing hard. what want do, , how did it a comments section instantiated in parent view, when click button. comments appear, , behave reddit's: can upvote or downvote them. pretty same! added arrows, , rating of comments between them: <div class="rating"> <ion-row> <button class="nocolor" (click)="ratecomment(comment, true)"> <ion-icon large name="arrow-up" [color]="israted(comment.rated, 1)"></ion-icon> </button> </ion-row> <ion-row> <span [style.margin-left]="pointsmargin(comment.rating)">{{comment.rating}}</span> </ion-row> <ion-row> <button class="nocolor" (click)="ratecomment(comment, false)"> <ion-icon large name...

python - Permission denied in write block at neo library -

i have spike2 files (*.smr) , want convert first in matlab files , in h5 files. when try write block throws me error: [errno 13] permission denied: '\mismr.mat' maindir = '\pyedmond'; datadir = '\pyedmond'; os.chdir(maindir) fname='\mismr.smr' fullfname = datadir+fname r = spike2io(filename = fullfname) w = neomatlabio(filename= fname[:-4]+'.mat') seg = r.read_segment() bl = block(name='a block') bl.segments.append(seg) w.write_block(bl) how can permission ? using windows 10. , python 3.5

ios - Swift 3/AV Foundation - trouble setting delegate with setsamplebufferdelegate -

im having trouble setsamplebufferdelegate. 1 of parameters dispatch queue , im not sure should feeding it. ive tried few things doesnt seem working, , result captureoutput not being called because delegate not being set. let queue = dispatchqueue.global(qos: .background) videooutput.setsamplebufferdelegate(self, queue: queue) if videooutput.samplebufferdelegate != nil { print("buffer delegate set") } the print statement not being called nor delegate method captureoutput ive tried videooutput.setsamplebufferdelegate(self, queue: dispatchqueue.main) and videooutput.setsamplebufferdelegate(self, queue: dispatchqueue.background) im shaky on dispatch queues right now, , have no deep understanding. im not sure if problem stemming misuse of queues or else. being called in viewdidload right now. *edit - yes adding output capture sessions in viewdidload dispatchqueue.global(qos: .background).async { if self.capturesession.canaddo...

Sudoku Solver in C, runs perfectly, but ends with a segmentation error. Can't find the source -

i have written program in c solved sudoku puzzles. works perfectly, , prints out correct solved puzzle, however, before program should end, segmentation fault , program crashes. struggling find problem coming from. sorry large amount of code, thought if guys saw everything. (also sorry if there bad c practices, noob.) #include <stdio.h> #include <math.h> #include <stdbool.h> struct table{ int cells[9][9]; bool fixed[9][9]; }; void enternum(struct table* t); void solver(struct table g); void draw(struct table t); bool checkinput(struct table* t); int main(){ setbuf(stdout, null); struct table t; struct table* tp = &t; int x, y; bool loop = true; while(loop == true){ for(x = 0; x < 9; x++){ for(y = 0; y < 9; y++){ t.cells[x][y] = 0; } } draw(t); enternum(tp); draw(t); if(checkinput(tp)){ loop = false; }else{ printf("\n invalid soduku puzzle\n"); } } s...

c++11 - Usage of noexcept in derived classes -

i encounter issue while using noexcept specifier on derived classes, more precisely when parent abstract class (has protected constructors). hereafter example of way declare classes. with public constructor in base class: ok. same code protected , derived class no more "nothrow movable". do miss something? std::is_nothrow_move_constructible correct traits use in derived class declarations or should use else? thanks answers. #include <cstdlib> #include <iostream> class baseok { public: baseok ( baseok&& other ) noexcept {} }; class basenok { protected: basenok ( basenok&& other ) noexcept {} }; class childok : public baseok { public: childok ( childok&& other ) noexcept ( std::is_nothrow_move_constructible < baseok >::value ) : baseok ( std::move ( other ) ) {} }; class childnok : public basenok { public: childnok ( childnok&& other ) noexcept ( std::is_nothrow_move_constructibl...

node.js - Angular2 Cli installation problems -

Image
i want give shot @ angular 2 i'm working install angular2 cli now, when install , run ng new newapp , awkwardly opens command line , says 'mg' (not 'ng'). here's happens when run 'ng new myapp' i'm running sudo npm install -g angular-cli@latest gives following output: npm warn engine angular-cli@1.0.0-beta.19-3: wanted: {"node":">= 4.1.0","npm":">= 3.0.0"} (current: {"node":"4.6.1","npm":"2.15.9"}) npm warn engine @ngtools/webpack@1.1.4: wanted: {"node":">= 4.1.0","npm":">= 3.0.0"} (current: {"node":"4.6.1","npm":"2.15.9"}) npm warn engine @angular-cli/ast-tools@1.0.7: wanted: {"node":">= 4.1.0","npm":">= 3.0.0"} (current: {"node":"4.6.1","npm":"2.15.9"}) npm warn optional dep failed...

xamarin.ios - Why am I getting a "requires Indie (or higher) license" error while using Xamarin Community? -

i european high school student codes apps part-time. i've been using xamarin studio around year on mac amazing student program. it expired me, tried renew it, find out it's available american college students, since microsoft acquired xamarin, figured xamarin community version work fine. updated ide, xamarin.ios , xamarin.android , suddenly, i'm getting 3 different "requires indie (or higher) license" errors whenever try build apps. i couldn't build more , there's no way can afford pay $2000/year, that's around ten times budget have whole project. will have redo work? my question is: xamarin community include functionalities of student program had before? if clean reinstall, me? yes can install community edition , it's having functionality

Can I mix MySQL APIs in PHP? -

i have searched net , far have seen can use mysql_ , mysqli_ meaning: <?php $con=mysqli_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed connect"; }else{ echo "connected"; } mysql_close($con); echo "done"; ?> or <?php $con=mysql_connect("localhost", "root" ,"" ,"mysql"); if( mysqli_connect_errno( $con ) ) { echo "failed connect"; }else{ echo "connected"; } mysqli_close($con); echo "done"; ?> are valid when use code is: connected warning: mysql_close() expects parameter 1 resource, object given in d:\************.php on line 9 done for first , same except mysqli_close() . second one. what problem? can't use mysql_ , mysqli together? or normal? way can check if connections valid @ all? (the if(mysq...) ) no, can't use mysql , mysqli toget...

Integration tests with Spring Boot and MySQL -

i familiar spring data jpa , test repositories kind of declaration (spring 4): @runwith(springjunit4classrunner.class) @contextconfiguration(classes = {persistenceconfig.class}) @sql({"classpath:it-data.sql"}) public class myrepositoryit { @autowired private myrepository repository; @test public void sometest() { ... } } so in charge of creating mysql schema , tables test class inserts test data (it-data.sql), , src/test/resources/persistence.properties contains datasource config. now want same thing in spring boot project. coded simple project works (a controller uses service retrieve data repository getting data mysql database). problem not able code simple test tests repository (i don't want load whole app test repository), either context errors or datasource config errors. starting from @runwith(springrunner.class) public class myrepositoryit { @autowired private myrepository repository; @test public void ...

Python "constructor not accessible in restricted mode" -

this has been driving me crazy, on , off, few months. i'm developing addon module kodi (formerly xbmc), exclusively python. whenever try open file, so: file = open(self.msg_bdy_props["filename"], "r") this exception thrown: ioerror: file() constructor not accessible in restricted mode from i've read, restricted mode of python era long past. there still parts of lingering around? can't work around time, , need open , read files. idea might happening , how around issue? thanks!

Webpack resolve.alias does not work with typescript? -

i try shorten imports in typescript from import {hello} "./components/hello"; to import {hello} "hello"; for found out can use resolve.alias in webpack configured part following resolve: { root: path.resolve(__dirname), alias: { hello: "src/components/hello" }, extensions: ["", ".ts", ".tsx", ".js"] }, webpack builds, , output bundle.js works. typescript's intellisense complain cannot find module so question whether or not webpack's resolve.alias works typescript? i found following issue there's no answer it. if you're using ts-loader , you'll have syhchronize webpack alias settings paths setting in tsconfig.json . { "compileroptions": { "baseurl": "./", "paths": { "hello": ["src/components/hello"] } } } if you're using awesome-types...

javascript - Calculate Time since MySQL timestamp -

disclaimer: javascript skills limited, , knowledge of javascript standard functions/library. forgive me, if question stupid. have standard mysql timestamp given , want user see, how time has passed since timestamp. know there time_diff function, that's generic me, need user-readable solution. preferably "written 34 seconds ago", "written 2 hours ago", "written week ago", "written year ago", "written on 24th december 2005", etc. if there built-in function (or popular library), please let me know... alone enough, i'd hear suggestions on how write timer updating every time unit (the first minute should update every second, first hour every minute etc.). another solution found using mysql timestampdiff method, still generic, wouldn't have worry possible time-zone differences. (client in est, server elsewhere). updating done via ajax requests (probably bad idea when using multiple timestamps) or via manually incrementin...

javascript - How to implement promise for http get request? -

i have following http request:- $http({ method: 'get', url: 'getdata.php', params: {bill: 'active'} }) .then(function (response) { bill=response.data.results; }); the request made multiple times , want processing wait until http requests done. want implement promises , return promises @ end of function. how can implement promises around http request? var arr=[]; arr.push(callhttp()); arr.push(callhttp()); arr.push(callhttp()); promise.all(arr).then(....) function callhttp(){ return $http({ method: 'get', url: 'getdata.php', params: {bill: 'active'} }) }

username and pass login loop bash -

the loop gets initiated though if statement makes no sense, new bash not lot of things make sense me first=0 echo enter username read user log1=$(grep -q $user username_pass.txt) echo enter password read pass log2=$(grep -q $pass username_pass.txt ) if [ $log1=0 ] && [ $log2=0 ]; echo welcome first=1 fi while [ $log1=1 ] || [ $log2=1 ]; echo wrong user name or password echo enter username read user echo enter password read pass done if [ $log1=0 ] && [ $log2=0 ] && [ first=0 ]; echo welcome fi [ … ] not particularly special syntax in shells. you’re passing arguments $log1=0 , ] command called [ , removes ] arguments , passes rest test . supposing $log1 contains “username”, result is: test 'username=0' when test gets 1 argument, checks if argument non-empty string. $log1=0 never empty string. what you’re looking pass operator , operands separate arguments, this: if [ "$log1" = 0...

python - Removing items from list if argument is False -

my code check if time valid, returns list true , false, depends, want if it's false remove list. here's code def markvalid(s): = [] if len(s) > 2: if s[1] - s[0] > 0.1: a.append(true) else: a.append(false) in range(1, len(s) - 1): if s[i] - s[i - 1] < 0.1 or s[i + 1] - s[i] < 0.1: a.append(false) else: a.append(true) if s[-1] - s[-2] > 0.1: a.append(true) else: a.append(false) return if len(s) == 1: return [true] if len(s) == 2 , s[1] - s[0] > 0.1: return [true, true] else: return [false, false] just don't append false s? however if understand correctly, want filter input list, right? if case can use current function like >>> test=[5.1, 5.6, 6.0, 1...

python - How to calculate the max click interval using pandas? -

i have dataset indicates when ip click link: ip time i want calculate maximum click interval of every different ip. is there anyway this? if understand question, you're looking following. import pandas pd df = pd.dataframe({'ip':[1,1,1,1,1,2,2,2,2], 'time':pd.date_range('01-15-16 12:00:00', periods=9)}) df_grp = df.groupby('ip')['time'].apply(lambda x: x.max() - x.min()) this calculates time difference between first , last clicks associated ip.

fft - Add a sinusoid to a speech file in MATLAB -

Image
i have speech file , attempting add sinusoid of frequency 300 hz speech sample, following code: % add sine wave speech signal clear all; close all; load spf2.mat; % sound(speech) pxx= pwelch(speech); plot(pxx); xlim([0 500]); f0 = 300; %hz fs = 8000; % samples per second dt = 1/fs; % seconds per sample stoptime = 2.74775; % seconds t = (0:dt:stoptime-dt)'; % seconds y = sin(2*pi*f0*t); newspeech = speech + y; sound(newspeech) pxx= pwelch(newspeech); figure plot(pxx); xlim([0 500]); however, not appear added signal properly. the power spectrum of original signal , power spectrum of 'newspeech' (which should contain original speech , sinusoid) same! fig 1: power spectrum of original speech file 0 500 hz fig 2: power spectrum of new speech signal 0 500 hz please let me know going wrong. you have scaling issue, power of sinusoid alone: and peak power of audio signal ~1e8

python - setting up the model in gensim for GoogleNews -

the following model setup correctly text8 don't know else should write google news model make work correctly. here's code text8: sentences = word2vec.text8corpus("text8") model = word2vec.word2vec(sentences) #model.init_sims(replace = true) model_name = "text8_data" model.save(model_name) here's code google news: model = gensim.models.word2vec.load_word2vec_format('googlenews-vectors-negative300.bin', binary=true) #model.init_sims(replace=true) model_name = "google_news" model.save(model_name) my end goal calculating wmd distance on these models. else should add code google news able use wmd distance? model.wmdistance(cleaned_f1_words, cleaned_f2_words)

How does a PayPal "Donation" button redirect to viglink.com? -

this redirection link visible if right-click on donation button , select 'copy link address': http://redirect.viglink.com/?format=go&jsonp=vglnk_147839002580313&key=07fb2a1f7863b1992bda53cccc658569&libid=iv5t8z6q01000dx6000dakx7eydyz4q4d&loc=http%3a%2f%2fcityoflakeland.activeboard.com%2f&v=1&out=https%3a%2f%2fwww.paypal.com%2fcgi-bin%2fwebscr%3fcmd%3d_donations%26business%3dandrewbb%2540gmail%252ecom%26lc%3dus%26item_name%3dtalkfl%252eorg%26no_note%3d0%26cn%3dthanks%2520for%2520keeping%2520talkfl%252eorg%2520ad%2520free%2521%26no_shipping%3d1%26currency_code%3dusd%26bn%3dpp%252ddonationsbf%253abtn_donate_sm%252egif%253anonhosted&title=talkfl.org&txt=%3cimg%20src%3d%22https%3a%2f%2fwww.paypalobjects.com%2fwebstatic%2fen_us%2fi%2fbtn%2fpng%2fbtn_donate_74x21.png%22%20alt%3d%22donate%22%3e this original paypal code behind donation button: <a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&...

Subtract datetime objects to get numerical result in milliseconds (Python) -

trying find elapsed time 2 strings hold timestamp , in format hh:mm:ss.mss . basically, want subtract 2 datetime objects , numerical result in milliseconds . here code: from datetime import datetime elapsed_time = 0 s = '13:46:34.550' e = '13:46:36.750' # interested on time part, not date start_time = datetime.strptime(s, '%h:%m:%s.%f') end_time = datetime.strptime(e, '%h:%m:%s.%f') #elapsed_time = end_time - start_time #elapsed_time = (end_time - start_time).microsecond for both elapsed_time calculations typeerror: unsupported operand type(s) -: 'datetime.datetime' , 'int' . it should print 00:00:02.250 or (ideally) 2200 . any ideas doing wrong? the following worked me (using python 3.5.2): from datetime import datetime elapsed_time = 0 s = '13:46:34.550' e = '13:46:36.750' # interested on time part, not date start_time = datetime.strptime(s, '%h:%m:%s.%f') end_time = datetime.s...

Crystal Report Group Fields Summery in Header? -

Image
i have 4 groups. trying accumulative summation between grownups. ex: group1: = 140 group2: = 70 group3: = 20 group4: = 10 group4: = 10 group3: = 50 group4: = 20 group4: = 30 group2: = 70 group3: = 20 group4: = 10 group4: = 10 group3: = 50 group4: = 20 group4: = 30 here snapshot of real report: i have tried using summerize fields sum first level , worked. tried sum summzrize fields, not possible sum those. tried totalrunningfields, display results in footer only. tried using custom formula, wasn't successfully. can give me way of doing this. also, if example great. actually after while, tried think of way implement report. crystal report tells not grouping on data makes hard implement logic based on grouping. what did in th end have created view, , created several procedures selects view. each select have necessary grouping. after that, made sure each select contains id's can...

How to delete a row that contains a certain code in the first column using excel VBA? -

i run report weekly , step must take delete row contains phrase, in case "cfs-ghost-djkt", in column a. rows read through start @ 7 , have variable end. i have looked online , according have found following code should work , error , not line cells(lrow,"a") i believe far deleteing part goes ok way written problem selection aspect. firstrow = 7 lastrow = cells(rows.count, "a").end(xlup).row cells(lrow, "a") if not iserror(.value) if .value = "cfs-ghost-djkt" .entirerow.delete end if end as per narrative ("i must ... delete a row") seem bother 1 occurrence of phrase "cfs-ghost-djkt" in case there's no need iterating through cells try finding and, if successful, delete entire row dim f range set f = range("a7", cells(rows.count, "a").end(xlup)).find(what:="cfs-ghost-djkt", lookin:=xlvalues, lookat:=xlpart) if not ...

javascript - regex js parse string of functions -

i'm looking create regex expression parse string of functions, typically looking this: " b ( ) c d ( 1, 2 ) text(' asdf sg sf sd sdf ') " into array spaces removed except spaces within either single or double quotes. ie, this: ['a','b()','c','d(1,2)',"text(' asdf sg sf sd sdf ')"] i'm sure type of problem has been around since birth of computing surprised can't find neat regex solution problem on web! any appreciated! just mean--a sequence of letters ( \w+ ), maybe ( ? ) followed white space ( \s* ) , parenthesized ( \(.*?\) : var str = " b ( ) c d ( 1, 2 ) text(' asdf sg sf sd sdf ') "; var re = /\w+(\s*\(.*?\))?/g; // ^^^ identifier // ^^^^^^^ arglist // remove spaces in each result, except spaces in "string literals" 'a b'. function squeeze(str) { return s...

python - Remove tuple from nested list of tuples -

i have nested list nested list of tuples below, nest_list= [[('aa','1'),('bb','2')],[('cc','3'),('bb','4')],[('dd','5'),('dd','6')]] i need parse through list , delete tuples containing value 'bb' final nested list below final_nest_list= [[('aa','1')],[('cc','3')],[('dd','5'),('dd','6')]] i tried use nested "for loop" doesn't seem efficient. there "recursive way" of doing in python, depth of nested list changes should work. one use list comprehension remove unwanted items, considering depth of nesting may vary, here's recursive way it: nest_list= [[('aa','1'),('bb','2')],[('cc','3'),('bb','4')],[('dd','5'),('dd','6')]] def remove_items(lst, item): r = [] in lst: ...

python - What is the most pythonic way to open a file? -

i'm trying clean code little bit, , have trouble figuring of these 2 ways considered pythonic one import os dir = os.path.dirname(__file__) str1 = 'filename.txt' f = open(os.path.join(dir,str1),'r') although second seems cleanest one, find declaration of fullpath bit much, since used once. import os dir = os.path.dirname(__file__) str1 = 'filename.txt' fullpath = os.path.join(dir,str1) f = open(fullpath,'r') in general, better thing avoid calling functions inside of call, if adds line of code ? with open('file path', 'a') f: data = f.read() #do data or f = open(os.path.join(dir,str1),'r') f.close()

qt - how to create a scrollbar for rectangle in QML -

Image
like web pages,when content's high beyond rectangle,there scrollbar. there else can me? have tried listview,but can't use in rectangle there example in latest documentation snapshots of qt quick controls 2 , how use scrollbar without flickable: import qtquick 2.7 import qtquick.controls 2.0 rectangle { id: frame clip: true width: 160 height: 160 border.color: "black" anchors.centerin: parent text { id: content text: "abc" font.pixelsize: 160 x: -hbar.position * width y: -vbar.position * height } scrollbar { id: vbar hoverenabled: true active: hovered || pressed orientation: qt.vertical size: frame.height / content.height anchors.top: parent.top anchors.right: parent.right anchors.bottom: parent.bottom } scrollbar { id: hbar hoverenabled: true active: hovered || presse...

django - Can't set expire header on images with Apache -

Image
i trying tell browsers cache type of image files (png/jpg/gif/etc) application, setting .htaccess file in root of django application. .htaccess <ifmodule mod_expires.c> expiresactive on expiresdefault "access plus 1 seconds" expiresbytype image/gif "access plus 365 days" expiresbytype image/jpeg "access plus 365 days" expiresbytype image/png "access plus 365 days" </ifmodule> apache loadmodule authz_core_module modules/mod_authz_core.so loadmodule dir_module modules/mod_dir.so loadmodule env_module modules/mod_env.so loadmodule log_config_module modules/mod_log_config.so loadmodule mime_module modules/mod_mime.so loadmodule rewrite_module modules/mod_rewrite.so loadmodule setenvif_module modules/mod_setenvif.so loadmodule wsgi_module modules/mod_wsgi.so loadmodule unixd_module modules/mod_unixd.so loadmodule expires_module modules/mod_expires.so loadmodule headers_module ...

What is the functionality of the Bitwise and Bitshift operators in Java? -

i understand bitwise , bitshift operators in java do , dont understand practical use is. instance, when useful use " ~, <<, >>, >>>, &, ^,| " modify or compare bits of values? bit fields (flags) they're efficient way of representing state defined several "yes or no" properties. acls example; if have let's 4 discrete permissions (read, write, execute, change policy), it's better store in 1 byte rather waste 4. these can mapped enumeration types in many languages added convenience. communication on ports/sockets always involves checksums, parity, stop bits, flow control algorithms, , on, depend on logic values of individual bytes opposed numeric values, since medium may capable of transmitting 1 bit @ time. compression, encryption both of these heavily dependent on bitwise algorithms. @ deflate algorithm example - in bits, not bytes. finite state machines i'm speaking of kind embedded in piece of hard...

I want to connect Arduino UNO to an android app -

i want connect arduino uno android mobile app via otg cable, both can connect each other. can send me android code it. i not know if possible, it's not easiest way achieve this. more feasible make http / socket ... connection between application , arduino, having server in midst. app -> server <- arduino.

conv neural network - what should be the depth of a convolution layer for grayscale and black and white images? -

i'm going through lecture notes here: http://cs231n.github.io/convolutional-networks/ in first convolution layer, typically @ 5x5x3 3 refers rgb color space , 5x5 height , width of picture. however, if i'm looking @ grayscale images 5x5x1 last dimension 0 1 (perfectly black white)? similarly, if simpler pure black , white images, 5x5x1 last dimension 0 or 1? yes you're right. in case of grayscale or black , white images have 1 feature map in input layer.

jquery - on getting the value of a radio button -

i ask what's wrong code, seems legit me. when select radio button, radiomininum still remains 0 . var radiominimum=0; $('#mmininum').click(function(){ if($(this).is(':checked')){ radiominimum = 1; alert(radiominimum); } else{ radiominimum=0; alert(radiominimum); } }); alert(radiominimum); inside if-else radiominimum displays correctly. if checked,its 1. bottom alert-outside .click radiominimum still displays 0. everything appears working expected: var radiominimum = 0; $('#mmininum').click(function(){ if($(this).is(':checked')){ radiominimum = 1; console.log(radiominimum); } else{ radiominimum=0; console.log(radiominimum); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input typ...

android - why my MotionEvent.ACTION_BUTTON_PRESS did not call -

i have problem 1 of feature ontouchlistener. here code. private float mprevx; private float mprevy; private static final string tag = "moveablebutton"; public mainactivity mainactivity; public moveablebutton(mainactivity mainactivity1) { mainactivity=mainactivity1; } @override public boolean ontouch(view view, motionevent motionevent) { float currx,curry; if (motionevent.getactionmasked()==motionevent.action_button_press) { log.d(tag, "ontouch: action_button_press"); intent = new intent(mainactivity, newactivity.class); mainactivity.startactivity(i); return true; } else if(motionevent.getactionmasked()==motionevent.action_down) { log.d(tag, "ontouch:action_down "); mprevx = motionevent.getx(); mprevy = motionevent.gety(); return true; } else if (motionevent.getactionmasked()==motionevent.action_move) { log.d(tag, "ontouch: acti...