Posts

Showing posts from September, 2011

Disable Horizontal Scrolling in PhpStorm -

is there way this? i'd rather have code wrap , within 80-100 character line lengths. scroll on every time swipe driving me crazy! there "soft wraps" functionality in ide -- -- virtually (on screen only) breaks line multiple show whole line without need horizontal scrolling. it can enabled at: for files: settings/preferences | editor | general | use soft wraps in editor for current file only: view | active editor | use soft wraps these options available via gutter context menu (the area line numbers are). if have customized context menu long time ago ... may not there (as added there straight away).

domain driven design - Dealing with a user dependent application -

an application i'm writing heavily dependent on current logged in user, give concrete example lets have list of products. now every user has 'rights' see products, particular details of product, , edit / remove fewer of those. e.g.: the user can see 3/5 products the user can see details 2 out of 3 products ... as case of application's domain, have tendency pass around user in methods. becomes cumbersome time time. have pass in user in methods, pass down 1 needs it. my gut tells me i'm missing something, i'm not sure how tackle problem. i gave thoughts @ using class holds user, , inject class everywhere need it. or using static property. now time time handy pass in user in method, guess override then: public dosomething(user user = null) { var u = user ?? this.authservice.user; ... } are there other ways tackle kind of problem ? your gut correct, keep listen it. authorization checks should not mixed core domain checks....

xamarin.forms - Xamarin Forms IoC containter + navigation service -

does xamarin.forms have built-in ioc navigation service? mean prism, register routes. if yes - documentation? if not - xamarin.forms have built-in navigation service in near future? also - if not - best mvvm fw xamarin.android, xamarin.ios, xamarin.winxyz , xamarin.forms? , why? it seems me comes down battle between prism , freshmvvm - brings me important questions: which of these 2 performing better? (which 1 faster?) which of these more lead way of mvvm frameworks considering mobile development in future? no xamarin forms not offer navigation prism. had goal of making built in navigation similar prism, has since disappeared roadmap. there no direct ioc concept built directly xamarin forms. if developing native ui's prism isn't purpose built xamarin forms. in case might should @ mvvmcross. battle tested in lot of classic xamarin apps. if developing xamarin forms, prism best use. opinion may biased, it's public opinion of many of on xamarin tea...

php - Wordpress wp_link_pages() to display pagination for posts -

Image
i'm using wp_link_pages() display pagination, looks like: <span class="current">1</span> <a href="/2">2</a> <a href="/3">3</a> <a href="/4">4</a> but, want display pagination as please me! thanks.

symfony - How to deal with permissions using docker - nginx / php-fpm -

i'm trying deploy simple symfony application using nginx & php-fpm via docker. two docker services : 1. web : running nginx 2. php : running php-fpm; containing application source. i want build images can deployed without external dependency. that's why i'm copying source code within php container . on development process; i'm overriding /var/www/html volume local path. # file: php-fpm/dockerfile php:7.1-fpm-alpine copy ./vendor /var/www/html copy . /var/www/html volume /var/www/html now docker-compose configuration file. # file : docker-compose-prod.yml version: '2' services: web: image: "private/web" ports: - 80:80 volumes_from: - php php: image: "private/php" ports: - 9000:9000 the problem permissions. when accessing localhost, symfony botting up, cache / logs / sessions folders not writable. nginx using /var/www/html serve static files. php-fpm using /var/www/ht...

android - Check if need to update the local data(Web Service) -

i have android app , need improve both performance , request internet. have web service in .net. when enter in profile of person need download profile again, want verify if need download profile(new data). i thinking make date column , whenever modifies profile, update column date. in android, load localdb , verify if "update date" of local same remote db(web service) , if not download data api. its right way do? better approach? maybe using int verify "the version of profile"? thank you you can't know on local device happening on web server without contacting it. cache profile in android memory cache or database, , call web service in background check new data. i cache profile on server, on web service because performance other consumers of web service if have (like web app). when change profile(inside post or put method don't forget invalidate cache). when receive new profile web service update database or cache again in android. ...

html - Change color of Icon-Image on :hover – what other ways are there? -

Image
i have following problem , drives me crazy: basicly have div-container background. background should change when hover (see pichture). png , instead of white should turn red. what have done until now: first: css sprite thought best solution becuase div changes it's size (responsive) , icon not have fixed size not clean: had small offset on hovering. not sure why… mybe can fixed…  second: 2 separate images but not option in case because need work inline styles. :hover ist not available inline style. thrid: tried mask-box-image was woderful solution… but firefox not support it. does has idea how solve it? give try css .icon-cont{ height:300px; width:300px; background-color: #ff0000; text-align:center; } .icon-cont:hover{ background-color: transparent; } .icon-cont:hover .icon, .icon-cont:hover .icon::before, .icon-cont:hover .icon::after { border-color:#ff0000; } .icon{ height:0px; border-bottom:2px solid #fff; width:60%; line-...

algorithm - Breadth First Search Pseudo Code Understanding -

Image
i have 2 questions regarding pseduo code above. what function solution(node) do? how 1 implement it? on 3rd last line, check if child not in frontier. how 1 check in fifo queue? solution(node) returns full solution problem instead of node. in pathfinding problem, might return full path start end node example: def solution(node): result = [] while(node.predecessor not none): result.append(node.predecessor) node = node.predecessor linear search frontier. if isn't possible, still work long check whether node in explored after dequeued, requires memory.

Insert list of vectors to multiple tables in R -

i have list of 12 tables. same. 1 of tables : $x2015_kvish_1_10t kvish keta maslul yom nefah status date 1 1 10 1 2 1346 na 2015-06-15 00:00:00 2 1 10 1 2 788 na 2015-06-15 01:00:00 3 1 10 1 2 626 na 2015-06-15 02:00:00 4 1 10 1 2 652 na 2015-06-15 03:00:00 5 1 10 1 2 597 na 2015-06-15 04:00:00 6 1 10 1 2 798 na 2015-06-15 05:00:00 7 1 10 1 2 2344 na 2015-06-15 06:00:00 8 1 10 1 2 3617 na 2015-06-15 07:00:00 9 1 10 1 2 3669 na 2015-06-15 08:00:00 10 1 10 1 2 2873 na 2015-06-15 09:00:00 11 1 10 1 2 2926 na 2015-06-15 10:00:00 12 1 10 1 2 2928 na 2015-06-15 11:00:00 13 1 10 1 2 3681 na 2015-06-15 12:00:00 14 1 10 1 2 4158 na 2015-06-15 13:00:00 ....... 168 rows in total and have list of 12...

parsing - How do you parse and process HTML/XML in PHP? -

how can 1 parse html/xml , extract information it? native xml extensions i prefer using 1 of native xml extensions since come bundled php, faster 3rd party libs , give me control need on markup. dom the dom extension allows operate on xml documents through dom api php 5. implementation of w3c's document object model core level 3, platform- , language-neutral interface allows programs , scripts dynamically access , update content, structure , style of documents. dom capable of parsing , modifying real world (broken) html , can xpath queries . based on libxml . it takes time productive dom, time worth imo. since dom language-agnostic interface, you'll find implementations in many languages, if need change programming language, chances know how use language's dom api then. a basic usage example can found in grabbing href attribute of element , general conceptual overview can found @ domdocument in php how use dom extension has been covered exte...

swift - Why can't I initialize this struct? -

i want make swift error describes how type of variable coming objective-c wrong. here's how tried define struct : public struct unexpectedresulttypeerror<expected, actual>: error { let expected: expected.type let actual: actual.type init(expected: expected.type, got actual: actual.type) { self.expected = expected self.actual = actual } } i figured fine, can't initialize it: unexpectedresulttypeerror<string, any>(expected: string.self, got: type(of: serializedresult)) cannot invoke initializer type 'unexpectedresulttypeerror<string, any>' argument list of type '(expected: string.type, got: any.type)'

reactjs - Remove value from array in Reducer -

so have following code. if action active, itll store activity type in array called selectedactivitytype. however, trying remove activity type if action not active. any ideas: const initialuserstate = { selectedactivitytype: [], } export const activitytypes = (state = selectedactivitytype, action) => { switch (action.type) { case types.diary_update_activity_type: if(action.active) { return { ...state, selectedactivitytype: [...state.selectedactivitytype, action.activitytypeid], } } else { return { ...state, } } default: return state } } i've taken code here , modified use in snippet examples. the below snippet illustrate problem. current setup push value array if exists. meaning not have unique values in array . run snippet below , see duplicate entry. let state = { selectedactivitytype: [ ] }; const activitytypes = (state = selectedactivitytype, action) => { switch (acti...

How do I get the vertices of a defined area / region in google maps -

i'm trying vertices of region that's showing in google. for example here region of "piñeiro" in buenos aires, argentina: https://www.google.com.ar/maps/place/piñeiro,+provincia+de+buenos+aires/ and here region kent in united kingdom: https://www.google.co.uk/maps/place/kent,+uk/ in both region recognized google , shows polygon on map. i want vertices of polygon without having manually define or copy myself. the information i'm looking list of latlng coordinates defining polygon. how can that? the polygons show when using google maps. not available through google maps api or google places api. if @ response format here: https://developers.google.com/places/web-service/details#placedetailsresponses . geometry object contains location coordinate , view port. "geometry" : { "location" : { "lat" : -33.866651, "lng" : 151.195827 }, "viewport" : { ...

How to exclude folder/file from teamcity/Octopus Deploy? -

i generating build using teamcity , deploying build using octopus(used octopack) , have been successful doing so. but, 1 thing unable figure out -- how can exclude folder/file part of created package going custom installation directory? please try exclude purge octopus deployment step i exclude app_data folders applicationpath. can see screenshot above

multivariate testing - Can mvabund be used for a nested experimental design? -

i'm using mvabund , manyglm test differences in species composition in samples taken different treatment plots (experimental treatment plots or control plots). don't wish use adonis because taxa variance increases mean , taxa have low variance. i have 24 samples in total (rows in dataset samples) have 181 different species recorded (in columns). species ants , samples trees. my experimental design nested have 3 trees within each plot , plots either treatment or control. account effect of different tree species if possible. my first question: trees pseudoreplicates within each plot there way account nested design in mvabund? my second question: when have applied model below, output not give p values each species in univariate tests. why this? the model shows significant effect of treatment: mod2 <- manyglm(data.mvabund ~ data$treatment, family="negativebinomial") anova(mod2) multivariate test: res.df df.diff dev pr(>dev) (interc...

Angular 4 - Structural directive Can't bind to X since it isn't a known property of Y -

i'm trying write structural directive remove , display components according user permissions. this code , error recive import { credantialsstorageservice } './_services/credantials-storage.service'; import { directive, input, templateref, viewcontainerref } '@angular/core'; import { } 'lodash'; @directive({ selector: '[accessroles]' }) export class accessrolesdirective { constructor( private templateref: templateref<any>, private viewcontainer: viewcontainerref, private readonly credantials: credantialsstorageservice) { } @input() set accessroles(roles: [string]) { let isvalidarraywithroles = roles != null && array.isarray(roles) && roles.length > 0; let isuserinoneoftheroles = isvalidarraywithroles && some(this.credantials.get().roles , role => roles.indexof(role) > -1); if (isuserinoneoftheroles) { this.viewcontainer.createembedde...

Unable to install numpy python 2.6 -

i trying install numpy on python 2.6 (linux centos 6.8) pip #pip install numpy collecting numpy retrying (retry(total=4, connect=none, read=none, redirect=none)) after connection broken 'protocolerror('connection aborted.', gaierror(-2, 'name or service not known'))': /simple/numpy/ ...//several more of same error not find version satisfies requirement numpy (from versions: ) no matching distribution found numpy also tried easy_install, , got error #easy_install numpy searching numpy reading http://pypi.python.org/simple/numpy/ download error: [errno -2] name or service not known -- packages may not found! reading http://pypi.python.org/simple/numpy/ download error: [errno -2] name or service not known -- packages may not found! couldn't find index page 'numpy' (maybe misspelled?) scanning index of packages (this may take while) reading http://pypi.python.org/simple/ download error: [errno -2] name or service not known -- packages may n...

node.js - How to write a date/time value? -

the date/time format tokens straightforward. however, how use them write date value cell using spreadsheets.values.append method ? (i coding in node.js.) you can't. values apis writing values themselves, not formats. if want write formats, need use spreadsheets.batchupdate method, either updatecellsrequest , repeatcellrequest , or appendcellsrequest .

java - How to create different files for logger hierarchy in tomcat? -

in tomcat application, want use 2 loggers log general event informations , errors 2 different files. logger eventlogger = logger.getlogger("event"); logger errorlogger = logger.getlogger("error"); now want following: logs of eventlogger should written "events.log" file, , errorlogger logs should written in "errors.log" file. logs other logger (e.g. tomcat logs) should written catalina.out (or other default file). how can achive juli? or need third party lib? this can't achieved juli. might use log4j. basically need appenders. manage logs go separate files. example configuration in xml : <?xml version="1.0"?> <!doctype log4j:configuration system "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="console" class="org.apache.log4j.consoleappender"> <layout class="org.apache.log4j.enha...

node.js - ExpressJS prevent my app from being hacked -

i writing app give user1's money user2, if user1 agrees user2 completed task successfully. i have several ideas on how go this, worried security. not understanding subject as should , hoping advice. one method listen if user1 happy user2's job completion. example express code saving data firebase db: app.post('/general/something', function(serverreq, serverres) { var data = serverreq.body; var ref = db.ref("stuff/"+data.useroneid).update({ ishappy: true }); serverres.send("posted"); }); then check if user happy in db , send user2 user1's money. however, seems if (especially user2) post data (user1's id) server @ "/general/something" , receive userone's money. we can assume user2 knows user1's firebase userid. because need users able reference each other , userid way i've found firebase (without giving other user's email address out). what best way of completing task? ...

ssh - How to use VPN with Bitbucket Pipelines -

i need access remote server bitbucket pipelines. remote server available specific host has ip address whitelisted. here want: pipelines <---> gateway host <---> remote server i trying use sshutle setup ssh-based vpn forward network traffic via gateway host, looks pipelines don't allow containers run vpn (see issue #12753 ). what can access remote server? there solution if forwarding http/https enough you. use ssh set socks5 proxy. first, add bitbucket's public ssh key ~/.ssh/authorized_keys on gateway server. open repository --> settings --> (pipelines) ssh keys , follow instructions on page. then add these steps bitbucket-pipelines.yml : # start in foreground (-fn), use compression (-c), set port forwarding (-d) ssh -fn -c -d 41337 user@server.foobar.com export http_proxy='socks5://localhost:41337' export https_proxy='socks5://localhost:41337' use curl check whether proxy works: curl http://checkip.amazonaws.co...

c# - Updating detached entities in Entity Framework -

loading parents db, closing context. after point when parents processed(added toys children, toys can shared amongst children: many many relationship), need updated , each 1 updated once. public class parent { public int parentid { get; set; } public virtual list<child> children { get; set; } } public class child { public int childid { get; set; } public int parentid { get; set; } public virtual parent parent { get; set; } public virtual list<toy> toys { get; set; } } public class toy { public int toyid { get; set; } public virtual list<child> child { get; set; } } they have other properties, toys of each children inserted. parents updated in db. public void updateparents(list<parent> parents) { using (var ctx = new context()) { foreach (var parent in parents) { parent.children.foreach(c => c.toys.foreach( t => ctx.entry(t).state = entitystate.added)); ...

How can I find a specific file using python? -

i new service if make mistake please tell me. i new python , have ideas on projects want start. 1 of these projects includes process of looking in file in specific folder , being able write, read or delete it. i want make program allows user enter password , able access, print screen, create, edit, delete text files. said text files contain information such passwords or profiles of people or dirarie entered. able print, delete , edit files need program able match , locate file within specific folder file (file name) user inputed. folder in question folder actual program saved in because default location saved , @ level that's can do/program @ minute. i using version 3.5.2 of python , grateful if me problem... sincerely isaac, to start things off, i'm going assume have basic required knowledge of python. , i'd preface answer recommending @ least try , google before asking on stackoverflow. that being said, following excellent resource accomplish: http...

python - greenthreads doesn't run just after the spawn call -

i'm creating simple program uses eventlet greenthreads , cannot understand behavior. following example seems me thread runs when call .wait() method. read documentation , can't find method similar "start" method provided threading module. there similar method force thread run after creation (spawn call)? python 2.7.6 (default, oct 26 2016, 20:30:19) [gcc 4.8.4] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import eventlet >>> def test(): ... print("this test") ... >>> gth = eventlet.spawn(test) >>> >>> gth.wait() test >>> tl;dr: need eventlet.sleep() or wait useful, network. observed behavior expected synthetic test. production code provides excessive opportunities running other greenthreads. in other words: it works similar os threads real code . eventlet provides cooperative multitasking . every thread...

POST every 5 sec. What HTTP timeout to choose ? -

so, have situation. working on mobile-web live tracking system. clients send gps coordinates every 5 seconds , process data on server , update ui every 5 seconds. all until now. the problem if http response start take long. on server side try fast possible executing on separate thread after initial parameter validation. i don't want have bunch of http request waiting around , others being initiated. what http timeout should have if have 5 seconds post going out ? should try low 4 seconds ? push limits taking in consideration internet speed , other aspects ?

Java Maven Mojo : Object Class Default Value -

i trying write maven plugin in java. want in following manner: <pluginaction>tokenreplace</pluginaction> <tokenreplacerconfig> <prop1>a</prop1> <prop2>b</prop2> </tokenreplacerconfig> for have following main mojo java class: public class token extends abstractmojo{ @parameter(defaultvalue="tokenreplace") private string pluginaction; @parameter private tokenreplacerconfig tokenreplacerconfig; ..... } my tokenreplacerconfig class follows: public class tokenreplacerconfig{ private string prop1; private string prop2; ... } my question that, want have default values set prop1 , prop2 in case user using plugin doesn't provide tag. want know how can achieve this. i tried: public class tokenreplacerconfig{ @parameter(defaultvalue="a") private string prop1; @parameter(defaultvalue="b") private string prop2; ......

python - How to convert a worksheet to a Data frame in Pandas? -

i trying read different worksheets excel workbook in python pandas. when read entire workbook , want apply .merge() first worksheet read others not considered. tried read each worksheet of workbook guess not converted data frames because when apply .merge() end following error: valueerror: invalid file path or buffer object type: <class 'pandas.core.frame.dataframe'> this have done far: this code works converting entire workbook data frame data of first worksheet processed import pandas pd import pypyodbc #sql extractor start_date = date.today() retrieve_values = "[dev].[cs].[qt_kpiexport] @start_date='{start_date:%y-%m-%d}'".format( start_date=start_date) connection = pypyodbc.connect(driver="{sql server}", server="xxx.xxx.xxx.xxx", uid="x",pwd="xxx", trusted_connection="no") data_frame_sql = pd.read_sql(retrieve_values, connection) #read entire workbook wb_data = pd.excelfile("c:\...

Infopath form with Multiselection window popup. -

hi have question regarding possibility of doing following in infopath 2013: want make field repeating section upto 10 times , every time while starting filling section multiple selection list should pop-up , checked values specfic field should displayed on other field. repeating section consists of single text field , data retreived multiple selection list should text field. thispossible in infopath or should write code in c# or javascript.

c# - Invoke windows service methods programmatically from a REST application(web api)? -

i have rest api created using web api c# , need programmatically invoke method inside of windows service running on same box. i have done reading on topic , understand 1 way self-hosting api inside windows service. need know other possible implementation possibilities. any inputs in regard welcome.

javascript - What's the equivalent of a list comprehension like this one in ES2016 or greater? -

python 3.6: [f"cat #{n}" n in range(5)] gives ['cat #0', 'cat #1', 'cat #2', 'cat #3', 'cat #4'] new javascript, what's equivalent in new ecmascript? array comprehension in js proposed es2016, never made final release. firefox supported comprehensions time, support dropped in later versions. you can use array#from close comprehension. const result = array.from({ length: 5 }, (_, k) => `cat #${k}`); console.log(result);

chef converge failed, but no error reported -

i seeing chef converge failed no errors. error message : running handlers: running handlers complete chef client failed. 21 resources updated in 14 seconds could please tell me failing? i found answer why chef-client failing . had change permissions on chef-server update chef-client.

Binary Search implementation in Python -

i trying implement solution using binary search. have list of numbers list = [1, 2, 3, 4, 6] value searched = 2 i have written this def searchbinary(list, sval): low = 0 high = len(list) while low < high: mid = low + math.floor((high - low) / 2) if list[mid] == sval: print("found : ", sval) elif l2s[mid] > sval: high = mid - 1 else: low = mid + 1 but when trying implement this, getting error like: index out of range. please in identifying issue. a few things. your naming inconsistent. also, not use list variable name, you're shadowing global builtin. the stopping condition while low <= high . important. you not break when find value. result in infinite recursion. def searchbinary(l2s, sval): # not use 'list' variable low = 0 high = len(l2s) while low <= high: # main issue. long low not greater high, while loop must run ...

Best practice for deploying angular 2 with spring backend -

i new angular 2 , develop project using spring backend , angular 2 front end. question best practice develop such project ? putting them on same server or different servers. there limited guidelines on web subject. if points me in right direction glad.. usually you'd host angular app within cdn, host cdn. one example of hosting compiled site through s3, using route 53 host site itself. tutorial on how this. the tougher part java application itself. there's multiple options out there, depends on how application built, require servlet container, etc. but basically, want static site hosting statically, not part of java code. helps clean separation of duties, , provides performance improvements. need figure out how host actual java application.

c# - getting message in a command from the discord chat -

i have line needs recieve message discord text channel. choice = video[int.parse(commandhandler.message .content)-1].url; i tried lot of things, including searching in api don't have clue. here command [command("join", runmode= runmode.async), summary("joins voice channel")] public async task joinvoice([remainder, summary("the text echo")] string searchp="") { ivoicechannel voicechannel = (commandhandler.last iguilduser).voicechannel; if (voicechannel == null) { await replyasync("u have in channel first"); return; } string choice = ""; videosearch searchrisolts = new videosearch(); if (searchp != "") { if (searchp.contains("https://")) choice = searchp; else { list<videoinformation> video = searchrisolts.searchquery(searchp, 1); await replyasync("1) " + video[0].titl...

build - Makefile error when building on Cygwin -

i installing nasa's software (heasoft) source code on cygwin (32-bit) running on windows 10. configure ran successfully, make gives following errors: makefile:26: /home/mario/heasoft-6.21/heacore/build_dir/makefile-std: no such file or directory gmake[2]: *** no rule make target '/home/mario/heasoft-6.21/heacore/build_dir/makefile-std'. stop. gmake[2]: leaving directory 'c:/cygwin/home/mario/heasoft-6.21/heacore/build_dir' make[1]: *** [makefile:74: heacore] error 2 make[1]: se sale del directorio '/home/mario/heasoft-6.21/build_dir' make: *** [makefile:10: all] error 2 my problem file /home/mario/heasoft-6.21/heacore/build_dir/makefile-std not found; however, exists , located in correct directory. edit: here can seen file exists: $ ls /home/mario/heasoft-6.21/heacore/build_dir config.guess config.sub hd_config_info headas-init.csh headas-setup.in hmakerc lhea-fixperl makefile-ccfits config.log configure hd_install.c head...

python - How do I change the color of a single rectangle in a grid? -

i've programmed grid, want change color of single rectangle in grid. x = 5 y = 5 height = 30 width = 50 size = 20 color = (255,255,255) new_color = (255,255,0) screen.fill((0,0,0)) def draw_grid(): y in range(height): x in range(width): rect = pygame.rect(x * (size + 1),y * (size + 1),size,size) pygame.draw.rect(screen,color,rect) x += 20 rects.append((rect,color)) y += 20 rects = [] colored_rects = [] while 1: event in pygame.event.get(): if event.type == quit: sys.exit() draw_grid() if pygame.mouse.get_pressed()[0]: mouse_pos = pygame.mouse.get_pos() i,(rect,color) in enumerate(rects): if rect.collidepoint(mouse_pos): rects[i] = (rect,new_color) colored_rects.append((rect,new_color)) rect,color in rects: pygame.draw.rect(screen,color,rect) rect,new_color in colored_rects: pygame.draw...

python 2.7 - How to get a row from a file that starts with multiple prefixes -

i'm trying rows starts 's1', 's2'. below code. import os f = open("test.csv","r") lines = f.readlines() f.close() f = open("test.csv","w") line in lines: if (line.startswith("s1") || line.startswith("s2")) f.write(line) f.close() when run script i'm getting syntax error near '||'. looked link , made changes accordingly - how check if string starts 1 of several prefixes? please let me know if i'm doing wrong. fyi, i'm using python 2.7. thanks!

SQL Server Date when member turns 65 -

i need find date of member gonna turn 65 or 19. have dob , age. need date shows when turn 19 or 65. id dob age date_turning_65_or_19 -------------------------------------------- 2 1952-09-30 64 2017-09-30 i need last column result please me doing it. i trying different formulas not working. i tried this case when month(getdate()) <= month(dateofbirth) , datediff(year, dateofbirth, getdate()) = '65' convert(date, convert(varchar(2), month( dateofbirth)) + '/' + convert(varchar(2), day(dateofbirth)) + '/' + convert(varchar(4), year(getdate()))) when datediff(year, '19510901', getdate()) = '64' convert(date, convert(varchar(2), month( dateofbirth)) + '/' + convert(varchar(2), day(dateofbirth)) + '/' + convert(varchar(4), year(getdate() + 365.25))) select *, case when dateadd(year, 19, dob) < getdate() dateadd(year, 19, d...

rest - Consuming RESTful web service from email link buttons -

i came across scenario need call controller method on click of link (basically link buttons text "approve" , "reject") in client email. client can approve or reject. accordingly method in controller gets called further triggers mail user respective contents. second part of scenario. in first part (though have implemented it) user had raised request new registration client got mail contents "approve" , "reject" buttons. i using spring mvc apache freemarker template. newuserregrequest.ftl <html> <head> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"/> </head> <body> <h2>hi,</h2> <h3>new registration bidmanager development:</h3> <span>this request has been raised user details below -</span> <div> first name : ${bmusermodel...

sql - Select rows with same id but different result in another column -

sql: have table this: +------+------+ |id |result| +------+------+ |1 |a | +------+------+ |2 |a | +------+------+ |3 |a | +------+------+ |1 |b | +------+------+ |2 |b | +------+------+ the output should like: output: +------+-------+-------+ |id |result1|result2| +------+-------+-------+ |1 |a |b | +------+-------+-------+ |2 |a |b | +------+-------+-------+ |3 |a | | +------+-------+-------+ how can this? select id, max((case result when 'a' 'a' else null end)) result1, max((case result when 'b' 'b' else null end)) result2, table1 group id results +------+-------+-------+ |id |result1|result2| +------+-------+-------+ |1 |a |b | |2 |a |b | |3 |a |null | +------+-------+-------+ run live demo on sql fiddle: ( http://sqlfiddle.com/#!9/e1081/2 )

ruby - Rails hanging when trying to generate controller -

for reason can't seem use rails generate command. been trying generate controller called home , 1 called artists seems keep hanging. when cancel request, following stack: ^c/users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/run.rb:117:in `gets': interrupt /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/run.rb:117:in `verify_server_version' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/run.rb:62:in `run' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/run.rb:42:in `warm_run' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/run.rb:35:in `call' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/rails.rb:24:in `call' /users/username/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/c...

javascript - Handle dropdown's focus state -

i making dropdown component in pure javascript. when user click on dropdown toggle, content gain focus , content being displayed. when user click outside of it, content loses focus , gets hidden. so far, works great. however, encountering 2 problems. the first 1 when element inside dropdown clicked (eg: anchor tags), dropdown loses focus, shouldn't. the second 1 when dropdown toggle clicked while dropdown content being displayed, dropdown should close instead of closing re-opening due click registered on dropdown toggle. html: <div class="dropdown"> <a href="#" class="dropdown-toggle">dropdown toggle</a> <div class="dropdown-content" tabindex="0"> <ul> <li> <a href="http://example.com">my profile</a> </li> <li> <a href="http://example.com">log out</...

python - Using lxml, how can I read text inside nested elements? -

i'm trying search 500 xml documents specific phrases, , output id of element contains of phrases. currently, code: from lxml import etree import os import re files = os.listdir('c:/users/me/desktop/xml') search_words = ['house divided', 'committee divided', 'on division', 'division list', 'the ayes , noes',] f in files: doc = etree.parse('c:/users/me/desktop/xml/' +f) elem in doc.iter(): word in search_words: if elem.text not none , str(elem.attrib) != "{}" , word in elem.text , len(re.findall(r'\d+', elem.text))>1: votes = re.findall(r'\d+', elem.text) string = str(elem.attrib)[8:-2] + "," string += (str(votes[0]) + "," + str(votes[1]) + ",") string += word + "," string += str(elem.sourceline) print string ...

excel - Deactivate entire sheet selection after paste -

i asked question , received great answer on site, running different problem. code below works running through each workbook in folder, copying sheet's contents, , pasting contents master workbook how like: sub conslidateworkbooks() 'code pull sheets multiple excel files in 1 file directory 'into master "consolidation" sheet. dim folderpath string dim filename string dim sheet worksheet dim wbname string activesheet range("a1").activate end application.screenupdating = false folderpath = activeworkbook.path & "\" filename = dir(folderpath & "*.xls*") wbname = activeworkbook.name while filename <> "" if filename <> wbname workbooks.open filename:=folderpath & filename, readonly:=true each sheet in activeworkbook.sheets copyorrefreshsheet thisworkbook, sheet next sheet workbooks(filename).saved = true workbooks(filename).close ...

Java/Gson: Change serialization of an array to that of an object -

i have java program reads json files have attributes these: "property": { "value1": 4.35684302507939 } in actual program, "property" double array, , contains fixed amount of values. format of json file fixed, , have write json files conform it. there way, can serialize double array, looks in code example? easiest way think this, create class property , serialize that, i'd avoid it. json file doesn't contain value, several others. thought, maybe can create jsonobject out of array, don't know how can have serialized in right place. ex. "name" : "bob" "age" : "13" "property": { "value1": 4.35684302507939 } instead of "name" : "bob" "property": { value1": 4.35684302507939 } "age" : "13" every appreciated.

python - How do I run a BeaufiulSoup4 command in BeauifulSoup 3? -

i'm trying add new code larger project, code uses beauifulsoup4 , project used beautifulsoup 3.2.1. if try run beautifulsoup 3.2.1 on code error .parent commands exist in code. try upgrading project beauifulsoup4, errors failed test in part of project prefer not tamper with. supervisor told me it's against company policy have 2 different versions of same pip installed. there way me add .parent command beautifulsoup 3.2.1? soup = beautifulsoup(response.content, 'html.parser') na = soup.find(id='pizza stores') links = na.parent.parent.find_all('a') when try run code in beautifulsoup 3 typeerror: 'nonetype' object not callable i changed changed beautifulsoup(response.content, 'html.parser') beautifulsoup(response.content) when trying run in beautifulsoup 3. the problem not in parent , in find_all , should findall in bs3. doc = '<html><body><div><div id="pizza stores"></div...

javascript - How do I return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback ca...