Posts

Showing posts from January, 2011

java - Cannot Upload a file using Jax-RS -

i want use jersey framework. i´m running web service, using ant app, on java ee7. application server glassfish my method this: package mypackage.service; ... import org.glassfish.jersey.media.multipart.formdatacontentdisposition; import org.glassfish.jersey.media.multipart.formdataparam; @post @path("createsomething") @consumes(multipart_form_data) @produces(application_xml) public response createsomething(@formdataparam("upload") inputstream is, @formdataparam("upload") formdatacontentdisposition formdata, @queryparam("some") string some, @context httpservletrequest request) { string filelocation = "c:\\uploadfile\\" + formdata.getfilename(); //more things, not matter try { ctrl.savefile(is, filelocation); string result = "successfully file uploaded on path " + filelocation;

javascript - How to start using yoda speak web service -

i web programming beginner programming knowledge level cannot handle problem , googled lot still no result. using yoda speak api http://www.yodaspeak.co.uk/webservice/yodatalk.php?wsdl it xml file. xml file documentation file? how can set text box , button call program? wrote codes not work. html: <p><h1>here converter changing sentences yoda's style</h1></p> <input type="text" id="input"> <button class="button" onclick="convert()">convert</button> javascript: function convert(){ var input = document.getelementbyid('input').value; } and sorry not know how continue. sorry. have checked ws.js. more info @ http://www.ibm.com/developerworks/webservices/library/ws-wsajax/ you may better off using rest style api's such this, http://funtranslations.com/api/yoda since integrating javascript easy. here functional example using funtranslations yoda api. $

linux - check file existence cron job -

i trying write cronjob action if replicationtest.txt not exist , replicationtestseen.txt exist in specific directory. right doing not working. here doing: 0 3 * * 0 [ [ ! -e /dv1/replicationtest/replicationtest.txt ] && [ -e /dv1/replicationtest/replicationtestseen.txt ] ] && echo 'replication passed' | mail -s 'replication test passed' myemail@email.com || echo ' replication failed' | mail -s 'replication failed' myemail@email.com even when conditions right cron email replication passed still emails replication failed. you’re mixing test s. pattern of [ [ ... ] && [ ... ] ] should not work. see this answer details. if change tests should work: [[ ! -e ... ]] && [[ -e /dv1/... ]] test conditions outside of cron before putting them crontab. , make sure of which shell cron set use .

spring - Getting LazyInitializationException within in a @Transactional method -

i’m getting exception when access method controller: {"status":"failure","exception":"lazyinitializationexception","exceptionmessage":"failed lazily initialize collection of role: org.mainco.subco.lessonplan.domain.lessonplan.classrooms, not initialize proxy - no session","errormessage":"failed lazily initialize collection of role: org.mainco.subco.lessonplan.domain.lessonplan.classrooms, not initialize proxy - no session"} controller: @autowired private thirdpartyservice m_thirdpartysvc; … @requestmapping(value = "/launch", method = requestmethod.get) @transactional public string launchlti(final @requestparam string assignmentid, final model model, final httpservletrequest request, final httpservletresponse response, final principal principal) throws invalidkeyexception, uns

ios - Array index out of range error on conditional declaration Swift -

func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat { if let getimurl = newslists[indexpath.section][indexpath.row].imageurl string?{ if getimurl != "none"{ return 230.0 }; return 70.0 }else{ return 70.0 } } the error appears when have bad connection, possibly causing newslists array populate slowly, anyway, index out of bounds error refers line if let getimurl = newslists[indexpath.section][indexpath.row].imageurl string?{ my question is, if there issue line shouldn't program run code in between else brackets? is not purpose of conditional declaration? if not, how prevent error? the purpose of if let declaration unwrap string? optional. error when accessing array assume newslists[indexpath.section][indexpath.row] exists instead of checking it. try if newslists.count > indexpath.section { if newslists[indexpath.section].count > ind

php - When to use single quotes, double quotes, and backticks in MySQL -

i trying learn best way write queries. understand importance of being consistent. until now, have randomly used single quotes, double quotes, , backticks without real thought. example: $query = 'insert table (id, col1, col2) values (null, val1, val2)'; also, in above example, consider "table," "col[n]," , "val[n]" may variables. what standard this? do? i've been reading answers similar questions on here 20 minutes, seems there no definitive answer question. backticks used table , column identifiers, necessary when identifier mysql reserved keyword , or when identifier contains whitespace characters or characters beyond limited set (see below) recommended avoid using reserved keywords column or table identifiers when possible, avoiding quoting issue. single quotes should used string values in values() list. double quotes supported mysql string values well, single quotes more accepted other rdbms, habit use single quot

Scala: parse MIME/multipart raw emails over HTTP one at a time -

i'm trying parse raw email messages on http 1 @ time come in mime/multipart. here chunk of 1 of mails, mail code threw exception on java.nio.charset.malformedinputexception: input length = 1 and here (i think) relevant chunk of mail: content-type: multipart/alternative; boundary="------------000401070001090809020709" --------------000401070001090809020709 content-type: text/plain; charset=windows-1252; format=flowed content-transfer-encoding: 8bit is there scala library out there handling type of input? otherwise there easy way write code handles it? i've been looking @ mime4j , scala code in particular. as of now, code uses scala.io.source.fromurl scrape raw mail follows: scrape(scala.io.source.fromurl(url)) which turns bufferedsource string , splits it: source.mkstring.split("\n\n", 2) i've tried using implicit codec since scala.io.source.fromurl can take codec: implicit val codec = codec("utf-8") codec.onm

android - Google Maps Api V2 draw circle around current position -

im working google maps api v2 on android project, need able draw circle around users current position , display markers points of interest within radious around users current position. im struggling small marker denotes users current position can draw circle around it. this code far. //set map , display users current position. mapfragment mapfragment = (mapfragment) getfragmentmanager() .findfragmentbyid(r.id.nearbymapsearch); mapfragment.getmapasync(this); final googlemap map = (((mapfragment) getfragmentmanager().findfragmentbyid(r.id.nearbymapsearch)).getmap()); map.setmylocationenabled(true); //zoom users location geolocationhandler geohandler = new geolocationhandler(getactivity().getapplicationcontext()); log.i("search fragment", "" + geohandler.getcurrentlatitude() + " , " + geohandler.getcurrentlongitude()); latlng loc = new latlng(geohandler.getcurrentlatitude(), geohandler.getcurrentlongitud

mongodb - Load Balancing Mongo DB on GCE instance -

the default click deploy mongodb gce sets 1 primary node, 1 secondary node , 1 arbiter node. can't figure out how mongodb manages distribute reads between primary , secondary nodes. have explicit external ip each node available don't want point apps 1 node or other ... how figure out load-balancer ip (if there such thing) can give app mongodb connection url? in order connect replica set of mongodb, need specify hosts in standard uri connection scheme. example, describe connection replica set named test , following mongod hosts: db1.example.net on port 27017 db2.example.net on port 2500 you use connection string resembles following: mongodb://db1.example.net,db2.example.net:2500/?replicaset=test for more information mongodb's connection string uri format, take @ artcile .

c# - Generic argument in dynamic proxy interceptor -

to add , retrieve objects memory cache have cache util class these methods: public static t getnativeitem<t>(string itemkey) public static void addnativeitem(string key, object item, timespan timeout) to remove noise data access class use castle dynamic proxy , in particular case use ninject.extensions.interception . the problem getnativeitem<t>(string itemkey) of cache util, in interceptor how can retrieve t invocation ? the ninjectwebcommon binding: kernel.bind<imatchdataaccess>().to<matchdataaccess>().intercept().with<cacheinterceptor>(); the imatchdataaccess interface have signature: public interface imatchdataaccess { [cached(minutes: 10)] ienumerable<domainmodel.match> getmatches(matchfilterdto matchfilter); } and cacheinterceptor have implementation: public class cacheinterceptor : iinterceptor { public void intercept(iinvocation invocation) { var cachedattr = invocation.request.method.getattribu

WSO2 Identity Server - Federated SAML using WSO2 as Proxy Server? -

could please clarify if there chance interconnect wso2 identity server existing corporate idp using saml federated connection mechanism. needs configured unify realm , proxy authentication external idp? thanks in advance support. if use wso2 proxy or federation bus, need register idp , service provider in wso2 , in idp should register wso2 service provider. if use wso2 service provider, need register existing idp in wso2 idp , wso2 service provider in idp side. you can follow this document more information. thanks!

Method object in javascript -

i have written following code , not showing alert. var test = function(message) { this.show = function() { alert(message) } } (new test("hiii")).show(); (new test("helooo")).show(); when changed following... removed bracket of - (new test("hiii")).show(); it shows both "hiii" , "helooo" alert. note: did not make changes - (new test("helooo")).show(); var test = function(message) { this.show = function() { alert(message) } } new test("hiii").show(); // was(new test("hiii")).show(); (new test("helooo")).show(); can explain why? the problem, oddly enough, fact left out semicolon after function expression: var test = function(message){ this.show = function() { alert(message) } } // <-- missing semicolon that means ( ... ) following function expression taken argument list function call. add missing semicolon , first

html - jquery select trigger action if option is changed from specific value to another specific value -

in code. have 'no path' option value trigger when selected. have hierachy of no path, mono, stereo, surround. surround being highest option , no path being lowest. what i'm trying have div class triggered if option higher eg. surround. so if option on "surround" , change "stereo" trigger event. the same applies if went "surround" "mono" trigger event because going higher lower. however...if go "mono" "stereo" (or "mono" "surround) not trigger event because going higher option. i have tried manually code got confusing , long , didnt work. it if - changing option less important (or lower than) option selected - trigger event else - don't trigger event. i've trawled through lots of sites , tried piece halfway before stuck. any thoughts on how better? here code: script var hello = ('select option:selected'); alert(hello); $('select').on('change

java - How to upload files to server using JSP/Servlet? -

how can upload files server using jsp/servlet? tried this: <form action="upload" method="post"> <input type="text" name="description" /> <input type="file" name="file" /> <input type="submit" /> </form> however, file name, not file content. when add enctype="multipart/form-data" <form> , request.getparameter() returns null . during research stumbled upon apache common fileupload . tried this: fileitemfactory factory = new diskfileitemfactory(); servletfileupload upload = new servletfileupload(factory); list items = upload.parserequest(request); // line died. unfortunately, servlet threw exception without clear message , cause. here stacktrace: severe: servlet.service() servlet uploadservlet threw exception javax.servlet.servletexception: servlet execution threw exception @ org.apache.catalina.core.applicationfilterchain.internaldofilter(

angularjs - Angular dependency injection - I keep seeing two different ways of doing it -

sometimes see dependency injection in angular done like: angular.module('controllers') .controller('bookslistctrl', ['$scope', 'books', function($scope, books){ books.get(function(data){ $scope.books = data; }); }]); and looks following without array, , passing dependencies directly function: angular.module('controllers') .controller('bookslistctrl', function($scope, books){ books.get(function(data){ $scope.books = data; }); }); is 1 right way? depend on whether doing dependency injection on controller vs directive vs etc? sometimes see dependency injection in angular done like: angular.module('controllers') .controller('bookslistctrl', ['$scope', 'books', function($scope, books){ books.get(function(data){ $scope.books = data; }); }]); and looks following without array, , passing dependencies directly function: angular

Android storing data online -

i have ~5k active users own small app. thought app needs user favourites etc. saving data on online. , maybe add user login screen facebook or google+ when saving data. that's why use parse, amazon? 1 easy use? http://docs.amazonwebservices.com/amazonsimpledb/latest/developerguide/welcome.html https://parse.com/ i have own 5gb bandwidth web server can do? i'm new in php language , maybe security problems? or should use json? what suggest how do? the best known app use own api. best solution build little api in server.

javascript - How to hide times header of a timelineMonth view on Kendo UI Scheduler widget? -

i'm trying hide times header kendo ui scheduler widget until now, didn't achieved results need in choosen type of view. don't need times because events day events. therefore, there way of not showing times such 12:00 am, 13:00 am, etc... i followed documentation , if put in script, scheduler doesn't show anymore. here're scripts: databinding: function(e) { var view = this.view(); view.times.hide(); view.timesheader.hide(); }, and/or databound: function(e) { var tables = $(".k-scheduler-times .k-scheduler-table"); //required: remove last table in databound when grouped tables = tables.last(); var rows = tables.find("tr"); rows.each(function() { $(this).children("th:last").hide(); }); }, then, other alternative, added line of script views section: minortickcount: 0 all rows 12:00 d

javascript - how to skip value in ng-repeat if it is already in another list? -

i have, example, person data tags following: $scope.person.groups = ['ios'] and tags list: $scope.tagslist = ['android', 'ios', 'pm'] how display ['android', 'pm'] ng-repeat ? i tried: <li ng-repeat="tag in tagslist" ng-show="tag != person.groups">{{tag}}</li> but didn't work. how display records not in second array? you should use filter. here's how can it: html: <li ng-repeat="tag in tagslist | arrfilter: person.groups">{{tag}}</li> filter: app.filter('arrfilter', function() { return function(collection, person) { var output = []; angular.foreach(collection, function(item) { if(person.indexof(item) == -1) { output.push(item); } }) return output; } })

sql - Updating column based on another column's value -

how update table structured this: id[pkey] | parent_id | position 1 1 2 1 3 1 4 1 5 1 6 2 7 2 8 2 9 2 10 3 11 3 12 3 ...and on to achieve result: id[pkey] | parent_id | position 1 1 1 2 1 2 3 1 3 4 1 4 5 1 5 6 2 1 7 2 2 8 2 3 9 2 4 10 3 1 11 3 2 12 3 3 ...and on i thinking somehow mixing select distinct parent_id cats t; with create sequence dpos; update cats t1 set position = nextval('dpos') t.parent_id = t1.parent_id; drop sequence dpos; although im not experienced postgres, , not sure how use kind of foreach. appreciate help y

structure - MySQL documents linking -

i have 4 tables: orderforms deliverynota invoices creditnota what make possible link of document other document. example creditnote id 10 linked invoice id 155. orderform 17 linked deliverynote 10. i see 3 possible solutions: create table every link ex.: orderform_link_diliverynote, orderform_link_invoice, orderform_link_creditnote, deliverynote_link_invoice, ... table "document_linking" 5 columns: link_id, orderform_id, deliverynote_id, invoice_id, creditnote_id. table "document_linking" once again 5 cols, in following way: link_id, documentype_one (eg.: invoice, creditnote, ...), document_id_one, document_type_two (eg.: invoice, creditnote, ...), document_id_two i personaly prefer last one, in opinion dynamic solution. if ever add 1 or more doctypes, able without changing document_linking table. other advantage, in opinion, can link documents of thesame type. as don't have experience on kind of linking, ask advice. every kind of welcom

swift - How to create a global variable? -

i have global variable needs shared among viewcontrollers. in objective-c, can define static variable, can't find way define global variable in swift. do know of way it? from swift programming guide global variables variables defined outside of function, method, closure, or type context.global constants , variables computed lazily you can define file , can access in current module anywhere. can define in somewhere in file outside of scope.there no need static , global variables compute lazily. var yourvariable = "somestring" and can access anywhere in current module. however should avoid global variables not application state , reason of bugs. as shown in answer in swift can encapsulate them in struct , can access anywhere. can define static variables or constant in swift also.encapsulate in struct struct myvariables { static var yourvariable = "somestring" } you can use variable in class or anywhere let string

javascript - BLOB object is not visible -

actually, trying image using $http , storing data in blob object can use after on html <body ng-app="myapp"> <div ng-controller="homectrl"> <button ng-click="download()">download</button> <img id="photo"/> </div> controller: angular.module('myapp', []); angular.module('myapp').controller('homectrl', ['$scope', '$http', function($scope, $http) { $scope.download=function() { $http.get('https://placeholdit.imgix.net/~text?txtsize=15&txt=image1&w=120&h=120').success(function(data){ var arraybufferview = new uint8array( data ); var blob = new blob( [ arraybufferview ], { type: "image/png" } ); var urlcreator = window.url || window.webkiturl; var imageurl = urlcreator.createobjecturl( blob ); var img = document.queryselector( "#photo" ); img.src = imageurl; }).error(function(er

PhpMyAdmin direct console (like SQLyog) -

we have use phpmyadmin database access i've used software sqlyog or database console within phpstorm. i'm finding phpmyadmin clumsy , slows down workflow. there way phpmyadmin mimic sqlyog or phpstorm? there api console-like access? i don't know sqlyog or phpstorm @ all, if you're looking console-like access there's small "console" button in bottom corner of phpmyadmin screen brings sort of console may you. sql tab gives interface directly enter sql queries; though it's not in console-like way.

optimization - CPU limit background processes on Linux -

i found: http://www.refining-linux.org/archives/64/programmatically-limit-cpu-usage-of-certain-processes/ limiting processes cpu % - linux but wonder how detect xwindow applications in background , cpulimit them? hint? that useful limiting cpu usage web browsers in background. my quick , dirty solution: https://gist.github.com/dmgr/08f9dc89095eab4c74b5 as described here: https://stackoverflow.com/a/2042371/2838914 you can't directly pid window id, have go other way around, mapping windows id , pid together.

ios - Using of symbolic breakpoints for child classes in Xcode? -

i have class someclass inherited uiview , want track method setframe: called. in case of uiview add symbolic breakpoint value -[uiview setframe:] can't same own class - never called/stopped on breakpoint. , of course can't use -[uiview setframe:] because called times. how solve issue? i override setframe: in own class in case don't need symbolic breakpoint , it's better use usual breakpoint instead. in case need add changes in own class , not appropriate me. if understand correctly, want put breakpoint on -[uiview setframe:] have stop when "self" object of class someclass. can breakpoint condition. like: (int) strcmp("someclass", (const char *)class_getname((id)[(id) $arg1 class])) == 0 the trick here $arg1 alias register holds first argument, , in objc methods first argument self . note, $arg1 register alias defined architectures use registers argument passing; in particular 32-bit x86 not pass arguments way. followi

jsf - Refreshing PrimeFaces form element dataTable (code details provided) -

i have search form. after clicking on search button data refreshes, datatable columns not (columns refreshed on second button click). apparently doing wrong. dynamic column code inspired primefaces showcase myform.xhtml: <h:form id="my_form"> #{mybean.initbean()} ... <h:panelgrid id="main"> <h:panelgrid id="buttons"> <p:commandbutton id="submitsearch" value="#{msg['button.execute']}" actionlistener="#{mybean.submitsearch}" update="resultpanel"/> </h:panelgrid> </h:panelgrid> <h:panelgrid id="resultpanel" border="0"> <p:datatable id="resulttable" var="result" value="#{mybean.searchresults}"> <p:columns value="#{mybean.columns}" var="co

amazon web services - Copy all files from S3 to ESB drive -

is there way how copy files s3 ebs drive belonging ec2 instance (which may belong a different aws account s3)? we performing migration of whole account , upgrading instances t1 t2 type , backup data s3 somewhere outside s3 (and glacier since glacier closely linked s3) in case goes wrong , lose data. i found articles , docs talking ebs snapshots not sure if s3 data can copied ebs (in other way manually). according this docs, can ssh instance , copy data s3 buckets local ebs drive, have specify name of bucket. there way how copy buckets there? aws s3 sync s3://mybucket i achieve this: pseudocode: for each bucket aws s3 sync s3://bucketname bucketname endfor is there way how using aws cli? i agree rdp-cloud's answer, if insist on creating ebs backups, answer question - there no single aws cli command sync available buckets in 1 go. can use bash script list of available buckets , sync looping through them: #!/bin/bash buckets=($(aws s3 ls | awk '

android - Multiple dex files define: when I am adding admob. this is due to ActionbarSherlock Lib -

when adding admob gradle file,i getting " com.android.dex.dexexception: multiple dex files define landroid/support/annotation/animres;" . happening because of actionbarsherlock lib. after searching on google, people suggested remove support v4 jar file.but solution not working. please me out solution. edit my gradle file: buildscript { repositories { mavencentral() // or jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.3' } } apply plugin: 'com.android.application' dependencies { compile files('libs/bolts-android-1.1.4.jar') compile files('libs/bolts-android-1.1.4-javadoc.jar') compile files('libs/picasso-2.3.4.jar') compile files('libs/parse-1.8.3.jar') compile project(':customtablib') compile project(':simple-crop-image-lib') compile project(':slidedatetimepicker') compile files('libs/gcm.jar')

MySQL ROLLUP: Wrong total for one column calculated by a formula -

in query below, 1 of rollup sums has formula referring other columns. seems in case mysql uses formula in rollup line instead of totaling column values. the value nertek seems calculated using fields in total line, i.e. (462.053-479.710+0)*2700 , result -47673.9 instead of summing column values 61632-75232-12214-21744-3945+4079-43697+13500 = -77621 . what doing wrong? mysql> select k.nvalasztekkey nvalasztekkey, k.nerdokey nerdokey, concat(v.sfafaj, ' ', v.svnev) svalasztek, concat_ws(' ', e.sfalu, e.serdoresz, r.sname) serdoraktar, k.nhossz nhossz, elk.nm3ar, sum(fkiterm) fkiterm,sum(felad) felad, sum(fvasar) fvasar, sum(fkiterm)+sum(fvasar)-sum(felad) fkeszlet,(sum (fkiterm)+sum(fvasar)-sum(felad))*elk.nm3ar nertek keszlet k left join elokalk elk on (k.nvalasztekkey=elk.nvalasztekkey , k.nerdokey=elk.nkey) left join valasztekok v on (k.nvalasztekkey=v.nkey) left join erdok e on (k.nerdokey=e.nkey) left join raktarak r on (k.nerdokey-1000000=r.nkey) ne

SWIFT: Subscript int in String (Cnndition works, assignment not) -

i want assign first char of string. of course there advance function, me (i come c++) easier read when using [index]. defined extension string type: extension string { subscript (i: int) -> character { return self[advance(self.startindex, i)] } subscript (i: int) -> string { return string(self[i] character) } ... this works fine condition like: if (s[0] == "u") but when assigning value like var c = s[0] i error compiler can't subscript string type of int. difference? i think compiler cannot infer return type of subscript , since these 2 subscript have same input signature. so have specify subscript want use. this, var c:character = s[0] or var c:string = s[0]

Javascript recursion for sudoku? -

i working on sudoku puzzle, put items in array. so, whenever invalid number, have call function recursively, cant that. can't understand problem id. my methods are: function checkvalidity(x,y) { var number = math.floor((math.random()) * 10); var validnumber = true; (i = 0; < 9; i++) { if (sudokuvaluearray[i][y] == number) { validnumber = false; } } (i = 0; < 9; i++) { if (sudokuvaluearray[x][i] == number) { validnumber = false; } } if(validnumber==true) { return number; } else if(validnumber == false) { return checkvalidity(x, y); } } and second function is: function createsudokesample() { (var x = 0; x < 9; x++) { (var y = 0; y < 9; y++) { sudokuvaluearray[x][y] = checkvalidity(x, y); } } } by default had initilized sudokuvaluearray 0; now how recursion? you re

php - Yii Pagination not remember the dropdown list value -

i have problem pagination in yii ,when click on next page button doesn't remember value , must choose dropdown list again showing detail ;what should do/ thank answer store selected value session, use session condition checking

git - When is it safe to delete local branch? -

the situation this: i created remote branch other remote develop branch -> fetched local -> made changes -> git add -> git commit -> pushed remote , made pull request. pull request still there , branch hasn't been merged yet. is safe delete local branch hasn't been merged yet? i don't want have bunch of local branches don't need anymore. it's technically safe delete local branch once you've pushed remote branch , retrieve changes remote branch, if pull request not merged yet. however, i'd wait until pull request merged. whole idea behind having pull requests, opposed allowing merge want, allow feedback loop between developer , maintainer of project. depends on project's etiquette , level of trust maintainer has towards you, may take several roundtrips of improvements before pull requests merged. i'd avoid hassle of having recreate local branch each time , leave there , work on until request merged.

javascript - Counting number of span stored inside variable in jquery -

basically trying count number of spans stored inside items variable length returning 0 var items = '<br><span class="holiday">buddha jayanti</span><br><span class="workingday">shiva ratri</span>'; var length = $(items).find('span').length; alert(length); //returning 0 is there somthing missing here? because span @ root of element set, .find() not return elements, need use .filter() instead var items = '<br><span class="holiday">buddha jayanti</span><br><span class="workingday">shiva ratri</span>'; var length = $(items).filter('span').length; snippet.log(length); <!-- provides `snippet` object, see http://meta.stackexchange.com/a/242144/134069 --> <script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script> <script src="https://ajax.googleapis.com

javascript - dynamically added elements won't take proper css (js only) -

i have <ul> element gets it's <li> 's dynamically added, im trying first <li> bit wider rest width of 63% while others 60%, reason first 1 gets 60%, idea why? i can not use css file, has javascript only. here code: $('.list').css({ liststyle: 'none', padding: '0', height: '100%', overflowx: 'scroll', }); $('.item-wrapper').css({ background:'#ffffff', width: '60%', margin: '5px', }); $('.item-wrapper').first().css({ width:'63% !important', }); edit: i've failed add resulting markup, here is: <ul class="list" style="list-style: none; padding: 0px; height: 100%; overflow-x: scroll;"> <li class="item"> <div class="item-wrapper" style="width: 60%; margin: 5px; background: rgb(255, 255, 255);"> <img class="thumbnail" src="images/frame_0001.p

Accessing Session Variables at server side in asp.net -

client side <script type="text/javascript"> function getistektalebi(id) { var istek2 = id; '<%session["username"] = "'+istek2+'"; %>'; alert('<%=session["username"].tostring() %>'); } </script> how can use session in server side in .cs asp.net this code alow , working question string val = httpcontext.current.session["deger"].tostring();

add generic list item to another existing list item using c# -

i have generic list filled items. in list have 1 column unique (like id). , have generic list other items , same id column. way fill items lists: foreach (string s in l1) { gridviewsource src = new gridviewsource(); src.test = "id" + s; list.add(src); } foreach (string s in l2) { gridviewsource src = new gridviewsource(); src.test = "id" + s; src.test2 = "somerandomtext" + s; list2.add(src); } what i'm trying add items list2 list if have same id. should add item list2 id "id3" item "id3" of list . merging. don't want add them bottom of list or insert them between items. tried concat method it's adding items add end of list: list = list.concat(list2).tolist(); edit: i try explain way: my list looks this: [0] => test = "id1", test2 = "" [1] => test = "id2", test2 = "" [2] => test = "id3", test2 = "" [3] =&

ios - Saving in Core Data -

at abcviewcontroller.m product *pro = [nsentitydescriptioninsertnewobjectforentityforname:@"product" inmanagedobjectcontext:_appdelegate.managedobjectcontext]; pro.name = _nametext.text; [_context insertobject:pro]; [_appdelegate savecontext]; savecontext in appdelegate contains - (void)savecontext { nsmanagedobjectcontext *managedobjectcontext = self.managedobjectcontext; if (managedobjectcontext != nil) { nserror *error = nil; if ([managedobjectcontext haschanges] && ![managedobjectcontext save:&error]) { // replace implementation code handle error appropriately. // abort() causes application generate crash log , terminate. should not use function in shipping application, although may useful during development. nslog(@"unresolved error %@, %@", error, [error userinfo]); abort(); } } } any need of "[_context insertobject:pro

php - How to preg_match first occurrence in a string -

i trying extract from:address email body. here have far: $string = "from: user1@somewhere.com test.. original message sent from: user2@abc.com"; $regexp = "/(from:)(.*)/"; $outputarray = array(); if ( preg_match($regexp, $string, $outputarray) ) { print "$outputarray[2]"; } i email address of first occurrence of from: .. suggestions? your regex greedy: .* matches any 0 or more characters other newline, many possible . also, there no point in using capturing groups around literal values, creates unnecessary overhead. use following regular expression: ^from:\s*(\s+) the ^ makes sure start searching beginning of string, from: matches sequence of characters literally, \s* matches optional spaces, (\s+) captures 1 or more non-whitespace symbols. see sample code : <?php $string = "from: user1@somewhere.com test.. original message sent from: user2@abc.com"; $regexp = "/^from:\s*(\s+)/"; $outputarray = arr

PayPal IPN message: what is the difference between Reversed and Refunded? -

i interested difference between reversed , refunded values payment_status on ipn messages? saw official description on paypal ipn variables page , don't understand difference. according this answer refunded called after reversed . true? refunded: refunded it reversed: paypal reversed on dispute. if win dispute followed cancel-reverse.

php - Make two database connections available in a model to use in laravel 5 -

i using 2 connections in project. 1 mysql , mongo. creating separate database each user/company. so while register need create 2 database each type mysql , mongo. i have added line below regular eloquent in regular auth user model use illuminate\database\eloquent\model eloquent; use jenssegers\mongodb\model eloquent; user class like class user extends eloquent implements authenticatablecontract, canresetpasswordcontract i want both connection available in same model. can switch connection use like db::connection("connection name") but need comment line use jenssegers\mongodb\model eloquent; to use mysql , comment regular eloquent use mongo use illuminate\database\eloquent\model eloquent; is there way out include both , can switch connection anytime without commenting of them. looking forward support. sorry if sound irrelevant new laravel i have tried , working fine single include use illuminate\database\eloquent\model eloquent; jen

uinavigationbar - Objective C UIBarButtonItem as toggle button for edit and save -

i have written code place right bar button item customview.while selecting edit changes save option.now selecting save saves values.if again try select edit action not firing.the code written below, item = [[uinavigationitem alloc]init]; btnn = [uibutton buttonwithtype:uibuttontypecustom]; [btnn setframe:cgrectmake(0, 0, 40, 40)]; btnn.layer.maskstobounds = no; btnn.layer.cornerradius = 8.0; [btnn addtarget:self action:@selector(rightbarbuttoncustompressed:) forcontrolevents:uicontroleventtouchupinside]; [btnn setimage:[uiimage imagenamed:@"edit"] forstate:uicontrolstatenormal]; uibarbuttonitem* rightbtn = [[uibarbuttonitem alloc] initwithcustomview:btnn]; item.rightbarbuttonitem = rightbtn; self.navigationbar.items = @[item]; -(ibaction)rightbarbuttoncustompressed:(uibarbuttonitem*)btn { item = [[uinavigationitem alloc]init]; btnn = [uibutton buttonwithtype:uibuttontypesystem]; [btnn setframe:cgrectmake(0, 0, 40, 40)]; btnn.layer.maskstobounds = no; btnn.lay

Set Tesseract font for OCR -

Image
i use tesseract serial number recognition, want recognize single characters, no word, no dictionary. therefore use 1 of trained tesseract font-types serial number achieve better recognition results. these trained tesseract font-types: andale_mono.ttf arial_black.ttf arial_bold.ttf arial.ttf comic_sans_ms_bold.ttf comic_sans_ms.ttf courier_new_bold.ttf courier_new.ttf georgia_bold.ttf georgia.ttf gottf impact.ttf times_new_roman_bold.ttf times_new_roman.ttf trebuchet_ms_bold.ttf trebuchet_ms.ttf verdana_bold.ttf verdana.ttf since trained font-types have different font-desin styles, there problems in distinguishing example "z" , "2" characters. times new roman has more rounded design, while arial has more straight lines. my experience is, tesseract has problems distinguish "z" , "2" due changed similarity of other font-designs. therefore think can achieve better recognition results, if 1 font-type (for example arial) used character

Check if one cell of several cells on a row in Excel has length 30 -

i have several rows within each row several cells , want check if 1 of these cells in row has length 30. i tried using len function, problem have check several cells in row @ 1 moment. excel treats true 1 , false 0. if array of true/false values comparing each cell in row length of 30 , take maximum, know if @ least 1 cell has length of 30. to check a2:g2 cell has untrimmed length of 30 characters/digits put in h2, =and(max(index(--(len(a2:g2)=30),,))) fill down subsequent rows. to retrieve first value 30 characters/digits in length put i2, =iferror(index($a2:$g2, , small(index(column($a:$g)+(len($a2:$g2)<>30)*1e+99, , ), column(a:a))), "") fill right possible second, third, etc. values 30 characters wide. fill down necessary catch subsequent rows.

ms word - Add specific citation based on user selection with vba -

i trying create userform user selects year , citation specific book inserted based on option. have tried inserting docvariable (called "bookyear") field inside text , changing variables value (to "aus15") through vba. code below doesnt work think i'm on right path sub macro2() if mycombobox = 2015 activedocument.variable("bookyear").value = "aus15" activedocument.fields.update end if end sub found answer mytext = "aus15" selection example: ''çode select bookmark selection.fields.add range:=selection.range, _ type:=wdfieldcitation, text:=mytext

objective c - iOS __kindof NSArray? -

i've been checking out ios 9 new features developer , of them stackview awesome. when went the header file of uistackview saw this: @property(nonatomic,readonly,copy) nsarray<__kindof uiview *> *arrangedsubviews; what __kindof on nsarray*. able specify type on nsarray * now? little test: @interface dxtest () @property (strong, nonatomic) nsmutablearray <__kindof nsstring *> *strings; @end @implementation dxtest - ( instancetype ) init { self = [super init]; if( self ) { _strings = [nsmutablearray new]; [_strings addobject:@(1)]; <-- compiler warning wieeeeee } return self; } @end are able specify type on nsarray * now? yes, through objective-c's new lightweight generics. in example provided, have property of type nsarray , which accept elements uiview s. now, can specified follows (without __kindof ). @property(nonatomic,readonly,copy) nsarray<uiview *> *arrangedsubviews; and in case,