Posts

Showing posts from August, 2015

java - object oriented programming in android -

i want use method in 1 of classes in class , code doesn't have error when run project "unfortunately project * hast stopped" error. , when copy method instead of creating object , on run program without problem , can 1 tell me may problem ? public void onclick(view arg0) { string p = "+989357835774"; string m = "test"; sendsms sms = new sendsms(); sms.sms(p, m); } public class sendsms extends activity { public void sms (string phonno , string message){ pendingintent pi = pendingintent.getactivity(this, 0, new intent(this, sendsms.class), 0); smsmanager sms = smsmanager.getdefault(); sms.sendtextmessage(phonno, "+9891100500", message , pi, null); } } these errors : 08-23 19:31:00.065: e/androidruntime(9985): fatal exception: main 08-23 19:31:00.065: e/androidruntime(9985): java.lang.nullpointerexception 08-23 19:31:00.065: e/androidruntime(9985):

time - Creating a timer in python -

import time def timer(): = time.localtime(time.time()) return now[5] run = raw_input("start? > ") while run == "start": minutes = 0 current_sec = timer() #print current_sec if current_sec == 59: mins = minutes + 1 print ">>>>>>>>>>>>>>>>>>>>>", mins i want create kind of stopwatch when minutes reach 20 minutes, brings dialog box, dialog box not problem. minutes variable not increment in code. you can simplify whole program using time.sleep : import time run = raw_input("start? > ") mins = 0 # run if user types in "start" if run == "start": # loop until reach 20 minutes running while mins != 20: print ">>>>>>>>>>>>>>>>>>>>>", mins # sleep minute time.sleep(60) # increment minute total mins +=

ajax - Is it possible to do long polling with XPages? -

the title question, can long polling domino xpages? instead of polling server, query takes place again when first 1 times out. you want deploy own servlet implement this. xpages being based on osgi allows in form of plugin full access user session.

java - Getting some data from HTML using regex -

i trying data html. code: public static void main(string[] args) { final string str = "<div class=\"b-vacancy-list-salary\">\n" + " 50 000\n" + " 70 000\n" + " usd.\n" + " </div>"; system.out.println(arrays.tostring(gettagvalues(str).toarray())); } static final string tag = "<div class=\"b-vacancy-list-salary\">\n"; private static final pattern tag_regex = pattern.compile(tag+"(.+?)</div>"); private static list<string> gettagvalues(final string str) { system.out.println(tag); final list<string> tagvalues = new arraylist<string>(); final matcher matcher = tag_regex.matcher(str); while (matcher.find()) { tagvalues.add(matcher.group(1)); } return tagvalue

ios - How to see if object is contained in an embedded NSArray, then grab the other items in the set -

i have nsarray contains many nsarrays, each containing pair of nsstrings such following: [["a", "b"], ["u", "a"], ["x", "y"], ...] , , interested first checking see if contains particular object, , grabbing other paired object , putting in array. example, if checking "a" in above array, result array contain ["b", "u"] i know how iterate on each array, trouble deciding how grab paired object inside array... thanks! for (nsarray *innerarray in outerarray){ if ([innerarray containsobject: @"a"]){ //how extract other object , save array? } } if you're sure data have structure describe, can use fact inner array have 2 element - index of "other" element 1-indexofyourelement: for (nsarray *innerarray in outerarray){ nsuinteger ix = [innerarray indexofobject:@"a"]; if (ix!=nsnotfound){ id objecttoadd = innerarray[1-ix];

uiview - Unable to display view when I call it from a separate ViewController in iOS -

i have view controller in application on screen have uiview user required tap on. when that, want call viewcontroller's view, , display on screen user. unfortunately, having trouble displaying view. the name of viewcontroller making call called "mainviewcontroller", , viewcontroller view wish display called, "nextviewcontroller" here code make call: - (void) touchesbegan:(nsset *)touches withevent:(uievent *)event { nslog(@"i touched."); _nextview = [[nextviewcontroller alloc] init]; //this code not being called [self.view addsubview:_nextview.view]; //neither being called } where _nextview property declare in .h file of mainviewcontroller. this method being called, reason because able see log statements print output, reason unable call lines after that. can see i'm doing wrong? thanks in advance reply. you shouldn't add view of view controller view without making view controller child view con

excel - Skip rows with blank cell in particular column -

please advise me how change code select rows if have value in bc column (ignore complete row if cell in bc column blank): private sub commandbutton3_click() range("a:a,b:b,c:c,e:e,bc:bc").select selection.copy workbooks.add selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks:=true, transpose:=false selection.pastespecial paste:=xlpasteformats, operation:=xlnone, skipblanks:=true, transpose:=false end sub first run code is. perform row deletions in added workbook: sub dural() dim n long, long, r range n = cells(rows.count, "bc").end(xlup).row = n 1 step -1 set r = cells(i, "bc") if isempty(r) r.entirerow.delete end if next end sub

jquery animation briefly stutters -

i have simple page block such: #block { width: 50px; height: 50px; background: red; visibility: hidden; } jquery code follows: var block = $('#block'); function changecol() { block.animate({width: 100, height: 100}, 300, function() { block.animate({width: 50, height: 50}, 300, changecol()); }); } $(document).ready(function() { block.css('visibility', 'visible'); changecol(); }) so i'm trying start chain of callback functions , it's working. problem have short pause in first animation (during first block "growth"). stops (maybe?) 1.5 seconds , run smoothly. idea why happens? get rid of () in second callback: var block = $('#block'); function changecol() { block.animate({width: 100, height: 100}, 300, function() { // changecol instead of changecol() here block.animate({width: 50, height: 50}, 300, changecol); }); } $(document).ready(function() {

ember.js - Ember route with quotes deprecation warning -

i upgraded ember rc7. have bootstrap tabs map child routes using 'linkto' in following way: {{#linkto page.tab1 href=false tagname=li}}{{#linkto page.tab1}}tab 1{{/linkto}}{{/linkto}} {{#linkto page.tab2 href=false tagname=li}}{{#linkto page.tab2}}tab 2{{/linkto}}{{/linkto}} this has worked no problem until rc7. following warning: debug: ------------------------------- ember.js:364 debug: ember.version : 1.0.0-rc.7 ember.js:364 debug: handlebars.version : 1.0.0 ember.js:364 debug: jquery.version : 1.9.1 ember.js:364 debug: ------------------------------- ember.js:364 render combined-scripts.js:995 deprecation: provided quoteless destination route parameter of page.tab1 linkto helper. soon, perform property lookup, rather treated string. rid of warning, wrap form.index in quotes. opt in new behavior, set env.helper_param_lookups = true @ null.<anonymous> (http://localhost:9001/bower_components/ember/ember.js:28036:15) @ object.anonymous (http://

iphone - Best iOS data structure to store sizes and colours of a product -

i developing ios application deals products. these products can have sizes , colours (clothes, example). need data structure store available colours , sizes current product (for 1 product @ time). price has part of data structure, since every colour-size combination might have different price, url product image of specified size. i have thought of two-dimensional array (i.e. nsarrays of nsarray) first dimension colour , second size , content of cell price , url, there inconvenience when product has sizes without colours or vice versa. is there other better data structure satisfies needs, or choice best? thanks! you should build own data structure(s) have layers. example: @interface variant : nsobject @property (nonatomic, strong) uicolor *color; @property (nonatomic) cgfloat price; @property (nonatomic, strong) nsstring *size; // might want better structure hold @end @interface product : nsobject @property (nonatomic, strong) nsstring *title; @property (nonatomic,

javascript - Can't access link below another positioned element -

i trying create swipe event hide / show navigation @ bottom of mobile-ready page. swipe needs @ bottom of page, if user swiping on navigation itself. i have <nav> <div class=swipearea> above it, both fixed bottom of page, , .swipearea z-indexed above nav. of course, makes links in navigation unclickable. have tried making <nav> swipeable, drags elements in <nav> on desktop test machine when swipe down. if put event on div.swipearea, functionality works charm, no links clickable. i need able click link , able swipe navigation or down. suggested small tab pull down, client doesn't want use that. want navigation hidden default, swipe , navigation appears, swipe down , disappears. of course, need navigation links work too. example code: <div class="swipearea"></div> <nav> <ul> <li><a href="somewhere.html">link1</a</li> <li><a href="another.html&q

scripting - Is there a list of all of the Python Libraries? -

if there provide link website? please not down vote question because signed stackoverflow, , wanna still able ask questions. all libraries? no. however, documentation has guide built-in libraries, , python package index has lot of 3rd-party libraries.

javascript - Prevent nested elements from triggering an event for parent element -

structure: .parent (has if/else toggle on click) -> .child (has nothing) <div class="parent">parent <div class="child">child</div> </div> the parent element styled hide overflowing content , toggle height on click. when user clicks, parent element expand show child element. want users able click on child element without parent element toggling original size , hiding child element. want toggle happen on parent. i realize child element still contained within parent element's clickable area, there way exclude it? solution 1: compare target currenttarget: $("#parentele").click( function(e) { if(e.target == e.currenttarget) { alert('parent ele clicked'); } else { //you exclude else block have nothing within listener alert('child ele clicked'); } }); fiddle e.target element started event. e.currenttarget (bubbling up) parentele in click event tha

initially populate data in rails if database is empty from application -

i have created database migration, , migrated data both on development , production servers. populate database application, if empty , avoid rake db:seed , other similar methods. know done through rake db:seed, since application deployed not pollute deploy.rb capistrano, or manually on both development , production. is there hook on database open or initialization of active record can like if !pages.first pages.populate end i aware of recommended methods populate database, still prefer app. thanks as eluded to, not best idea in world, maybe try using on of these approaches: an initializer called each time rails environment loaded. something in config.after_initialize block. see http://guides.rubyonrails.org/configuring.html

git rebase i vs git rebase --onto -

i think made mistake. wanted delete commit, used git rebase -i , deleted last commit. deleted changes have made in working directory , stage ones. how can be? know wouldn't have had problem if deleted older commits. there way delete last commit , keeping changes in working directory? btw, difference between using git rebase -i , git rebase --onto <branch name>~<first commit number remove> <branch name>~<first commit kept> <branch name> ? git rebase won't launch @ if you've got uncommitted changes known files. it'll fail error: cannot rebase: index contains uncommitted changes. some variation of error has been around since 2007. how did launch git rebase -i @ all? that written, question relates git rebase -i 's defaults. without arguments, it'll default checked-out branch, , attempt rebase against <remote>/<branch> configured 'upstream' of branch you've checked out. can check branch&#

c# - EWS Search Appointment Body for Substring -

i need search substring in user's calendar appointments. don't have other information appointment (guid, start date, etc.). know particular substring in body. i've read couple articles on how body of appointment, search guid or subject. i'm trying use code below search substring in body, error can't use body in finditems . is there way this? assuming there's no way me other info appointment, there approach can take? //variables itemview view = new itemview(10); view.propertyset = new propertyset(emailmessageschema.body); searchfilter sfsearchfilter; finditemsresults<item> findresults; foreach (string s in substrings) { //search messages body containing our permurl sfsearchfilter = new searchfilter.containssubstring(emailmessageschema.body, s); findresults = service.finditems(wellknownfoldername.calendar, sfsearchfilter, view); if (findresult

javascript - Animation between content levels in AngularJS webapp -

Image
i building functionality web app working on. app running on angularjs 1.0.7 the functionality following: user can navigate app quite conventionally, drilling down levels of content. 1 ng-view, several controllers more controllers , partials inside. in 4 first levels of content, user has ability see 'path' (same breadcrumbs): here things become interesting. when user clicks on 1 of levels, level expand , content of level inside it. opened content slide down: as reference understand better, think of evernote's mobile app. there, use same mechanism switch between views on same level, every level can represented controller in 1 parent. in case, however, 4 levels in hierarchical structure. on level 1 have option see several level 2's, on level 2 can go several different level 3's. i trying see how make possible. need keep previous , new content visible during transition. in end, implemented functionality clever use of dummy elements. when nav

Wordpress: Menu item 'forum' disappear when it becomes Current-menu-item -

after number of updates in wordpress, 1 of menu items (forum (simple:press) disappears when choose page in menu. before update works perfect, , @ moment other menu items working well. forum menu item gives problem. by inspecting of elements saw word 'forum' missing. another menu item (profiel) f.i. works fine. profiel i wager is being hidden css. try identify style applied menu item when becomes active (probably .active class added), in style.css or whatever. there's chance there following attribute being applied it: .active { display: none; }

javascript - get data from server Backbone.js application -

update: updating question answer of sushanth --, have faced troubles prevent code run [the latest update of code in question below after quote "latest update" & issues below it] i developing backbone.js application , stuck getting data server. http://localhost:8888/client/i/schedule this url represents json array of required data, problem here how make view read data collections , model there 3 files below: the first 1 view // filename: views/schedule define([ 'jquery', 'underscore', 'backbone', 'collections/schedule', 'text!templates/schedule.html' ], function($, _, backbone, schedulecollection, scheduletemplate) { var scheduleview = backbone.view.extend({ el: $(".app"), initialize: function() {}, render: function() { console.log('schedule view loaded successfully'); } }); return new scheduleview; }); the second 1 collection // filename: collections/sche

Camel and load balancer -

i using camel implement route, load data db , apply processing on before producing results saved in db again. part of web application. my problem war going deployed load balancer 2 servers. there 2 camel contexts 2 routes performing same processing on same db. i have case same record being processed 2 routes. how handle problem prevent routes performing same job twice? if need have setup each server might receive same record - need idempotent route . , need make sure idempotent repository same between machines. using database repository easy option. if not have database, hazelcast repo might option. what can issue determine unique in records - such order number or customer + date/time or increasing transaction id number.

.net 4.0 - C# Extension Method Not Defined -

i have basic extension method: namespace phpimport { public static class stringextensionmethods { public static bool isnullemptyorwhitespace(this string thestring) { string trimmed = thestring.trim(); if (trimmed == "\0") return true; if (thestring != null) { foreach (char c in thestring) { if (char.iswhitespace(c) == false) return false; } } return true; } } } i'm trying use in same project (separate .cs file), in same namespace, , i'm getting 'string' not contain definition 'isnullemptyorwhitespace' error. namespace phpimport { class aclassname: aninterface { private void somemethod() { if (string.isnullemptyorwhitespace(astringobject)) { ... } } } } i've tried rebuildin

Android Exception "JSONArray fail" while fetching data from sql server using c# JSON webservice -

i developing android app , c# desktop app. c# application connecting sql server database. reading/sending data in android database using json c# web service. i using code retrieve data database , display in android in table. here android code: public class studentactivity extends activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.student); button button2 = (button) findviewbyid(r.id.button2); button2.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { string rs = null; inputstream = null; try{ httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://10.0.2.2:51220/service1.svc/getdata?"); httpresponse response = http

In Jenkins, if next trigger build is in pending state then how to abort running build and start running next pending build? -

in jenkins, if 1 build running , next 1 in pending state should running 1 should aborted , next pending 1 should start running , on. i have few projects , each project has few jobs in it, tried save build_number env variable in 1 text file (build_number.txt) , take number abort previous triggered build making build_number.txt file each job not looking efficient , have create many build_number files each job every project. can please suggest me better approach thanks based on comments, if sending many emails actual problem, can use poll scm poll once in 15 minutes or so, or specify quiet time job. ensure build taken once in 15 minutes. users should locally test before commit. if jenkins used verifying commits don't see wrong in sending email if build fails. after all, supposed know that, no matter if fixed in later update intentionally or unintentionally. but if still want abort running job if there updates, can try following. lets call job aborted job a crea

html - How to convert Javascript quiz to show a button after a a combination of buttons are chosen -

i'm trying figure out how change code around when answers questions, certain link or button depending on combination of questions asked. prefer use javascript , html because that's know. <html> <head> <style type="text/css"> <!-- .bgclr {background-color: white; color: black; font-weight: bold;} --> </style> <script language="javascript"> script , many more available free online @ javascript source!! http://www.javascriptsource.com <!-- begin // insert number of questions var numques = 4; // insert number of choices in each question var numchoi = 3; // insert number of questions displayed in answer area var answers = new array(4); // insert answers questions answers[0] = "cascading style sheets"; answers[1] = "dynamic html"; answers[2] = "netscape"; answers[3] = "common gateway interface"; // not change below here ... function getscore(form) { var score = 0; var

xamarin.android - YouTube Video API Time Out -

i using xamarin mono android google api binding. receive http 308 error, timeout, when upload video that's larger 75 mb. unable cast videosinsertrequest.requestfactory gdatarequestfactory , set time out. no gdatarequestfactory exists. request factory of type icreatehttp , it's create method returns httpwebrequest. there way set youtuberequest's time out property or upload videos way? googleauthenticator auth2; youtubeservice yt = new youtubeservice (auth2); string name = string.format("{0} {1}", etstatusupdate.text, datetime.now.tostring()); var videosinsertrequest = yt.videos.insert (helpers.makevideo (name, etstatusupdate.text), "snippet,statistics,status", makevideofilestream (), video_file_format); //((gdatarequestfactory)videosinsertrequest.requestfactory).timeout = 9999999; videosinsertrequest.progresschanged += videosinsertrequest_progresschang

List sorting C# using 2 fields -

i have list of custom objects. object contains 1 string , 2 decimals. sort list based on 2nd decimal field descending first decimal field. for eg: object 1 -> "a", 100, 10 object 2 -> "b", 300, 0 object 3 -> "c", 200, 200 object 4 -> "b", 400, 0 would sorted object 3, object 1, object 4, object 2 i apologize if has been answered - please point me post not find it list.orderbydescending(o => o.field2) .thenbydescending(o => o.field1);

regex - Rename with pattern -

i have lot of files looking this: "this file.txt" "this file.txt" "this m file.txt" "this m file.txt" so basically, if try describe it, filename composed of 2 parts, 1 in upper case, other in lower case (though first letter of second part can in upper case too). words can composed of 1 single char. when there's choice, single character word in upper case in considered of first part. i'd extract first part of filename, composed of upper case words, put them lowercase (with first letter uppercase), , seperate rest hyphen. so result i'm expecting is: "this - file.txt" "this - file.txt" "this - m file.txt" "this m - file.txt" what have far is: rename 's/^(([a-z]{2,}| )+)(.*)/\u\l$1\e - $3/g' * but there quite few problems (one letter upper case words don't match, , first word capitalized). i think regex you're looking be: s/^((?:[a-z]+ )+)/(join "

c# - need help around IQueryable query result -

assuming following tables person id name personteam id person_id is_supervisor team_id team id timesheet id team_id i obtain timesheets supervisor. got name of supervisor, need select team got supervisor role. select time sheet of teams. i believe following query does var alltimesheets = ctx.personteam.where(y => y.person.name == supervisor_name).where(x => x.is_supervisor == true).select(z => z.team).select(t => t.timesheet); afer operation cannot understand alltimesheets a iqueryable<icollection<timesheet>> i expected more a <icollection<timesheet>> or ienumrable . then questions : why got kind of result ? how obtain timesheet[] got iqueryable < icollection < timesheet > > ? why did kind of result ? expected more icollection<timesheet> an iqueryable<t> is ienumerable<t> . reason it's returning iqueryable can chain other methods orderby

java - jfreechart crashes when using Yahoo Finance Quotes -

Image
question resolved: solution changing jfreechart v1.0.15 i have peculiar problem. what have set file sends url request yahoo finance website , uses results draw jfreechart in jframe. what can't head around following: for url requests, jframe crashes it starts, shows white screen. whereas other requests, program works fine. example for example: this request: "http://ichart.yahoo.com/table.csv?s=goog&a=0&b=1&c=2011&d=6&e=24&f=2013&g=d&ignore=.csv"; works fine. but request: "http://ichart.yahoo.com/table.csv?s=goog&a=2&b=1&c=2012&d=6&e=24&f=2013&g=d&ignore=.csv"; causes error. how possible? note i know following: jframe crashes jvm doesn't make note of (doesn't notice crashes) downloading of stock quotes (the information jfreechart uses) goes perfect in both cases the code downloading data , displaying in jfreechart comes this site (the code posted r

google app engine - NotSerializableException FacebookConnectionFactory -

i'm using jsf 2.0, spring social facebook , google app engine. getting error when execute code: web.xml: <welcome-file-list> <welcome-file>login.jsf</welcome-file> </welcome-file-list> login.jsf: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:prime="http://primefaces.org/ui"> <h:outputtext value="#{user.text}" /> </html> usersessionmbean: @managedbean(name = "user") @sessionscoped public final class usersessionmbean implements serializable { oauth2operations oauthoperations = null; facebookconnectionfactory connectionfactory = null; private facebook fbusersession = null; private string text = "loging..."; public usersessionmbean() { connectionfactory = new facebookconnectionfactory("my_key&

gruntjs - grunt-init copyAndProcess corrupting png files -

i've started using grunt-init. have working, except i'm finding images/*.png files in template corrupted in transit destination folder. i suspect init.copyandprocess function corrupting them (they open in gimp template folder not destination folder). how can copy instead of copyandprocess subset of files in template? preferably using pattern 'images/**' identify files. you can use filestocopy, since pass noprocess hash, telling grunt-init files should not process. refer http://gruntjs.com/project-scaffolding#copying-files (grunt-init documentation) , example @ line 73 of commit https://github.com/gruntjs/grunt-init-jquery/blob/ecf070d7469d610441458111bc05cd543ee5bbc0/template.js .

MySql LEFT JOIN within LEFT JOIN -

i trying following mysql query search box. trying return "album" info (title etc) while including thumbnail of first image in album. however, have 2 tables image info. first, photos_albums contain images in album, first image id table, image info in photos table. believe problem having, need tell first left join limit query 1, have had no luck doing this. think need join within join? on appreciated. select albums.title, albums.title_url, photos.path, photos.medtype, photos.vpath albums left join photos_albums on photos_albums.album_id = albums.id left join photos on photos_albums.photo_id = photos.id albums.user = '$site_user' , ( albums.title '$keyword%' or albums.title '% $keyword%') limit 6 you can try this select a.title, a.title_url, q.path, q.medtype, q.vpath albums left join ( select pa.album_id, pa.photo_id, p.path, p.medtype, p.vpath ( select album_id, min(photo_id) photo_id

javascript - Display an alert after submitting a form using angularjs -

i'm using angularjs login form, , i'm making api call server username/password , display alert. login.jade // form input(type="submit",ng-click="submit()") div.alert(ng-show="showalert",class="{{alert}}",ng-animate="{show: 'alert-show', hide: 'alert-hide'}") button(ng-click="showalert = !showalert") fadein controller.js $scope.submit = function () { if ($scope.username != undefined && $scope.password != undefined) { $http({ method: 'post', data: { username: $scope.username, password: $scope.password }, url: 'api/login' }). success(function (data, status, headers, config) { if (data.auth) { $scope.alert = data.alert; } else { $scope.alert = data.alert; } }). error(function (data, status, headers, config) { // else }); $scope.showalert = true; } } data.alert

jquery - Bootstrap scrollspy won't work -

i'm trying implement bootstrap scrollspy on website i'm working on no matter do, can't seem work (or anything matter). the website can viewed @ http://thecreativecompany.stage.webcomm.com.au/ here's javascript: $(document).ready(function () { var offset_height = $("nav").height(); $('#nav-wrapper').height(offset_height); $("nav").affix({ offset: $("nav").position() }); $('body').scrollspy({ target: '#nav-menu', offset: offset_height }); $('#menu li a').click(function (event) { var scrollpos = $('body').find($(this).attr('href')).offset().top - (offset_height - 1); $('body,html').animate({ scrolltop: scrollpos }, 500); return false; }); }); i believe you're missing .nav class in menu. docs: then add data-target attribute id or class of parent element

html - Hide element by class in pure Javascript -

this question has answer here: what queryselectorall, getelementsbyclassname , other getelementsby* methods return? 8 answers i have tried following code, doesn't work . idea have gone wrong? document.getelementsbyclassname('appbanner').style.visibility='hidden'; <div class="appbanner">appbanner</div> using jquery or changing html not possible using [self->webview stringbyevaluatingjavascriptfromstring:@""]; in objective-c. document.getelementsbyclassname returns htmlcollection (an array-like object) of elements matching class name. style property defined element not htmlcollection . should access first element using bracket(subscript) notation. document.getelementsbyclassname('appbanner')[0].style.visibility = 'hidden'; updated jsfiddle to change style rules of

php creating an update function, binding, arrays and PDO -

ok im continuing on journey of learning adapt pdo , oop , @ slow rate. here issue. im trying create function handle updates mysql, feels complicated point type out manually. doing lot of handling big updates forms wanted make function reusable think way on complicated it, there more concise way while keeping code easy review? this update function: // take data arrays, loop through , print each out // concatenate onto set , concatenate clause // on end unless there no criteria in case print nothing public function update_sql($table="users",$update_array,$criteria=""){ $sql = 'update `'.$table.'` set '; $sqlfieldparams = array(); // creating array `user_id` = :user_id etc etc foreach ($update_array $fieldname => $fieldvalue) { $sqlfieldparams [] = $fieldname . '= :' . $fieldname; } // concatenate don't print if there no criteria passed $sql .= implode(', ', $sqlfieldparams) . ($criteria ? '

regex - inline multiple matching within a search string in perl -

i have opengl code have special indentation after running astyle. example, glbegin(gl_lines); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glend(); the above code want change thing below. glbegin(gl_lines); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glvertex2f(1.0f, 2.0f); glend(); in special case whatever there in between glbegin , glend want shift 4 white spaces. i want inline , using perl. it's hard mean "inline." assume want use -e command line option. pretty simple use of perl. should spend time documentation. in windows cmd shell: perl -p -e "$i=0 if/glend/;s/^/ / if $i;$i=1 if /glbegin/" < infile.c > outfile.c in bash replace double quotes single ones.