Posts

Featured post

Formatting string according to pattern without regex in php -

how can format arbitrary string according flexible pattern? solution came using regular expressions, need 2 "patterns" (one search , 1 output). example: $str = '123abc5678"; desired output: 12.3ab-c5-67.8 i use pattern in variable (one user can define without knowledge of regular expressions) this: $pattern = '%%.%%%-%%-%%.%'; so user have use 2 different characters (% , .) a solution regex this: $str = '123abc5678'; $pattern_src = '@(.{2})(.{3})(.{2})(.{2})(.{1})@'; $pattern_rpl = "$1.$2-$3-$4.$5"; $res = preg_replace($pattern_src, $pattern_rpl, $str); //$res eq 12.3ab-c5-67.8 way complicated since user need define $pattern_src , $pattern_rpl. if string vary in length, more complex explain. yes, write function/parser builds required regular expressions based on simple user pattern %%.%%%-%%-%%.%. wonder if there "built in" way achieve php? thinking sprintf etc., doesn't seem trick. ideas?

vba - Copy Excel Data With Source Formatting -

i recorded macro this, , copied macro code , adapted how needed it. however, issue source formatting not kept when paste on new worksheet. step did miss? must selection.pastespecial right? below non-working syntax selection.autofilter activesheet.listobjects("db1.accdb").range.autofilter field:=1, criteria1:="pink" lastrow = 2 worksheets("sheet2").range("a65536").end(xlup).row next lastrow range("a1", "m" & lastrow).copy sheets.add after:=activesheet selection.pastespecial paste:=xlpasteallusingsourcetheme, operation:=xlnone, skipblanks:=false, transpose:=false range("a1").select activesheet.name = "pink" no need selection.pastespecial , normal copy method sufficient. sub copytest() '/ source destination '-------- ----------- sheet1.usedrange.copy sheet2.cells(1, 1) application.cutcopymode = false end sub << --this work c

python - How can I feed keys in to a terminal for unittesting purposes -

i'm working on plug-in vim, , i'd test behaves correctly, under start-up, when users edit files e.t.c. to this, i'd start terminal, , feed keys in it. i'm thinking of doing python script. there way this? in pseudo-python might this: #start terminal. here konsole konsole = os.system('konsole --width=200 --height=150') #start vim in terminal konsole.feed_keys("vim\n") #run vim function tested konsole.feed_keys(":let my_list = myvimfunction()\n") #save return value file system konsole.feed_keys(":writefile(my_list, '/tmp/result')\n") #load result python open('/tmp/result', 'r') myfile: data = myfile.read() #validate result assertequal('expect result', data) i think should verify core functionality of plugin inside vim, using unit tests. there's wide variety of vim plugins, provide additional mappings or commands, invoked user, , leave behind side effects in buffer, or output

ios - Align baselines with characters in large line heights with Text Kit -

Image
when draw attributed string fixed line height text kit, characters aligned bottom of line fragment. while make sense on 1 line characters varying in size, breaks flow of text multiple lines. baselines appear decided largest descender each line. i've found article people behind sketch explaining exact problem in bit more detail , showing solution does, not explaining how achieved this. this want basically: when showing 2 lines large line height, result far ideal: the code i'm using: let smallfont = uifont.systemfont(ofsize: 15) let bigfont = uifont.systemfont(ofsize: 25) let paragraphstyle = nsmutableparagraphstyle() paragraphstyle.minimumlineheight = 22 paragraphstyle.maximumlineheight = 22 var attributes = [ nsfontattributename: smallfont, nsparagraphstyleattributename: paragraphstyle ] let textstorage = nstextstorage() let textcontainer = nstextcontainer(size: cgsize(width: 250, height: 500)) let layoutmanager = nslayoutmanager() textstorage.append(n

java - .class files under target/classes folder Maven -

i have maven project once run maven build mvn clean install target/classes folder generated suspicious .class file. can see .class file under folder. how can identify .class file being pulled from. i searched in source code , can't find results string search. this class, rmiinvocationwrapper_stub.class

xcode - CocoaPod Storyboard error: -

i made cocoapod include in main project, splash screen animations used while app loading page go to. builds fine in cocoapod project, when include local copy in other projects local folder, following error on storyboard... error: not enough arguments provided; input document operate on? any idea on going on here? it ended being issue .podspec file. had .source_files spec including not swift file, storyboard.. apparently xcode not cool (shown below).. spec.source_files = 'cocoapodprojectfolder/source/*.{swift, storyboard}' to fix had move storyboard file correct spec: resource_bundle... spec.source_files = 'cocoapodprojectfolder/source/*.{swift}' spec.resource_bundle = {'cocoapodproject' => 'cocoapodprojectfolder/source/*.{storyboard}'}

php - WooCommerce dashboard. Edit order page - Product display -

Image
i need sort order - products different displaying woocommerce. need sort products in order variantion (i know how). problem don't find how can edit page. know can't edit woocommerce core files, woocommerce updates code disapears. i know can done function somehow so how can edit order page product display ? image want edit (order products display. display variantion):