Posts

Showing posts from March, 2012

Mass Find and Replace in Multiple XML Files -

i need find , replace on 700+ xml files following: <base>7.4</base> needs become <base>7.2</base> however, tool have use notepad++, , continually crashes when try "replace in files" function. there easy way perform mass find , replace? i'm not of coder, they're in same folder, maybe there's way use .bat file run through them? advice on or how write appreciated. thanks in advance, colette xml annoying process, because whilst looks plain text - isn't. it's therefore not ideal use 'text based' pattern matching replace it, because ... well, can break formatting on it. i'd suggesting: download perl (like activestate community edition) install xml::twig module (ppm install xml::twig ); use script below - specify files want change on command line (e.g. thisscript.pl file1.xml file2.xml file3.xml ) like this #!/usr/bin/env perl use strict; use warnings; use xml::twig; sub replace_base {

Building an Admin Area in AngularJS -

i purchased angular template using build application, want build admin area application, didn't want admin routes mixed in public routes , controllers, right confused, don't know how go it, know how done in angularjs. basically asking separate frontend andgularjs app backend angularjs app? , if yes suggested way go in end have secure admin area. i don't know if server side framework might related in case use laravel 5 . usually use ui-router , prefere organize states in 2 main groups public , private , create many child states of them: $stateprovider .state('public', { abstract: true, template: "<ui-view/>" }) .state('public.site', { url: '/site', controlleras: 'vm', controller: 'sitectrl', templateurl: 'site/_site.html' }) .state('public.site.home', { url: '/', controlleras: 'vm', controller: 'homectrl', te

php - Access to variable in controller and render -

i have on form template new.html.twig select elements of entity loaded ( $categories ). controller public function newaction(request $request){ $entity = new playlist(); $form = $this->createcreateform($entity); $em = $this->getdoctrine()->getmanager(); $categories = $em->getrepository('publicartelappbundle:category')->getallcategories();** return $this->render('publicartelappbundle:playlist:new.html.twig', array( 'categories' => $categories, 'entity' => $entity, 'form' => $form->createview(), )); } select filter serves make search. select in twig template displays categories obtained query. new.html.twig <div class="form-group"> <label for="publicartel_appbundle_category_name">search category: </label> <select id='selectcategory' class="form-control select2">

(Android) Set Width/Height of (Image-)Button in Java Class -

i want set width , height of imagebutton in java class , width of button should width of display / 4 , height of button should height of display / 4 . code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); int width = size.x; int height = size.y; imagebutton button = (imagebutton) findviewbyid(r.id.imagebutton); // button.setwidth(width/4) // button.setheight(height/4) } apparently there's no method button called setwidth() or setheight() , how can accomplish it? possible weight looking for. example code give 4 rectangles, takes quarter of screen <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" androi

tkinter - Quit function for python 2 -

i'm following tutorial in python 3 using python 2. in tutorial following code used: button2 = ttk.button(self, text="disagree", command = quit) when run code error: nameerror: global name 'quit' not defined is there equivalent function use in python 2? tried sys.exit() froze tkinter window rather closing out. tkinter wants root.quit(). (root root tkinter object)

prolog - generate a range of ints -- "out of local stack" [beginner] -

gen(n,r) : r value between 0 , n-1, in order. n non-zero positive int. n given. for example: ?- genn(2,r) . gives r=0;r=1. implemented this, has "out of local static error": gen(x,0). gen(x,r) :- gen(x,r1), r r1+1, r<x, % why line r>=0. % , line can't keep range successfully? result: ?- genn2(3,r). r = 0 ; r = 1 ; r = 2 ; error: out of local stack to understand why program not terminate, use failure-slice . end, insert goals false understand why goals added irrelevant. if resulting fragment not terminate, original program not terminate either. can see, there not happening in part. in fact program terminate never . gen(_x,0) :- false . gen(x,r) :- gen(x,r1), false , r r1+1 , r<x , r>=0 . (there more issues: definition true goal gen(-1,0) not intended.) the best way solve @ once use clpfd instead of more complex handle (is)/2 or use between/3 : gen(n0, r) :- n1 n0-1, b

sql - Start MySQL from the Windows Command Line -

Image
i want add ip address user allowing him remote control, learn far need paste line in commend line. grant privileges on *.* 'user'@'ip address' identified 'password'; but when did , received error * in original attempt, 'user' , 'ip', 'password' written, not in example. why commend line beginning mysqluc> , not mysql> ? i tried use how create localhost database using mysql? explanation but, doesn't help. added : added environment variable, , when write mysql, i recived following error " if have installed mysql installation bin folder have been added %path% environment variable. in command prompt type mysql , issue respective grant command. start mysql client command prompt below. see documentation more information. mysql -u odbc -p

ios - ARC Async Block Best Practices -

my application sends lots of messages via http requests. wrote simple wrapper around http request has primary method fire off request , return nsdata result. it looks this: - (void)sendrequest:(nsurlrequest *)request { [[[nsurlsession sharedsession] datataskwithrequest:request completionhandler:^(nsdata *data, nsurlresponse *response, nserror *error) { nslog(@"---->> request returned"); if (_delegate == nil) return; if (error == nil) { // forward along [_delegate requestreturnedresult:data withresponse:response];

internet explorer 8 - Unknown Runtime Error when using JavaScript to append CSS to Body in IE8 -

i'm having issue inserting css @import rule <body> in internet explorer 8. i'm doing way defer non-critical css. when run following code "unknown runtime error" on line 6 ( ref_obj.innerhtml = ... ): var css_path_str = "my.css", el_body = document.getelementsbytagname('body')[0], ref_obj = document.createelement("style"); ref_obj.type = "text/css"; ref_obj.innerhtml = "@import url(\""+css_path_1_str+"\");"; el_body.appendchild(ref_obj); as can guess, code works on chrome , firefox without issue. after doing search here on so, stumbled on post - why document.getelementbyid('tableid').innerhtml not working in ie8? - says innerhtml style [and few other elements] on ie read-only. any ideas how can edit code work around these limitations? note : pure vanilla javascript. edit : problem solved, completeness, here code should work (cross-browser). var css_path_str = &

AngularJS cacheFactory not working -

this code: app.directive('topnav', function(api, $cachefactory) { return { scope: {}, restrict: 'e', templateurl: 'packages/partials/includes/header.html', link: function($scope) { var cache = $cachefactory('datacache'); if( cache !== undefined ) { api.data().success(function(data){ $scope.phone = data.phone; $scope.mail = data.email; cache.put('data', data); }); } else { $scope.phone = cache.get('data').phone; $scope.mail = cache.get('data').email; console.log(cache.get('data')); } } }; }); the problem returns undefined , don't know what's going wrong, may go wrong ?

windows - How to programatically check the "Password must meet complexity requirements" group policy setting? -

Image
window has 5 group policy settings related password security: enforce password history maximum password age minimum password age minimum password length password must meet complexity requirements store passwords using reversible encryption i know how use netusermodalsget read most of these items . doesn't support checking if password complexity requirement enabled: enforce password history : usrmod0_password_hist_len maximum password age : usrmod0_max_passwd_age minimum password age : usrmod0_min_passwd_age minimum password length : usrmod0_min_passwd_len password must meet complexity requirements : ? store passwords using reversible encryption : i know wmi's rsop ( "resultant set of policy" ) unsuitable, as works on domain . , i'm not going crawling through undocumented binary blob (i.e. want supported way). note : don't care "store passwords using reversible encryption" group policy setting. bonus you can use n

sql - What is the best way to increase view counter column of a row in each select? -

often portals news sites, wonder whether practice or not update view counter field of table while selecting row. lets have news table id, title, details, publishdate , viewcounter. perform following query on each request of news detail page? how mixing of select , update each request hurt performance? select * news id=120; update news set viewcounter=viewcounter+1 id=120; could there difference in performance if put view tracker data in table, table viewscount columns id, newsid,viewcount? in case, execute following code: select * news id=120; update viewscount set viewcount=viewcount+1 newsid=120; i see 1 more option track browser request data each request, , later aggregate rows each news id. design, run 2 queries each request: select , insert, following: select * news id=120; insert newsview(newsid,browser,ipaddress,operatingsystem,col1,col2) values(120,'netscape','202.xx.xx.xx','windows',col1value,col2value) but have seen in short span of tim

java - Match a character exactly once with regex -

how can match character once regex in java? let's want strings contain 1 time digit 3, , doesn't matter is. i tried ".*3{1}.*" match "330" specified period don't care character is. how can fix this? ^[^3]*3[^3]*$ match (not three), three, (not three). edit: adding ^ , $ @ beginning , end. force regex match whole line. @bobbyrogers , @mindastic

c# - Azure Long-running external web service calls -

i've written windows service in c# interfaces third party via external web service calls (soap). of calls respond , slowly (for example, quick = retrieving list of currencies; slow = retrieving historical value of currencies per product on many years) the external service works fine when run on local machine - quick calls runs 20 seconds; slow calls runs 30 minutes. can't speed of 3rd party service , don't mind time takes return answer.. my problem when deploy service azure virtual machine: quick call works locally; slow ones never returns anything. have tried exception handling, logging files, logging eventlog. there no clear indication of goes wrong - seems whatever reason - long running web service calls, never return azure. i've read somewhere there sort of connection-recycling happening every 4 minutes, suspect somehow causing external web service response land somewhere in void load balancer or whatever not knowing longer whom requested content.

objective c - iOS 9 ATS SSL error with supporting server -

i installed xcode 7 , tried running app under ios 9. i'm getting infamous error: connection failed! error - -1200 ssl error has occurred , secure connection server cannot made. thing server support tlsv1.2 , i'm using nsurlsession . what problem then? apple has released full requirements list app transport security . turned out working tls v1.2 missing of other requirements. here's full check list: tls requires @ least version 1.2. connection ciphers limited provide forward secrecy (see below list of ciphers.) the service requires certificate using @ least sha256 fingerprint either 2048 bit or greater rsa key, or 256bit or greater elliptic-curve (ecc) key. invalid certificates result in hard failure , no connection. the accepted ciphers are: tls_ecdhe_ecdsa_with_aes_256_gcm_sha384 tls_ecdhe_ecdsa_with_aes_128_gcm_sha256 tls_ecdhe_ecdsa_with_aes_256_cbc_sha384 tls_ecdhe_ecdsa_with_aes_256_cbc_sha tls_ecdhe_ecdsa_with_aes_128_cbc_sha256 tls_ecdh

compiler errors - undefined reference to `roundf' - C language -

i'm new c , keep running same error. typing code in nano text editor , compiling in linux terminal. operating system ubuntu 14.04. here's example of code won't compile, #include <math.h> #include <stdio.h> int main() { float x = 23.33f; x = roundf(x); printf("%f\n", x); return (0); } the error receiving is, cc example.c -o example /tmp/ccwv0or8.o: in function `main': example.c:(.text+0x1d): undefined reference `roundf' collect2: error: ld returned 1 exit status make: *** [example] error 1 any appreciated, thanks! link math library: cc example.c -o example -lm the math library functions not part of standard c library linked default. need link yourself. there's interesting thread why it's not part of libc: why have link math library in c?

angularjs - Instantiating a controller that uses an isolate scope for a test -

so have controller test file with: scope = $rootscope.$new(); ctrlinstance = $controller( 'formctrl', { $scope: scope } ); this controller isn't getting instantiated correctly, because scope i'm passing in doesn't have data has (due being passed isolate scope). these first few lines of formctrl: var vm = this; vm.stats = angular.copy( vm.statsstuff ); vm.stats.showx = vm.stats.showy = true; note vm.statsstuff has data bound (due '=' scope in corresponding directive), i'm not sure how pass these values when instantiate controller in test. any appreciated. adding directive: angular.module( 'mymodule' ) .directive( 'formstuff', function() { return { restrict: 'e', templateurl: 'dir.tpl.html', scope: { statsstuff: '=' }, controller: 'formstuffctrl', controlleras: 'formctrl',

sql server - Handling multi-select list in database design -

i'm creating clinic management system need store medical history patient. user can select multiple history conditions single patient, however, each clinic has own fixed set of medical history fields. for example: clinic 1: diseaseone diseasetwo diseasethree clinic 2: diseasefour diseasefive diseasesize for patient visit in specific clinic , user should able check 1 or more diseases patient's medical history based on clinic type. i thought of 2 ways of storing medical history data: first option: add fields corresponding clinic patient visit record: patientclinic1visitrecord: patientclinic1visitrecordid visitdate medhist_diseaseone medhist_diseasetwo medhist_disearthree and fill each medhist field value "true/false" based on user input. second option: have single medicalhistory table holds clinics medical history detail table hold patient's medical history in corresponding visit. medicalhistory clinicid medicalhistoryfieldid medicalhis

c++ - Opencv assertion failed <size.width>0 && <size.height>0 in cv::imshow -

#include <opencv\cv.h> #include <opencv2\highgui\highgui.hpp> #include<opencv\cvaux.h> #include<opencv\cxcore.h> #include <opencv2\imgproc.hpp> #include <iostream> #include<conio.h> using namespace cv; using namespace std; void main() { mat src = imread("greyscale.jpg"); \\image edited imshow("input", src); mat dest; \\processed image threshold(src, dest, 100, 255, thresh_binary); imshow("result", dest); waitkey(); } the above code when executed on visual studio 2013 express (configured opencv 3.0) not show compiling errors. output window displays error opencv error: assertion failed (size.width>0 && size.height>0) in cv::imshow, fi le c:\builds\master_packslave-win64-vc12-shared\opencv\modules\highgui\src\windo w.cpp, line 271 press key continue . . . , window pops saying open cv has crashed. i'm new opencv , appreciated.thanks in advance! i have gone through similar problems the

java - How to manage Heap (Min heap) if the value of already added item changes -

i java developer ( non cs/it educational background). have developed interest in algorithms , trying implement prim's algorithm calculating mst. have told in order let know context question independent of mst. i have implemented own minheap instead of using java.util.priorityqueue (although when changed code , used facing same problem have mentioned ahead). i add items heap value of item deciding comparison can change after items have been added in heap. once value changes heap not changed , hence upon removing item wrong item popped out. how tackle situation.. i pasting code reference. adding items of type vertex in minheap. each vertex has 'int cost' associated used compare 2 objects of vertex. add object of vertex in heap , heap adjusted per current value of 'cost' once object of vertex added if cost changed want how adjust , reflected in heap. please me in regards , please correct me if going in wrong direction. public class mstrevisited { pu

Joomla admin login is not showing any error and is not redirecting to dashboard -

i have login problem joomla administrator page. when enter login credentials " not redirecting dashboard " or not showing error. stays on same page after load not redirecting. i tried follwing configurations in phpmyadmin database: 1) "plg_authentication_joomla" under jos_extensions have set following values following attributes: a)enabled : 1 b)access :1 c)protected:1 d)state:0 2) plg_authentication_ldap under jos_extensions have set following values: a)enabled : 0 b)access :1 c)protected:0 d)state:0 3) plg_user_joomla under jos_extensions have set following values: a)enabled : 1 b)access :2 c)protected:0 d)state:0 i have tried resetting password under jos_users . not changes...kindly me... the "plg_user_joomla" has "access" set 1.

SQL Server : creating stored procedure -

i need write stored procedure should take customerid parameter , return name atbv_contacts , parameter of contactid column same customerid . my problem guess i'm trying id, therefore won't show me customer's id. plus don't think procedure written correctly following errors: msg 3609, level 16, state 2, procedure atsp_getnameid, line 7 transaction ended in trigger. batch has been aborted. msg 50000, level 18, state 1, procedure strg_database_changelog, line 90 invalid object name. please check typo. my current code: create procedure atsp_getnameid (@customerid int) begin select contactid atbv_contacts contactid '%' + @customerid + '%' end replace this create procedure atsp_getnameid (@customerid int) begin select contactid atbv_contacts contactid =@customerid end

python - Code for coyping specific lines from multiple files to a single file (and removing part of the copied lines) -

first of all, new this. i've been reading on tutorials on past days, i've hit wall want achieve. to give long version: have multiple files in directory, of contain information in lines (23-26). now, code have find , open files (naming pattern: *.tag ) , copy lines 23-26 new single file. (and add new line after each new entry...). optionally remove specific part each line not need: c12b2 -> before c12b2 (or similar) need removed. thus far have managed copy lines single file new file, rest still eludes me: (no idea how formatting works here) f = open('2.tag') n = open('output.txt', 'w') i, text in enumerate(f): if >= 23 , < 27: n.write(text) else: pass could give me advice ? not need complete code answer, however, tutorials don't skip explanations seem hard come by. without importing os : #!/usr/bin/env python3 import os # set directory, outfile , tag below dr = "/path/to/direc

What is the best practice for multiple colors in a sentence in HTML/CSS? -

i know want keep style , content separate, assuming want display: <h1>roygbv</h1> on page, each letter matching color, best practice this? would be: <h1><font color="red">r</font><font color="orange">o</font> and on? , assuming have multiple words in paragraph needed colored like: sally found red seashells down blue seashore out in yellow sun ... is ok have font tags on html? alternative can think of putting them in span tags , adding class. allow me change definition of red in css file iterations of red. <font> tag deprecated. mdn docs best way in question itself. using span wrap particular word. .red { color: red; } .blue { color: blue; } .yellow { color: yellow; } <p>sally found <span class="red">red</span> seashells down <span class="blue">blue</span> seashore out in <span class="yellow">yellow&

ruby - Gem uninstall permission denied @ rb_sysopen -

i'm having problems gems install. believe installed sudo. tried uninstall using: gem uninstall -aix /usr/local/cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/stub_specification.rb:75:in `initialize': permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.2.0/specifications/bundler-1.10.5.gemspec (errno::eacces) any fantastic.

c# - Why can't I access the Database property of an IdentityDbContext? -

i have identitydbcontext declared as: public class appcontext : identitydbcontext<appuser, approle, guid, appuserlogin, appuserrole, appuserclaim> { ... } identitydbcontext extends dbcontext , declaration looks like: public class identitydbcontext<tuser, trole, tkey, tuserlogin, tuserrole, tuserclaim> : dbcontext tuser : microsoft.aspnet.identity.entityframework.identityuser<tkey, tuserlogin, tuserrole, tuserclaim> trole : microsoft.aspnet.identity.entityframework.identityrole<tkey, tuserrole> tuserlogin : microsoft.aspnet.identity.entityframework.identityuserlogin<tkey> tuserrole : microsoft.aspnet.identity.entityframework.identityuserrole<tkey> tuserclaim : microsoft.aspnet.identity.entityframework.identityuserclaim<tkey> { ... } dbcontext has public property called database . in integration test instantiate appcontext , delete test database, want call context.database.createifnotexists() , database proper

c# - Convert string value with '$' into double -

have not found similar question on yet (regarding '$'). i'm following this example , trying expand pre-existing method convert strings doubles. general structure of code looks so: string str = "$1,000.00"; double output; var success = double.tryparse( str , numberstyles.allowleadingwhite | numberstyles.allowtrailingwhite | numberstyles.allowleadingsign | numberstyles.allowdecimalpoint | numberstyles.allowthousands | numberstyles.allowexponent | numberstyles.allowcurrencysymbol , null // cultureinfo.invariantculture // or numberformatinfo.invariantinfo break conversion '$'.. , out output ); console.writeline("'{0}' --> {1}, {2}", str, output, success); this works. problem i'm getting dealing '$' character when the iformatprovider parameter of double.tryparse() method set either cultureinfo.invariantculture or numberformatinfo.invaria

tree - Alfresco all parents of a folder -

i'm working alfresco 5.0.d. there way find parents of node ? in javascript webscript want parent folder tree of specific folder until documentary library. there must function returns in 1 call folder tree want. don't know function. thank you. you can use 1 of scriptnode api path details qnamepath read-only qname type path node displaypath read-only display path node then string operation convert in required format.

php - Frequent Ajax calls (2-3 times per second) -

i creating game, user moving main object (left/right/up/down). every time moves it, make request server, php place position of player onto map. the game fast, user should move 2-3 times per second, after 196-200 request error, , not able connect server 3-5 minutes, not good. how can solve issue considering have full access control panel , can not change request frequency? sometimes http server or firewall blocks these request prevent ddos attacks. to solve problem, can use websocket ( https://en.wikipedia.org/wiki/websocket ) instead of ajax calls. for each ajax call, browser made these steps: request 1: - open connection - request - response - close connection request 2: - open connection - request - response - close connection but if use websockets can just: - open connection - request - request - request - request - request - request - response - request - request - request - (...) and close step executed when change page, close browser or force cl

paypal - Subscription Buttons. Initial Payment instead of Trial? -

i've read there's option, when setting recurring payments (specifically subscriptions), include initial payment, i'm seeing "trial period". i can't use trial period, because there's no guarantee users continue subscription after trial period over. please advise. subscription button doesn't support initial payment. may have option creating recurring profiles paypal classic api(express checkout + createrecurringpaymentsprofile). optionally specify initial payment initamt field when creating recurring profile. see integration guide here .

java - Gson error expected begin_object but was string at line 1 column 1 path $ -

i hope give me hand on gson issue can't solve. quiet common apparently since found many topic on subject, didn't manage use answers. i have error : com.google.gson.jsonsyntaxexception: java.lang.illegalstateexception: expected begin_object string @ line 1 column 1 path $ here json : {"valeurs":[{"ident":"1","lien":"r8wzdmerigo","categorie":"1"},{"ident":"2","lien":"neqgjgz08fw","categorie":"2"}],"success":1} then pojo: public class gitmodel { @serializedname("ident") @expose private int ident; @serializedname("lien") @expose private string lien; @serializedname("categorie") @expose private int categorie; public int getident() {return ident;} public string getlien() { return lien; } public int getcategorie() { return categorie; } } and in main activity : restadapte

python - Arrow direction set by data, but length set by figure size -

Image
i draw arrow indicating gradient of function @ point, pointing in direction tangent function. length of arrow proportional axis size, visible @ zoom level. say want draw derivative of x^2 @ x=1 (the derivative 2 ). here 2 things tried: import matplotlib.pyplot plt import numpy np fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 2, 1000) y = x**2 ax.plot(x, y) x, y = (1.0, 1.0) grad = 2.0 # fixed size, wrong direction len_pts = 40 end_xy = (len_pts, len_pts*grad) ax.annotate("", xy=(x, y), xycoords='data', xytext=end_xy, textcoords='offset points', arrowprops=dict(arrowstyle='<-', connectionstyle="arc3")) # fixed direction, wrong size len_units = 0.2 end_xy = (x+len_units, y+len_units*grad) ax.annotate("", xy=(x, y), xycoords='data', xytext=end_xy, textcoords='data', arrowprops=dict(arrowstyle='<-', connectionstyle="arc3")) ax.a