Posts

Showing posts from January, 2013

get elements in "AND" in logic string with Python -

i want parse logic strings , combinations of elements in "and" logic. instance, string '( , ( b or c ) )' should [[a,b],[a,c]] , string '( , b , ( c or d , f ) or f , g )' should [[a,b,c],[a,b,d,f],[f,g]]. i'm trying use pyparsing. following post here parsing complex logical expression in pyparsing in binary tree fashion manage nested list letters grouped according preferences ("and" has preference on "or", , parenthesis overrides this): import pyparsing pp complex_expr = pp.forward() vars = pp.word(pp.alphas, pp.alphanums + "_") | pp.regex(r"[+-]?\d+(:?\.\d*)?(:?[ee][+-]?\d+)?").setname('proteins') clause = pp.group(vars ^ (pp.suppress("(") + complex_expr + pp.suppress(")") )) expr = pp.operatorprecedence(clause,[ ("and", 2, pp.opassoc.left, ), ("or", 2, pp.opassoc.left, ),]) #print expr complex_expr ...

why `ifroom` does not work - android studio -

hi there try set ifroom in menu item. can see in code try possible senario (please see each showasaction item <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity"> <item android:id="@+id/action_forward" android:title="forward" android:icon="@drawable/ic_action_arrow_forward" android:showasaction="ifroom" ></item> <item android:id="@+id/action_zoom_in" android:title="zoom in" android:icon="@drawable/ic_action_zoom_in" android:showasaction="ifroom|withtext" ></item> <item android:id="@+id/action_home" android:title="home" android:icon="@d...

emulation - Visual Studio Android Emulator Display Keyboard -

Image
how can display keyboard on vs android emulator? in avd can setup emulator configurator, there no way in vs. i found solution in android setting → language input → keyboard click on current keyboard , switch "hardware show input method"

Has Sitecore 8 built-in support for MVC areas? -

is sitecore 8 has built-in support mvc areas? or still need install sitecore plugins? thanks quoting kevin brechbühl (from the sitecore mvc puzzle ): sitecore has no support areas out of box, there multiple solutions available integrate them in solutions: resolve area in mvc.renderrendering-pipeline use custom controllerrunner , custom renderer resolve area configurations we saw sitecore working on solution integrate areas core. rumor has integrate similar pattern brainjocks mvc.renderrendering pipeline.

python - Genetic Algorithm roulette selection - returning 2 parent chromosomes -

i want implement roulette wheel selection in ga algorithm. tried following guide https://stackoverflow.com/a/5315710/536474 sends new population instead of 2 best parents. suppose found fitness score initial population , need select 2 parent chromosomes population according fitness. , further goes crossover , mutation processes. in following case, how can find 2 best parents crossover based on roulette wheel selection? population = [[text1],[text2],[text3],.....[textnum]] fitnesses = [0.8057515980834005, 1.2151126619653638, 0.6429369518995411, ... 0.805412427797966] num = 50 it doesn't send new population, num parents. if want 2 parents call roulette_select way: roulette_select(population, fitnesses, 2) often ga crossover operator expects 2 parents there variations many parents (e.g. genetic algorithms multi-parent recombination - a.e. eiben, p-e. raué, zs. ruttkay ). there self-crossover operators. so having num input parameters makes sense.

What are the constraints of Swift's array syntax? -

i'm working through exercises in the swift programming language , , 1 thing noted odd array syntax. per this answer , array<t.generator.element>() works, yet var common = [t.generator.element]() not. @ same time, var common: [t.generator.element] = [] correct. what rules around array syntax/initialization? why doesn't second line work?

python - Django Rest Framework: Implementing Many-to-Many relationship in Serializer -

i'm using django rest framework create custom api movies model defined follows: models.py from django.db import models class genres(models.model): genre = models.charfield(max_length = 128, unique = true) class movies(models.model): popularity = models.floatfield() director = models.charfield(max_length = 128) genres = models.manytomanyfield(genres, related_name = 'movies') imdb_score = models.floatfield() movie_name = models.charfield(max_length = 500) now, in application, each genre can have multiple movie instances , vice versa. result, there many-to-many relationship between genres model , movies model. want allow admin chose multiple genres particular movie while posting new movies instances @ api endpoint. serializers.py from shoppy.models import movies, genres rest_framework import serializers class genresserializer(serializers.modelserializer): class meta: model = genres class moviesserializer(serializers...

PDF not showing on visitors browser -

i have webpage ( http://optiswissopen2015.ch/page/noticeboard ) pdfs on it. of them linked same way. on browsers (ie8 sure) shown text instead of open pdf viewer. <a href=" /files/noticeboard/1436883318_sism2015.pdf" download runat="server" class="button color3"> my first thought was, may have problem in header. converting them .ps , doesn't help. what can do, open right browsers? last option, zip them :-( yes, the issue in file content type returned pdf files on server. verify use curl -i [url] or wget -s [url] or online tool . for example, 1436883318_sism2015.pdf returns (incorrect): http/1.1 200 ok etag: "[omitted]" last-modified: tue, 14 jul 2015 14:15:18 gmt content-type: text/plain content-length: 1188394 date: mon, 27 jul 2015 17:19:21 gmt accept-ranges: bytes server: litespeed connection: close and anmedleguide.pdf returns correct header: http/1.1 200 ok date: mon, 27 jul 2015 17:21:25 gm...

javascript - jQuery on click for two buttons in same div -

i have site displays bar graphs of data. trying implement pagination graphs user can click 'next' or 'previous' scroll through different subsets of total data. here html section in question: <div class="graph_fields_wrap1 row backdrop col-lg-12"> <div class="col-lg-6"> <h3 class="titles">top ten author citations</h3> <h4 class="titles">all time (from 1970)</h4> <button class="pager" id="previous1" type="button"><span class="glyphicon glyphicon-chevron-left"></span> previous</button> <button class="pager" id="next1" type="button">next <span class="glyphicon glyphicon-chevron-right"></span></button> <div class="chart1 bs-component"></div> </div> <div class="col-lg-6"> ...

html5 - Using <video> with <source>, where do you add the crossorigin attribute? -

when using <video> tag alone, 1 adds crossorigin attribute so: <video src="blah" crossorigin="anonymous"></video> however, i've had trouble finding out correct placement of 'crossorigin' when using multiple video sources , example: <video> <source src="/somesource.mp4"> <source src="/somesource.webm"> </video> do put 'crossorigin' attribute on <video> tag or individual <source> tags? if later, mean each source can have individual crossorigin handling within 1 video tag? do put 'crossorigin' attribute on tag or individual tags? the w3c specs specify crossorigin attribute on video tag (or more precisely htmlmediaelement) not on src element (or again more precisely, htmlsourceelement). so, assuming follows specs, rash assumption - see margus's answer exmple, should put cross origin attribute on video tag rather individual source ...

java - Creating a static method that builds a RadioButton returns a NullPointerExeption -

so have static method building radiobutton: public static radiobutton createaradiobutton() { radiobutton radiobutton = new radiobutton(null); return radiobutton; } and have assignment statement: radiobutton = createaradiobutton(); which gives me nullpointerexeption. now how write static method create radiobutton perform good? doing wrong in here? you can't pass in null context argument radiobutton . @ least need this: public static radiobutton createaradiobutton(context context) { radiobutton radiobutton = new radiobutton(context); return radiobutton; }

javascript - Can't use chained locator in protractor -

i need test 2 textboxes. here's page view: <div class="wrap-ctrl ng-scope" ng-switch-when="input"> <input type="text" name="surnameinput" class="text-field ng-pristine ng-isolate-scope ng-pending ng-touched" data-ng-class="::surnamefeature ? 'box-ctrl_tooltip' : ''" placeholder="input surname" data-ng-model="input.surname" ng-model-options="{updateon: 'blur'}" data-input-type="fio-surname" data-dts-input="" data-ng-disabled="$root.isdisabled(prefix + 'surnameinput')" data-validator="restrictvalue, required, percentcyrillic=50" data-message-id="surnameerrors" data-warning="istruegendersurname" data-warning-id="surnamewarnings"> <!-- ngif: ::surnamefeature --> <!-- ngif: ::surnamefeature --> ...

comparison - How do I match "|" in a regular expression in PowerShell? -

i want use regular expression filter out if string contains 1 of "&" or "|" or "=". tried: $compareregex = [string]::join("|", @("&","|", "=")); "mydfa" -match $comparestr powershell prints "true". not wanted, , seems "|" has confused powershell matching. how fix it? @kayasax answer in case (thus +1), wanted suggest more general solution. first of all: not using pattern you've created. suspect $comparestr $null , match anything. to point: if want create pattern match characters/strings , can't predict if of them be/contain special character or not, use [regex]::escape() item want match against: $patternlist = "&","|", "=" | foreach-object { [regex]::escape($_) } $compareregex = $patternlist -join '|' "mydfa" -match $compareregex in such case input can dynamic, , won't end pattern matches an...

c# - OpCode.Call to Generic Method in different assembly using raw IL -

i want call generic method using raw il instructions. in order learn how using reflection.emit , experimenting dynamic assembly. the method want make call following: public class class1 { public void method1<t>() { console.writeline("classlibrary1.class1.method1<t>()"); } } these instructions using byte[] ilcodes = new byte[7]; ilcodes[0] = (byte)opcodes.ldarg_0.value; ilcodes[1] = (byte)opcodes.call.value; ilcodes[2] = (byte)(token & 0xff); ilcodes[3] = (byte)(token >> 8 & 0xff); ilcodes[4] = (byte)(token >> 16 & 0xff); ilcodes[5] = (byte)(token >> 24 & 0xff); ilcodes[6] = (byte)0x2a; this method resides in diferent assembly , token see there obtained this: int token = modulebuilder.getmethodtoken(typeof(classlibrary1.class1).getmethod("method1").getgenericmethoddefinition()).token; i setting bytes methodbuilder.createmethodbo...

python 3.x - Python3 tk TreeView dynamic column width -

relevant code below. looking way dynamically size ttk treeview widget's column fit text inside it. have treeview (within class) minwidths on columns, text fill "notes" column infinitely long , column needs resize take string. limit max size needless still want dynamic hold large string of text if needed neat when string shorter. there 2 solutions really, either dynamic sizing or calculating pixel width required given string, font.measure() mentioned doesn't seem applicable python 3.x any great, i'd tiny thing sorted can finish up! sql.connect(dbfile) dbconnection: cursor = dbconnection.cursor() self.treestudentlog = ttk.treeview(self.mainframe, columns=("type","points", "notes"), height=21) yscrollbar = ttk.scrollbar(self.mainframe, orient='vertical', command=self.treestudentlog.yview) xscrollbar = ttk.scrollbar(self.mainframe, orient='horizontal', command=self.treestudentlog...

node.js - Is there a way to enable paging in node js REPL -

i see paging when have long outputs in node js repl. is possible, how? vorpal.js node module looks trick. vorpal turns node app interactive cli, , supports extensions including implementation of less command in node. something work: var vorpal = require('vorpal')(); var less = require('vorpal-less'); vorpal .catch('[commands...]') .action(function (args, cb) { args.commands = args.commands || []; var cmd = args.commands.join(' '); var res; try { res = eval(cmd); } catch(e) { res = e; } this.log(res); cb(); }); vorpal .delimiter('myrepl>') .show(); this turn application repl within context of app, can accept less command: $ node myrepl.js myrepl> 6 * 6 | less 36 : (less prompt) disclaimer: wrote vorpal

java - Trying to create toolbar and getting rendering error -

im trying create toolbar im getting error. searched , didnt found solution. error: following classes not found: android.support.v7.widget api version 16. styles.xml file: <style name="apptheme" parent="theme.appcompat.light.noactionbar"> <item name="colorprimary">@color/colorprimary</item> <item name="colorprimarydark">@color/colorprimarydark</item> <!-- customize theme here. --> </style>

function - What type of programming is this? -

Image
i finished taking entry placement test computer science in college. passed, missed bunch of questions in specific category: variable assignment. want make sure understand before moving on. it started out easy things, "set age equal age" int age = 18, pretty simple but then, had question had no clue how approach. went like... "determine if character c is in alphabet , assign variable" i function, issue is, gave me literally line write entire answer (so 50 characters max). here how answer box looked: my first thought like in_alphabet = function(c) { var alphabet = ["a", "b" ... "z"] if(alphabet.indexof(c) != -1) return true; } but solution has 2 issues: how can set "c" value when whole function equal in_alphabet? i can't fit small answer box. 99% sure looking else. does know looking for? can't think of 1 line solution this language doesn't matter (although solution in java/c+...

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...

javascript - How to Calculate PV and FV Formula in JS? -

i want compute pv , fv in javascript, before working in excel had function pv , fv function did me , i'm searching in javascript please me out if has implemented pv , fv formula in js here fiddle after tried @mariya davydova answer https://jsfiddle.net/46sbsxf6/5/ but geting n.an pv in excel answer 1,982,835.27 <div>rate <input type="text" class="rate" value="0.128/12"/>per <input type="text" class="per" value="63"/>nper <input type="text" class="nper" value="0"/>pmt <input type="text" class="pmt" value="-3872917.00" />fv <input type="text" class="fv" /> </div> <button class="calcpv">calculate pv</button> <button class="calcfv">calculate fv</button> <br/> <input type="text" class="total" placeholder=...

node.js - NodeJS/Mongoose: exports.function and module.exports incompatibility -

this user.js var mongoose = require('mongoose'); var bcrypt = require('bcrypt-nodejs'); var userschema = mongoose.schema({ email: { type: string, unique: true }, password: string, }); var user = mongoose.model('user', userschema); function createdefaultusers() { user.find({}).exec(function (err, collection) { if (collection.length === 0) { user.create({ email: 'name@eemail.com', password: 'password0', }); } exports.createdefaultusers = createdefaultusers; module.exports = mongoose.model('user', userschema); i call createdefaultusers in file create initial users. but when gives me following error: usermodel.createdefaultusers(); ^ typeerror: object function model(doc, fields, skipid) { if (!(this instanceof model)) ...

java - Testing Color class in android not working as expected -

i trying write test cases java class in android application, , doesn't seem work expected. this test case: public void testgetcolor() throws exception { shadescolor color = new shadescolor(100, 200, 250); assert.assertequals(color.rgb(100, 200, 250), color.getcolor()); assert.assertequals(100, color.getred()); assert.assertequals(200, color.getgreen()); assert.assertequals(250, color.getblue()); } following shadescolor class. public class shadescolor { int color; public shadescolor(int red, int green, int blue) { color = color.rgb(red, green, blue); } public int getcolor(){ return color; } public shadescolor interpolate(shadescolor endcolor, double percentage){ int red = (int)(this.getred() + (endcolor.getred() - this.getred()) * percentage); int green = (int)(this.getgreen() + (endcolor.getgreen() - this.getgreen()) * percentage); int blue = (int)(this.getblue() + (endcolor.get...

jquery - Making a variable in Javascript from AJAX return Value -

i scanned lot of pages here didn't find answer. i'm new php , javascript , seeking create variable (for comparison purpose) jquery return value. i'm creating registration system use check username availability: $(document).ready(function() { $("#username").keyup(function (e) { //removes spaces username $(this).val($(this).val().replace(/\s/g, '')); var username = $(this).val(); if(username.length < 2){$("#user-result").html('');return;} if(username.length >= 2){ $("#user-result").html('<i class="fa fa-refresh fa-spin"></i>'); $.post('core/check_username.php', {'username':username}, function(data) { $("#user-result").html(data); }); } }); }); i can display return value in span form validation purpose, need compare return value set of criteria. can please...

java - Custom shaped Views in Android -

Image
i need build set of custom shaped views programmatically. thing is, these views not same shape, , shapes determined based on how many of element have. say have 3 elements: ["a","b","c"] visual effect should follows: if there 2 elements, follows: i've done in swift custom drawing inside of custom view, unsure of syntax java. simple example of drawing shape me in right direction. //get points bounding view //pad = space between polygons //leftx = left bound of parent view //rightx = right bound of parent view //topy = top bound of parent view //bottomy = bottom bound of parent view //width = width of single polygon before transform //peak = how far polygon reach space of polygon after transform (1/3 polygon width) //tip = peak padding taken account var context = uigraphicsgetcurrentcontext() var pad:cgfloat = (cgfloat)(numbers.applicationpadding) var l...

android - RecyclerView smoothScroolToPositionFromTop() -

is there alternatives listview's smoothscrolltopositionfromtop() recyclerview? trying migrate listview code recyclerview, , don't see recyclerview version of anywhere. there 1 method called recyclerview.smoothscrolltoposition() , cannot define offset relative top element of screen (i need list scroll position, , stop when position first visible child in list). to smooth scroll target position top can use custom linearlayoutmanager that: public class customlinearlayoutmanager extends linearlayoutmanager { private context context; public customlinearlayoutmanager(context context) { super(context); this.context = context; } public customlinearlayoutmanager(context context, int orientation, boolean reverselayout) { super(context, orientation, reverselayout); this.context = context; } public customlinearlayoutmanager(context context, attributeset attrs, int defstyleattr, int defstyleres) { super(co...

java - Log4j nosql appender Failed to authenticate against MongoDB server -

i'm trying use apache log4j nosql appender . i've configured connect mongodb instance, seem getting authentication error when running project maven install: error failed authenticate against mongodb server. unknown error. i using mongodb 3.0.4 , have created following user with: use test db.createuser({ user:"loguser", pwd:"pwd", roles:["readwrite","dbadmin"] }) and checked can connect using: mongo -u loguser -p pwd my log4j2.xml: <?xml version="1.0" encoding="utf-8"?> <configuration status="debug"> <appenders> <nosql name="databaseappender"> <mongodb databasename="test" collectionname="logging" server = "localhost" port="27017" username = "loguser" password = "pwd"/> </nosql> </appenders> <loggers> <r...

javascript - Change class from not to print, to print by check box in HTML -

i have lot of checkboxes , want print ones thats been checked. i've tried toggle, works until check it. here code: css <style type="text/css" media="print"> .dontprint { display: none; } </style> html <div class="dontprint"> <div class="checkbox"> <label><input type="checkbox"id="coms"> \\private\computer services </label> </div> <div class="coms"> <select class="form-control"> <option >read</option> <option >edit</option> </select> </div> </div> js $("#coms").click(function(){ $(".dontprint").toggle(); }); don't toggle visibility of class, toggle class itself. $("#coms").click(function() { $(this).parent().toggleclass("dontprint", !$(this).is(":checked")); }); and avoid having r...

symfony - Show data in a table using twig -

i have problem, code : {% order in afilteredigdetails %} {% if order.availability == 0 %} <tr> <td colspan="3" style="background: #ff0000;color:#ffffff">available</td> </tr> <tr> <td> {{ order.gift_id }} </td> <td> {{ order.idm }} </td> <td> {{ order.email }} </td> </tr> {% else %} <tr> <td colspan="3" style="background: #0000ff;color:#ffffff">unavailable</td> </tr> <tr> <td> {{ order.gift_id }} </td> <td> {{ order.idm }} </td> <td> {{ order.email }} </td> </tr> {...

Read camera permission for iOS in Xamarin -

i have ios app developed in xamarin. when app not have permission access microphone, if user tries access microphone app, check settings using avaudiosession.sharedinstance().requestrecordpermission (delegate(bool granted)) , display message. now need same if app not have permission access camera. need check if permission granted camera , display message accordingly. how can this? did checked answer? detect permission of camera in ios think that's solution looking :). edit: here highest voted answer's code ported c# // replace media type whatever want avauthorizationstatus authstatus = avcapturedevice.getauthorizationstatus(avmediatype.video); switch (authstatus) { case avauthorizationstatus.notdetermined: break; case avauthorizationstatus.restricted: break; case avauthorizationstatus.denied: break; case avauthorizationstatus.authorized: break; default: throw new argumentoutofrangeexception(); } ...

c# - Check if Listbox contains a certain element -

i know question posted here multiple times i've read threads , nothing works me decided ask here. i want check if string in listbox. i've tried listbox.items.contains("stringtomatch") but nothing. i tried foreach (var item in form1.filtertypelist.items) { if (item.tostring() == "stringtomatch") { break; } he doesn't find anything. why? how can solve that? try using way... findbytext strig tomatch = "stringtomatch"; listitem item = listbox1.items.findbytext(tomatch); if (item != null) { //found } else { //not found }

PHP merge arrays by value for 2 different array value -

i have tried merge 2 different arrays single array. can 1 me please? i have array this [0] (array)#2 [rank] "579" [id] "1" [1] (array)#4 [rank] "251" [id] "2" [0] (array)#2 [size] "s" [rank] "251" [1] (array)#15 [size] "l" [rank] "579" i need this [0] (array)#2 [size] "s" [rank] "251" [id] "1" [1] (array)#15 [size] "l" [rank] "579" [id] "1" untested, should work, or @ least close. for ($array1 $key1 => $value1) { ($array2 $key2 => $value2) { if ($value1['rank'] == $value2['rank']) { $result[$key1] = [$value2['size'], $value1['rank'], $value1['id']]; }; }; };

python call a function with kwargs -

i have function: def myfunc(): kwargs = {} = 1 b = 2 kwargs.update(a=a, b=b) newfunc(**kwargs) and newfunc def newfunc(**kwargs): print its not giving value of 1 whats wrong ? two things. first, kwargs argument in myfunc empty dict, won't pass parameters. if want pass value of a , b newfunc , can either use kwargs = {'a':1, 'b':2} newfunc(**kwargs) or newfunc(a=1, b=2) in both cases, 'a' , 'b' in kwargs dict of newfunc function. second, should extract argument kwargs dict in newfunc . print kwargs.get('a') should suffice.

eclipse - Show warning when EL not found -

i'm creating jsf applikation , kind of warning (preferably console) if make typos in el-expression. example: on page wanted show text localized. locale-config in faces-config.xml set , works var 'msgs'. i used code on page: <h:outputtext value="#{msg.title_edit_customer}"/> when checked page in browser, nothing got showed. took me while realize made typo - #{msgs.... worked expected. can activate kind of debug-output, can see directly there invalid el somewhere? my setup: eclipse 4.4.2, tomcat 8, myfaces 2.2.8 thanks @sjuan76 figure out: create own javax.el.elresolver , methods can return null/false. open source of class org.apache.myfaces.el.unified.resolver.scopedattributeresolver , copy methods facescontext(elcontext) , findscopedmap(facescontext, object) (since scopedattributeresolver final, can't extend it). edit getvalue-method: @override public object getvalue(elcontext context, object base, object property) {...

Rails belongs_to one of two models -

i'm working 2 different models person , organization . among many other attributes, both person , organization can contractor . if working person model , wanted store contractor information contractor belongs_to :person , done it. seems contractor belongs 2 other models. i searched around on google , found lot of info how assign ownership 2 different models @ once. (for example sale must belong both buyer , seller .) in situation contractor either person or organization . there way elegantly store contractor information both models in same table? if not, figure can make 2 different contractor tables, figured might opportunity learn something. many in advance. maybe can try this. rails provide polymorphic-associtions . can try build 1 model named contractorinfo belongs contractable(use polymorphic: true), person has_one contractorinfo contractable, organization has_one contractorinfo contractable.

jquery - Checkbox and Radio-Input sometimes not visible on Android -

i'm doing single-page web-app first time. i'm using jquery 2.1 , swiper page slides. can see old version here : www.die-dunkle-wache.de/haushaltsanalyse_1_1/haushaltsanalyse_1_1.html everything worked fine far, have encountered 3 problems not know how solve myself. when open page on tablet checkboxes , radioboxes visible , others not (the last pages --> starting @ blue slide "finanzen"). on android when soft keyboard pops mess due resizing. when use andoid keyboard "forward" jumps next input field. thats nice if @ end of page jump next slide , gets chaotic. i hope can me these problems.

jsf - Java null checks on Javabean nested attributes -

i'm working bigdecimal calculations , read it's better check null surround try catch. example: private bigdecimal computespringrateboltwasher() { if (boltwasher.getmaterial().getelastic_modulus() != null) { bigdecimal term1 = boltwasher.getmaterial().getelastic_modulus().multiply(bigdecimal.ten); // other equations return results; } return null; } but here nullpointerexception because bolt washer's material null. how cleanly check null on material on elastic modulus? does boil down this? i'll have few other attributes in method i'll need check , messy. private bigdecimal computespringrateboltwasher() { if (boltwasher.getmaterial() != null) { if (boltwasher.getmaterial().getelastic_modulus() != null) { edit the reason return null in facelets page, if not input values have been entered results page shows ? (with omnifaces coalese) bolt washer spring rate = <h:outputtext value="#{of:coalesce(contro...

ios - How would I use non deprecated API for SKPaymentQueue? -

i using using deprecated api , want update code use non-depcreated code. so big question how response list? - (void) buyfeature:(nsstring*) featureid { // skproduct *myproduct; if ([skpaymentqueue canmakepayments]) { skpayment *payment = [skpayment paymentwithproductidentifier:featureid]; // skpayment *payment = [skpayment paymentwithproduct:myproduct]; [[skpaymentqueue defaultqueue] addpayment:payment]; } else { [[nsnotificationcenter defaultcenter] postnotificationname:@"purchasedone" object:nil]; uialertview *alert = [[uialertview alloc] initwithtitle:@"warning" message:@"you not authorized purchase appstore" delegate:self cancelbuttontitle:@"ok" otherbuttontitles: nil]; [alert show]; [alert release]; } } - (void) purchase: (int) productindex { [self buyfeature: [aryproductids objectatindex: pro...

ios - How to use a library if it's been used internally by another library? -

i have been using cisco library "libassistsdk.a" part of cisco remote expert mobile service , apparently library uses sdwebimage internally. have lot of duplicates here , there. what should ? example code: duplicate symbol _objc_ivar_$_sdimagecache._ioqueue in: /users/********/library/developer/xcode/deriveddata/appname-ezewidnzfmvgaqhkczrmaahscmak/build/intermediates/appname.build/debug-iphoneos/appname.build/objects-normal/armv7/sdimagecache.o similarly others include remote expert mobile/expert_assist_ios_sdk-10/assist_ios_sdk/libassistsdk.a(sdwebimagedownloader.o) remote expert mobile/expert_assist_ios_sdk-10/assist_ios_sdk/libassistsdk.a(sdwebimagedownloaderoperation.o) remote expert mobile/expert_assist_ios_sdk-10/assist_ios_sdk/libassistsdk.a(sdwebimageprefetcher.o) remote expert mobile/expert_assist_ios_sdk-10/assist_ios_sdk/libassistsdk.a(sdwebimagemanager.o) ld: 65 duplicate symbols architecture armv7 clang: error: linker command failed exit code 1 (...

html - How do i link a submit button to my email address -

how use submit button send form, when filled, email address? <header>minimalistic form</header> <form id="form" class="topbefore"> <p> <input id="name" type="text" placeholder="name"><br /> <input id="email" type="text" placeholder="e-mail"><br /> <textarea id="message" type="text" placeholder="message"></textarea><br /> <input id="submit" type="submit" value="go!"></p> </form> thanks help! html not have ability provide server's capability of sending email. there options available send mail, using appliation server in end. currently language/ application server using listen request ? (which server sending html page rendered on browser ?)

network programming - What is a higher reliability protocol than TCP? -

i know tcp has 16-bit checksum, catch errors in transmission. tcp outputs on other end theoretically reliable... point. this article suggests tcp not reliable 1 might hope if after "high reliability": http://iang.org/ssl/reliable_connections_are_not.html#ref_6 are there readily available protocols, or transport libraries (c/c++ preferred), more reliable tcp? speed of moderate concern too. i imagine transport library reimplementation of of parts of tcp. it shame tcp isn't more flexible allow tradeoff more reliability @ cost of throughput/latency/speed. lot more reliability if made checksum 32-bit instead of 16-bit. , again if chose make 64-bit. there seems big cost adding own reliable transport layer on top of tcp: starters, hardware acceleration support processing tcp won't suffice, , you'll need provide of cpu time process layer. additionally, lot of complexity , code implement such thing, have been avoided if tcp checksum larger or selectable. ...

c++ - Floyd Warshall Algorithm for a planar grid graph -

Image
i have graph this: and implemented graph array this: g[i][j][k] k has 4 cells , shows whether vertex connected 4 neighbor vertices or not. example for: g[1][1][0] = 0 g[1][1][1] = 1 g[1][1][2] = 1 g[1][1][3] = 0 it shows vertex(1, 1) connected 2 vertices. i know floyd warshall algorithm normal types of graphs. but how can implement flyod warshall algorithm kind of graph? thank. floyd-warshall algorithm inefficient such sparse graph. graph sparse because every vertex connected no more 4 other vertices. in dense graph vertex can connected n-1 other vertices, n number of vertices in graph. floyd-warshall algorithm more or less efficient, still, if don't need shortest paths between each pair of vertices or finding negative-length cycles, consider using priority queue finding shortest path between source , other vertices: https://en.wikipedia.org/wiki/dijkstra's_algorithm#using_a_priority_queue . or breadth first search can used if weights in graph e...

android - Will this code consume all purchases of managed Items V3 for this user? -

i found code on web. think can release managed items , make them available purchase again or need modification? seems i'm not able test correctly. looks need test button release managed items. on right track or totally misguided ? need opinion please don't have release managed items ... public void consumeallolderitems() { bundle owneditems = null; try { owneditems = mhelper.mservice.getpurchases(3, sgame.getcontext().getpackagename(), "inapp", null); } catch (remoteexception e1) { // todo auto-generated catch block e1.printstacktrace(); } int response = owneditems.getint("response_code"); if (response == 0) { alertnonstatic("consumeallolderitems() google responded ok our consumables"); arraylist<string> ownedskus = owneditems.getstringarraylist("inapp_purchase_item_list"); arraylist<string> purchasedatalist = owneditems.getstringarraylist(...