Posts

Showing posts from June, 2010

node.js - How to block routing to a page in the public folder -

i'm trying design nodejs application, there confused about. in application, plan put of frontend material in folder /public , put line app.use(express.static(__dirname + '/public')); in app.js file. so in place, user able go thesite.com/gallery/stuff , work because gallery folder in /public . but if don't want user able visit area? how can intercept request , make sure logged in, example? there way make parts of public folder not public? you can put router right before it app.all('/gallery/*', function(req, res, next){ if(!req.user) next(new error('you shall not pass!')); else next(); }); app.use(express.static(__dirname + '/public'));

c - Fill value by value a char * -

i'm trying fill char *info inside struct nodo; this struct : struct nodo { char *info; struct nodo *prec; struct nodo *succ; }; typedef struct nodo nodo; and whole function : nodo *q,*t = null,*head = null; int i, nodi=0 ; char *c = a, *k = a; while ( *c != '\0') { if (*c == ' ') nodi++; c++; } (i = 0; nodi != 0; i++) { if (i == 0){ head = createfirstnodo(); t = head;} if (i == 1) q = createsecondnodo(head); else q = creatennodo(head); nodi--; } char *k = a; int = 0; while ( *k != '\0' ) { if (*k == ' ' ) { head = head->succ; = 0; } head->info[i] = *k; // error exc bad access i++; k++; } return t; } k char* , should scroll char[] assigned , should copy of values proper place in head->info[i] char *info in struct if k hits space, nodo goes next nodo , 'i' become 0 again since i need word filled...

c# - ComboBox change depending on type of cell -

what want function fill comboboxpromoter using information data grid view in form. basically should work this: if event type clubber, display promoter (names) eventtype (clubbing) combo box. else if event type exhibitor display promoters (names) related exhibitions. the code below 1 combo box: private void cmbpromoter_selectedindexchanged(object sender, eventargs e) { promoterform frm = new promoterform(); promoterbl pbl = new promoterbl(); if (txttype.text == "exhibition") { cmbpromoter.datasource = pbl.getpromotersbytype(frm.dgvpromoters.currentrow.cells[4].value.tostring()); cmbpromoter.refresh(); } else if (txttype.text == "clubbing") { cmbpromoter.datasource = pbl.getpromotersbytype(frm.dgvpromoters.currentrow.cells[4].value.tostring()); cmbpromoter.refresh(); } and class of promoter public list<advertiser> getpromotersbytype(string ptyp...

html - Make each square in a grid change color on hover with CSS -

i created grid of gray squares using css. want them turn black when hover on of squares. current solution turn square on hover black. can using css? imagine involve using spans. below code: .square { background-color: #737373; float: left; position: relative; width: 30%; padding-bottom: 30.66%; margin: 1.66%; } .square:hover { background-color: black; } <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> you'll want wrap .square elements in container, use css below. html: <div id="container"> <div class ="square...

excel - Paste multiple sheets into a single Word document -

i'm trying copy , paste each worksheet in workbook onto new sheet in single word document. unfortunately copying contents of first worksheet, though seem looping through worksheets. thought inserting page break work isn't. won't let me format in word. want contents of a1 have header style. this code: sub exceltoword() dim ws worksheet dim wkbk1 workbook set wkbk1 = activeworkbook application.screenupdating = false application.displayalerts = false application.enableevents = false each ws in wkbk1.worksheets wkbk1.activesheet.range("a1:a2").copy dim wdapp object dim wddoc object dim header range 'file name & folder path dim strdocname string on error resume next 'error number 429 set wdapp = getobject(, "word.application") if err.number = 429 err.clear 'create new instance of word application set wdapp = createobject("word.application") end if wdapp.visible = true 'define paths file strdocname = "p:\...

delphi - avoid complete check of an if statement -

the code sample below should evaluate string. function evaluatestring(const s: ansistring): ansistring; var i, l: integer; begin l := length(s); i:=1; if (l > 0) , (s[i] > ' ') , (s[l] > ' ') ..... end; but if l=0 (s[i] > ' ') create access violation. can avoid problem while keeping if condition? you need either put {$b-} statement on top of code, or enable boolean short circuit evaluation in project settings. since {$b-} default, may have turned on before, or there {$b+} directive somewhere turning off. in short circuit evaluation mode {$b-} , delphi creates code (roughly) equivalent this: if (l > 0) begin if (s[i] > ' ') begin if (s[l] > ' ') begin ..... end; end; end; in contrast, full boolean evaluation mode {$b+} , equivalent this: var a,b,c : boolean; := (l > 0); b := (s[i] > ' '); // executed c := (s[...

css - How to show column footer in grouped grid in AngularJS ui-grid? -

i'm using angularjs ui-grid , followed tutorial show column footer of gird, worked fine. however, after added grouping function in grid, column footer disappeared. from 105_footer tutorial, used aggregate column values: aggregationtype: uigridconstants.aggregationtypes.sum in grouping's column definition, added aggregate column values: treeaggregation: {type: uigridgroupingconstants.aggregation.sum} the problem column aggregation isn't aware of grouping, trying blindly aggregate visible rows in column. result in wrong answer. there 2 forms of wrong here: grouping default puts labels text - "max: 30" example in age column. aggregation cannot aggregate. can fix customfinalizerfn, i've done in plunker below aggregation aggregates visible rows, including groupheader rows. if had 1 level of grouping , expanded all, sum aggregation end double real value. if had 2 levels of grouping triple. in short, think it's bad idea use co...

c++ - Displaying Matrix elements in Strange Order -

i not sure order of printing called hence called strange. consider following sample example: 1 3 5 2 6 7 expected output: 1,2 1,6 1,7 3,2 3,6 3,7 5,2 5,6 5,7 or example: 1 2 3 4 5 6 7 8 9 output: 1,4,7 1,4,8 1,4,9 1,5,7 1,5,8 1,5,9 ... , on. i have analyzed number of possible combinations rows^columns given matrix.here solution: #include <iostream> #include <vector> #include <string> #include <cstdlib> #include <cstdio> using namespace std; void printallpossiblecombinations(int** a, int h, int n, string prefix) { if (h == 0) { (int = 0; < n; i++) { cout << prefix << a[0][i] << endl; } } else { (int = 0; < n; i++) { string recursivestring = prefix; recursivestring.append(to_string(a[h][i])); recursivestring.append(1, ','); printallpossiblecombinations(a, h-1, n, recursivestring); ...

c++ - How to move class in the same thread -

i'm trying add threading in app write in c++ , qt. i have class framework , 1 name devicemngr. the framework.h defined below: class framework : public qobject { q_object qthread frameworkthread; public: framework(); the framework initialized main. main doing : qapplication app(argc, argv); qthread frameworkthread; framework *deviceframework = new framework; deviceframework->movetothread(&frameworkthread); qobject::connect(&frameworkthread, signal(finished()), deviceframework, slot(deletelater())); after, main in main windows , give deviceframework argument. mainui mywindows(*deviceframework); mywindows discussing deviceframework using signal/slots. framework based access android device using class devicemngr , methode. how possible me add devicemngr in same thread framework. can in framework.cpp: framework::framework() { device = new devicemngr(); device->movetothread(&frameworkthread); } and devi...

fonts - How to deal with a typeface with the wrong character for "inverted question mark"? (Google Quicksand) -

Image
i using quicksand font google, , in internationalization process, realized spanish inverted question mark not correctly represented. is possible fix easily? https://www.google.com/fonts/specimen/quicksand this not "wrong character", designers of quicksand wanted inverted question mark. if want different shape: use subsetting , exclude inverted question mark, , fall font has shape want. also, without additional details on context you're in (feel free update question information) it's impossible tell how that, or if there better solutions (on web, instance, can have single-character font exact inverted question mark want, listed "first font use" , use quicksand fallback. way you'll use own preferred version)

r - Resize margins between different plots in one graph -

Image
i want plot 3 plots 1 graph using layout command below. unfortunately margins between plot 1 , 2 quite big. tried "heights=c()" command don't want change proportion between both plots. love have same size both plots, therefore decrease margin between, haven't found adequate solution yet , not sure how use par(mar) command in here. layout(matrix(c(1,1,3,2,2,3),2,3,byrow=true)) hist(data$x,breaks=16,prob=true,xlab="x",ylab="density",main="",ylim=c(0.000,0.040)) axis(side=1,at=seq(40,120,10),labels=seq(40,120,10)) lines(density(data$x,na.rm=true), col="blue", lwd=2) lines(density(data$x,na.rm=true, adjust=2),lty="dotted",col="darkgreen", lwd=2) qqnorm(data$x,main="") boxplot(data$x) thank assistance. there possibility use ggplot aes() instead? thanks lot! thore it appears me excess whitespace entirely caused combination of top , bottom margins between under , on figures. playing ar...

Iterated Graphing in For Loop via Python -

for k in range(10): rtpi = (pratio / float(math.pi)) + x*0 plt.plot(x,rtpi,'r') this produces flat line. how can this: for k in range(10): rtpi = (pratio / float(math.pi)) + x*0 plt.scatter(x,rtpi,'r') basically, every individual point, 1 point represented on graph per 1 point on x-axis. if understand question correctly, this suggests should use plt.plot , add "o" for k in range(10): rtpi = (pratio / float(math.pi)) + x*0 plt.plot(x,rtpi,'ro')

database - How do I connect to a Netcool / Omnibus "Object Server" using Python? -

i'm trying connect netcool 7.1 object server using python, i'm running issues. seems sybase type database, stripped down. i'm using sybase module , freetds, following error when try connect: traceback (most recent call last): file "netcool.py", line 12, in <module> db = sybase.connect('foo','foo','foo','foo') file "/usr/lib64/python2.6/site-packages/sybase.py", line 1194, in connect datetime, bulkcopy, locale, inputmap, outputmap) file "/usr/lib64/python2.6/site-packages/sybase.py", line 850, in __init__ self.connect() file "/usr/lib64/python2.6/site-packages/sybase.py", line 898, in connect status = conn.ct_options(cs_set, cs_opt_chainxacts, not self.auto_commit) file "/usr/lib64/python2.6/site-packages/sybase.py", line 272, in _servermsg_cb raise databaseerror(msg) sybase.databaseerror: msg 17001, level 10 no srv_option handler installed. has conne...

c++ - How to check for real equality (of numpy arrays) in python? -

i have function in python returning numpy.array: matrix = np.array([0.,0.,0.,0.,0.,0.,1.,1.,1.,0.], [0.,0.,0.,1.,1.,0.,0.,1.,0.,0.]) def some_function: rows1, cols1 = numpy.nonzero(matrix) cols2 = numpy.array([6,7,8,3,4,7]) rows2 = numpy.array([0,0,0,1,1,1]) print numpy.array_equal(rows1, rows2) # returns true print numpy.array_equal(cols1, cols2) # returns true return (rows1, cols1) # or (rows2, cols2) it should extract indices of nonzero entries of matrix (rows1, cols1). however, can extract indices manually (rows2, cols2). problem program returns different results depending on whether function returns (rows1, cols1) or (rows2, cols2) , although arrays should equal. i should add code used in context of pyipopt , calls c++ software package ipopt . problem occurs within package. can arrays not "completely" equal? somehow must because not modifying returning 1 instead of other. any idea on how debug problem...

How to use command line arguments in c (OS: Windows)? -

i'm unable make program asks user input 3 arguments on command line: 1) operator (+, -, *, /); 2) integer (n); 3) integer (m). program should act basic calculator producing output in format: . e.g. operator='+' n=5 m=6 output: 5+6 = 11 if want take argument command line while user executes program can use argv vector fetch values int main(int argc, char** argv){ } so if execute program follows, ./prog + 1 2 argv contain follwing, argv[0] = 'prog', argv[1] = '+', argv[2] = '1', argv[3] = '2', so can fetch each value argv , implement logic. read this tutorial better understanding.

How to calculate factorial using prolog -

i have code calculating factorial below : fact(1,1). fact(x,r):- x1 x-1, fact(x1,r1), r r1*x. in mind code shouldn't work right does! reason? think when call fact(3,r), first calculate " x1 x1 -1 ". goes next rule fact(x1,r1) . call goal part again , code execution return goal " fact(x,r) " , continue until reach fact(1,1). means never goes r r1*x part. so, seems thinking wrong. can tell me step step code execution order in code? thanks once "reach" fact(1,1) , "return" calling recursive iteration , proceed part r r1*x of iteration, r1=1 . return again previous level , on. let's @ non-trivial iteration: fact(3,r) : x <- 3, x1 <- 3-1 = 2, fact(2,r1) : x' <- 2, x1' <- 2-1 = 1, fact(1, r1'), => r1'=1 (matched fact(1,1)) r'<- r1' * x' = 2 r1 = r' = 2 r <- r1*x = 2*3 = 6. here variable ' denoting variables correspond...

android - Unable to import import com.google.api.client.http.HttpTransport -

Image
i unable import com.google.api.client.http.httptransport i have tried downloading dependencies https://developers.google.com/api-client-library/java/google-api-java-client/download and adding them project by project > open module settings > dependencies > + > file dependency > google-api-client-android-1.20.0.jar > ok with no luck. copy google-http-client-1.20.0.jar app/libs add compile filetree(dir: 'libs', include: ['*.jar']) app/build.gradle in dependencies . go tools --> android--> sync project gradle files . now can import class:)

python - Installing mpyfit ("error: command 'c:\\mingw\\bin\\gcc.exe' failed with exit status 1") -

when installing python package mpyfit , receive following error: "error: command 'c:\\mingw\\bin\\gcc.exe' failed exit status 1" information: python version: 2.7.8 environment: anaconda machine: windows 8.1 here traceback: c:\users\roger\anaconda\pkgs\mpyfit>python setup.py install running install running bdist_egg running egg_info writing mpyfit.egg-info\pkg-info writing top-level names mpyfit.egg-info\top_level.txt writing dependency_links mpyfit.egg-info\dependency_links.txt reading manifest file 'mpyfit.egg-info\sources.txt' reading manifest template 'manifest.in' writing manifest file 'mpyfit.egg-info\sources.txt' installing library code build\bdist.win-amd64\egg running install_lib running build_py running build_ext building 'mpyfit.mpfit' extension c:\mingw\bin\gcc.exe -dms_win64 -mdll -o -wall -impyfit/cmpfit -ic:\users\roger\anaconda\lib\site-packages\numpy\core\include -ic:\u sers\roger\anaconda\include -i...

c# - How to get file type from encrypted file? -

how file type using c# encrypted file (i.e. file.enc )? encryption method: shift cipher z 256 shift cipher encryption: y i = (x i + k) % 256 x i = (y i - k) % 256 where: x i , = 1 : n, input in plain bytes. y i , = 1 : n, output cipher bytes. k shift key secret byte between 1 , 255. if have decrypt file first, how decrypt without using exhaustive search find shift key ? i'm not talking getting .enc can that. i'm not able determine how file before encryption such .doc , .xls , .pdf , .jpg , or .wav file types. what have tried: byte[] bytearray = file.readallbytes(openfiledialog1.filename); // mean double mean = 0; (int = 0; < bytearray.length; i++) { mean += bytearray[i]; } mean = mean / bytearray.length; txtmean.text = mean.tostring("#.000"); // median bytearray.tolist().sort(); int median = bytearray[(int)math.floor((decimal)(bytearray.length / 2))]; txtmedian.text = median.tostring(); // mode var groups = bytearray.gr...

Remove a SPID after LINQ in Entity Framework -

i have application use entity framework interact ms sql database. in make calls dbcontext inside using blocks. problem i'm having that, after dbcontext has been disposed of, spid sits there status of sleeping until application exits. how remove these hanging spids? you don't want to, should work: ((sqlconnection)dbcontext.database.connection).clearallpools(); as mentioned above, can , negatively impact performance of application (and perhaps other applications). perhaps real question might be, why want remove spid? you add pooling=false connection string should prevent application using connection pool @ all. depending on application, may or may not affect performance greatly.

Curses - How to insert predefined name of INPUT items? -

how please insert predefined name of input items ? my efforts: (info: character "_" cursor) def edit_item(stdscr, item_name) stdscr.addstr(1, 2, "item name:") r = stdscr.getstr(2, 16, 15) return r edit_item(stdscr, 'foo') edit_item(stdscr, 'bar') result: item name: _ item name: _ the desired result: item name: foo_ item name: bar_ thank help. @thomas dickey: no :-( try better describe need.. - call function 'edit_item' parameter 'foo' # ok - screen prints 'item name: foo' # ok - cursor behind word 'foo_' # ok - press key arrow left (2x) change cursor 'f_o' # not work - edit word 'foo' 'fao' it's understand? # # # # # # # # # # # # # # # # # this need in curses. demonstration in bash read -e -i "foo" -p "edit item name: ...

java - How to close AsyncHttpClient with Netty for an asynchronous Http request? -

using asynchttpclient netty provider prevent main program terminate when execute asynchronous request. instance, following program terminates after println , or not, depending on whether provider jdkasynchttpprovider or nettyasynchttpprovider : public class program { public static completablefuture<response> getdataasync(string uri) { final asynchttpclient asynchttpclient = new asynchttpclient(); final completablefuture<response> promise = new completablefuture<>(); asynchttpclient .prepareget(uri) .execute(new asynccompletionhandler<response>(){ @override public response oncompleted(response resp) throws exception { promise.complete(resp); asynchttpclient.close(); // ??? correct ???? return resp; } }); return promise; } public static void main(string [] args) throws ...

ios - Load second app interface in a segue -

Image
basically want depicted in image below: however loads middle , third interface, first hidden both swiping onto , in circle indicators @ bottom. i'd able load second interface , swipe left first , swipe right third. there way achieve this? building first apple watch app on here :) looks there concept of uinavigationcontroller-ish behaviour built wkinterfacescontroller. take at: pushcontrollerwithname(_:context:) and docs found here : hierarchical. style suited apps more complex data models or apps data more hierarchical. hierarchical interface starts single root interface controller. in interface controller, provide controls that, when tapped, push new interface controllers onto screen. edit: looking more. watchkit limited looks. the best solutions come add 3 interfacecontroller, segues between. left -> main -> right. then assign custom skinterfacecontroller main: class interfacecontroller: wkinterfacecontroller { override init() {...

sql - Restrict records returned by view with group by rollup whilst modifying totals -

i need create view has average columns. view accessed month , year , create global (full table scan) , later use different condition such as: month 05 year 2015 / month 04 year 2015 right have created this: create or replace view view_x_tipology select dt_ref, gg_ref, mm_ref, yyyy_ref, avg(pcr_qt) pcr_tot, avg(ltr_qt) ltr_tot, avg(tbr_qt) tbr_tot, avg(qt_total) day_total stock_base group rollup (dt_ref, gg_ref, mm_ref, yyyy_ref) my main problem grand total (i don't need sub totals) has 3 total value, , other fields null dt_ref gg_ref mm_ref yyyy_ref pcr_tot ltr_tot tbr_tot tot 28/05/2015 28 5 2015 118654 9433 19729 147816 28/05/2015 28 5 118654 9433 19729 147816 28/05/2015 28 118654 9433 19729 147816 28/05/2015 118654 9433 19729 147816 29/05/2015 29 5...

javascript - Get image attribute based on class name -

i have images have data-url attribute want value of data-url based on click on element. my html is <img class="youtube-poster" src=" http://i2.ytimg.com/vi/juijgbxj-4w/maxresdefault.jpg " data-url="https://www.youtube.com/embed/juijgbxj-4w"> <div class="video-poster-player"><i class="play"></i><div> and js is $(document).on('click', '.video-poster-player', function(event) { var classname = $(event.target).attr('class'); var frameurl = classname.parent().find('.youtube-poster').data('url') console.log(classname) console.log(frameurl) }); in console classname.parent not function so, .parent() valid on jquery object , not on string ( classname ). following work scenario (not pretty, works ). <img class="youtube-poster" src=" http://i2.ytimg.com/vi/juijgbxj-4w/maxresdefault.jpg " data-url="https://www.youtub...

Spring Boot: Dynamic ServletPath and ContextPath for Embedded Tomcat -

i'd modify embedded tomcat, can programmatically modify incoming request: original input: http://localhost:8080/webapp/foo contextpath = , servletpath = /webapp/foo modified: contextpath = /webapp , servletpath = /foo i can't within spring itself, because session cookie path getting set tomcat. and can't use static contextpath because multi tenancy app. i tried use tomcatembeddedservletcontainerfactory tomcat = ...; tomcat.addcontextvalves(new valvebase() { public void invoke(request request, response response) throws ioexception, servletexception { ... } }); but wasn't able set servletpath there. do have idea how achieve this? it's hard tell you're trying achieve, have tried setting property in application.properties file: server.context-path=/webapp this put whole application in /webapp context path

wampserver - Joomla backup doesnt show the same on my local machine -

i have backed online joomla site (with akeeba) , try have version of site on wamp(local machine). problem after extraction(and kickstart) site not same online version. menues not in same order , horizantal vertical , footer , image slider stopped working. appreciate regardin issue please. thnaks

Creating a custom toolbar in android -

Image
i trying create custom extended toolbar in android edit text in toolbar. layout want implement looks this the code have written implement this: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="256dp" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" > <edittext android:layout_width="fill_parent" android:layout_height="wrap_content" ...

Drupal block revision control for Writer, Editor, and Publisher role users -

is there drupal module control block content before being published. a person create block , post content , assign editor role user. editor review block content , made changes on content , assign reviewer role user. reviewer review content , publish or unpublish it, untill publish block content page should retain old published content if any. please highlight modules can go it. https://www.drupal.org/project/block_access block access module may need.

Getting data from a Spinner (Android Studio) -

i'm trying data 3 spinners, ready post it. i'm having trouble load of errors code don't understand...i'm new java/android. i've looked around , code i'm using comes stackoverflow answer work: //spinner data final spinner findviewbyid(r.id.spinner_house); string spinner_house_data = spinner_house.getselecteditem().tostring(); final spinner findviewbyid(r.id.spinner_year); string spinner_year_data = spinner_year.getselecteditem().tostring(); final spinner spinner_name = (spinner) findviewbyid(r.id.spinner_name); string spinner_name_data = spinner_name.getselecteditem().tostring(); the specific errors are: (r.id.spinner_house); not statement findviewbyid(r.id.spinner_year); not statement thanks help, i'm new android , it's bit confusing! (this json request take 5 lines of jquery!) i think solve problem: final spinner spinner_house = (spinner) findviewbyid(r.id.spinner_house); ...

allDocs query returning design docs in PouchDB -

i'm using smart ids in docs can search log type , date. using pouchdb-find plugin create indexes, though aren't being used yet. this example alldocs query: var start = 'log_2015-05-28t23:00:00.000z', end = 'log_2015-05-29t23:00:00.000z; return db.alldocs({ startkey: start, endkey: end, include_docs: true }); the results of query includes design docs. here's example key of 1 of them: _design/idx-a1f9f055e1ec4dfb9f5e9fd9ac7fc6bb why getting design docs if keys outside of start , end key range? you want startkey , endkey , not startkey , endkey . :)

indexing - solr does not index all the documents -

i getting set of records dbpedia, 1-365 days. indexing these unique records solr. in each iteration 2000 documents getting indexed total number of records sent solr 449872 , total documents on solr "numfound": 428411 i set maxdocs limit 100000 is there idea this?

ios - ParseCrashReporting - Apple Mach-O Linker Error after enabling it -

i had parse ios sdk v1.2.20 on app. after updating latest version (v1.8.0), got 23 apple mach-o linker errors. the thing did deleted parse.framework file , replaced new parse.framework , bolts.framework . don't understand why many errors. start "_sqlite3". if click error, shows me detailed page, starts undefined symbols architecture x86_64 know going wrong? appreciate help. linking libstdc++6.0.9.dylib , libsqlite3.0.dylib worked me. flag, doubt it. try adding libstdc , see if works.

javascript - Best regular expression for matching the domain part of emails -

i trying make regex can match domain portion of email address. right have use 2 of them, 1 gets email addresses , matches domain, i'm still having issues. right code have this: var email_ex = /[a-za-z0-9]+(?:(\.|_)[a-za-z0-9!#$%&'*+/=?^`{|}~-]+)*@(?!([a-za-z0-9]*\.[a-za-z0-9]*\.[a-za-z0-9]*\.))(?:[a-za-z0-9](?:[a-za-z0-9-]*[a-za-z0-9])?\.)+[a-za-z0-9](?:[a-za-z0-9-]*[a-za-z0-9])?/ig; // match email addresses on page email_ex = new regexp(email_ex); var domain_ex = /[a-za-z0-9\-\.]+\.(com|org|net|mil|edu|com|org|net|mil|edu|co\.uk|au|li|ly|it|io)/ig // match domains domain_ex = new regexp(domain_ex); var match = document.body.innertext; // location pull our text from. in case it's whole body match = match.match(email_ex); // run regexp on body's textcontent i'd rather not have have list of tld's, haven't been able find expression enough the simplest regexp: /@([^\s]*)/ var email = "test@example.domain";...

osx - Verify Xcode Command Line Tools Install in Bash Script -

i creating bash script setup development environment. part of script need install xcode command line tools , don't want script continue execution until installation has been completed. when run: xcode-select --install it prints install has been requested or has been installed. want able wait until message changes being installed. the relevant part of script follows: check="$(xcode-\select --install)" echo "$check" str="xcode-select: note: install requested command line developer tools\n" while [[ "$check" == "$str" ]]; check="$(xcode-\select --install)" sleep 1 done unfortunately $check empty because xcode-select --install not return , instead echoes message terminal. i know have solved issue, had crack @ problem today, , discovered prints stderr , not stdout. code used determine whether xcode installed or not: check=$((xcode-\select --install) 2>&1) echo $check str="xcode-s...

c# - Need to 'BindingList' a member of a struct to a combobox -

good morning: i have situation have struct: private struct employeeinfo { public string lastname; public string firstname; public string fullname { get; set; } public string address; public string employeeid { get; set; } } private bindinglist<employeeinfo> ei = new bindinglist<employeeinfo>(); i have combobox on screen needs populated 'fullname' member can index of list access other information in it. is possible? had members own separate bindinglist (i.e. not in struct), didn't seem right me. i tried few different things (which didn't work), , did search here, nothing seemed close enough doing. thank you, always. :) robert do this, perhaps in form constructor : combobox.valuemember = "employeeid"; combobox.displaymember = "fullname"; combobox.datasource = ei; then setup selection change handler : private void combobox_selectedindexchanged(object sender, eventargs e) { combobox cmb...

jquery - $.ajax method does not call server method -

can in identifying issue please. $.ajax({ type: "post", url: '@url.action("deleteprintjobs", "followmeprint")', //url: "/followmeprint/deleteprintjobs", not work data: { jobids: appendjobids }, success: function (data) { }, error: function (x, y, z) { } }); if pass url using url.action , works, not /{controller}/{action} . suspect because of routing not working. url in browser http://localhost/kiosk/followmeprint/deleteprintjobs . how handle kiosk in routing?

xtext - Why does the error method return an error? -

i want validate input corresponding following grammar snippet: declaration: name = id "=" brcon=bracketcontent ; bracketcontent: deccon=deccontent (comp+=comparator content+=deccontent)* ; deccontent: (neg=("!"|"not"))? singlecontent=varcontent (op+=operator nextcon+=varcontent)* ; my validation looks that: @check def checknocycleinhierarchy(declaration dec) { if(dec.deccon.singlecontent.reference == null) { return } var names = newarraylist var con = dec.deccon.singlecontent while(con.reference != null) { con = getthatreference(con).singlecontent if(names.contains(getparentname(con))) { val errormsg = "cycle in hierarchy!" error(errormsg, sqfpackage.einstance.bracketcontent_deccon, cycle_in_hierarchy) return } names.add(getparentname(con)) } }...

wordpress - Column count on webkit browsers -

i'm using css code manage columns in page (i'm on wordpress 4.2.2 + visual composer plugin): -webkit-columns: 2 200px; -moz-columns: 2 200px; columns: 2 200px; -webkit-column-gap: 20px; -moz-column-gap: 20px; column-gap: 20px; it works fine on firefox whole paragraph disappears on chrome , safari (webkit). suggestion? edit: can't add screenshot (i need @ least 10 reputation ti post images), there's website link

javascript - How to use angularjs $anchorScroll on div only if div is hidden? -

i'm using angularjs develop web application. have several nested div . each of them correspond item user can select. example of div display in official angularjs documentation : http://plnkr.co/edit/qncmfyjpup2r0vuz0ax8?p=preview in code each div have ng-click="gotoanchor(x)" event when click on div if partially hidden, pull on page , user can see clicked div . have header in page first div anchor , click event not directly @ top of page. , if click on first div, scroll , header won't visible. question is, there way activate anchor if div isn't displayed on screen ? if have other solution anchors, take it. thank in advance. if understand question correctly issue when using $anchorscroll header either a : being covered div scrolled frame, or b partially covering div scrolled frame. either way there 2 solutions should review: first make sure you're employing css layer elements, header (if fixed) should have z-index sup...

Infinite recursion in PHP echo statement -

why code cause infinite recursion? class foo { public static function newfoo() { return new foo(); } public function __tostring() { return "{${foo::newfoo()}}"; } } echo new foo(); // infinite recursion new foo(); // finishes is because __tostring() returning object? can't possible because according docs this method must return string, otherwise fatal e_recoverable_error level error emitted. ( ref ) or infinitely recurse within __tostring() method? echo new foo(); creates foo , tries echo it, casts object string invoking magic method __tostring . in method, however, invoke static method foo::newfoo , returns new object, again casted string in __tostring itself, gets called again. so yes, here infinite recursion. to clarify: public function __tostring() { return "{${foo::newfoo()}}"; } is equivalent to public function __tostring() { $foo = foo::newfoo(); return "$foo"; // ...

Png Image instead of Text in PHP -

hello want show png image instead of text in php file site. my code: function format_age($t) { if ($t<30) return "live"; return sprintf("%d%s%d%s%d%s", floor($t/86400), ' tage ', ($t/3600)%24,' std. ', ($t/60)%60,' min.'); } so instead of "live" want show png image. hope can me. thanks , regards you need give bit more background information if expect proper answer question. if you're echoing return value, might sufficiënt: what this: if ($t<30) { return '<img src="/path/to/image.png">'; }

php - Woocommerce API returns 1, but works -

i'm trying write own payment gateway woocommerce , it's going pretty well. payment provider can callback verify payment status, created callback function. add_action('woocommerce_api_'.strtolower(get_class($this)), array(&$this, 'callback')); public function callback() { mail('my@email.com', 'callback ideal', print_r($_request,true) . print_r($_server,true)); echo '+'; return '+'; } when call callback url, recieve email that's in callback function, output callback gives 1. i did googling on 1 means, means callback doesn't end or isn't called @ all. in case called, since recieve email. point me in right direction ? must missing something. update: when kill script exit in callback function, can see output. isn't appropriate solution the reason might action been called via ajax. in wordpress ajax default returns die() function before function ends. if...

html - Is there an upside down caret character? -

i have maintain large number of classic asp pages, many of have tabular data no sort capabilities @ all. whatever order original developer used in database query you're stuck with. i want to tack on basic sorting bunch of these pages, , i'm doing client side javascript. have basic script done sort given table on given column in given direction, , works long table limited conventions follow here. what want ui indicate sort direction caret character ( ^ ) , ... what? there special character direct opposite of caret? letter v won't quite cut it. alternatively, there character pairing can use? there's ▲: &#9650; , ▼: &#9660;

io - Python – BinaryIO Stream read while writing -

i need stream in python writing stuff. while writing it, threaded method should read it, until gets closed (eof). so far can create stream stream = io.binaryio('binarystart') , stream.seek(0, 1) begining of stream read it. cannot append binary strings end of stream. because main process shares same stream (therefor same cursor , cursor position) threaded reader. any ideas solve this?

Broadcast get to all shards in Elasticsearch -

i'm using routing when indexing documents. in cases handy perform without routing parameter , have broadcast search. not find documentation on how except note, issuing without correct routing, cause document not fetched. for comparison, search api specifies: when executing search, broadcast index/indices shards (round robin between replicas). shards searched on can controlled providing routing parameter is supported or there way achieve that?

ruby on rails - Issues with Koudoku plan subscription creation on user sign up -

i'm using koudoku accept payment .i have listing , users .setup koudoku gem instructed guides . how can make every user on app enroll in plan on sign up(i'm using devise) , send info stripe in same process , goal have on free plan , can upgrade in dashboard? so far have , stuck. 1) create function "create_subscription" in subscription model take parameters subscription params hash class subscription < activerecord::base include koudoku::subscription belongs_to :user belongs_to :coupon def create_subscription @subscription = subscription.new plan_id = ::plan.first.id subscription.subscription_owner = @owner_id subscription.save subscription end end 2)call function in devise registrations controller class users::registrationscontroller < devise::registrationscontroller include applicationhelper def create super @user.create_subscription() # sends email user when user created. timarchemailer.welcome_em...

android - ListView items are overlapped -

Image
items listview overlapped after delete items. why? example before , after delete first item: i deleting elements using method: public void updatedata(list<parseobject> data) { mgrouplist.clear(); mgrouplist.addall(data); notifydatasetchanged(); } listview: <listview android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@null"/> getview in adapter: @override public view getview(int position, view convertview, viewgroup parent) { viewholder viewholder; if (convertview == null) { viewholder = new viewholder(); convertview = mlayoutinflater.inflate(r.layout.card_item, parent, false); viewholder.mcardviewnative = (cardviewnative) convertview.findviewbyid(r.id.card_view); convertview.settag(viewholder); } else { viewholder = (viewholder) convertview.gettag(); } //code ...

java - How to apply the same changes to two projects -

i have 2 identical projects. second project/app same has ads disabled. i need apply lot of changes project 1, means applying them project 2 is there easy way apply changes project 2 without having manually each change again? is there way refactor 2 projects care common codebase, , have configuration flag disables ads? way don't have 2 common code bases maintain. have ios project similar, , build targets in xcode. otherwise think gold old fashioned hand merge way it. use whatever comes vcs of choice, or app beyondcompare. good luck.

r - dplyr rename not working with regular expression -

the select function works fine when try rename variables according conditions require(dplyr) select(iris, petal = starts_with("petal")) however when try keep other variables using rename(iris, petal = starts_with("petal")) error: arguments rename must unquoted variable names. arguments petal not. i have no idea why dplyr complains this. if behavior intended, right way rename variables using starts_with (or contains) while keeping other variables there? select renaming them you. can add everything() call in order rest of columns select(iris, petal = starts_with("petal"), everything()) # petal1 petal2 sepal.length sepal.width species # 1 1.4 0.2 5.1 3.5 setosa # 2 1.4 0.2 4.9 3.0 setosa # 3 1.3 0.2 4.7 3.2 setosa # 4 1.5 0.2 4.6 3.1 setosa # 5 1.4 0.2 5.0 3.6 setosa # 6 1.7 0...

syntax - How to define the type of elements in an rdf:Seq? -

i want create property defining rdf:seq rdfs:range of object : eg:myproperty rdf:property; rdfs:range rdf:seq; . i'm looking way define type of elements stored in rdf:seq . example, don't want : eg:typeofelement rdf:class; . eg:somethingelse rdf:class; . [] eg:myproperty [ rdf:seq; rdf:_1 [a eg:typeofelement]; # it's type want rdf:_2 [a eg:typeofelement]; # it's type want rdf:_3 [a eg:somethingelse]; # don't want type ]; . is there way define rdf:seq elements of type of eg:typeofelement when define eg:myproperty ? (i can use owl if necessary.) there number of ways accomplish this, depending on implementation preferences. advice use rdf:li special property in place of arbitrary rdf:_nnn , easier extend. rdf:li equivalent rdf:_1 , rdf:_2 in order. following code blocks equivalent: :myseq rdf:seq; rdf:_1 :foo; rdf:_2 :bar . :myseq rdf:seq; rdf:li :foo; rdf:li :bar ....

java - Gradle compile dependency is not added to classpath -

Image
i've added reflections framework android project. wasn't added classpath. android studio suggests need add manually, cannot start app since gradle cannot build it. here build.gradle of app module: apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "21.1.2" defaultconfig { applicationid "my.package" minsdkversion 21 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } lintoptions { abortonerror false } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile project(':offlinetasks') compile project(':tasks') compile project(':models') compile 'com....