Posts

Showing posts from April, 2015

html - Force selection options to one line -

Image
<select id="semester"> <option value="fall">fall</option> <option value="spring">spring</option> <option value="summer">summer</option> </select> <select id="year"> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> </select> <p> <input class="submit" value="submit" type="submit" /> </p> i have code, which, on stackoverflow on 1 line (except button). on our cms, however, each select element shows on different line this: what can force these on 1 line? add display: inline-block elements make them display in 1 line: <select id="semester" style="display: inline-block;"> <option value="fall">fall</option> ...

ruby on rails - host can not recognized in postgres -

we have seen issue in log fatal: lock file "/tmp/.s.pgsql.5432.lock" exists hint: postmaster (pid 4696) using socket file "/tmp/.s.pgsql.5432"? log: not bind ipv4 socket: address in use we have deleted /tmp/.s.pgsql.5432.lock we restarted postgres service service restarted but psql -h localhost -d database -u newuser shows error role 'newuser' not exists but if connect without host psql -d database -u newuser it worked, how can work host options ? is there ,missing somthing after deleting tmp file? same last one, have 2 instances of postgresql running on machine. you delete socket file rather shutting down instance. allows second instance start, it's listening on unix socket. presumably listen_addresses unset/empty doesn't attempt bind tcp/ip socket, since it'd fail if tried , port 5432 in use. the other instance still running , still listening on port 5432 tcp/ip connections. when specify -h localhost tcp/...

.htaccess - Trying to enforce http://www in url on a Cake PHP site -

my current .htaccess file looks this rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l] how can add http://www. in cases? any appreciated. the solution independent of php framework it's best resolved in apache configuration (.htaccess): at top of .htaccess file, after rewriteengine on directive, include following: rewritecond %{http_host} ^example\.com rewriterule (.*) http://www.%{http_host}/$1 [r=301,l] explanation: if site accessed bare domain ( example.com ) redirect www subdomain. if not using other subdomains (ie. www ) make generic: rewritecond %{http_host} !^www\. rewriterule (.*) http://www.%{http_host}/$1 [r=301,l] explanation: if host not start www. redirect www subdomain.

javascript - Moment's fromNow returning strange result -

i'm using fromnow in moment , seem getting odd results. var moment = require('moment'); var months = { jan: '1', feb: '2', mar: '3', apr: '4', may: '5', jun: '6', jul: '7', aug: '8', sep: '9', oct: '10', nov: '11', dec: '12' } var input = "3 aug 2015, 12:30".replace(/,/g, "").split(' ') var time = input.pop().split(':') var date = input.reverse() var t = date.concat(time); t[1] = months[t[1]]; t = moment(t); console.log(t.fromnow()); this printing out "in month". it seems array you're feeding moment (i.e. ["2015", "aug", "3", "12", "30"] ) not valid date. if print out t.todate() after assigning moment(t) states "invalid date". why not doing , let moment parse date properly: var m = moment("3 aug 2015, 12:30", "dd mmm...

javascript - Preventing multiple toggling at a same time -

how can prevent slidedown , slide of sub menu @ same time?my navigation has menu , 1 of menus has sub menu.when click on menu has sub menu , sub menu opens,closes 2 times , closes there 1 click.it happens in mobile devices.so take @ codes html <ul class="nav-menu align-right"> <li class="current"><a href="index.html#header">home</a></li> <li><a href="index.html#about-us">about us</a></li> <li> <a href="#" class="extra">extra</a> <ul> <li><a href="blog-three.html">blog grid 3</a></li> <li><a href="blog-four.html">blog grid 4</a></li> </ul> </li> <li><a href="index.html#contact">contact</a></li></li> </ul> and js $(window).on('load resize', function(){ if($(window)...

Jersey & Spring Boot turns non-ok response statuses to 404 -

i using jersey spring boot 1.2.5. have jersey controller (annotated @produces(mediatype.application_json) ) works fine , returns json long return ok response such as return response.ok(dto).build(); but whenever try return custom error status such as return response.status(status.conflict).build(); it gets turned 404 such as <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>error 404 not found</title> </head> <body> <h2>http error 404</h2> <p>problem accessing /error. reason: <pre> not found</pre> </p> <hr> <i> <small>powered jetty://</small> </i> <hr/> </body> </html> any ideas what's going on here? jersey expects response contain entity. if return empty map error code, error gets passed onto browse...

objective c - NSMutableArray overwrites last object -

i had initialized both nsmutablearray , nsmutable dictinay outside loop overwriting last object array nsmutabledictionary *dictnew=[[nsmutabledictionary alloc]init]; nsmutablearray *newarr =[[nsmutablearray alloc]init]; //dictnew=[[nsmutabledictionary alloc]init]; (int i=0; i<[[[contactsdata valueforkey:@"firstname"] objectatindex:0] count]; i++) { [dictnew setobject:[[[contactsdata valueforkey:@"firstname"]objectatindex:0]objectatindex:i] forkey:@"firstname"]: [dictnew setobject:[[[contactsdata valueforkey:@"lastname"]objectatindex:0]objectatindex:i] forkey:@"lastname"]; [dictnew setobject:[[[contactsdata valueforkey:@"phones"]objectatindex:0]objectatindex:i] forkey:@"phones"]; nslog(@"%@",dictnew); [newarr addobject:dictnew]; nslog(@"newarr %@",newarr); } you can't reuse dictnew that. need new instance each iteration. have it, end adding same dic...

Nivo Slider not working on Laravel-5 -

i followed guide , loaded everything. far works, background url doesn't seem work on css file. adding source code. i've researched 50 posts, neither 1 discuss how right. my code. i've tried both (../images , (/images , don't work. .theme-default .nivoslider { position:relative; background:#fff url(../images/loading.gif) no-repeat 50% 50%; margin-bottom:10px; -webkit-box-shadow: 0px 1px 5px 0px #4a4a4a; -moz-box-shadow: 0px 1px 5px 0px #4a4a4a; box-shadow: 0px 1px 5px 0px #4a4a4a; files in /images/loading.gif add these links page head {!! html::style('css/default.css') !!} copy these files /css/js , link them page: {!! html::script('css/js/jquery.nivo.slider.js') !!} {!! html::script('css/js/jquery.nivo.slider.pack.js') !!} then copy index page or view : <div id="wrapper"> <div class="slider-wrapper theme-default"> <div id="slider" class=...

node.js - Why am I getting Unexpected token '\u0000' when using npm install -g package -

this windows specific issue haven't found information when googling issue. had been using ionic framework relies on cordova (or phonegap). however, problem not specific of these packages. see error quite often. so, error when run command such following: npm install -g cordova however, substitute various other packages , same error. i'll paste snippet (very brief) below of error message. strange had ionic project working in directory earlier. today told me ionic not found. hunch different issue main issue describing here. i installed git bash have linux-like environment try. select git bash bash window various bash commands. if there easier way fix windows users, please let me know. have seen courses on pluralsight instructors seem happily using npm no problems. also, when use yeoman, @ point, in many cases, same error. error npm err! failed parse json npm unexpected token '\u0000' @ 1:1 npm err! npm err! ^ npm err! file: c:\users\bruce\appdata\r...

xcode - TI SmartConfig Framework not working in iOS Simulator -

i used ti smartconfig framework in app configure cc3000 modules.the code downloaded texas instruments site not working in simulator , showing following error, it's working when device connected. ld: warning: ignoring file /naresh/cc3000_smartconfig_ios_source-1.1/src/cc3x/libftc_debug_arm_64.a, missing required architecture i386 in file /naresh/cc3000_smartconfig_ios_source-1.1/src/cc3x/libftc_debug_arm_64.a (2 slices) ld: warning: ignoring file/naresh/cc3000_smartconfig_ios_source-1.1/src/cc3x/libftc_release_arm_64.a, missing required architecture i386 in file /naresh/cc3000_smartconfig_ios_source-1.1/src/cc3x/libftc_release_arm_64.a (2 slices) undefined symbols architecture i386: "_objc_class_$_firsttimeconfig", referenced from: objc-class-ref in cc3xutility.o objc-class-ref in cc3xmainviewcontroller.o objc-class-ref in cc3xmainviewcontroller_ipad.o ld: symbol(s) not found architecture i386 clang: error: linker command failed exit code 1 (use -v see invocation) ...

how to calculate number of days in year in sql server 2008 -

i want calculate number of days in year in sql server 2008 management studio. for example: 2016 : 366 2014 : 365 you can try: declare @y int; set @y = 2014; select datediff(day, cast(@y char(4)), cast(@y+1 char(4))) days result: days 365 2version comment: declare @y int; set @y = 2014; select datediff(day, cast(cast(@y char(4)) date), cast(cast(@y+1 char(4)) date)) dayscnt

forms - Angularjs cannot read property firstname of undefined -

i have form such as html: <form ng-submit="log(user)"> <input type="text" ng-model="user.firstname"> <input type="text" ng-model="user.lastname </form> angular: .controller ('', function ($scope){ $scope.log = function (user){ console.log (user.firstname) } }) this working before throws cannot read property user.firstname please me. thank you angualarjs rich in 2 way data binding . didn't need pass scope object user in function log. available in controller updated value. initialise user scope object , try code in html: <form ng-submit="log()"> <input type="text" ng-model="user.firstname" /> <input type="text" ng-model="user.lastname" /> </form> in js .controller ('', function ($scope){ $scope.user = {}; // declare here $scope.log = function (){ co...

Regex Or and Greedy -

i trying perform regex not sure how write or condition because of greedy behavior of regex. some_text=(?<value>.*)&|some_text=(?<value>.*)$ the above regex want write better 1 following: some_text=(?<value>.*)(?:&|$) but because of greediness, 1 not stopping value when encounters first & instead goes end of string. thanks help you can use negation regex: some_text=(?<value>[^&]*) [^&]* match 0 or more of character not &

python - Zipping two list of lists -

need got lost in zipping 2 lists of lists (matrix). the matrices same format, them zipped in tuple pairs each element in same position. for example, m1 = [['a', 'b', 'c'], ['d', 'e'], ['f', 'g']] m2 = [['s1', 's2', 's3'], ['s4', 's5'], ['s1', 's3']] what expect is, same format: z = [[('a', 's1'), ('b', 's2'), ('c', 's3')], [('d', 's4'), ('e', 's5')], [('f', 's1'), ('g', 's3')]] i can write function looking elegant way of doing in python. zip() , zip() again: [zip(*paired) paired in zip(m1, m2)] the zip() function pairs each element of input sequences; m1[0] m2[0] , m1[1] m2[1] , etc., , each of pairs pair elements again ( m1[0][0] m2[0][0] , m1[0][1] m2[0][1] , etc.). if python 3, you'll h...

html - Text-Align: Center - Not Working -

i trying use text-align: center align name on dj website - http://www.jameswinfield.co.uk/v2.html# however isn't working. have kind of fix using left: 30% looks messy on thinner screens name goes 2 lines , obscures next text section. i have tried playing display: block , margin: 0 auto neither seem working. .james { color: #f235e9; font-size: 6.25em; position: fixed; left: 30%; top: 28%; text-transform: uppercase; font-family: oswald; letter-spacing: 6px; } .und { color: #f235e9; font-size: 3.125em; position: fixed; left: 35%; top: 42%; text-transform: uppercase; font-family: oswald; } <div class="cen"> <div class="james"> <p>james winfield</p> </div> <div class="und"> <p>underground house dj</p> </div> <ul id="ticker01"> <li><a href="https://www.mixcloud.com/j...

excel - Macro imports text file into multiple worksheets, I just want it all to import into one -

... , have "***" between each file here's have far: sub combinetextfiles() dim filestoopen dim x integer dim wkball workbook dim wkbtemp workbook dim sdelimiter string on error goto errhandler application.screenupdating = false sdelimiter = "|" filestoopen = application.getopenfilename _ (filefilter:="text files (*.txt), *.txt", _ multiselect:=true, title:="text files open") if typename(filestoopen) = "boolean" msgbox "no files selected" goto exithandler end if x = 1 set wkbtemp = workbooks.open(filename:=filestoopen(x)) wkbtemp.sheets(1).copy set wkball = activeworkbook wkbtemp.close (false) wkball.worksheets(x).columns("a:a").texttocolumns _ destination:=range("a1"), datatype:=xldelimited, _ textqualifier:=xldoublequote, _ consecutivedelimiter:=false, _ tab:=false, semicolon:=false, _ comma:=false, space:=false, _ other:=true, otherchar:="|" x = x + 1 whil...

javascript - Promise code are read twice -

i use following code read json file , return promise i've 2 questions return globasync("folder/*.json").catch(function (err) { throw new error("error read: " + err); }).map(function (file) { return fs.readfileasync(file, 'utf8') .then(function (res) { console.log("test"); return json.parse(res); }, function (err) { throw new error("error :" + err); }).then(function () { console.log("test2"); }); }); i use console log , see console printed twice test test test2 test2 why happening , how avoid ? in place i've put console.log("test2"); need invoke event json parse finished , still return outside json object (to caller), when add last then doesn't work(the returned object undefined),any idea how right? update try following doesn't work... return globasync("folder/*.json").catch...

tomcat7 - Memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file -

situation : installed memcached on centos 5 (64 bit). ended installing php plugins using pecl, though they're unnecessary now. problem :when execute /etc/init.d/memcached start i following error: starting memcached: memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: no such file or directory but file libevent-2.0.so.5 present in /opt/couchbase/lib/. should there in other folder ? how memcached start ? /opt/couchbase/lib not set on system library path default. that's why unable find libevent when running /etc/init.d/memcached. to solve can run command follows: ld_library_path=/opt/couchbase/lib /etc/init.d/memcached or solve on long term add following file (assuming using centos): /etc/ld.so.conf.d/couchbase.conf and in file add path "/opt/couchbase/lib". run ldconfig , re-run command start memcached.

d3.js - Modifiying dimple layout grouped chart -

i using same chart below. want push x-axis headers i.e. regular, premium, budget little bit below i.e. top padding or margin. give styling give background color , change text color. tried using fill , not work desired. hide price tier/channel also http://dimplejs.org/examples_viewer.html?id=bars_vertical_grouped these svg text elements there no top-padding or margin. can move them down bit increasing y property though, running following after call chart.draw method move labels down 5 pixels: d3.selectall(".dimple-axis-x .dimple-custom-axis-label") .attr("y", function (d) { // y property of current shape , add 5 pixels return parsefloat(d3.select(this).attr("y")) + 5; }); to change text colour need use fill property (again that's svg text thing): d3.selectall(".dimple-axis-x .dimple-custom-axis-label") .style("fill", "red"); to colour background of text little less trivial, the...

api - How do I expose the service written in Java for all platforms? -

i have "autocomplete" server written in java. http(s) server accepts protobuf . have written thick desktop client uses service populate textbox autosuggestions. intend make service generic, can used other platforms. how go ? if release proto definitions tie 3-4 languages only. if release client jar , restrict java. suggestion api/system designers appreciated. you can expose webservice . from wikipedia page: a web service method of communication between 2 electronic devices on network. software function provided @ network address on web service on in concept of utility computing. w3c defines web service software system designed support interoperable machine-to-machine interaction on network. there 2 types of webservices: 1- soap webservices. 2- rest webservices. all programming languages provide methods creating , consuming websevices. this stackoverflow thread provides explanation of webservices.

calculate load time of landing page url when an user clicks on href link in javascript -

i trying find out load time of landing page url of ad. when user clicks link/ad, goes landing page abc.com. want to know whether operation finished or time has taken load. possible in javascript? my first thought pre-calculate size of resources, , when render client application, instead of having direct urls, have map url , it's size. need connection speed, can calculate when page loads (for instance, take small image, calculate download time , transfer rate). maybe there's smarter gzip compression, since browsers support it.

Best way to deserialize Json array in php? -

this question has answer here: how extract data json php? 2 answers what's way deserialize json in php? actual thought not use external libraries through code. downloaded resource: $variable = file_get_contents("http://api.football-data.org/alpha/soccerseasons/"); $decoded = json_decode($variable); var_dump($decoded); now have in variable array decoded, advise me values of json? update - decoded content: array(11) { [0]=> object(stdclass)#1 (7) { ["_links"]=> object(stdclass)#2 (4) { ["self"]=> object(stdclass)#3 (1) { ["href"]=> string(52) "http://api.football-data.org/alpha/soccerseasons/394" } ["teams"]=> object(stdclass)#4 (1) { ["href"]=> string(58) "http://api.football-data.org/alpha/soccerseasons/394/teams" } ["fixtures"]=> object(stdclass...

html - Difference result for a heading within p and div tag -

i trying make paragraph email address. cannot make style it. .mail { margin: .7rem 0; padding: .3em .8em; border: 1px solid #ddd; transition: .2s; color: #aaa; } .mail a:hover { background-color: #ddd; } .mail a:hover { color: #333; } <p class="mail"><h3><a href="mailto:chenghuayang.com@gmail.com">chenghuayang.com@gmail.com</a></h3></p> <hr> <div class="mail"><h3><a href="mailto:chenghuayang.com@gmail.com">chenghuayang.com@gmail.com</a></h3></div> jsbin here. i've never realised there's more difference between p , div other semantic meaning or properties margin or line-height . okay, i'll use div instead of p tag. here questions in mind: what call difference, , why work this? are there other examples of behaviour? (i hope wouldn't miss else this.) ...

java do while loop keeps looping after condition is met -

i new java programmer , writing program sets 3 model numbers 3 printers. if user inputs wrong values want continue asking user model number. got work if first value user inters the number 1 of 3 printers. if first value not 1 of possible values , second input still keeps repeating loop. package printing; import java.util.scanner; public class newclass { public static void main(string[] args) { int count = 0; string machine1 = "546"; string machine2 = "892"; string machine3 = "127"; scanner s = new scanner(system.in); system.out.print("model number:"); string modelnumber = s.nextline(); // increment count if first input value wrong if (!s.equals(machine1) || !s.equals(machine2) || !s.equals(machine3)) count++; // if user inputs right value while (true) { if (modelnumber.equals(machine1)) { system.out.pr...

java - Action Intent not receiving extra stream -

i have app working great when using android.intent.action.send. user pdf via share adobe. when change manifest file android.intent.action.view receive "attempt invoke virtual method 'java.lang.object android.os.bundle.get(java.lang.string)' on null object reference" the reason need view because user needs open email , click preview on file attachment chooses app. there want able use itext edit pdf. if don't add android.intent.action.view program not on list. public void existingpdf(view view) { intent intent = getintent(); string action = intent.getaction(); string type = intent.gettype(); //intent.setaction(android.content.intent.action_view); try { //intent intent = intent(); // uri pdfuri = (uri) getintent().getextras().get(intent.extra_stream); pdfreader pdfreader = new pdfreader(pdfuri.getpath()); //pdfreader pdfreader = new pdfreader(android.o...

c++ - pass by reference : no known conversion for argument 6 from 'int' to 'int&' -

i have function pass argument reference since expect function edit it. function called @ several places , care ref value when called @ particular instance . pseudocode: test_fn(int a, int b, inc , int d, int e, int& ref) { //bunch of other functionalities //. //. ref = (a*b+c)*(d+e); } test_fn(1,2,3,4,5,0)//everywhere not care ref int value = 0; test_fn(1,2,3,4,5, value)//i care value here , use in remainder of code . why can not pass 0 directly ? tried passing null , has long int int conversion error. why wrong ? , best way achieve expected outcome here? in order pass variable reference has exist, passing 0 or null means you're sending in constant. cannot edit value of constant, actualy not variable. as solving problem, probaby should use pointers achieve that, check if pointer set 0, null or if use c++11, nullptr

c# - switch/case on viewmodel in controller, refactoring advice highly appreciated -

i use advice on refactoring. in application users able dynamically add new form fields; customfield. each type (text, dropdown, checkbox, etc.) viewmodel (textboxviewmodel, dropdownviewmodel, checkboxviewmodel, etc.) defined. when post form, appropriate edit action executed , read each customfield store values. currently implementation works ugly; switch/case/if/else through viewmodel types , based on type execute required logic. this the current implementation: private static void maptomodel(ticket ticket, ticketviewmodel model) { ticket.id = model.id; ticket.name = model.name; ticket.attributes.clear(); foreach (var cvm in model.controls) { var attribute = new ticketattribute { id = cvm.id, name = cvm.name, }; if (cvm textboxviewmodel) { attribute.value = ((textboxv...

sql - Select all dates between two dates and display the unique count of inventory id -

im using oracle db .i have 2 table inventory , grounding_info . each inventory can have multiple grounding info or none. table structure follows. inventory --------- inventory_id grounding_info -------------- info_id inventory_id grounding_date i want count of inventories grounded on each date between given date range. if no inventory grounded on date , date should displayed count 0. please help.. tried below query: select tble.dte,count(distinct(groundinginfo.inventory_id)) cmt atl_grounding_info groundinginfo outer join ( select to_date('2015/01/01 12:00:00 a.m.' ,'yyyy/mm/dd hh:mi:ss a.m.') - 1 + rownum dte all_objects groundinginfo to_date('2015/01/01 12:00:00 a.m.' ,'yyyy/mm/dd hh:mi:ss a.m.') - 1 + rownum <= to_date('2015/04/01 11:59:59 p.m.' ,'yyyy/mm/dd hh:mi:ss p.m.') ) tble on groundinginfo.date_turned_in = tble.dte group tble.dte but returned error: "ora-00933: sql command not en...

php - how to show title as url instead of id in laravel 5.1? -

in controller public function show($id) { } in route route::get('post/{id}','postcontroller@show'); how show title url instead of id ? , possible change url title otherwise need specify unique title in database table ? in controller public function show($title) // understanding { } in route route::get('post/{title}','postcontroller@show'); in view use title instead of id .

regex - mySQL replace string + additional string with a static value -

unlike php, don't believe mysql has preg_replace() feature, matching via regexp. here strings have in code: http://ourcompany.com/theapplestore/... http://ourcompany.com/anotherstore/... http://ourcompany.com/yetanotherstore/... as can see, there constant in there, http://ourcompany.com/ , there variable string namely theapplestore , anotherstore , etc. etc. i want replace constant string, plus variable string(s), , trailing slash (/) after variable string(s), single shortcode value , namely {{store url=''}} edit if helps, store codes same length, going sch131785 sch185399 sch634019 etc. i.e., 9 characters long how this? thanks. i thought might useful: there no way in mysql. find using regexp, yes; replace, no. said, there post extension library mentioned, sagi : is there mysql equivalent of php's preg_replace?

android - How to reduce the size of a C++ static library -

i'm developing cross-platform static c++ library , wondering if there build flags reducing size of final mylib.lib , libmylib.a files on each platform (ios, android, windows)? i understand every single dependency gets pulled build process , file size coming from. why static library huge? but shouldn't there way have linker/librarian remove code mylib based on dependency calls made rather theoretically possible? the linker when building final .executable, seems same rules apply @ library linking level. overall big problem me because cross-platform library around 500mb windows , around 200mb on ios. oddly, android reasonable 3.5mb.

Euler#12, what's wrong with my Python program? -

the 12th problem : the sequence of triangle numbers generated adding natural numbers. 7th triangle number 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. first ten terms be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... let list factors of first 7 triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3,5,15 21: 1,3,7,21 28: 1,2,4,7,14,28 can see 28 first triangle number have on 5 divisors. what value of first triangle number have on 5 hundred divisors? my program in python 3.4 def nfactor(n): k=2 c=0 while k<=n: if n%k==0: n=n//k c+=1 else: k=k+1 return c a=1 in range(10**6): a+=i if nfactor(a)>=500: print(a) break i waited more 10 minutes , never have answer. , own program not bad , must run in seconds.. makes me crazy lol didn't find mistake. can me please? thank in advance ! edit my solution : import math def nfactor(n): ...

ios - How to get type of class of delegate in swift -

how can know type of class of delegate? self.delegate.iskindofclass() , self.delegate.ismemberofclass() not working. when print println(self.delegate) prints caller controller class. cant check it. if want check if delegate kind of class use following if self.delegate exampleclass { }

Basic Authentication Middleware with OWIN and ASP.NET WEB API -

i created asp.net web api 2.2 project. used windows identity foundation based template individual accounts available in visual studio see here . the web client (written in angularjs) uses oauth implementation web browser cookies store token , refresh token. benefit helpful usermanager , rolemanager classes managing users , roles. works fine oauth , web browser client. however, retro-compatibility concerns desktop based clients need support basic authentication. ideally, [authorize] , [authorize(role = "administrators")] etc. attributes work both oauth , basic authentication scheme. thus, following code leastprivilege created owin basicauthenticationmiddleware inherits authenticationmiddleware . came following implementation. basicauthenticationmiddleware handler has changed compared leastprivilege's code. use claimsidentity rather series of claim . class basicauthenticationhandler: authenticationhandler<basicauthenticationoptions> { private...

jquery - How to stop resize when meet the width size of an element -

i wanted #map element resize whenever window resize. however, if browser window resize , meet 930 pixel width, #map element should stop resizing if browser extend full screen width. here's actual code. $(window).on('resize',function(){ var _framey = $(window).height(), _framex = $(window).width(), _map = $('#map'); if (_framex <= _map.width()) { _map.css({ 'width': _framex, 'height': _framey }); } else if (_framex >= 930) { _map.css({ 'width': _framex, 'height': _framey }); } }).resize(); i wanted maintain resizing function below 930 pixel of #map, when browser screen-width resize , on 931 pixel, #map element should stop resizing , stay @ 930 pixel width. this part wrong because ".width()" return current width of element , not value in css element. have set in code 930px value in condition. if (_framex <= _map.width()) { _map.css({ 'width': _framex,...

jquery - Cookie not being attached in Ajax request under the same domain? -

i have asp.net web form page. android , phone application loading url in web-view , attaching cookie it. making ajax request part of page same domain. in ios case cookie being attached in ajax request, while in android case cookie not. here js code sending request. function sendrequest(url, data, callback) { $.ajax({ type: "post", data: data, url: url, xhrfields: { withcredentials: true } }) .done(function (response) { // }); }; is there need add attach cookie explicitly in android case or should attached itself. any appreciated ?

How to get output of 'git describe' into Jenkins build name -

what's best (or any!) way put output of command in jenkins build name? i'd put output of git describe command build name of jenkins job. i've installed build-name-setter plugin hopes of setting build name like: ${env, var="git_describe"} i don't know how set $git_describe before name set! i've tried using envinject plugin. way dynamically set environment variables use groovy script. work well, except job running on remote slave , groovy script (apparently) running on master. if need "describe" data (i.e. can't use existing $git_branch or $git_commit environment variables), add "execute shell step" with: echo git_describe=$(git describe) > git.properties then after that, add envinject build step injects properties git.properties file.

generics - jsf el expression to build methodname -

is possibile build methodname variable value? <c:foreach value="#{db.pojo.classlist}" var="v"> <c:foreach items="#{db.pojo.methodnameslist}" var="o"> <c:set var="superman" value="#{o}" /> #{v.[superman]} </c:foreach> </c:foreach > ... database.entity.list list of generic classes. list<?> list.. i can use generic class if know methodname. <c:foreach value="#{db.pojo.classlist}" var="v"> #{v.value} </c:foreach > #{v.[superman]} punch period. #{v[superman]} that <c:set> unnecessary, way. #{v[o]} i use more self-documenting variable names though. e.g. #{bean[property]} #{entity[field]} see also: our el wiki page

ruby on rails - Displaying profile in view confusion -

so working on personal project learn rails nesting , decided use devise. created profile model , controller handle displaying other information user input @ later time. , utilized after_create :create_profile handle heavy lifting. have setup in model , controllers information passed correctly, when comes displaying user's profile confusion arises. this profile controller class profilecontroller < applicationcontroller before_action :find_profile before_action :find_user before_action :authenticate_user! def new @profile = profile.new end def create @profile = current_user.create_profile(profile_params) end def show @profile = @user.profile end def update @profile.update_attributes(profile_params) if @profile.save redirect_to profile_path(current_user) end end private def find_user @user = user.find(params[:id]) end def find_profile @profile = profile.find(params[:id]) end def p...

c# - spliting a list and using for a paging effect -

i have below list made database bring x number results. split result list of 15 have list<list<subjectmodel>> split list model. know can this, there may not complete spilt 15 final have less. on mvc if create paging effect how can done calling diffent index of data loaded or have go server each time. i presume have have parial page within page. list<subjectmodel> model = new list<subjectmodel>(); generally can use .skip() , .take() linq methods in following way: .skip(pagesize * pagenumber - 1).take(pagesize) i recommend not fetch all, split, instead real paging using methods above. when using methods against real o/r mapper entity framework, translate rdbms's sql. you can use action method parameters in controller know page requested. pagesize constant or configuration value. you can start learn whole concept googling: [implement paging in asp.net mvc]

ios - specific view orientation for specific views using Swift -

i've searched , haven't found date swift alternative question. have in total 8 views in application, want first 3 locked in portrait. rest can rotate willingly. how can achieve in swift? the easiest way each governed different view controller, , these presented view controllers. presented view controller in charge of app's possible orientations (by implementing supportedinterfaceorientations ).

javascript - Safari Extension Settings to Injected Script -

i'm trying pass variable settings in safari extension injected javascript. i've managed message passed have no idea how use variable out of handlemessage scope can use in injected file. variable printername in handlemessage function appears not accessible outside of function? global.html safari.application.addeventlistener('message', handlemessage, false); function handlemessage(msg) { if(msg.name === 'printername') { alert(msg.message); } var printername = safari.extension.settings.printername; safari.application.activebrowserwindow.activetab.page.dispatchmessage('printername', printername); } injected.js var printername; function handlemessage(msg) { if(msg.name === 'printername') { printername = msg.message; } } if (window.top === window) { safari.self.addeventlistener('message', handlemessage, false); safari.self.tab.dispatchmessage('printername', printername); ...

java - Postgres Serial not-null constraint -

i have following database tables: create table company ( id serial not null, name character varying(50), activestatus boolean, address bigint, remarks character varying(1024), revision integer ) create table company_version ( id serial not null, company_id integer, name character varying(50), revision serial not null, revision_previous integer, revision_timestamp timestamp without time zone, revision_comment character varying(100), revision_userid character varying(50) ) on company table have trigger executes after insert. insert company_version (company_id,name,revision_previous,revision_timestamp,revision_comment,revision_userid) values (new.id, new.name, (select max(revision) company_version),current_timestamp,'inserted in application','the application') returning revision revision_param; update company set revision = revision_param id = new.id; when i...