Posts

Showing posts from March, 2013

perl - How to print 10 letters preceding every occurrence of a particular character? -

using grep , can print occurrences of uppercase letter "z" in document. output, however, display entire lines in every "z" in document found. need limit printing 10 letters appearing before every occurance of "z". e.g., if document has line "aaaabbbbbbbbbccccccdddddddz", print "ccddddddd", 10 letters appearing before. if there fewer 10 letters prior "z", nothing needs printed. if "z" appears multiple times in single line, 10 letters preceding each of these "z"'s should printed, e.g.: "aaaabbbbbbbbbzcccccdddddddz" print "abbbbbbbbb" , "ccdddddddz". the result output list of these letters, e.g.: abbbbbbbbb ccdddddddz how can print 10 letters preceding every occurrence of letter "z" in document? simple: grep -op '.{10}(?=z)' <<< aaaabbbbbbbbbzcccccdddddddz explanation: -o : print match, not entire line -p : use

c# - Line between 2 controls doesn't redraw -

i have b buttons created dynamically code , want draw line between first node , last in same stackpanel . problem whenever call function doesn't make line first b button instead move line right. my code line draw function: public void createaline() { redline = new line(); redline.x1 = nodul_nou[0].margin.left ; redline.y1 = nodul_nou[b].margin.top - 40; redline.x2 = nodul_nou[b].margin.left ; redline.y2 = nodul_nou[b].margin.top - 40; solidcolorbrush redbrush = new solidcolorbrush(); redbrush.color = colors.black; redline.strokethickness = 4; redline.stroke = redbrush; workplace.children.add(redline); } note: nodul_nou[b] button speak about, not draw line between first button , nodul_nou[0] , , b button , nodul_nou[b] .

ajax - jsf 2.0 viewscope in two windows need to refresh each other -

i have problem: i have view-scoped bean/view overview of data (list). when clicks on item, opens view-scoped window/browser tab loads , shows detailed information item clicked. all need "overview-window" change status-image "unread" "read" (i prefer ajax), when user opens detail page, need kind of property-injection; work in 2 different view-scopes? how can this? thanks help add. info: tried property-injection (other view-scoped bean); values resetted; seems created new view-scoped overview bean no content)

jquery - Web page loading text -

maybe question before wasn't able find relevant answer needs. ask how people make loading text, text grey example , left right becoming white while page load. when reach end - page loaded , page show. same thing spinners... or example how make page show loading 0%, 1% - 100% , when it's 100% page load... best way accomplish this? thanks. some comments here not possible without flash have seen done in pure html before. common in complex demo / visualisation apps , web apps. the trick page loads javascript code kicks in preload images , other resources cache. can monitor progress of using javascript , update progress bar while you're doing it. this article discusses caching images first comment @ end links article caching other resources: http://www.useragentman.com/blog/2012/01/16/caching-images-with-javascript-and-html5-progress-bars/ i've seen done quite lot if page loads lot of content through ajax request. enable require quite structural chan

linux - extract lines of a file each day in bash -

i have file 20.000.000 lines , each day file added or removed lines , need crontab, need each day obtain 9 files of 50.000 lines. for example: bigfile file 20.000.000 lines. and need generate 9 files, first file line 1 50000, second file line 50001 100000, third file line 100001 150000 . . . i can't split first time because file change days, , second problem have if first time obtain 9 files second day need continue last line use. for example first day use 450.000 lines, second day need first line line 450001 500000, , third day need use 900001 first file. the split not works because if use split first time, files change, files have not work second day can me? use split command ( manpage ). for example: $ split -l 50000 /path/to/bigfile

How to check if certain group of files of similar format exist in PHP? -

i wonder there possible ways check if group of files exit format as: $filename=$anything_id."_".random.".jpg"; random can any. have lots of files like gb_23232.jpg, gb_23122.jpg, gb_23332.jpg, gb_23422.jpg, gb_23732.jpg, gb_23922.jpg , on. i want delete files starts gb_ you can use these code $mask = 'gb_*.*'; array_map('unlink', glob($mask)); another code foreach (glob("gb_*.*") $filename) { unlink($filename); }

c - gdb doesn't stop on breakpoint -

i'm trying debug shared library run under check in unit-testing scenario. shared library statically linked (no dlload ) , both unit-testing application , shared library compiled debugging symbols ( -g ) in gdb want set breakpoint in function contained in shared library. set breakpoint successfully, when runs passes on break-point. what i've tried already: i placed printf in shared library, printed out, function called. here's makefile i'm using compilation: shell = /bin/sh cc = gcc cflags = -g -wall -std=gnu99 -iinclude extra_flags = -fpic -shared libflags = -fpic -shared ldflags = -shared -pthread -lcheck debugflags = -o0 -d _debug releaseflags = -o2 -d ndebug -combine -fwhole-program test_ldflags = -lcheck -lllist -llib -wl,-rpath $(objdir) objdir = lib target = $(objdir)/libllist.so test_target = starttest sources = $(shell echo src/*.c) headers = $(shell echo inc/*.h) test_sources = $(shell echo tests/*.c) test_objects = $(t

html - Validating and submitting - form inputs with two dimensional element -

i have form fieldset follows. inputs dynamically generated based on number entered in prior input field using jquery. first dimension of 2-dimentional array index generated inside loop. <fieldset id="accompanying"> <legend>accompanying members</legend> <p> <input type="text" name="members[0][firstname]" placeholder="enter first name"> <input type="text" name="members[0][lastname]" placeholder="enter last name"> <input type="text" name="members[0][age]" style="width: 30px;" placeholder="age"> <br> <br> <input type="text" name="members[1][firstname]" placeholder="enter first name"> <input type="text" name="members[1][lastname]" placeholder="enter last name"> <input type="text" name="members[1][age]" style="width: 30px;&quo

postgresql - Merge 3 tables in one table -

i have 3 tables (t1, t2, t3) in postgresql. have same number of columns ( 168 cols) same type , overall 300k rows. how can add of them in 1 table? insert t4 select * t1 union select * t2 union select * t3 or, if want create table during select: select * t4 t1 union select * t2 union select * t3; sql fiddle example

Google URL Shortener 403 Rate Limit Exceeded -

using google url shortener api, working fine till started testing @ load. started getting 403 rate limit exceeded errors google, though signed use api , comes 1,000,000 hits day. can see requests coming in on google reporting tool, , sending 403's everything. 403's started coming @ around 345/350 hits api, have been continuing hours. thoughts? the api limits requests 1 request / per second / per user. a user defined unique ip address. so if doing load testing single ip have cause rate limit issue. https://developers.google.com/analytics/devguides/reporting/mcf/v3/limits-quotas#general_api

android - Listview does not show data fetched from database -

i trying populate listview fetching data sqlite using cursor. no data displayed in listview though cursor has expected rows. here code: public class showusers extends activity { userdbadapter db; @override protected void oncreate(bundle savedinstancestate) { try { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_user_profile); db = new userdbadapter(getapplicationcontext()); db.open(); populatelistviewfromdb(); } catch (exception e) { log.e("error", "error occured: " + e.tostring()); e.printstacktrace(); } } @suppresswarnings("deprecation") private void populatelistviewfromdb() { cursor cursor = db.getallrecords(); startmanagingcursor(cursor); log.i("myapp", "total users: " + cursor.getcount()); toast.maketext(getapplicationcontext(),

ruby on rails - UnknownAttributeError in Controller -

with of @sasha created nested form treatments in patients: now error: unknownattributeerror in patientscontroller#update unknown attribute: treatment my patients update controller looks this: def update @patient = patient.find(params[:id]) respond_to |format| if @patient.update_attributes(params[:patient]) format.html { redirect_to @patient, notice: 'patient updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @patient.errors, status: :unprocessable_entity } end end end and form this: <%= form_for @patient |f| %> <%= f.fields_for ([@patient, @patient.treatments.build]) |tf| %> <%= render 'treatment_form', form: tf %> <% end %> <%= f.fields_for ([@patient, @patient.treatments.build]) |tf| %> <%= render 'treatment_form', form: tf %> <% end %> <%= f.submit %> <% end

android - Gradle: Error parsing XML: not well-formed (invalid token) -

Image
i'm getting compilation error in xml file cant seem spot problem.. error randomly came , don't recall touching file maybe cant see problem. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mybetswindow"> <button android:id="@+id/addbetbutton" android:text="add bet" android:layout_width="wrap_content" android:l

Copying a file results in java.io.FileNotFoundException (Access is Denied) from output -

file file1 = new file(file.getabsolutefile() + "/example/directory/example.png"); file1.mkdirs(); file1.setwritable(true); file1.createnewfile(); try { fileinputstream = new fileinputstream(exampleinputdirectory); fileoutputstream os = new fileoutputstream(file1); filechannel srcchannel = is.getchannel(); filechannel dstchannel = os.getchannel(); dstchannel.transferfrom(srcchannel, 0, srcchannel.size()); is.close(); os.close(); } catch (ioexception e) { e.printstacktrace(); } this setup copying image file new directory tree. however, when code executed following: java.io.filenotfoundexception: *points output directory* (access denied) have gone creating file1 incorrectly? the problem here because of using file1.mkdirs(); and file1.createnewfile(); together. since file1 object been given 'directory' attributes after creating directory calling "file1.mkdirs()", again using same object create '

How to detect if javascript mailto failed (eg no email client configured) -

i have found if use code: function emailer() { return window.open("mailto:someone@gmail.com?subject=whatever is") } emailer(); on computer no email client configured, well, doesn't work. in case find out if there error , paste text send element in page , prompt user paste message email , send me - in less convenient way. how detect if there error on using mailto? update: i wait little longer responses looks not possible. think have offer simpler alternative every time , make obvious user use if automated email option fails.

php - displaying wordpress post on another site -

i'm trying find best way display posts saved in wordpress on site. i've found various options far problem i'm getting can't seem find answers on when post displayed, none of formatting kept, example, in main content of post, paragraphs, bullet points , font stylings aren't displayed. if add image post appears left out. i'm hoping best way php , mysql, looking throught wordpress files i'm unsure how structured. wordpress directory located in same directory of site (e.g mysite/wordpress) this maybe many other people have asked i'm struggling find correct terminology inorder search answer. you don't need connect directly blog database. can create new file in wordpress directory , include wp-blog-header.php file: example: <?php require('./wordpress/wp-blog-header.php'); // change fit path ?> <p>recent posts:</p> <ul> while (have_posts()) : the_post(); ?> <li><?php the_title(); ?> <

F# Partial Active Pattern Matching "Rule Will Never Be Matched" -

given following active pattern: let (| hasmatch |) (x:string) = if x.contains("0") some() else none;; and following pattern matching func: let testfn x = function | hasmatch -> printfn "%a" | _ -> printf "nope";; the last line's wildcard pattern says warning fs0026: rule never matched all of examples see seem infer partial active patterns must return some('a) match, , ones return none captured wildcard. error seems differently. what missing? i think should add none case active pattern declaration follows: let (| hasmatch | _ |) (x:string) = if x.contains("0") some() else none;; in orignal example, compiler infers want return option type. when run printf in example, see print some null when there match. also, bad return some() , should return some(x) or similar

java - how to get element position in 2D array when mouse clicked? -

im building board using gui(may board game). have created 2d array make cells gomoku game. want make function: whenever click cell, cell position displayed. private cell[][] cells; private in row; private int col; update: ....... jpanel pn = new jpanel(new gridlayout(row, col, 0, 0)); cells = new cell[row][col]; (int = 0; < size; i++) { (int j = 0; j < size; j++) { pn.add(cells[i][j] = new cell()); } ...... private class mouselistener extends mouseadapter { public void mouseclicked(mouseevent e) { (int = 0; < size; i++) { (int j = 0; j < size; j++) { if ( ) { system.out.println("x: " + + ", y: " + j); } } } } i cant make work although i've tried several times , different conditions in if you can add m

css3 - Onmouseout transition with animation -

i'm trying animate div on mouseout keyframes animation : div{ -webkit-transition: -webkit-animation:flipiny 2s; } div:hover{ -webkit-animation: flipiny 0.8s; } so when user mouseout there transition,but want using animation keyframes not normal transition: @-webkit-keyframes flipiny { 0% { -webkit-transform: perspective(400px) rotatey(90deg); opacity: 0; } 40% { -webkit-transform: perspective(400px) rotatey(-10deg); } 70% { -webkit-transform: perspective(400px) rotatey(10deg); } 100% { -webkit-transform: perspective(400px) rotatey(0deg); opacity: 1; } }

android - Combine two portrait layouts in one landscape -

i designed application phones layouts portraits. think can place 2 portrait layouts standing side side making 1 landscape layout tablet. has idea how make simple? assume can use table layout, samples going in row route, when need columns one, 2 columns should have equal width. wish if utilize simple include statement include nested layouts instead of copying them, because if decide change one, need replicate changes in tablet layout bad practice of code duplication. i suggest use linearlayout weightsum=2 , horizontal orientation , can use include tags portrait layouts weights 1.

interface - Can't Open Main.Storyboard -

the document "main.storyboard" not opened. operation couldn’t completed. (com.apple.interfacebuilder error -1.) -- that's error keep receiving. after doing research, apparently need switch fonts attributed plain can't access storyboard file how supposed that? or there solution? thank you i face same issue when pull code github: occur due duplicate of identifier. of file name again reuse. click on storyboard->open source code remove duplicate identifier. find indentifer name click on error. copy whole error message. this works me.``

ios - Any way to specify a non-returned value for an RKEntityMapping? -

because working non-kvc rest service have need designate bool attribute isspecial request url rather of returned json. instance, if make request http://www.service.com/getobject?isspecial=no specify attribute isspecial no . can accomplish effect adding multiple response descriptors, 1 each of getobject?isspecial=yes , getobject?isspecial=no , need have way of defining special attribute mapping - not mapping attributes key paths key paths, rather request url. how might accomplish this? you @ using routing path patterns , using pattern meta data during mapping. i'm not sure can pull out queries individually may need have method on managed object subclass takes meta data , extracts parts want store.

ajax - How do I display real-time information to the user? -

i need show new comments user in real-time (similar youtube's live comments system no auto-adding). maybe need use pools asyn controller handle requests , show if user clicks on "show more 10 comments". or, example, similar stackoverflow's alert new inbox messages. it looks you're wanting 'push' data user in real-time. previously might have been done bit of 'hack' solution known long-polling with long polling, client requests information server in way similar normal polling; however, if server not have information available client, instead of sending empty response, server holds request , waits information become available (or suitable timeout event), after complete response sent client. however might want html5 world of websockets . i'd recommend reading on signalr , following tutorials (watch pluralsight videos). asp.net signalr new library asp.net developers simplifies process of adding real-time web function

java - Not Contain REGEX -

the regex have write match single or double quoted strings (string begin single or double quoted string , end same type) , inside quote not contain other instances of type of quote. what have far ^('|").*\1 but not know how control inside quote not contain same type of quote. how about pattern p = pattern.compile("^(\"[^\"]*\"|'[^']*')$"); not elegant using \1 , should job done.

Short-circuit OR operator in Lucene/Solr -

i understand lucene's , (&&), or (||) , not (!) operators shorthands required, optional , exclude respectively, why 1 can't treat them boolean operators (adhering boolean algebra). i have been trying construct simple or expression, follows q = +(field1:value1 or field2:value2) with match on either field1 or field2. since or merely optional, documents both field1:value1 , field2:value2 matched, query returns score resulting in match on both clauses. how enforce short-circuiting in context? in other words, how implement short-circuiting in boolean algebra expression || b || c returns true if true without looking whether b or c true. strictly speaking, no, there no short circuiting boolean logic. if document found 1 term, can't tell not check other. lucene inverted index, doesn't check documents matches directly. if search a or b , finds a , gets documents have indexed value. gets b in index, , list of documents containing (this simplify

control amount of loops (batch file) -

i wondering if there way put limit on loop batch file. mean this: have script: @echo off :start echo enter password set /p password= if %password%== abcdefg goto correct if not %password%== abcdefg goto start :correct echo job timeout 2 > nul exit :wrong echo wrong timeout 1 > nul exit say wanted go through start 3 times, , after that, go wrong. how that? @echo off setlocal enabledelayedexpansion /l %%a in (1, 1, 3) ( set /p "password=enter password: " if "!password!"=="abcdefg" goto :correct echo wrong, try again timeout /t 1 >nul ) exit :correct echo job timeout /t 2 > nul exit

android - The setDefaultValue for ListPreference don't work using dynamic entries -

i have set lp.setdefaultvalue("2"), when run app, find 2th item isn't selected, why? thanks! public class photopreference extends preferenceactivity{ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.mypreference); setcontentview(r.layout.photo_preference); // adview resource , load request. adview adview = (adview)this.findviewbyid(r.id.adviewpreference); adview.loadad(new adrequest()); listpreference lp = (listpreference)findpreference("setlastfolder"); charsequence[] entries = { "one", "two", "three" }; charsequence[] entryvalues = { "1", "2", "3" }; lp.setentries(entries); lp.setentryvalues(entryvalues); lp.setdefaultvalue("2");

Excel cell name number adding -

i confuse explain question/problem, best so. i want write formula display value cell jumping cell in particular sequence. e.g. column d =a1 =a6 =a11 =a16 ----- ---- ----- it sequence of 5 cells write 2 rows formula =a1 , =a6 , drag formula , got as =a1 =a6 =a3 =a8 anyone please guide me. you can use offset() , row() =offset($a$1,(row()-1)*5,0) paste in d1 , copy down as example if have in a values correspond row numbers you'll following sample outcome | b | c | d ------------------ 1 | | | 1 2 | | | 6 3 | | | 11 4 | | | 16 5 | | | 21 6 | | | 26 7 | | | 31 8 | | | 36 9 | | | 41 ... explanation: offset() returns reference range specified number of rows , columns cell or range of cells. row() returns row number of reference. therefore formula evaluated to: for d1 - go 0 ((1-1)*5) rows , 0 columns a1 a1 (1+0) for d2 - go 5 ((2-1)*5) rows , 0 columns

asp.net mvc 4 - MVC 4, Model and model render differently -

i'm not sure why behavior, happy if pointing me right source, i'm not sure need google. view model public class generalday { public byte tintweekday { get; set; } public string nvardayname { get; set; } public bool assigned { get; set; } } controller [childactiononly] public partialviewresult targetday(models.viewmodels.promotion promotion) { var daylist = gd.generaldaylist(); foreach (var day in daylist) { promotion.targetday.add(new models.viewmodels.generalday { assigned = promotion.targetday.firstordefault(x => x.tintweekday == day.tintweekday) != null, nvardayname = day.nvardayname, tintweekday = day.tintweekday }); } modelstate.clear(); return partialview(promotion); } view @model generalday @using xxx.viewmodels; <fieldset> //first part @(model.tintweekday) @(model.nvardayname) @(model

Is there a TTL for MySQL as there is in MongoDB? -

in mongodb there expireafterseconds index deletes object automatically after amount of time. wondering if there such thing in mysql? mongodb docs expiring data no, need delete data when it's expired. you can implement similar adding datetime field , run scheduled task in operating system (a cronjob on unix-like systems). you can schedule directly in mysql: mysql manual: using event scheduler stack overflow: how schedule mysql query?

python - What happens if I read a file without closing it afterwards? -

i used read files this: f = [i.strip("\n") in open("filename.txt")] which works fine. prefer way because cleaner , shorter traditional file reading code samples available on web (e.g. f = open(...) , line in f.readlines() , f.close()). however, wonder if there can drawback reading files this, e.g. since don't close file, python interpreter handles itself? there should careful of using approach? this recommended way: with open("filename.txt") f: lines = [line.strip("\n") line in f] the other way may not close input file long time. may not matter application. the with statement takes care of closing file you. in cpython, letting file handle object garbage-collected should close file you, in other flavors of python (jython, ironpython, pypy) can't count on this. also, with statement makes intentions clear, , conforms common practice.

xampp - while configuring Joomla 1.5, it shows error -

i using xampp 1.8.1 . it working fine in joomla 2.5 & joomla 3. not working joomla 1.5, showing errors. strict standards: non-static method jloader::import() should not called statically in /libraries/joomla/import.php on line 29 like above shows multiple errors. then have changed php.ini file set error_reporting e_all & ~e_notice after changing shows same error actually it's not error. it's showing because you(joomla) not following best practices. you(joomla) must follow standards when code. joomla 1.5 kind of out-dated now. few strict standards. anyway when using joomla 1.5 fix . advise not use obsolete versions of joomla. below show without strict standards. error_reporting = e_all & ~e_notice check out list here . read more

python - Execute a CLI command and store in a variable using telnetlib -

i using python telnetlib taking "running config" output router.how store "show running-config" output in variable.and print variable.my requirement each , every output display in console when executing each , every line of code.is there option aviod these print statements. import telnetlib #import getpass ipaddr = "10.1.1.1" passwd = "abcd123" tn = telnetlib.telnet(ipaddr) if password: try: print (tn.write (password + "\n")) print(tn.read_until("router>")) print(tn.write("enable\n")) print(tn.read_until("password:")) print(tn.write(passwd + "\n")) print(tn.read_until("router#")) print(tn.write("show clock\n")) print(tn.read_until("#")) print(tn.write("show running-config\n")) print(tn.write("\040\n")) print(tn.write("\040\

javascript - how convert classes of element to an array? -

i have <div> this. <div id="div" class="a b _c d _e f"></div> how can convert classes of <div> javascript array? var cls = $('#div').attr('class'); cls = $(cls).match(/_\s+/g).join(" "); //separate classes begin underscore. cls = $(cls).toarray(); but doesn't work. use split() function: var array; array = $('#div').attr('class').split(' ');

Use multiple font in meteor -

i have paragraph , need change font. here template: template(name="test") p.test testing here css .test font-size 18pt text-align center line-height 30pt font-family "lucida calligraphy" i have define font-family "century gothic" @ top of code of css default font , working. font-family "lucida calligraphy" not working ?? did research came know font-awesome still have no solid idea please me out guys. thank in advance!!!

java - Owner postgres table is wrong -

i using postgresql in application, , have problem, table being created postgres owner, instead of user, user01 . guess connect config right. problem when deploy app tables owner being postgres , if connect in localhost owner user01 . connection jdbc config: db.url=jdbc:postgresql://localhost/lesson01 db.username=user01 db.password=user01password config table: -- table: atividade -- drop table atividade; create table atividade ( id bigserial not null, nome character varying(255), valor double precision, constraint atividade_pkey primary key (id) ) ( oids=false ); alter table atividade owner postgres; //i need owner here user01 if need more info context problem, tell me. anyone me, please?

c# - NXT to pc bluetooth text message -

how can send bluetooth text message nxt pc , read in pc? i use this: byte[] byteout = new byte[65]; int = 0; try { byteout[0] = (byte)(textbox1.textlength + 5); //number bytes in output message byteout[1] = 0x0; //should 0 nxt byteout[2] = 0x00; //&h0 = reply expected &h80 = no reply expected byteout[3] = 0x9; //send bluetooth byteout[4] = 0x0; //box number - 1 byteout[5] = (byte)(textbox1.textlength + 1); //message size null terminator //copy bytes output array (i = 1; <= textbox1.textlength; i++) { byteout[(i + 5)] = convert.tobyte(asc(textbox1.text.substring((i - 1), 1))); } byteout[textbox1.textlength + 6] = 0x0; //add null terminator serialport1.write(byteout, 0, textbox1.textlength + 7);

html5 - How to change the particular part of a page dynamically using jquery? -

i have page header, content , footer. <div data-role="page" id="home"> <div data-role="header"> </div> <div data-role="content" id="1"> </div> <div data-role="footer"> </div> </div> now want change content part in page , header, footer same in home page another page also. <div data-role="page" id="page1"> <div data-role="header"> </div> <div data-role="content" id="2"> </div> <div data-role="footer"> </div> </div> thanks in advance. updated: for example: have page multiple options in fiddle http://jsfiddle.net/fccyc/1/ .if want click on particular button if click on bookmark button content replace change header , footer same.and if click on mapview content change header , footer same , map.js file has load map. $('#1').load(

set intersection - issues with intersect in matlab -

consider following example: time = datenum('2010-03-03 00:00','yyyy-mm-dd hh:mm'):60/(60*24):... datenum('2010-07-31 23:00','yyyy-mm-dd hh:mm'); jday = datenum('2010-01-01 00:00','yyyy-mm-dd hh:mm'):60/(60*24):... datenum('2010-12-31 23:00','yyyy-mm-dd hh:mm'); idx = intersect(time,jday); why isn't idx same size time? have thought these should identical in length seeing time portion of jday. ideas? you create vectors using colon operator , non-integer interval. since intersect element comparisons, you're bound have inaccuracies due floating-point representation, , in case suspect it's issue. if want verify that, suggest use ismember identify members not equal (but supposed be).

android - Drawing an outer shadow when drawing an image -

Image
i create rounded version of image in app drawing canvas. draw faint outershadow around image, cant quite right. have 2 questions: 1. how can draw outer shadow (i can seem draw shadow x or y offset) 2. how can draw shadow not have artifacts shown in attached image. code: ![public bitmap getroundedcornerbitmap(bitmap bitmap, float cornerradius) { bitmap output = bitmap.createbitmap(bitmap.getwidth()+6, bitmap.getheight() +6, config.argb_8888); canvas canvas = new canvas(output); final int color = 0xff424242; int shadowradius = getdipsfrompixel(3); final rect imagerect = new rect(shadowradius, shadowradius, bitmap.getwidth(), bitmap.getheight()); final rectf rectf = new rectf(imagerect); // not achieve desired effect paint shadowpaint = new paint(); shadowpaint.setantialias(true); shadowpaint.setcolor(color.black); shadowpaint.setshadowlayer((float)shadowradius, 2.0f, 2.0f,color.black);

python - Can you return tags where condition is not met in BeautifulSoup? -

i'm trying input tags page, don't want return type attribute, hidden . i can hidden fields soup.find_all('input', attrs={'type': 'hidden'}) can't negate attrs!={'type': 'hidden'} . is there simple one-liner way of getting tags don't match condition on given attribute? you'll have use function match : def input_not_type_hidden(tag): return tag.name == 'input' , tag.get('type') != 'hidden' soup.find_all(input_not_type_hidden)

zend framework2 - ZF2 - How to pass data from controller to helper -

i need pass data controller custom view helper. tried in 2 ways, unfortunately can't make working. have registered helper in module.config.php the first way tried pass variables controller helper: in controller: public function indexaction() { $this->data = $this->getapplicationtable()->gettypes(); $helper = new testhelper(); $helper->setvariables($this->data); } here helper: class testhelper extends abstracthelper { public $data; public function __invoke() { var_dump($this->data); // output null return $this->getview()->render('helper-view.phtml', $this->data); } public function setvariables($var) { if($var){ $this->data = $var; var_dump($this->data) // output array correct data } } } in layout, display this: <?php echo $this->testhelper(); ?> and got error helper-view.phtml variable empty.

path - C++ conversion from char * to unsigned char? -

hello i'm trying create take program path , put in in registry file, keep on having error. here code: #include <iostream> #include <windows.h> #include <winuser.h> #include <tchar.h> #include <limits> using namespace std; void reg() { char buffer[max_path]; getmodulefilename(null,buffer,sizeof(buffer)); const unsigned char path[ max_path ] = {buffer}; ::hkey handle_key = 0; ::regsetvalueex( handle_key, "my directory", 0, 1, path, sizeof path ); }; the error i'm getting says invalid conversion 'char*' 'unsigned char' [-fpermissive] i have spent hours looking solution, can't find one. the problem, i'm guessing, line const unsigned char path[ max_path ] = {buffer}; the problem here try create array of single characters character pointer. you use variable temporary regsetvalueex call, don't need it. instead call function buffer directly. also, should not use sizeof here

jquery - Anything slider multiple images -

i use slider , job perfectly, time slider looks little different. slide panel show image/video , little part of next image. behavior possible slider or should search plugin? make sure set width , height of each panel (e.g. li ) or elements within each panel (img, embed, iframe, etc). if panels same size, set dimensions of wrapper (e.g. ul ) , make sure resizecontents option true ( ref ).

asp.net mvc - C# property lifetime on successive http calls -

i have c# property on server side , setting on http request. property value persist request? sorry if silly one? in general, no. persist if it's property of stored in session variables (for example in controller's tempdata or in application session data), or if have other custom mechanism preserves value across requests. refer state management recommendations page on msdn overview of options.

Calling a function with double parameters () in javascript -

anyone know happens when call function double () so get_separate_save_methods_function(url, false); becomes get_separate_save_methods_function(url, false)(); i've never seen before seems change false argument true, when remove () same argument becomes false. it's not code , i'm trying work out if mistake or has been done of purpose. no, () doesn't change argument false true . get_separate_save_methods_function(url, false)(); can used when get_separate_save_methods_function(url, false) returns function. calls returned function. given get_separate_save_methods_function name, not mistake it's hard tell more code.

c# - (How) can I export a function from a .NET assembly without using C++/CLI? -

i'm working on c# component consists of 2 dlls: a .dll written in c++/cli exporting symbol; unfortunately, dll dynamically links against crt , there doesn't seem way around that. a c# assembly. the c++/cli dll gets loaded , loads c# assembly (and forwards calls it). possibly simplify scenario export symbol c# assembly right away? you can export functionallity c# com server way should pretty easy call c++ other non-c# com object.

sql - Decompose one row into multi rows according conditions -

i have table : id a_kode b_kode c_kode -------------------------------- 1 10 12 0 2 15 0 0 3 0 16 17 4 0 0 0 require query provide result : id kode ------------ 1 10 1 12 2 15 3 16 3 17 4 0 first need union rows exists not 0 value , add rows 0 columns values zeroes. select id,a_kode kode t a_kode<>0 union select id,b_kode kode t b_kode<>0 union select id,c_kode kode t c_kode<>0 union select id,0 kode t a_kode=0 , b_kode=0 , c_kode=0

git - Commits from other users in GitHub ar re-commited by me -

Image
i don't understand why when commits new file shows on end if deleted , re-written same thing when didn't touch file. we both use windows. idea causes , how avoid it? they're not same, or else git wouldn't have mentioned different. there 1 possibility if else looks same: stuff can't see must different, i.e. white space. it's not space/tab kind of issue based on screen shot. it's either white space @ end of line (like spaces) or ever more cr/lf issue using windows. you need set core.eol , core.safecrlf , core.autocrlf . in particular, if set core.safecrlf true git yell @ if edited incorrectly. if want check happened, you'll need open in checkin via it's tag , check line-endings using editor can display them, or can check size before , after. crlf version of file should longer because of cr. in fact, should (based on diff) 108 bytes longer.

c# - How to access rstrui.exe from code behind? -

please tell me how access system restore "rstrui.exe" c# code. i tried calling c:\windows\system32\rstrui.exe ; not accessible @ all. i need call function redirecting controls system restore. thanks.... you can access c:\windows\system32 using following property: environment.systemdirectory environment.systemdirectory property you can run executable using following method: process.start(path.combine(environment.systemdirectory, "rstrui.exe")); path.combine method process.start method update >>> ahhh... see problem. when accessing system32 folder 32 bit code on 64bit windows 7 , vista (maybe windows 8 too), windows 'cleverly' changes part of request path syswow64 . why may have got 'could not find path' error. in order around this, can use following: process.start(@"c:\windows\sysnative\rstrui.exe"); a more complete answer might be: if (environment.is64bitprocess) { process.start(path

c# - Error The Write timed out -

can tell me wrong code? code in c#... gives me error "the write timed out", set writetimeout... i want write data serial port. use .net framework 3.5 } serialport sp = new serialport("com6", 9600, system.io.por­ts.parity.none, 8, system.io.por­ts.stopbits.o­ne); sp.writetimeout = 500; sp.open(); try { sp.write("hello"); } catch (timeoutexception) { console.write­line("error"); } sp.close(); console.readkey(); } thanks

postgresql - Delphi edit unicode table data -

my delphi application using postgresql database (with unidac components). data stored in utf8 in database. read international characters, use handler: procedure tdmmain.ongettext(sender: tfield; var text: string; displaytext: boolean); begin text := utf8decode (sender.asstring); end; but, how possible store data, db? created handler, onsettext , sender.asstring := utf8encode (text); not working. how possible that? thanks. when reading , editing data, don't need recode utf-8 text (for example, in ongettext event). enough set useunicode option in tuniconnection.specificoptions property true , example, follows: uniconnection1.specificoptions.values['postgresql.useunicode'] := 'true'; and unidac automatically. http://www.devart.com/unidac/docs/pgsqlprov_article.htm

sql server 2008 - How to get union of two tables with different alias -

i want union want show 1 column twice different alias. e.g select first table1 union select second table1 it shows first output. but want show both first , second. how can achieved in mssql? union combines results 2 queries 1 set of columns. there's no way make column name change halfway down. closest can think of select first , null second table1 union select null first , second table1

java - How does Liferay login work? -

just user jack wants in this post, need portlet uses login through token authentication. stated there, portal-impl.jar unavailable me use, loginutil.login unaccessible. additionally, adding functionality existing ext plugin out of question because he's waaaay 'dense', , creating 1 bad practice. chose create own login function based on login() logic in loginutil . it's same code required portal-impl.jar 's properties stored locally (upgrade newer liferay version out of question think it's ok that). seems work fine, not logged in , no error apperas in tomcat. now, problem can't realise piece of code logs user in. assume it's this session.setattribute("j_username", useridstring); session.setattribute("j_password", user.getpassword()); session.setattribute("j_remoteuser", useridstring); session.setattribute(webkeys.user_password, password); ps : after custom login method (whic

java - Exception when querying a table with field BIT : JPQL -

i working jpql. have table in fields are 1. name datatype-varchar 2. sub datatype-bit in pojo file private string name; private byte sub; insertion successfull as: name= john sub=0 now when query table using : query = em.createquery("select c sample c c.name = '"+ (name)+ "'", sample.class); exception occurs: javax.persistence.persistenceexception: exception [eclipselink-3002] (eclipse persistence services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.conversionexception exception description: object [false], of class [class java.lang.boolean], mapping [org.eclipse.persistence.mappings.directtofieldmapping[sub-->sample.sub]] descriptor [relationaldescriptor(com.org.test --> [databasetable(sample)])], not converted [class java.lang.byte]. i think when getting values internally taking bit false. how can resolve problem?? i think should use boolean here.

java - SHA-256-encrypted string as directory name -

i need use sha-256-'encrypted' string part of path in filesystem (ext3, fat, ntfs, ...). i try encode base64, not work in cases, because base64-encoded string may contain '/', '\' or other invalid chars. is there (easy) way file-system-safe name of sha-256-'encrypted'-string? not use string.replaceall() possible invalid chars. thanks in advance help i not allowed write comments ... try answer. you should use uuids. must not longer sha-hash. if so, have imho done wrong.

controller - (prestashop) What is AdminController::$currentIndex for? -

i wandering what's purpose of admincontroller::$currentindex in prestahop. took relevant classes can't figure out. does know? it's url of current page. can see how set in admincontroller::init()

javascript - Defining variable in Meteor.js -

when define variable lists shown below , type lists in console, error referenceerror: lists not defined var lists = new meteor.collection('lists'); if (meteor.isclient) { template.hello.greeting = function () { return "my list."; }; template.hello.events({ 'click input' : function () { // template data, if any, available in 'this' if (typeof console !== 'undefined') console.log("you pressed button"); } }); } if (meteor.isserver) { meteor.startup(function () { // code run on server @ startup }); } it works if declare lists global variable: lists = new meteor.collection('lists'); question: why must scoped global? to access lists in console need use global scope console outside scope of file console considered own file. with var can access lists anywhere in file. in essence each file wrapped in function() {..} . why each file's variables can

C struct: consecutive fields without padding? -

any_t type ( int , struct something , …). consider structure: struct my_struct { any_t val, any_t array[10] } if define variable v : struct my_struct v; is safe use &v.val array of 11 any_t items? any_t *p = &v.val; f(p[0]); f(p[5]); f(p[10]); is guaranteed no padding added between val , array ? from c standard alone, not safe use &v.val array of 11 any_t these reasons: the c standard permits unnamed internal padding in struct: c 2011 (n1570) 6.7.2.1 15, “there may unnamed padding within structure object, not @ beginning.” unusual c implementation insert padding between val , array , because alignment requirements not require it, permitted , conceivably beneficial in circumstances, such causing array better aligned performance (rather necessity). even if there guarantee spacing of val , array elements same array of 11 any_t , there no guarantee pointer arithmetic works. c 2011 (n1570) 6.5.6 8 defines pointer arithmetic (inclu

Selenium for firefox Android -

does selenium support firefox android? if not, other tool support firefox android automation? i know selenium supports android native browser. thanks. yes, there being worked on that. think it's called selendroid . if that's not looking for, place start. also, in future there project called marionette unsure if yet ready use.

c# - Strange behaviour when initialising UISegmentedControl -

i'm writing monotouch app , i'm trying add uisegmentedcontrol view (programmatically not through ib). kept receiving following error message: application windows expected have root view controller @ end of application launch this strange because uisegmentedcontrol has nothing window root view controller. in end reduced code way down initialisation of variable: // code appears in class inherits uiview var segmentedcontrol = new uisegmentedcontrol (); i've tried putting code in class inherits uiviewcontroller , same behaviour occurred. tried putting appdelegate still same error displayed. note: debugging on ipad device when running code after playing around commented out random uiviewcontroller class have , app ran fine. i've tried commenting out various different uiviewcontrollers , every time runs fine there's not 1 view controller seems problem. it's if i've hit sort of limit amount of view controllers can have. is possible? , if not might

Best books or resources on web application security and user authentication? -

i'm looking learn more web application security , user authentication applies in 2013 , beyond across technologies php, java + spring, python + django/flask, ruby on rails, , modern application frameworks. anyone have suggestions? i gleaned a popular security.stackexchange post of these dated: the web application hacker's handbook: discovering , exploiting security flaws the tangled web michal zalewski writing secure code v2 ms press any suggestions appreciated! we have used spring security (acegi security) in various features ( database authentication, ldap authentication, web authentication, domain authentication) in project. please find references. http://www.springsource.org/spring-security http://www.springsecuritybook.com/ http://static.springsource.org/spring-security/site/docs/3.2.x/reference/springsecurity-single.html

verilog - Running timing simulation in modelsim -

i've created small design in verilog , want run timing simulation. since know how vhdl files, figured i'll (almost) same way. unfortunately, it's not easy. i've compiled design , received .sdo , .vho files. when i'm trying run testbench, receive error: > vsim work.sdesign_tb # vsim work.sdesign_tb # loading work.sdesign_tb # altera version supports single hdl # ** fatal: (vsim-3039) c:/users/k_impl/sdesign_tb.v(17): instantiation of 'sdesign' failed. # time: 0 ps iteration: 0 instance: /sdesign_tb file: c:/users/k_impl/sdesign_tb.v # fatal error while loading design # error loading design it looks quartus 12.1 created vhdl files, while want simulate verilog design (and quartus supports 1 vhdl @ same time). i've tried way, adding .sdo files sdf , run simulation through "start simulation". showed error (almost same above). how can bypass it? or maybe there way of running timing simulation verilog designs? to run timing

java - Android: how can I send verification email -

i'm developing android app, , after user registers, i'd send him verification email according mail entered in registration process. i saw several answers here have same problem: only gmail send mail self , know username , pwd. how can can send no matter mail provider? i have php backend, better there? i go back-end, several reasons: if there central back-end handles administration, should in charge of user administration , confirmation. sending email phone means more data usage user. sending email phone works if user on network allows smtp-connections outside own subnet. many isps, example, not allow that.

AngularJS: $scope NOT updating view from second controller -

i wonder if can help? i have 1 html file , controller assigned via $routeprovider so .when('/', { templateurl: 'views/contents.html', controller: 'firstctrl' everything working fine, had view ng-repeat on object , view updated so <tbody ng-repeat="item in contents.data"> <tr> this code working fine, updated item via firstctrl so $scope.contents = {}; $scope.contents.data = {...} i have extracted functionality out own controller, still same view, have 1 view , 2 controllers... second controller used specifying ng-controller on tbody so <tbody ng-controller="secondctrl" ng-repeat="item in contents.data"> <tr> now know controller working have insert ng-click on , fires the function. updating $scope second controller seems blank.. from documentation states if $scope exists in parent controller (first) child controller overwr

c# - Call a method from an invoked object -

i create instance of object can use elsewhere in class without going through more reflection if can it. after creating object (either through activator or constructorinfo, i've read arguments both used activator shorter example) have cast doesn't work. for example: server instance; public void a() { assembly loaded = assembly.loadfrom("c:\program files\test2\shared.dll"); servertype = loaded.gettype("server"); object obj = activator.createinstance(servertype, new [] { "test" }); instance = (server)obj; } public void b() { instance.startserver(); } this gives exception: system.invalidcastexception: [a]server cannot cast [b]server. type originates 'shared, version=0.0.0.0, culture=neutral, publickeytoken=2a032d22a4688508' in context 'loadfrom' @ location 'c:\program files\test1\shared.dll'. type b originates 'shared, version=0.0.0.0, culture=neutral, publ

continuous integration - Jenkins restart error, Starting Jenkins dirname: extra operand `/proc -

i trying restart jenkins, fails saying below error. has clue on this? $ service jenkins restart shutting down jenkins killproc: empty pid file /var/run/jenkins.pid /usr/lib64/jvm/jre/bin/java done starting jenkins dirname: operand `/proc/13265/exe' try `dirname --help' more information. basename: missing operand try `basename --help' more information. failed probabily when restart service jenkins not remove files in /proc directory. execute line before start jenkins: find /proc -maxdepth 2 -user jenkins -name exe -lname '*/bin/java' if have result (as in case) means there older /proc/xxxx dir , jenkins create one