Posts

Showing posts from June, 2015

java - How to configure Spring Security for a single page application? -

i faced problem configuration spring security single page application. so, defualt config looks like @configuration @enablewebsecurity public class securityconfiguration extends websecurityconfigureradapter { @autowired @qualifier("customuserdetailsservice") userdetailsservice userdetailsservice; @autowired public void configureglobalsecurity(authenticationmanagerbuilder auth) throws exception { auth.userdetailsservice(userdetailsservice); } @override protected void configure(httpsecurity http) throws exception { http.authorizerequests() .antmatchers("/", "/list").permitall() .antmatchers("/admin/**").access("hasrole('admin')") .and().formlogin().loginpage("/login").permitall() .usernameparameter("ssoid").passwordparameter("password") .and().csrf()

javascript - regular expressions- not including a character -

i want capture value name query string regular expression; have done folowing: /name=(.*)/g example: ?name=foo&bar=baz but grabs string end; know ^ used not; not figure out right syntax. thanks if want use regex can use non greedy operator this: name=(.*?)& btw, can regex cover more cases: name=(.*?)(?:&|$) working demo javascript code: var re = /name=(.*?)(?:&|$)/gm; var str = 'example: ?name=foo&bar=baz\nexample: ?name=foo\nexample: ?bar=baz&name=foo'; var m; while ((m = re.exec(str)) !== null) { if (m.index === re.lastindex) { re.lastindex++; } // view result using m-variable. // eg m[0] etc. }

amazon ec2 - Kubernetes cluster - use of EC2 instance storage for pods -

i starting ec2 test cluster of 3-minions of type 'm3.large' want use 32g ssd storage available on these machine pod running on want use using 'hostpath' mount portion of storage pod available life of minions however issue majority of storage allocated "/mnt/ephemeral/docker" not available on host 'hostpath' use. on minion looks like $ df -h filesystem size used avail use% mounted on udev 3.7g 0 3.7g 0% /dev tmpfs 748m 75m 674m 10% /run /dev/xvda1 7.8g 2.0g 5.5g 27% / tmpfs 3.7g 828k 3.7g 1% /dev/shm tmpfs 5.0m 0 5.0m 0% /run/lock tmpfs 3.7g 0 3.7g 0% /sys/fs/cgroup /dev/mapper/vg--ephemeral-docker 30g

javascript - How to set values in dynamically created text boxes -

in app creating dynamic textboxes clicking add button. can put values , time also. need when page loads, want given number of textboxes created , populated set of values. able create text boxes onload cannot set values. here giving fiddle have created functionality. how can set values dynamically? here fiddle myfiddle and want timepicker function in onload created boxes. function gettextboxaftervaliddation(val){ var str_array = ['jeet','chatterjee']; var randomid = '\''+"#interviewname"+val+'\''; var nameid = "interviewname"+val+""; var allnames = str_array.replace(/((\[)|(\]))/g,""); alert(randomid) $(randomid).val(arr[val]); return '<input class="txt1" name = "dynamictextbox" type="text" id = "'+nameid+'"/>'; } for(var = 0; < 4; i++){ var div = $("<div />"); div.html(gettextboxaftervaliddation(i));

sql - trying to update a column with difference between 2 dates when one can be NULL -

with following code: update factquote set conversiondays = case when conversiondate = null null else datediff(day, initialcontactdate, conversiondate) end keep getting message: msg 206, level 16, state 2, line 10 operand type clash: int incompatible date how can fix this? this not answer, simplification (which long comment). datediff() -- many other functions -- returns null when either date argument null . so, can simplify expression to: update factquote set conversiondays = datediff(day, initialcontactdate, conversiondate);

Un-gray grayed out files in Eclipse Project Explorer -

similar eclipse , mylyn : how disable grey files in explorer? my status i've unchecked "task context decorators" , i've uninstalled mylyn via removing packages /plugins , /features (i've never used tasks before). how relieve abyssal ailment? i've figured out! preferences > general > appearance > colors , fonts > git it git, , grayed out files/folders "uncommitted changes", while rest "ignored resources". changed colors.

c++ - What g++ link option to fix the error function not found -

my project uses g++ compiler compile source code distributed on several directories, executable built. in building final executable link error function not defined. i cooked following code scaled down of project , exposes same error, hope me out. so here directory tree , source files: ./ ./11/ c1.cpp c1.h ./12/ c2.cpp here files: ./11/c1.h: int f(); ./11/c1.cpp: #include "c1.h" int f() { return 0; } ./12/c2.cpp: #include "c1.h" int main() { f(); return 0; } here steps build files: cd 11 g++ -c -o ../c1.o c1.cpp cp c1.h .. cd .. ar cr libc1.a c1.o cd 12 g++ -i../ -l../ -lc1 c2.cpp yes, need compile c1 object , archive small, how project doing. and here error message: /tmp/cctfdzle.o: in function `main': c2.cpp:(.text+0x5): undefined reference `f()' collect2: ld returned 1 exit status thanks!

web - PHP mkdir not working as expected -

i'm working on php create folder every time request made server. can't seem syntax proper. if used $date variable works no problem, when add "clean" folder before it, won't create folder. <?php $time = $_server['request_time']; $date = date(ymd_hms, $time); $new = "clean/".$date; echo $new; if(!is_dir ($new)) { mkdir($new); } ?> put in ' quotes , give mkdir() appropriate params , should work fine: <?php $time = $_server['request_time']; $date = date('ymd_his', $time); $new = "clean/".$date; echo $new; if(!is_dir ($new)) { mkdir($new, 0777, true); } ?> mode: mode 0777 default, means widest possible access. more information on modes, read details on chmod() note: mode ignored on windows. return values: returns true on success or false on failure. note: don't have create folder clean first if you're using recursive = true option, otherw

ruby on rails - ActionMailer with NTLM auth (Exchange 2010) -

i have rails application using rails 4.2. how can send mail using exchange 2010 server ntlm authentication? according actionmailer docs: :authentication - if mail server requires authentication, need specify authentication type here. symbol , 1 of :plain (will send password base64 encoded), :login (will send password base64 encoded) or :cram_md5 (combines challenge/response mechanism exchange information , cryptographic message digest 5 algorithm hash important information) whatever auth method chose, keep getting error: net::smtpsyntaxerror: 504 5.7.4 unrecognized authentication type so found solution myself. kept getting error because exchange server use requires no authentication, should not pass authentication option @ all: config.action_mailer.smtp_settings = { address: 'smtp.yourdomain.com', port: 587, domain: 'yourdomain.com' } yes thats right: user_name , passwod , authentication lef

Ruby access propteries with dot-notation -

i'm trying build class used data structure storing values/nested values. want there 2 methods, get , set , accept dot-notated path recursively set or variables. for example: bag = parambag.new bag.get('foo.bar') # => nil bag.set('foo.bar', 'baz') bag.get('foo.bar') # => 'baz' the get method take default return value if value doesn't exist: bag.get('foo.baz', false) # => false i initialize new parambag hash. how manage in ruby? i've done in other languages, in order set recursive path, take value reference, i'm not sure how i'd in ruby. this fun exercise still falls under "you should not this" category. to accomplish want, openstruct can used slight modifications. class parambag < openstruct def method_missing(name, *args, &block) if super.nil? modifiable[new_ostruct_member(name)] = parambag.new end end end this class let chain many method

java - Spring - RestTemplate Error calling a https rest service (Certificate error) -

i call in tomcat war rest web service. web service invocation this: public usuariodto validardatostoken(string token, boolean incluirroles) throws modeloexception, daoexception { resttemplate resttemplate = new resttemplate(); userrestvo page = resttemplate.getforobject("https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), userrestvo.class); if (page != null && page.getstatusresult() != null && page.getstatusresult().getstatuscode().equals("ok") && page.getuser() != null) { ------------ return datos; } else { throw new modeloexception(erroresgeneralesenum.error_token_caducado); } } } public authentication authenticatereal(authentication authentication) throws authenticationexception { string username = authentication.getname(); string password = (string) authentication.getcredentials(); usuariodto usuario = null; try { usuario = usuari

associations - Rails - how to show attribute of an associated model -

i trying make app in rails 4. i asked related question , got clear answer. seems can't understand how take logic , apply elsewhere. rails how show attributes parent object i have user model, profile model projects model , universities model. associations are: profile belongs university profile belongs user university has many profiles university has many projects projects habtm user projects belong universities in projects controller, define @creator follows: def create logger.debug "xxx create project" #authorise @project @project = project.new(project_params) @project.creator_id = current_user.id @project.users << current_user respond_to |format| if @project.save format.html { redirect_to @project } format.json { render action: 'show', status: :created, location: @project } else format.html { render action: 'new' } format.json { render json: @project.errors, stat

PHP: file write permissions -

i have been banging head quite while because of this... i'm trying install mybb forum on virtual server (centos 7, apache http server, php 5.4.3) , ran troubles file permissions. mybb needs 2 files writable, 1 of them config.php , second 1 settings.php , both of them in directory inc . i set permissions on both files 666. wrote simple testing php page mimics way mybb tests ability write: <?php echo('config: '); $configwritable = @fopen('forum/inc/config.php', 'w'); if ($configwritable) { echo('yes'); } else { echo('no'); } echo('<br/>'); echo('settings: '); $configwritable = @fopen('forum/inc/settings.php', 'w'); if ($configwritable) { echo('yes'); } else { echo('no'); } ?> the page output is config: no settings: yes but if list files, show this root@localhost# ls -l forum/inc/config.php forum/inc/settings.php -rw-rw-rw-. 1 krkavec krkavec

objective c - Message controller iOS -

i new in ios programming, know old question confused here message controller. want make application in want send simple messages. if set multiple recipients can of 1 can view recipients? if so,then how can make private message 1 recipient can't view other recipients? here code composing message more recipients - (void)showsms:(nsstring*)file { if(![mfmessagecomposeviewcontroller cansendtext]) { uialertview *warningalert = [[uialertview alloc] initwithtitle:@"error" message:@"your device doesn't support sms!" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [warningalert show]; return; } nsarray *recipents = @[@"12345678", @"72345524"]; nsstring *message = [nsstring stringwithformat:@"just sent %@ file email. please check!", file]; mfmessagecomposeviewcontroller *messagecontroller = [[mfmessagecomposeviewcontroller alloc] init]; messagecontroller.messag

ruby on rails - rake db:migrate is not creating user table -

Image
i have following migrations problem rake db:migrate not executing first migration , no users table created. what reason this? what reason this? main reason you've ran migration - or perhaps later migrations - , rails therefore not think needs run it. a way see if case open db/schema.rb file: you'll see latest migration schema running. if supersedes 1 you're trying invoke, not run. -- fixes you could generate new migration, , copy code over: $ rails g migration addusers2 you'd add following: #db/migrate/_____.rb class addusers2 < activerecord::migration def change create_table :users |t| t.string :name t.timestamps end end end alternatively, wipe db , start again. can achieved using rake schema:load . this wipe data , start again

How do I create a new package within the src folder? (Android Studio) -

i apologize question easy, having trouble creating new packages within src folder. if me out fantastic. right-click on java/ directory , choose new > package context menu. type in package name, , click ok.

android - Understanding activity return transitions -

i using custom shared element transition when launch activity b activity a. works perfectly. i want use custom transition doesn't involve shared elements return transition activity b activity a. however, having trouble several parts: how tell framework return transition doesn't involve shared elements? what start , end values transition in return transition? enter transition, manipulated activity b's views drawn on top of activity a's. happens in return transition? appreciate can get! edit: further investigation revealed return transition's createanimator isn't being called though i'm calling setsharedelementreturntransition . know set call doing because doesn't try reverse original enter animation (default behavior) , instead of overlaps 2 views. edit #2: after looking @ george mount's answer, added @override public void capturestartvalues(transitionvalues transitionvalues) { transitionvalues.view.setvisibility(view.visi

c++ - How to get environment of a program while debugging it in GDB -

i debugging program in gdb on linux. using getenv , setenv calls read , set environment variables. example calling setenv("tz", "utc", 1); set tz environment variable timezone. to check if env variable set using gdb command show environment . prints environment variables , values. dose not show tz being set. even command show environment tz says environment variable "tz" not defined. is way check environment of debugged program? p *(char *) getenv("tz") reuturns correct value utc . the gdb command show environment shows environment belongs gdb [see note], not environment of program being debugged. calling getenv seems totally reasonable approach printing running program's environment. note gdb maintains environment array, copied own environment, uses start each new child process. show environment , set environment work on environment, set environment change environment variable next time start program b

ios - Database design for book structure (table of contents) and content -

i have list of entries, can thought of paragraphs book, stored separate objects of same class. these objects have ‘num’ property, along actual text, know order , can later display them in list in correct order (1,2,3, …). now want bring 1 step further , able ‘record’ structure of book, table of contents. in other words, book divided chapters, , each chapter further divided sections. first few paragraphs found under ch.1 sec.1, ch.1 sec. 2, , on way ch. n, s. m. i’m not sure of what’s way record information? i've been told should use database sql i'm not sure begin. the implementation must allow me ‘quickly’ determine following 2 things @ point: (1) given chapter , section #, paragraphs contained within section? (2) given paragraph #, chapter , section under? must flexible enough use same platform in future few edits if structure (depth-wise) of book changes (e.g. sections divided subsections, etc.). finally, should able handle optional divisions (i.e. sections have subs

c++ - Passing values of array to a function that modifies the value then returns it into a new array -

i'm having trouble getting code return correct arrays. void map takes in function such tiple , modifies value passed array src , returns new value dst printed out. can code compile doesn't return correct array. example, when takes in [1,2,3,4] returns [0,3,6,9] instead of [3,6,9,12] typedef int (*intmodifier)(int); int triple(int x){ return 3*x; } void map(intmodifier func, int src[], int dst[], int length){ for(int *i = src; < src + length; ++i){ dst[*i] = func(*i); } return; } void printintarray(int arr[], int length){ cout << "{"; if (length > 0){ cout << arr[0]; } for(int = 1; < length; ++i){ cout << ", " << arr[i]; } cout << "}"; } int main(){ int arr1[4] = {1, 2, 3, 4}; int arr2[4] = {0, 0, 0, 0}; int arr3[4] = {0, 0, 0, 0}; int arr4[4] = {0, 0, 0, 0}; cout << "testing map." << endl; cout << " setting arr1 =

vba - Estimating duplication percentage between rows in Excel -

i have excel (2010) data file on 200 variables (columns), , on 1,000 records (rows), each identified unique id number. however, i'm suspicious of these records fabricated, i.e., took existing record, replicated it, , changed few numbers make little different. therefore, need produce matrix show me number/percent of "same values" between each record , other records (e.g., record 1 , record 2 share 75 equal values, record 1 , record 3 share 57 equal values, record 2 , record 3 share 45 equal values, etc.). have few workarounds, take hours , don't produce simple matrix. don't care difference between values - whether equal or not. ideas appreciated! don't know how perform on huge dataset but: sub t() dim d, m(), nr long, nc long, r long, r2 long, c long dim v1, v2, long d = sheet1.range("a1").currentregion.value nr = ubound(d, 1) nc = ubound(d, 2) redim m(1 nr, 1 nr) r = 1 nr r2 = r nr

python - How do I find text between brackets while including the bracket using regex tokenization -

how extract text inside brackets using regex? example if have string = 'this test code [asdf -wer -a2 asdf] (ascd asdfas -were)' i want output [asdf-wer-a2-asdf], (ascd asdfas -were) i have looked everywhere , haven't been able solve problem. if can me great thank you you can use below regex pattern. here example \[[^\)]*\]|\([^)]*\)

c++ design: inheritance and returning opaque handles -

i have 2 interfaces looks this: class ithing { ... virtual ihandle* gethandle(void) = 0; virtual void usehandle(ihandle *handle) = 0; }; class ihandle { ... } i want users able implement ithing , ihandle. example, if user creates mything , myhandle , gethandle should return pointer myhandle , user can later use in usehandle . this work, don't design because multiple implementations of ihandle can mixed between implementations of ithing . in usehandle , users need explicitly downcast implementation of ihandle . there more type-safe way this? i'm not quite sure of want design. here thoughts hope helpful. the basic principle classes publicly derived ithing indeed ithing . eveything can ithing , can mything , including getting ihandle . there's no design issue, long ihandle derivates obey same principle. means things shouldn't make assumptions specific handles , vice versa. if make use in implementation of myhandle of assum

java - Android HorizontalScrollView doesn't work with EditText -

so have android app outputs ascii art equivalent type in, "hello world" to _ _ _ _ _ | |__ ___| | | ___ __ _____ _ __| | __| | | '_ \ / _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | | | | __/ | | (_) | \ v v / (_) | | | | (_| | |_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_| being it's formatted , needs stay formatted, want horizontal scrolling edittext put in. tried make 1 didn't work well... here's java: edittext medittext = (edittext) findviewbyid(r.id.text_status_id); horizontalscrollview mscrollview = (horizontalscrollview) findviewbyid(r.id.scroller_id); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); init(); } private void loaddoc(){ intent intent = getintent(); string message = intent.getstringextra(mainactivity.extra_message); string letter; edittext textview = new edittext(this); typeface courier

java - How to get a program to continue reading input after if statements are fulfilled (Morse Translator) -

before begin, novice programmer having been doing day. how program continue reading input after input has been fulfilled? below code, morse code english translator trying make, when input morse, example .-, gives me correct output, a. when combine morse letters, example .--..., should ab, else statement activates. should do? import java.util.scanner; public class morsetranslator { public static void main(string[] args) { system.out.println("please enter morse code wish translate."); scanner sc =new scanner(system.in); string morse = sc.next(); if (morse.equals(" ")) { system.out.print(" "); } if (morse.equals(".-")){ system.out.print("a"); } if (morse.equals("-...")){ system.out.print("b"); } if (morse.equals("-.-.")){ system.out.print("c"); } if (morse.equals("-.."

java - Printing the array -

i trying print contents of array. example have defined int array of size 10. user entered 8 numbers. last 2 positions in array have value of zero. when printing array ten positions. possible print till user entered.also user decides how many enter cannot hard code position printing array. thanks. is possible print till user entered. yes, keep track of how many items user entered. can done separate int counter variable increment user enters item, or if want, can fill array values user never enter, example, integer.min_value , , display results until reach non-sense values. danger here is, happens if user happens pick non-sense value? that's why i'd go first suggestion. also user decides how many enter cannot hard code position printing array. yep, said above. edit: or best of all, patricia shanahan says.

c - Reading number of commas in a string not working in Visual Studio 2010 -

i wrote simple c program counting number of commas in string. simple console c application done in visual studio 2010 professional. the string read text file answer wrong. after spending many hours trying , that, posting here, hoping can me out. pasting code here , sample line text file. please take @ it. #include <stdio.h> #include <stdlib.h> #include <malloc.h> int main() { char *myline; file *outputf; int line_len=4800; int ncomas=0; int i=0; int coma_count=0; outputf = fopen("c:\\tmp\\tmp.csv","r+"); if (outputf == null) { printf("couldn't open csv file writing.\n"); } else { myline=(char *)calloc(1,line_len); while(fgets(myline,line_len,outputf) != null) { ncomas=0; for(i=0;i<

Python 2: Using regex to pull out whole lines from text file with substring from another -

i have noob question. using python 2.7.6 on linux system. what trying achieve use specific numbers in list, correspond last number in database text file, pull out whole line in database text file , print (going write line text file later). code trying use: reg = re.compile(r'(\d+)$') line in "text file database": if list_line in reg.findall(line): print line what have found can input string like list_line = "9" and output whole line of corresponding database entry fine. trying use list_line input strings 1 one in loop doesn't work. can please me out or direct me relevant source? appendix: the text file database text file contains data similar these: gnl acep_1.0 acep10001-pa 1 gnl acep_1.0 acep10002-pa 2 gnl acep_1.0 acep10003-pa 3 gnl acep_1.0 acep10004-pa 4 gnl acep_1.0 acep10005-pa 5 gnl acep_1.0 acep10006-pa 7 gnl acep_1.0 acep10007-pa 6 gnl acep_1.0 acep10008-pa 8 gnl acep_1.0 acep10009-pa 9 gnl acep_1.0 acep

java - How can I initialize interdependent final references? -

i have class , factory function creates new anonymous class objects extending class. however, anonymous class objects have method in there references other objects. in full program, need create , combine parsers, i've stripped down code here. class base{ public base run(){ return null; } static base factory(final base n){ return new base(){ public base run(){ return n; } }; } } public class circularreferences{ public static void main(string args[]){ final base a, b; = base.factory(b); b = base.factory(a); } } i circularreferences.java:17; error: variable b might not have been initialized . that's true, wasn't, can't set aside space these variables , initialize them using references these spaces, filled proper values before ever used? can perhaps use new separately constructor? how can create these variables reference each other? the

Python tkinter update_idletasks is blanking the window -

[this has been edited in light of comments original post, , make context - 2 modules - clearer , summarise think key underlying issue. code updated. have working version not @ sure done right way.] (disclaimer ... im learning tkinter go along!) im attempting display progress bar while app running (eg walking music library folder tree doesnt matter here). i'd implement class in separate module main app can use elsewhere (also app in 2 modules). for reason, , because don't want upset app's main window design id progress bar appear in separate window. i've tried 2 ways ... own crudely drawn progress bar using text widget, , - once discovered - ttk.progressbar. im focusing on using ttk.progressbar. note had same problem either approach, getting contents of progress window display without preventing control reverting calling module. my class (progressbar) has methods start, update, , stop progress bar. understand there 3 ways force refreshing of status wi

javascript - Replicating jQuery slideToggle without jQuery -

since anki doesn't support jquery, how go converting jquery on particular document same effects produced in vanilla js, or purely in css3 (specifically of + button, , when clicking on list items)? $(document).ready(function () { $("#show-pronunciation").on("click", function () { $(".pronunciation").slidetoggle(); }); $("li").on("click", function () { $(this).find("dl").slidetoggle(); }); }); body { font-family: avenir, futura, sans-serif; background-color: #f7f7f7; } .definitions dl { border-left: 2px solid #ff1919; padding-left: 5px; } dt { font-weight: bold; } dd { margin-left: 1em; } .main { margin: 20px 20px 0 20px; border: transparent; border-radius: 5px; /*padding: 15px 10px 5px 10px;*/ border-collapse: collapse; background-color: #ff4c4c; padding-bottom: 5px; } .header { bo