Posts

Showing posts from January, 2011

python use the string as not string -

this question has answer here: how access object attribute given string corresponding name of attribute 2 answers i url this response.url i more date response. i wonder if there way in can pass things want , use in response this: x = 'url' return response.x you can use getattr : x = "url" return getattr(response, x) from docs: getattr(object, name[, default]) return value of named attribute of object. name must string. if string name of 1 of object’s attributes, result value of attribute. example, getattr(x, 'foobar') equivalent x.foobar . if named attribute not exist, default returned if provided, otherwise attributeerror raised.

post - How are Tweets sent? -

i confused here. how tweet sent server once hit "tweet" button website? to answer this, set proxy listener intercept requests , everything. set browser on localhost , everything, and, while received request while loading twitter.com, there no requests received time hit "tweet" , time showed in stream. how physically possible? there extremely simple i'm missing here? twitter uses https exclusively now, without setting mitm proxy, unable snoop on data being transmitted. with regards setting mitm proxy, check out piece of software: mitmproxy if you're looking send tweets yourself, separately twitters web page / apps, check out api: twitter 1.1 api - statuses/update most browsers come developer plugins, let see data being sent requests (including https requests). best - in opinion - chromes developer extension (which installed default), can opened pressing 'f12'. alternative firebug firefox, once installed can opened pressing ...

Python Django Form Wizard: How to implement cancel button -

i using form wizard , want implement cancel-button brings me page on clicked link brought me formwizard. there smart way this? @ moment adding redirect link starts form wizard that: <td><a href="/lecture/add/?redirect={{ request.path }}">create new lecture</a></td> then in get_context_data add self.request.get.get('redirect') context. in template have cancel-button redirects link context. works in step 1. in other steps information gone. have idea how solve this? appreciated! you might want use hidden input field transmit cancel action each time form submitted: <input type="hidden" name="redirect" value="{{ cancel_action }}" /> and read in view: def get_context_data(self, form, **kwargs): # ... if self.request.get.get('redirect'): # ... elif self.request.post.get('redirect'): context.update({ 'cancel_action' : self.request.post.get(...

html - CSS display:table and padding-top -

i using display:table in css in order place blocks in form. but there behaviour cannot understand: when 2 blocks set display:table-cell; , both depending on display:table father div, impossible put margin or padding-top on 1 block, without applying on second. a quick example: here i want put padding-top on second block. how can ? add vertical-align:top 1 want place up, , other 1 add padding need go down. .col1 { display: table-cell; vertical-align: top; } http://jsfiddle.net/nw8dg/5/

collections - How can Boolean/boolean serve as the key of a HashMap in Java? -

i have interview question asks if boolean can serve key of hashmap in java. wasn't sure how possible, , explanation. it unclear if boolean or boolean meant in question. perhaps both should handled in answer. that's great (and pretty funny!) question. you're going have 2 items, can mash multiple items each value. example: import java.util.arraylist; import java.util.arrays; import java.util.list; import java.util.map; import java.util.treemap; /** <p>{@code java booleankeyedmapxmpl}</p> **/ public class booleankeyedmapxmpl { public static final void main(string[] igno_red) { system.out.println("<boolean,string>:"); map<boolean,string> mbs = new treemap<boolean,string>(); mbs.put(true, "hello"); mbs.put(false, "goodbye"); system.out.println("true: " + mbs.get(true)); system.out.prin...

asp.net - MSBuild script to remove old files from a directory that are no longer in source control -

the context live website using teamcity pull git. deployed website not under source control. need clean old files on deployed site no longer in source control particular folder. we're doing in msbuild deleting in folder first, before doing copy: <itemgroup> <dirstoclean include="$(webdir)\foldertocleanse" /> </itemgroup> <target name="cleanwork"> <removedir directories="@(dirstoclean)" /> </target> <target name="copyfiles"> <message text="== copying website files =="></message> <copy sourcefiles="@(all)" destinationfiles="@(all->'$(webdir)/%(recursivedir)%(filename)%(extension)')" skipunchangedfiles="true" overwritereadonlyfiles="true"></copy> </target> we want able without deleting files in foldertocleanse , re-transferring everything, because not elegant , interferes change detection...

html - CSS Two borders. diffrent height -

i have question, possible in attachment in pure css? <h3 style="border-bottom:1px solid #515151"><span style="border-bottom:3px solid #0066b3">header</span></h3> http://i.stack.imgur.com/tw0uu.png you can way: h3 { height:14px; padding-bottom: 10px; width: 100%; margin: 20px auto; float: left; border-bottom: 1px solid black; } h3 > span { border-bottom: 5px solid blue; } and html <h3><span>header</span></h3> fiddle

powershell - Creating encrypted build parameter in TeamCity 8.0 from REST API -

i'm trying write powershell script creates parameter in teamcity build configuration, simple rest api. just set authenticated webclient , make put request parameters of build config: $webclient.uploadstring("http://server:8111/httpauth/app/rest/buildtypes/buildid/parameters/password, "put", "passwordstring") but parameter contains password , needs stored password type in team city. i know can change type of parameter manually teamcity's ui there way automate rest api (otherwise i'll doing manually on 100 build configs) jetbrains got me issue , explained type of functionality not available until release of 8.1 as alternative, there way of defining parameter in build's parent project, parameter inherited builds under project. it's perfect situation password can stored in root project , inherited automatically across builds.

A bit confused about HttpClient[Java] handling gzip responses -

my application makes http request api service, service returns gzipped response. how can make sure response indeed in gzip format? i'm confused @ why after making request didn't have decompress it. below code: public static string streamtostring(inputstream stream) { bufferedreader reader = new bufferedreader(new inputstreamreader(stream)); stringbuilder sb = new stringbuilder(); string line; try { while ((line = reader.readline()) != null) { sb.append(line).append("\n"); } } catch (ioexception e) { logger.error("error while streaming string: {}", e); } { try { stream.close(); } catch (ioexception e) { } } return sb.tostring(); } public static string getresultfromhttprequest(string url) throws ioexception { // add retries, catch exceptions httpclient httpclient = new defaulthttpclient(); httpget httpget; httpresponse httpresponse; inputstream stream; t...

get current active keyboard layout(language) in linux -

in c/c++ program want know language user going type. mean language id displayed in corner of task bar. en or ru or zh or fr or it. i know how list of possible layout: $ setxkbmap -query | grep layout output: layout: us,ru but how know 1 selected right now? (for current window) setxkbmap -print isn't helpful in case, first idea. have found little tool , easy compile sudo apt-get install git mkdir -p `~/src` cd `~/src` git clone https://github.com/nonpop/xkblayout-state.git cd xkblayout-state make now can run command ./xkblayout-state current layout, e.g. ./xkblayout-state print "%n" german% or list installed layouts ./xkblayout-state print "%n" german english english in case without trailing % . have expected that, because have not added \n .

python - Short animation class in Pygame? -

i litterally have no idea still how use classes. need 18 frame animation , have capability of doing anywhere (25 times) in 5x5 grid. ideas on how accomplished? anyway, have far: class showrectangles: def __init__(self): pass def flipcard(self): while showrect: pygame.draw.rect(window,black,[self.position,75*scale,75*scale]) self.blitoptions = self.image,self.position,[[55,self.frame,0],[75*scale,75*scale]] window.blit(pygame.transform.smoothscale(self.blitoptions,75*scale).convert_alpha()) if self.flipping , self.frame != 18: self.frame += 1 else: self.flipping = false class boardcard(showrectangles): def __init__(self,pos): self.position = pos self.rect = rect(self.position[0]*scale,self.position[1]*scale,self.position[0]+75*scale,self.position[1]+75*scale) self.flipping = false self.frame = 0 self.image = themedb["default"]["images"]["flipanimation"] # def getrect(self): ...

c# - How to fix The model item passed into the dictionary is of type error? -

i trying run first asp.net mvc application. created cotroller , view. data taken database. however, when project can run when try navigate customer page following error. the model item passed dictionary of type 'system.collections.generic.list`1[mvcapplication3.models.customer]', dictionary requires model item of type 'mvcapplication3.models.customer'. i bit confused here, error says has requesting model type. stack trace stack trace: [invalidoperationexception: model item passed dictionary of type 'system.collections.generic.list 1[mvcapplication3.models.customer]', dictionary requires model item of type 'mvcapplication3.models.customer'.] system.web.mvc.viewdatadictionary 1.setmodel(object value) +585211 system.web.mvc.viewdatadictionary..ctor(viewdatadictionary dictionary) +371 system.web.mvc.viewpage 1.setviewdata(viewdatadictionary viewdata) +48 system.web.mvc.webformview.renderviewpage(viewcontex...

Nested Loops in VBA Excel -

i have need create list based on data. need render numbers 000000 through numbers 080808. hoping format data this... 000000 - chw equipment rtu 000001 - chw equipment chiller etc. need list of potential combinations of numbers, description of be. like: =concatenate(a1,c1,e1," - ",b1," ",d1," ",f1) except looped through possible combinations. can me come loop this? i'm not familiar macros. a b c d e f 00 chw 00 equipment 00 rtu 01 hhw 01 sm steel pipe 01 chiller 02 steam 02 lb steel pipe 02 split system 03 med gas 03 copper 03 pump 04 ug/soil 04 cast iron 04 boiler 05 domestic water 05 plastic 05 cooling tower 06 compressed air 06 double-wall 06 air compressor 07 natural gas 07 sheetmetal 07 fan 08 refrigerant 08 fixtures 08 unit vent sub getallcombinations(...

xcode 5 - compiling source without including the files -

i creating library mac using xcode5 using code (c++) being developed , maintained other developer , @ different path library project. e.g. project @ /svntrunk/../../mylibraryproject/ the code want compile(use) in library @ /svntrunk/../../../utils/networkutils/src/source files here i have tried following approaches refer source files project don't copy them project, way when other developer updates code automatically reflected since pointing location. in case linker fails find symbols networkutils code. here while adding file project don't select 'copy items ..' option second approach took select 'copy items..' option while adding source files networkutils project. way files copied project , compiler able find symbols. if other developer updates networkutils code have manually copy updated code files doesn't seem right thing do. it seems move forward have go option 2. please let me know if there better way approach problem. thanks dev ...

photoshop - Elements 11 inner glow -

not sure if correct place ask have image trying add inner glow to. works fine if glow light coloured try make glow darker colour vanishes altogether. does know why or how add black inner glow? the blending modes play darkness , lightness u can , and there 2 main sections use 1st) darken modes (shows dark colors only) like multiply (it shows black , dark colors , hides white 2nd) lighten modes (shows white colors only) like screen (which hides black , darken photo , appears white , lighten colors) check page may understanding blending modes

javascript - For-Each Loop in TextArea -

when tried use handlebars foreach-loop within plain html textarea, encountered me unexpected behaviour. first let me show code: my template.html: <template name="test"> <textarea> {{#each array}} {{this}} {{/each}} </textarea> </template> my template.js: template.test.array = function(){ return ["string1", "string2", "string3"]; } the problem: i expected output looks that: string1 string2 string3 instead got this: <!--data:46xrgsl9ax8aca3ek--> <!--data:tu6ficxrrasloh2w9--> <!--data:5h3pkyb66dhw4zrwf--> as workaround used handlebars helper , manipulated value of textarea utilizing jquery, worked perfectly. still clarification case: why don't expected output? if use loop outside of textarea, prints strings properly. what these strings? javascript's internal object-ids or like? every little appreciated! these strings spark landmarks ...

sorting - sort, remove duplicates and blanks, return numbers only in an excel vba array -

in userform, have textbox multiline enabled . want user enter numbers in textbox each number being in new line , click commandbutton. commandbutton should store text array, sort in ascending order, remove duplicates , blanks , non numbers , return data excel sheet starting @ range i3. i tried coding failed sort, remove blanks , non numbers. moreover, output in excel sheet not recognized numbers :( in simple code, when following text entered textbox 1 2 3 4 6 5 the output on excel sheet is 5 1 2 3 4 6 here trial .. appreciated private sub commandbutton1_click() dim strtext() string dim long, k long k = 3 strtext = split(textbox3.text, chr(10)) = 0 ubound(strtext) sheet3.cells(k, 9).value = strtext(i) k = k + 1 next sheet3 .range("i3:i" & k).removeduplicates columns:=1, header:=xlno .range("i3:i" & k).sort key1:=.range("i3"), order1:=xlascending end end sub try following code: private su...

coffeescript - collection.find "fields" option interfere with "selector" argument -

i'd publish online users list clients, , exclude 'username' properties due security reasons. have following server side publish: meteor.publish 'onlineusers', -> users = meteor.users.find "services.resume.logintokens.0": $exists: true and works fine, producing following output: console.log users.fetch() >> [{ id: 'kfney2anhwzc4w4zx', createdat: fri jan 31 2014 20:04:40 gmt+0400 (msk), <...> }, { _id: 'tlnbhoqcex46v5l7s', createdat: fri jan 31 2014 20:05:04 gmt+0400 (msk), ... }] but add "fields" option publish arguments, result empty list: meteor.publish 'onlineusers', -> users = meteor.users.find "services.resume.logintokens.0": $exists: true fields: username: true console.log users.fetch() >> [] so questions are: does "find" method query ...

c# - returning text values from CheckBoxList -

i'm new coding missing obvious. i've tried searching here , various other resources can't code want i'm hoping can help. i have checkbox list populated sql query based on user input. intention user can check 1 or more items on list , sql stored procedure run each checked item value of selected item passed parameter value. so, if there 6 items in list , 3 checked code loop through list , each checked item run sp item's value parameter value before moving on next item in list. as first step in testing logic have code below supposed pass selected item's text label when button clicked, rather checked box's text value getting 'system.data.datarowview' int checkcount = chcklist.items.count; (int = 0; < checkcount; i++) { if (chcklist.getitemchecked(i)) { string str = chcklist.items[i].tostring(); label23.text = str; } } if change assignment of string str value 'string str = chcklist.getitemtext(i).tostring(...

ruby on rails - Using jQuery Autocomplete -

in rails 4 application, have search box in navbar using jquery's autocomplete. i'm using on user's index action. works good, except if click on user's name dropdown, want go profile page. users controller: def index if params[:term] @users = user.order(:name).where("lower(name) ?", "%#{params[:term]}%") render json: @users.map(&:name) end if params[:users_name] @users = user.search(params[:users_name]) end end search bar: <%= form_tag users_path, :method => 'get', :role => 'search', :class => "navbar-form navbar-right" %> <div class="form-group has-feedback"> <%= autocomplete_field_tag :users_name, '', users_path, :placeholder => "search", :required => true, :class => "form-control transition" %><span class="glyphicon glyphicon-search form-control-feedback"></span> </div> <% end...

r - Calculate a new matrix with multiple possible outcomes from pre-existing variables -

i need overlay 2 large matrices (or columns merger of two) generate final matrix analysis. have series of points counts made 3 times per year number of year (generating e.g. counts 2000_1, 2000_2, etc.), point wasn’t done 1 reason or another. if point done, there may have been detections or there may not. there 3 possible results each cell in final matrix calculated other 2 values. if no sampling occurred @ point on occasion, need value “.”; if sampling occurred no detections occurred, need “0”, , if sampling occurred , 1-n individuals detected, need “1”. in sample data below, i’ve combined 2 matrices simplify note actual datasets 750 records on 64 columns. in column 1, point id provided. next 5 columns (pt.x) provide whether count conducted in given year_rotation, , last 5 how many if detections. na no data, , should occur when sampling didn’t occur, happen if there sampling no 0 entered. sample point <- c(“a194”,” a234”,”a83”,” k37”,” ts47”) p0.1 <- c(1,1,1,1,0) p0.2 ...

javascript - Chrome Extension That Launches From An HREF click? -

we're building chrome extension our corporate environment. when user browsing web, if click on link, extension should view link , prompt user warning if link site have business relationship , warn them (and in few rare circumstances prevent them going link). we created extension that's appears button on toolbar , when user clicks on popup appears. that's good. want rid of button , have invoked when user clicks on link on whatever webpage they're viewing. extension read link , decide if should prompt user. how done though? how can make extension override href clicks? (note, we're not concerned when type in web address manually or click on link outlook, reasons beyond scope of question) thanks this simple do. inject content script onto every web page this: var anchors = document.queryselectorall('a') (var i=0; i<anchors.length; i++) { anchors[i].addeventlistener('click',function(event) { if ( /* check here if p...

javascript - adding options to select -

hi tried adding options select through javascript in 2 ways, neither worked: one way: function addyear() { var currentyear = new date().getfullyear(); var legalworkingage = currentyear - 16; var select = document.getelementbyid("year"); (var = legalworkingage; >= 1900; i--) { try {select.add(new option(i,0), null);} // standards compliant; doesn't work in ie catch(ex) {select.add(new option(i,0));} // ie }//for } //addyear second way: function addmonth() { var select = document.getelementbyid("month"); (var = 1; <= 12; i++) { var option = document.createelement('option'); option.text = option.value = i; select.add(option, 0); } //for } //addmonth i used <body onload="adddate()"> adddate(): function adddate() { addmonth(); addyear(); } html: <select id="month" name="month"> </select> <sel...

Testing against multiple Vagrant versions using Travis-CI -

i'd test vagrant plugin against multiple versions, using each release same ruby version embedded vagrant package. i've created following configuration file travis ci: language: ruby matrix: include: - rvm: 1.8.7-p357 gemfile: gemfiles/vagrant1_1.gemfile - rvm: 1.9.3-p448 gemfile: gemfiles/vagrant1_2.gemfile gemfile: gemfiles/vagrant1_3.gemfile - rvm: 2.0.0-p353 gemfile: gemfile but when try validate configuration against travis lint web service receive following error: found issue rvm key: specify ruby versions/implementations want test against using "rvm" key first experience travis ci, can't understand i'm doing wrong. travis seems require specify @ least 1 default rvm . like: language: ruby rvm: 2.0.0 matrix: # ... other issue i'm quite sure second gemfile in '1.9.3-p448' override first one. and third, vagrant officially supports 1 ruby version. before 1.4 vagrant works ruby 1...

vb.net - Grid letters with rectangle OCR -

i have been trying grid each letter rectangle on image (on image there colors white , black). i've started this: dim bmp bitmap = label1.image dim xmax integer dim ymax integer xmax = label1.width - 1 ymax = label1.height - 1 dim top, bottom, left, right integer dim first boolean = true dim last boolean = false dim first2 boolean = true dim last2 boolean = false dim pen pen = pens.red x = 0 xmax y = 0 ymax bmp.getpixel(x, y) if .r = 0 , .g = 0 , .b = 0 , first = true left = x first = false last = true elseif .r = 0 , .g = 0 , .b = 0 , last = true right = x end if end next y next x y = 0 ymax x = 0 xmax bmp.getpixel(x, y) if .r = 0 , .g = 0 , .b = 0 , first2 = true top = y fi...

runtime - Java code to run applications -

i need java code allow me run notepad , open specified file, example : string []a={"c:/users/day/desktop/a.txt"}; process p = runtime.getruntime().exec("notepad",a); this code runs notepad not open file a.txt . can problem ? the second argument in exec represents environmental variables. want string[] = { "notepad", "c:/users/day/desktop/a.txt" }; process p = runtime.getruntime().exec(a);

c# - How to validate view controls against data in the viewmodel -

i'm new @ wpf, , i'm getting head around validators, seems need inherit validationrule , override validate function, totally separated view model, if want validate against list/collection/set/dictionary in viewmodel, check whether new input not in list, example creating validation see whether or not username not taken. there several different ways validation in wpf. there's 2 main ways can think of off top of head create validation rules apply them in xaml implement idataerrorinfo in viewmodel validation rules specified in xaml (gui), while implementing idataerrorinfo moves validation logic viewmodel (business logic). while, validationrules nice because can create own , reuse them, fail provide validation in business logic required. the concept of client vs. server side validation interesting, perhaps pertains silverlight, since tagged wpf, i'm assuming difference whether validation occurs in views or viewmodels (ui or business logic). seem me if...

asp.net - How to Queue User Access to a Piece of Code? -

i have piece of code must prevented 2 used execute it. mean if different users press preview button queue should appear. use lock(this) in threading, work in case? need prevent users getting same id because getparticipantid() retrieves max(id) mysql table , sets id. protected void preview_click(object sender, eventargs e) { try { collectinfo(); lock (this) { database db = new database(); id = db.getparticipantid(); db.inserttoparticipantinfo(id, s1q1, s1q2, s1q3, s1q4, s1q5, s1q6, s1q7, s2q1, s2q2, s2q3, s2q4, s2q5, s2q6, s2q7, s2q8); db.inserttoparticipantcar(id, question1, question2, question3, question4, question5, question6, question7, question8, question9, question10, question11); } }

c# - Having trouble setting visibility of control through DataTemplates -

so, i'm building order tracking app different user accounts, of whom have less need-to-know others. means controls displayed accounts, , hidden others. the datacontext window set order class, , data binding within text fields works in regards displaying properties specific order. however, datatemplates , triggers i've made don't seem doing @ all, , i'm not entirely sure why. i've looked on web , can't seem find why it's not working. here's xaml: <label name="statuslabeltext" content="status:" fontsize="15" dockpanel.dock="top"> <label.resources> <datatemplate datatype="x:type local:order"> <datatemplate.triggers> <datatrigger binding="{binding path=selectedaccount}" value="color correct"> <setter property="visibility" value="hidden"></se...

php - when connection times out using curl or get_file_contents to an API it kills my script -

when connection timesout when using curl or get_file_contents because of network error or remote server doesn't respond reason kills script. i making these remote calls in loop , if 1 fails kills script. what best way handle if specific post fails, goes on next in loop instead of script dying? first set parameter curl timeout limit: curl_setopt($ch, curlopt_timeout, 1800); the result of curl_exec() call show if request successful or not: for(/* */) { $ch = curl_init(); //... $result = curl_exec($ch); if (!$result) { continue; // use jump next loop } // code not executed if request failed }

c - MinGW gcc malloc issue with -fno-builtin -

i having strange problem malloc , free in mingw gcc it can best illustrated following program(notice no external headers) void free(void* p) { write(1,"called free\n",12); } int main() { } i compiling following command: gcc -g -fno-builtin test.c running program, expect no output, yet when run program following output: called free called free called free called free using gdb, found free being called in mingwrt-4.0.3-1-mingw32-src\mingwrt-4.0.3-1-mingw32-src\src\libcrt\misc\glob.c is there anyway turn off? have thought specifying -fno-builtin have made program not expect able call things free edit: should clarify have written own memory library malloc , free , issue not want mingw call functions. not want use external libraries stdio or stdlib. i have implemented simple fix of renaming malloc , free ideally able name them malloc , free , not have worry external code calling them. if explain why mingw needs malloc memory in simple program wrote above...

xcode - Image morphing by integrating OpenCV2.framework in iOS -

i new ios , planning work on first app in have morph 1 image smoothly. have downloaded opencv2.framework , planning integrate code. have gone through links showing mathematical calculations required in couldn't it. can please suggest me way or sample tutorial demonstrating how can integrate , use opencv2.framework morph 1 image in ios? thanks.

html - CSS class:hover select all other elements -

i can't find how online, how go selecting elements within element , apply styles them. example: html: <div class="cont"> <div class="txt">hello world!</div> <img src="img1.jpg"> <img src="img2.jpg"> </div> css: .txt:hover + img { display:none; } i want class style hide images next it. hides 1 image @ moment though... if want hide all succeeding image elements, use general sibling combinator, ~ . .txt:hover ~ img { display:none; } example here you using adjacent sibling combinator, + , hide adjacent element.

c# - How to customize MVC url path -

Image
i trying create clean url path mvc controller , need little assistance. example desired path: http://www.linkedin.com/in/alumcloud . path linkedin , notice how has /in/alumcloud . i mine read: http://www.alumcloud.com/alumcloud/somecompanyname how mvc controller? below code in mvc controller, becuase controller needed respond get http methods. public class alumcloudcontroller : alumcloudmvccontrollerbase { // get: /alumcloud/details/5 public actionresult details(string companyname) { return view(); } } --here routeconfig public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } } -------...

Creating a function in R with an argument whose inputs begin with a number -

i apologize if has been answered somewhere can't find question similar anywhere. i trying create function 1 of input arguments (but isn't necessarily) string begins number. when try run function, r confused. for example: foo(df, 10, 5fum) gives me error: error: unexpected symbol in "do_cv_class(data,10,5fum" in function plan on taking "5fum" , parsing 2 arguments "5" , "fum" . don't want create 4th argument separate 5 , fum. any ideas? on great. as comments above suggest, need pass "5fum" string. without rewriting r's parser, it's impossible think of way foo(df, 10, 5fum) legal input. presumably you're thinking this: foo <- function(df, num1, str1) { str1_num <- as.numeric(gsub("([0-9]+)([[:alpha:]]+)","\\1",str1)) str1_alpha <- gsub("([0-9]+)([[:alpha:]]+)","\\2",str1) print(str1_num) print(str1_alpha) } foo(df, 10...

Modify Connectionstring Name for ASP.NET Identity -

i wanted store change connection string points existing database has necessary tables. when searched "defaultconnection" not able find in application, models folder not have of models related classes. see interface definitions metadata. can change connection string value in web.config make work, kind of intriguing know how implemented in case want customize logic, can find classes ? i using latest version of webapi , using vs 2013. what confusing me how modify classes implement custom logic, can't find model classes related identity. you right, web.config place change it. though can implement constructor in applicationdbcontext calls base [ identitydbcontext<tuser> ] class' constructor accepts nameorconnectionstring . there it's either specify use :base("data source=...;initial catalog=...;...") or use new overriden constructor. also, user should (by default) called applicationuser inherits identityuser (which dummy class im...

php - Laravel 4 applying custom filters to routes - error undefined offset -

trying prevent non-admin users accessing pages. must not doing correctly though because i'm getting error of undefined offset: 1 while trying access admin page while logged in admin. filter route::filter('admin', function() { if (!auth::user() || auth::user()->permissions != 1) return redirect::to('/'); }); routes route::resource('deals', 'dealscontroller'); route::resource('blog', 'postscontroller'); route::group(array('before' => 'admin'), function() { route::get('deals/create', 'dealscontroller'); route::get('blog/create', 'postscontroller'); }); i can't put filter on constructor of deals or blog controller because index page each of routes needs accessible users. when i'm not logged admin, routes function correctly , redirect home page when trying visit page admin-only. insights. just solved problem, occurring because of routing. trying...

Eclipse JPA and MySQL - Generic vs Eclipse Link platform in JPA facet -

Image
when adding jpa facet eclipse project there choice between generic , eclipse link platforms : what pros cons of each 1 ? i intend set project glassfish , mysql glassfish ships eclipselink default jpa provider. want choose eclipselink platform enhanced persistence.xml configuration (more graphical editing example). think of way. each jpa provider supports version of jpa specification (2.0 example). each jpa provider supports proprietary extensions. if want code more portable, choose generic jpa provider. if want take advantage of features specific jpa provider, choose jpa provider platform (like eclipselink). you can take @ this document explains difference between 2 in bit more detail. example, section 4.2.5 explains different options available in persistence.xml editor options. hope helps.

regex - variable number of match in a regexp -

i have file : #2/1/1/21=p1 5/1/1/21=p1 isid=104 3/1/1/9=p1 4/1/1/4=p1 5/1/1/17=p1 6/1/1/4=p1 isid=100 1/1/1/4=p1 6/1/1/5=p1 isid=101 i want line 1 ignored (it commented line) in line 2 want "3/1/1/9" "4/1/1/4" "5/1/1/17" in 3 variables var1 var2 , var3 in line 3 want "1/1/1/4" , "6/1/1/5" in 2 variables var1 , var2. for moment can ignore line 1, , match want on line 2 or line 3 : if {[regexp {^(\d/\d/\d/\d{1,2})=p1.*(\d/\d/\d/\d{1,2})=p1} $line value match1 match2]} { # works line 3 not line 2 } if {[regexp {^(\d/\d/\d/\d{1,2})=p1.*(\d/\d/\d/\d{1,2})=p1.*(\d/\d/\d/\d{1,2})=p1} $line value match1 match2 match3]} { # works line 2 not line 3 } how can have right number of matched line 2 , 3 ? try regex: [regexp {^(\d/\d/\d/\d{1,2})=p1.*?(\d/\d/\d/\d{1,2})=p1(?:.*?(\d/\d/\d/\d{1,2})=p1)?} $line value match1 match2 match3] ^^^ ...

PHP PDO retrieve MYSQL DB Size -

trying convert ugly mysql_ pdo i'm having difficulty creating equivalent. $rows = mysql_query("show table status"); $dbsize = 0; while ($row = mysql_fetch_array($rows)) { $dbsize += $row['data_length'] + $row['index_length']; } $decimals = 2; $mbytes = round($dbsize/(1024*1024),$decimals); echo "$dbsize"; i've done following without success: $sth = $conn->query('show table status'); $dbsize = 0; $dbsize = $sth->fetch(pdo::fetch_assoc)["data_length"]; $decimals = 2; $mbytes = round($dbsize/(1024*1024),$decimals); echo "$dbsize"; this wouldn't account $row["index_length"] this ended working me: $sth = $conn->query("show table status"); $dbsize = 0; $result = $sth->fetchall(); foreach ($result $row){ $dbsize += $row["data_length"] + $row["index_length"]; } $decimals = 2; $mbytes = round($dbsize/(1024*1024),$decimals); echo ...

string - C++ Passing pointer constant as parameter from main to method -

i attempting initialize variables within object, using function const pointers parameters. i keep getting errors in many of ways attempted, here code: class molecule { private: char s[21]; char d[21]; double w= 0; public: molecule(); void set(const char*, const char*, double); void display() const; }; int main() { int n; cout << "molecular information\n"; cout << "=====================" << endl; cout << "number of molecules : "; cin >> n; molecule *molecule = new molecule[n]; (int = 0; < n; i++) { char symbol[21]; char description[21]; double weight; molecule[i].set(&symbol,&discription,weight); //... } //implementation of class #include "molecule.h" #include <iostream> #include <cstring> void molecule::set(const char*, const char*, double) { s = &symbol; ...

excel - Need to match data in different sheets and replace data in another cell if it's a match -

i need match data in column a2 , on in sheet 1 data in column a2 , on in sheet 2. if data in column of sheet 1 , sheet 2 match need data in column b & c of sheet 2 replace data in column b & c of sheet 1. know little doing kind of stuff appreciated! sheet 1 b c 2 12345 5.35 9.95 3 15874 4.22 10.99 4 11111 2.24 5.99 5 98745 5.33 9.95 6 88552 4.24 8.95 sheet 2 b c 2 11111 2.09 5.79 3 12345 5.11 9.89 4 88552 4.01 8.79 need sheet 1 change to b c 2 12345 5.11 9.89 3 15874 4.22 10.99 4 11111 2.09 5.79 5 98745 5.33 9.95 6 88552 4.01 8.79 on third sheet use these functions column ='sheet1'!a2 column b =if('sheet1'!b2='sheet2'!b2,'sheet2'!b2,'sheet1'!b2) column c =if('sheet1'!c2='sheet2'!c2,'sheet2'!c2,'sheet1'!c2) copy sheet3 , paste values sheet1. should work unless column match. or if need dynamically. if ...

Jquery cannot get value from each function -

i using tables input fields in them. trying value set of input fields same class , compare each of adjacent input diffrent class name. can see value in input value returned empty jquery. $('.subtotal').each(function(){ var price = $(this).parent().parent().find('td input.price'); console.log(price.val()); }); here html. these rows repeated. <tr> <td> <input type="text" name="data[<?=$i?>][title]" class="title"/> <ul class="order_search_title"> </ul> </td> <td> <input type="text" name="data[<?=$i?>][author]" class="author"/> </td> <td> <input type="text" name=...

r - How to plot a colour wheel by using ggplot? -

Image
i'm reading book "ggplot2 - elegant graphics data analysis" (wickham, 2009) , section "scaling" (page 32) says this: scaling involves mapping data values points in space. there many ways this, here since cyl categorical variable map values evenly spaced hues on colour wheel, shown in figure 3.4. different mapping used when variable continuous. result of these conversions table 3.4, contains values have meaning computer. the book doesn't explain in detail how table 3.4, less figure 3.4. built-in database mpg . has idea how table , graph? in advance. was wondering how without coord_polar() , since example wickham's book not. turns out can use geom_point(...) . library(ggplot2) r <- seq(0,1,length=201) th <- seq(0,2*pi, length=201) d <- expand.grid(r=r,th=th) gg <- with(d,data.frame(d,x=r*sin(th),y=r*cos(th), z=hcl(h=360*th/(2*pi),c=100*r, l=65))) ggplot(gg) + geom_point(aes(x,y,...

php - batch update in codeigniter with simple array -

i want batch update in codeignter , pass array data, instead of running multiple queries. array ( [439] => 0 [440] => 0 [441] => 0 [442] => 1 [443] => 0 ) the 439, 440, 441, 442, 443 id's , 0, 0, 0, 1, 0 values need put active column. i can achieve running thru loop, want batch update. foreach($this->input->post($field_name) $key => $value) { $insert = array( 'id' => $key, 'active' => $value, ); $this->db->where('id', $key)->update($table, array('active' => $value)); } build array foreach loop, use batch update. edit: forgot second array() in opening array. may or may not needed. $data = array(array()); foreach($this->input->post($field_name) $key => $value) { $push = array( 'id' => $key, 'active' => $value, ); array_push($data, $push); } $this->db->update_batch(...

Is there a way to check the browser's ram usage with selenium (java) /web driver (chrome) -

is there way find/monitor browser's ram usage while running selenium test cases? (in java). it has work chrome/chrome's selenium driver. it sounded there potential capability (1 1/2 years ago) , didn't find else.

ios - UITable inside Scroll View or a Table View Header? -

Image
i'm building app parse data uitableview . using custom uitableviewcell class. i want add uiimage before , on top of uitableview , uiimage down below. question if should go head , make custom uitableview header view containing uiimage ? or if should put uitableview , uiimageview inside uiscrollview ? and how can that? when scroll in uitableview want uiimage on top disappear, if row in table view. image (john mayer on tour app: i appreciate solutions! thanks. edit: here's complete .m-code: #import "demosecondviewcontroller.h" #import "demonavigationcontroller.h" #import "postsobject.h" #import "rnblurmodalview.h" #import "afnetworking.h" #import "postsnextview.h" #import "kiimagepager.h" #import "tableheaderview.h" #import "demomenuviewcontroller.h" #import "uiviewcontroller+refrostedviewcontroller.h" @interface demosecondviewcontroller () <ki...

plsql - PL SQL trigger doesnt work -

hey guys have little wuestion here have written trigger fires on insert or update of table bestellung , want change things when inserting or updating file in table want change think u can see code. i working apex right , when try insert order throws me error table right being changed , trigger maybe doesnt see changes... i appreciate kind of thanks!!! create or replace trigger bestellschluss_iuar after insert or update on bestellung each row declare v_date2 date; v_hour number; begin select bestelldatum + 2 v_date2 bestellung bestellid = :new.bestellid; select extract(hour to_timestamp(sysdate))into v_hour dual; if :new.zieldatum null if v_hour > 17 update bestellung set zieldatum = bestelldatum + 3 bestellid = :new.bestellid; else update bestellung -- bestellung means order set zieldatum = bestelldatum + 2 --and means deliverydate = orderdate +2 bestellid = :new.bestellid; end if; elsif v_date2 > :n...