Posts

Showing posts from June, 2013

spring - Getting java.lang.reflect.InvocationTargetException when mocking MockMultipartHttpServletRequest -

i mocking mockmultiparthttpservletrequest below. please tell me causes java.lang.reflect.invocationtargetexception when debug single test case. @activeprofiles("development") @contextconfiguration(locations = { "classpath:asia/embla/fre/test/config/service-context.xml", "classpath:asia/embla/fre/test/config/data-context.xml" }) @runwith(springjunit4classrunner.class) public class bimdrawingservicetest { //private string ifcfilepath = "resources/famacweb-architect-2016-07-04.ifc"; @autowired private bimdrawingservice bimservice; @test public void manageupload(){ try { //multipartfile file = new mockmultipartfile("file", "famacweb-architect-2016-07-04.ifc", "text/plain", new fileinputstream(ifcfile)); mockmultiparthttpservletrequest request = new mockmultiparthttpservletrequest(); // assertequals("file na

c - Initializer element is not constant -

this question has answer here: structure member assignment causing syntax error when not inside function 5 answers i'm trying declare dummy head* global variable ide giving error: initializer element not constant how fix that? typedef struct mynode{ struct mynode *next; int value; }node; //declare global variable node *head = malloc(sizeof(node)); head->next = null; the obvious thing declare head variable global initialisation within function. typedef struct mynode{ struct mynode *next; int value; } node; node *head; int main (int argc, char **argv) { head = malloc(sizeof *head); if (!head) { /* error */ exit(-1); } head->next = null; return 0; }

Compare char in List C# -

i wonder if there c# functions checks if letter exists more once? in word, send string function parameter check whether letter exist more once or not. example string "aabdck" should return "a". there way use dictionary?? is there way use dictionary?? yes loop through each character in string , track number of occurrences of each character in dictionary<char, int> . dictionary<char, int> counts = new dictionary<char, int>(); foreach (var ch in mystring) { if (counts.containskey(ch)) { counts[ch]++; } else counts.add(ch, 1); } check dictionary keys value > 1. you can linq. i'm not in front of compiler, like list<char> multipletimes = mystring .groupby(c => c) .select(g => new { character = g.key, count = g.count() }) .where(a => a.count > 1) .select(a => a.character) .tolist();

c# - WPF binding expression in combination with Static or StaticResource -

is possible use static or staticresource in wpf binding expression achieve ischecked="{binding myarray[{staticresource myintvalue}].value}" without using converter? thanks no, not without converter. news converter pretty trivial though!

Chrome Apps on Mobile with Apache Cordova. Is Apache Cordova released or i sit in developer phase? -

we planning build chrome apps mobile devices enterprise product. want know whether apache cordova has released version. when go https://developer.chrome.com/apps/chrome_apps_on_mobile , in developer preview. mean can use release apps enterprise product.

java - Is there a way to Parse NULL value to XMLGregorian Date format? -

i getting response of capital (null) external system need convert xmlgregorian date format & set xmlgregorian object. this? following code snippet trying parse with: public static xmlgregoriancalendar toxmlgregoriancalendarwithtimezone(string date) throws parseexception, datatypeconfigurationexception { string format = "dd/mm/yyyy hh:mm:ss z"; gregoriancalendar cal = new gregoriancalendar(); simpledateformat formatter = new simpledateformat(format); formatter.settimezone(cal.gettimezone()); cal.settime(formatter.parse(date)); xmlgregoriancalendar calendar = datatypefactory.newinstance().newxmlgregoriancalendar(cal.get(calendar.year), cal.get(calendar.month) + 1, cal.get(calendar.day_of_month), cal.get(calendar.hour_of_day), cal.get(calendar.minute), cal.get(calendar.second), datatypeconstants.field_undefined, cal.get(calendar.zone_offset)); return calendar; } my s

python - Scala equivalent to scipy.optimize.minimize -

i'm trying port code, in r, python scala. original r code used nloptr, r interface nlopt. python code uses scipy.optimize.minimize . i've found minimize function in breeze.optimize post found on ( scipy-like functionality in java / scala? ), i'm not sure how suitable of replacement is. all appreciated. edit: know breeze.optimize doesn't directly have nlopt or slsqp, wondering trying use lbfgs.

android - What is the best practice of Global Dialog in my Application -

i have custom dialog builder in app trigger many events like: asynctasks, web service messages, ui input error or services don't have activity context. used create activity called currentactivity in application class. on resume of every activities sit on currentactivity . @override protected void onresume() { super.onresume(); myapplication.currentactivity = mainactivity.this; then in case of create dialogs used context. had 1 problem. example opened registeractivity , currentactivity changed it. when app goto background or case other activity opened, app crash on creating dialog context. handling witch activity currentactivity headache. googled , find guys embed customdialog in non-layout activty , open activity. seems not solution. updated for example have smsmanager class handle sending sms. wanna open dialog user chose custom options before sending sms. so best practice of global dialog in whole application? first of - bad practic

javascript - Call a changing variable from outside the function -

var slider = document.getelementbyid('test5'); nouislider.create(slider, { start: [1366], step: 1, range: { 'min': 200, 'max': 1920 }, format: wnumb({ decimals: 0, postfix: 'px', }) }); var app = angular.module('myapp', []); app.controller('mywidth', function ($scope) { $scope.width = inputformat.value; $scope.$watch('width', function (newvalue, oldvalue) { console.log('old:' + oldvalue); console.log('new:' + newvalue); }); console.log($scope.width + ' - scope width'); }); var inputformat = document.getelementbyid('input-format'); editorcontainer = document.getelementbyid('editorcontainer'); slider.nouislider.on('update', function (values, handle) { inputformat.value = values[handle]; //$(editorcontainer).css('width', values[handle]); }); inputformat.addeventlistener('ch

html - How do I vertically align an SVG and span in an inline UL? -

i have 2 <li> items inside <ul> styled display: inline-block . however, svg , text inside each <li> not line vertically. have tried using vertically-align: middle since inline-block elements did not work. ideally, middle of 2 elements aligned, aligning either top or bottom work well. svg { height: 20px; width: 20px; display: inline-block; background: green; } span { background: blue; } #retweet-icon, #favorite-icon { display: inline-block; } li.tweet-action { height: 22px; margin-left: 14px; display: inline-block; vertical-align: middle; } li.tweet-action:first-of-type { margin-left: 0px; } ul#tweet-actions { display: inline-block; list-style-type: none; float: left; padding: 0px; vertical-align: middle; } <ul id="tweet-actions"> <li class="tweet-action"> <div id="favorite-icon"> <svg xmlns="http://www.w3.org

asterisk - Elastix - No sound to external calls from sip phones connected through NAT -

we have provide remote partner 2 yealink sip phones can talk our hq , make external calls matters responsible. the partner on different isp has static ip open ports him only. the pbx behind firewall , have assign static ip , map ports 10000-20000 udp - tcp , port 5060 udp internal ip of pbx. have assign cid specific phones. phones register static have assigned. on sip extensions have nat=yes i try describe problem , when happening between partner , hq calls ok (2 way audio) using 3 digit extension numbers. call outside on specific cid ok (2 way audio) call specific phones outside line partially working (1 way audio - hear customer not way around) *we know isn't best approach , have in mind setup openvpn server secure connection. try add specific public ip , local subnet range in sip.conf general section. nat=yes externip=182.74.105.242 localnet=10.2.51.0/255.255.255.0 localnet=10.2.50.0/255.255.255.0 localnet=10.5.55.0/255.255.255.0

windows - Batch File folder detection -

yes, know need double-up %a %%a when used in batch file. ;) this works, not give me results want - much.. for /f %a in ('dir "d:\tomcat*" /ad /b ') /f %b in ('dir "d:\%a\webapps" /ad /b ') echo d:\%a\webapps\%b what is: for /f %a in ('dir "d:\tomcat*\webapps" /ad /b ') echo %a but, resulting error: the filename, directory name, or volume label syntax incorrect. i have need detect folders have tomcat in them , of following: d:\tomcat d:\tomcat1 d:\tomcat2 d:\tomcat_1 etc. thanks! you use if exist for /f %a in ('dir "d:\tomcat*" /ad /b ') if exist "%~a\webapps\nul" dir /b "%~a\webapps" \nul check if folder exist .

php - Add current year in redirect htaccess -

i try write rewrite rule route from: /abteilungen/einsatzabteilung/einsaetze.php to domain.de/abteilungen/einsatzabteilung/einsaetze/2016 (current_year) my .htaccess looks this: rewriteengine on redirect 301 /abteilungen/einsatzabteilung/einsaetze.php %{http_host}/abteilungen/einsatzabteilung/einsaetze/ is possible year @ end of target current year , how can this? edit full .htaccess throws 404 error: rewriteengine on rewriterule ^/abteilungen/einsatzabteilung/einsaetze.php$ %{http_host}/abteilungen/einsatzabteilung/einsaetze/%{time_year} [l,r=301] rewriterule ^(.*)einsaetze/([0-9]{4})$ $1/abteilungen/einsatzabteilung/index\.php/$2 in apache exist variable time_year rewriteengine on redirect 301 /abteilungen/einsatzabteilung/einsaetze.php %{http_host}/abteilungen/einsatzabteilung/einsaetze/%{time_year} try use rewriterule rewriteengine on rewriterule ^/abteilungen/einsatzabteilung/einsaetze.php$ %{http_host}/abteilungen/einsatzabteilung/einsaetze/%

http - get the response from SMS gateway in php -

this question has answer here: how send post request php? 10 answers how response sms gateway (in general) in site? the documentation sms gateway should describe how data presented via http; format specific sms gateway, there no standard. is gateway maintained third party? if 1 installed how presents information may part of configuration , issue off topic here. assuming gateway correctly configured, can see data presented gateway in $_request. in (very obscure) cases data may presented in raw post. just capture full request see how data being presented. easiest if php running mod_php in apache (you did not say) this: <?php $log=tempnam("/tmp", 'mo_sms'); $output="started " . date('r') . "\n"; $headers = apache_request_headers(); foreach ($headers $header => $value) { $output.="$header : $val

sql - Terribly slow query inner join -

in application have products , categories. product can in multiple categories. have 2 tables: cwobject (products) , entityobjectlink (link between product , category). have 1 query used lot after days of tweeking terribly slow. there aproximately 400k records in cwobject , 1.2m in entityobjectlink. this query: select top (99999) cwobject.* cwobject inner join dbo.entityobjectlink on cwobject.cwobject_guid = entityobjectlink.entityobjectlink_linkedcwobject_guid entityobjectlink_linkedcwentity_guid = '9a0e41d7-a472-445e-b94f-44fe1a1506b3' , cwobject_cwsitecluster_guid = '0f178176-9720-41c7-9528-99fdf30005e8' , cwobject_entitytype = 1 , (cwobject_predecessor_guid null) order cwobject_name asc entityobjectlink has relevant clustered index: primary key clustered ([entityobjectlink_linkedcwentity_guid] asc, [entityobjectlink_linkedcwobject_guid] asc) (pad_index = off, statistics_norecompute =

WPF DateTime Formatting -

i need format date, used below: <xcdg:column title="registratiedatum" fieldname="registratiedatum" width="1*"> <xcdg:column.cellcontenttemplate> <datatemplate> <textblock text="{binding stringformat='{}{0:dd/mm/yyyy hh:mm:ss }', targetnullvalue={x:static system:string.empty}}" /> </datatemplate> </xcdg:column.cellcontenttemplate> </xcdg:column> however, of date null, fields remain empty, guess due formatting appears this: 01/01/0001 00:00:00 any idea how restrict format "not null" values? sorry, if might basic question, still @ beginning stage of learning. a struct being value type , can never null . however, there several ways can fix issue: the cleanest , logical, in opinion, change datetime nullable<datetime> private datetime? mydate; public datetime? mydate { {

visual c++ - c++ libgen.h (mingw) missing for vc140 x64 project - helper functions -

i have these helper functions: std::string pathname_directory(const std::string &pathname) { char buffer[pathname.size() + 1]; memset(buffer, 0, sizeof(buffer)); std::copy(pathname.begin(), pathname.end(), buffer); return std::string(dirname(buffer)); } std::string pathname_sans_directory(const std::string &pathname) { char buffer[pathname.size() + 1]; memset(buffer, 0, sizeof(buffer)); std::copy(pathname.begin(), pathname.end(), buffer); return std::string(basename(buffer)); } which rely on libgen.h, mingw header. 1) why vs give error "expression must have constant value" lines containing "char buffer[pathname.size() + 1];"? 2) there pre-defined functions handle vs 2015? libgen.h posix header , question has no particular connection mingw . the compiler complains about: char buffer[pathname.size() + 1]; because standard c++ (any standard) prohibits variable length arrays (although c99 permits them). you avoid us

c++ - Qt Slots and Signals. Get Slot Receiver Object -

i have qlineedit want connect qlabel depending on validity of text entered. have 2 problems while doing this. qlineedit *text = new qlineedit(this); layout->addwidget(text, rowno, 0); qlabel *button = new qlabel(this); button->setstylesheet("qlabel { background-color : green; color : white; }"); button->setalignment(qt::aligncenter); button->settext("okay"); qobject::connect(text, signal(textedited(const qstring &)), button, slot(checkvalidity(const qstring &))); this not connect changes made in qlineedit custom slot. cannot figure out why! in custom slot, want change background colour of label depending on qstring passed. how reference label? present receiver of signal can't figure out way refer it. checkvalidity not qbutton 's slot, it's custom slot defined in own class (i assume that, since have not specified it). so, change last line to: qobject::connect(text, signal(textedited(const qstring &)), this, sl

python - How can you plot two lists of different 'first dimension' using matplotlib? -

i trying write code plots graph whilst going through loop , updates graph each iteration using matplotlib. plotting voltage_trim[0:index] in order avoid problem of having 2 lists of different size still error x , y must have same first dimensions. know how 1 plots 2 lists of different size have updating real time graph? voltage_trim = range(16) current_meas = [] fig1 = plt.figure() index, value in enumerate(voltage_trim): current_meas.append(random.randint(0,10)) plt.cla() plt.plot(voltage_trim[:index], current_meas ) your idea of trimming x values good. make work use voltage_trim[:index+1] . the index enumerate starts @ zero, first returned element want select 1 x value. therefore need values index+1.

How to auto select *all* items in dependent jQuery multiselect dropdown lists? -

my requirement when select customer combobox, need able auto-select items in dependent jquery multiselect dropdown lists. following started with. suggestion/help ! mvc view: <td> @if(viewbag.customer != null) { @( html.telerik().combobox() .name("ddlcustomer") .bindto((ienumerable<selectlistitem>)viewbag.customer) .clientevents(ce => ce.onchange("ddlcustomer_onchange")) ) } </td> <td> @if (viewbag.service != null) { @html.dropdownlist("ddlservice", (ienumerable<selectlistitem>)viewbag.service, new { onchange = "servicechange()" }) } </td> <td> @if (viewbag.type != null)

Copy Access Query to Excel via VBA (error 3343) -

i'm attempting copy results of access query , paste excel tab. i've googled around can't seem work, error "error 3343: unrecognized database format" assume has references have checked. does know correct references need work? references: visual basic application microsoft excel 14.0 object library ole automation microsoft office 14.0 object library microsoft activex data objects 2.8 library microsft dao 3.6 object library sub query() dim db dao.database dim rst dao.recordset dim sql string dim icol integer sheets("datadump1").select selection.clearcontents end set db = opendatabase("c:\folder\databasename.accdb") set rst = db.openrecordset("query 1") icol = 1 rst.fields.count activesheet.cells(1, icol) = rst.fields(icol - 1).name next icol activesheet.range("a2").copyfromrecordset rst rst.close db.close set rst = nothing set db = nothing end sub consider callin

Maven assembly: generate a resource zip file and include it into the main assembly zip file -

how can proceed include generated zip file main zip file maven assembly plugin? for example, have following folder structure: ./foldera/ ./file1 and want generate zip file content this: foldera.zip file1 here simplified config': pom.xml <?xml version="1.0" encoding="utf-8"?> <project > <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-assembly-plugin</artifactid> <configuration> <appendassemblyid>false</appendassemblyid> <descriptor>${basedir}/assembly-zipfoldera.xml</descriptor> <finalname>foldera.zip</finalname> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid>

Checkstyle not generating reports with Maven, but showing issues while in Eclipse any hints? -

checkstyle.xml looks <property name="severity" value="warning"/> <property name="fileextensions" value="java, properties, xml"/> <module name="treewalker"> <property name="tabwidth" value="4"/> <module name="javadocmethod"> <property name="scope" value="public"/> <property name="allowmissingparamtags" value="true"/> <property name="allowmissingthrowstags" value="true"/> <property name="allowmissingreturntag" value="true"/> <property name="minlinecount" value="2"/> <property name="allowedannotations" value="override, test"/> <property name="allowthrowstagsforsubclasses" value="true"/> </module> <module nam

php - Symfony2 and Facebook App. AccessToken from CanvasHelper empty -

i developing facebook app using symfony2. in index route (indexaction), ask user login , then, set access token in way in order retrieve info: $helper = $fb->getcanvashelper(); $accesstoken = $helper->getaccesstoken(); $fb->setdefaultaccesstoken($accesstoken); until here, works fine. problem comes when redirect in way other page of app indexaction: return $this->redirect($route, 301); in new page, if try execute previous code access token again, message: the default access token must of type \"string\" or facebook\\accesstoken @ /home/promocionescentros/www/vendor/facebook/php-sdk-v4/src/facebook/facebook.php:298)"} [] why happening this? can access token 1 time? thanks just replace: $accesstoken = $helper->getaccesstoken(); with: $accesstoken = (string)$helper->getaccesstoken();

java - maven build error: package org.apache.http does not exist -

i attempting send simple http post java program (for deploying on heroku). started demo project here . using mvn package builds project successfully. i added own additional file testpost.java few lines of code, added pom.xml , , still built fine. then tried add http code this example (minus package line), uses apache httpclient library. using mvn package results in following error: package org.apache.http not exist after searching solutions tried including dependency in pom.xml : <dependencies> <dependency> <groupid>org.apache.httpcomponents</groupid> <artifactid>httpclient</artifactid> <version>4.5.2</version> <scope>compile</scope> </dependency> </dependencies> my understanding should force download of necessary package no download shown on next compile (just same error), , package not visible in user .m2\repository\ folder. i tried inserting depen

laravel 4 - How I can open admin page in other tab with redirect:to? -

how can open admin page in other tab (target blank) when user login? in controller after validate return this: return redirect::to('/adminpanel'); you can't redirect user backend new tab. use javascript solution or ajax request .done (jquery like) callback redirect user after request finished.

python - Difference between two snippets of code? -

is there difference in terms of performance in doing this: for in range(t): arr = [int(arr_temp) arr_temp in input().strip().split(' ')] and this: for in range(t): arr = input().strip().split(' ') arr = list(map(int, arr)) if yes, better? according ipython's %timeit function, map bit faster: in [16]: s = ' '.join(map(str, range(1000))) in [17]: %timeit [int(c) c in s.split()] 10000 loops, best of 3: 171 µs per loop in [18]: %timeit list(map(int, s.split())) 10000 loops, best of 3: 138 µs per loop tested ipython 1.2.1 , python 3.4.3 , different input sizes ( range(1000) , range(10) , , range(100000) ). of course, interesting question is: part of code slowing down program (assuming that's why asking, , not out of pure curiosity). compared to, e.g., reading input (from file, presume?), or doing calculations data, might pretty insignificant.

c# - Bringing a Border into View -

Image
i have tabitem : <tabitem x:name="tabtfgwreadingmainhall" header="main hall" datacontext="{binding meeting}"> <tabitem.style> <style targettype="{x:type tabitem}"> <setter property="isenabled" value="false"/> <setter property="isselected" value="false"/> <style.triggers> <datatrigger binding="{binding numberclasses, converterparameter=1, converter={staticresource isequalorgreaterthanconverter}}" value="true"> <setter property="isenabled" value="true" /> </datatrigger> <datatrigger binding="{binding selecteditem, elementname=comboactivestudentassignmenttype}" value="{x:static studentinfoenums:studentassignmenttype.biblereadingmain}"> <setter proper

c++ How do I get variables from a class and put it into another class, and put it into a constructor? -

i have 2 h , cpp files. wanna know how call variables abe.h file or abe class bob.h or bob class. please help. abe.h #include <iostream> using namespace std; #ifndef abe #define abe class abe { private: int num; public: abe(); abe(int); void shownumber(); }; #endif // abe abe.cpp #include "abe.h" #include <iostream> using namespace std; abe::abe() { num=45; } abe::abe(int n) { num=n; } void abe::shownumber() { cout<<num; } bob.h #include "abe.h" #include <iostream> using namespace std; #ifndef bob #define bob class bob { private: abe a; public: bob(abe); void shownum(); }; #endif // bob bob.cpp #include "abe.h" #include "bob.h" #include <iostream> using namespace std; bob::bob(abe a1) { a=a1; //^not sure a=a1 doing if explain in simple terms or in deatil help. } void bob::shownum() { //how display here?? } so ho

algorithm - Number of integers in a list larger than a given integer possibly not in the list in log log time -

given unordered list of n nonnegative integers (with no guarantees distribution or repetition), want able given integer possibly not in list, , respond number of integers @ least large in list. have n^2 preprocessing time, , n*log(n) storage. possible? my not-good-enough solution binary search (log n time, constant space). storing map of possible queries in map take storage. edit: partial solutions require assumption on inputs, such distribution or max size of integer, useful. edit: known predecessor/successor problem. there's paper beame & fich in construct data structure stores n element sets of integers universe of size n in o(n) space , performs predecessor queries in o(min{(log log n) / (log log log n), sqrt(log n / (log log n))}) time. http://homes.cs.washington.edu/~beame/papers/stocpred.pdf edit - bounty: none of answers of morning i'm looking for. n not bounded. integers not under 32 bits. largest element may larger number of elements. assume no di

mysql - how to select distinct values from rows and columns both together -

Image
this database table values.there different topic names topic1 topic8. , want access distinct topic names these values. sql query ? to clarify answers: select command union operator returns distinct values. it's not needed distinct keyword. select union returns duplicate values too.

xcode7 - Could I create IPA file only with provisioning file in Xcode 7? -

first of ,i have provisioning file , p12 file ,but have not apple developer account. in xcode 6, can create ipa file using command line tool this: xcodebuild -exportarchive -exportformat ipa -archivepath $archivepath -exportpath ~/desktop/xx.ipa -exportprovisioningprofile '$provisioningfilename' could create ipa file using same way in xcode 7? rhetorically answering question - yes. xcodebuild work on xcode7 , command have mentioned creating ipa. basically have give actual values command work you.

ios - How to use daterformatter in datePicker view -

Image
i using swift2.2 xcode 7.3.1. want use date picker format 30 aug 2015 . picker in date mode,how display picker date formatter.i want datepicker following image: this stuff looking dd mmm yyyy link may http://nsdateformatter.com/

javascript - backbone.js - How to get rid of div? - how to render option? -

i need render select backbone.js. injects wrapper div? trying set tagname: '' not allowed. var muppetslistitemview = backbone.view.extend({ tagname: '',//leads error render: function() { this.$el.html('<option id="'+this.model.get('id')+'">'+this.model.get('key')+'</option>'); return this; }, if want handle html completly on own, how can achieve this, without backbone interfering , adding div? or alternatively, if can explain how renderd backbone injecting arbitrary attributes <option> tag when setting tag tagname: , great. (what mean is, have backbone injects id , key in html above "automatically" in option tag (but not using templating system)). thanks! you want use view.attributes id , use templates setting content of option normal. http://backbonejs.org/#view-attributes http://backbonejs.org/#view-template v

How to parallelize this embarrassingly parallel loop with Python -

i have embarrassingly parallel loop: # definitions def exhaustiveexplorationswithsimilarityall(inputfolder, outputfolder, similaritymeasure): phasesspeedupdictfolder=parsephasesspeedupdictfolder(inputfolder) avgspeedupprogramdict=computeavgspeedupprogram(phasesspeedupdictfolder) parameters={ programsphasesspeedupdicts:phasesspeedupdictfolder, programsavgspeedupdict:avgspeedupprogramdict } similarityhandler= similarityhandler(similaritymeasure,parameters) # sequential running filename in os.listdir(inputfolder): print filename exhaustiveexplorationswithsimilarity(inputfolder + filename, outputfolder + filename, similarityhandler) and make parallel using joblib parallel: # parallel version num_cores = multiprocessing.cpu_count() parallel= parallel(n_jobs=num_cores) filename in os.listdir(inputfolder): print filename parallel(delayed(exhaustiveexplorationswithsimilarity(inputfolder + filename, outputfolder + fil

grails - How to get gsp date picker to display range of years from x year to the current year? -

i'm using gsp tag display month , year in form. <g:datepicker name="mydate" value="${new date()}" precision="month" years="${1930..2015}"/> i want 2015 picked dynamically. if compute year outside, how specify variable in years range? you can follow link same. here author tried same.. http://www.icodeya.com/2012/04/grails-datepicker-limit-datepickers.html?m=1 and can go through grails documentation https://grails.github.io/grails-doc/3.0.x/ref/tags/datepicker.html of g:datepicker hope helps. thanks

Sorting an ArrayList whose first half is already relatively ordered -

i trying optimize sorting algorithm arraylist of 100 items. thing list has invariant first half of items in relative order themselves... (i.e. {1,1,4,5,6,2,1,11,4,3}, because first 5 items relatively ordered). in order take advantage of feature i'm considering sorting right half of list , merging 2 halves in order. reasoning sorting half list merging, can achieve time complexity of (m lg(m) + n) m = n / 2. make big-oh complexity better o(nlg(n)) or (m lg(m) + n) end reducing o(nlg(n)) anyways? any insight regarding big-oh of problem or efficient approach problem appreciated.

C# - Performance of reusing object with string properties vs creating new instance -

suppose have class contains 3 string properties. new instances of being created several times needlessly throughout application. class use these 3 strings perform linq query like: where(string1 == this.string1).where(string2 == this.string2).where(string3 == this.string3) instead of creating instance every single time object needed, i'm thinking modifying classes use type store 1 instance of object , modify string properties before using each time. right way optimize class? basically, i'm trying avoid overhead of creating instance , allocating memory strings every time. is there faster way perform above linq query instead? yes is. unless there're plenty of objects, difference in performance negligible.

Non-commercial alternatives to Views plugin for SonarQube Community Edition 5.6 -

are there alternatives views plugin community edition 5.6? not commercial plugins (governance license). cannot comment in sonarqube 5.5 , views plugin . as far (sonarsource) know, there's no alternative governance product - may open-source or commercial.

c - Add data to packet of a specific protocol -

i'm implementing new protocol called xor. first packets created in user space , sent network. after packet arrive other node in network. need create module intercept every module sent , add header or data. create module put data packet don't have success. i try things when activate module packets dropped. module doing: struct xorhdr { int in; int out; }; static unsigned int asnfwd_hook(const struct nf_hook_ops *ops, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { struct iphdr *iph; struct asnfwd_opt *opt; __be32 addr = 0; struct tcphdr *th; struct udphdr *uh; /* sanity check */ if (!skb) goto accept; /* recover ipv4 header */ iph = ip_hdr(skb); if (!iph) goto accept; if (iph->protocol == 17) { uh = (struct udphdr *) skb_transport_header(skb); if ((unsigned int) ntohs(uh->source) == xor_port && (unsigned in

asp.net - why can't web site not accessible using port 83? -

Image
i have hosted site windows server 2012 r2. have bind site port 81,83,2163. accessible using other port except port 83 using domain name ip, when i'm accessing using port 83 domain name not accessible, accessible using ip port 83. i have disable firewall still not working, why? edited from bindings list, select port 83 binding, , click "edit." dialog, specify fully-qualified domain name site in question "host name." allows iis respond request website via desired domain name reference.

c# - Delay reacting to TextChanged event -

i have winforms application reacts keystrokes in textbox using textchanged event. want delay reacting until there has been short gap (maybe 300 milliseconds) since last keystroke. below current code: private void timerelapsed(object obj) { if (textsearchstring.focused) { //this code throws exception populategrid(); texttimer.dispose(); texttimer = null; } } private void textsearchstring_textchanged(object sender, eventargs e) { if (texttimer != null) { texttimer.dispose(); texttimer = null; } texttimer = new system.threading.timer(timerelapsed, null, 1000, 1000); } my problem textsearchstring.focused throws system.invalidoperationexception . what missing? a system.threading.timer runs on background thread, means in order access ui elements must perform invocation or use system.windows.forms.timer instead. i'd recommend system.windows.forms.timer solution easiest. no need dispose , rei

asp.net mvc - Viewmodel set up Aspt.net MVC 6 -

i'm having trouble understanding how implement viewmodel in asp.net mvc, have following tables: form id, data report id, formid, owner, category, status, submissiondate reportvalues id, reportid, title, value i'm looking way display , edit report , reportvalues in 1 viewmodel reportvalues.reportid = report.id reportvalues have multiple entries relate report. i have had @ similiar questions on here , tried following tutorial ( http://techfunda.com/howto/262/list-data-using-viewmodel ) , coming empty handed. if need more information let me know , in advance replies! your view model nothing more class. can solve many ways, here's example. create 3 classes would. public class form { public int id { get; set; } public string data { get; set; } } public class reportvalues { public int id { get; set; } public int reportid { get; set; } public string title { get; set; } public string value { get; set; } } public class

unityscript - How to load TextAsset from txt file containing extended ASCII characters in Unity? -

in case specifically, have bullet-points (• or #149) in text file. if copy paste "•" unity text field in editor, shows up, pretty sure bullet-point lost in reading process. (i checked in debug mode, , indeed bullet-point lost @ reading). this how read in text file textasset: textasset content = resources.load(slidemanager.slidelanguage+"\\"+filename+" ("+slidemanager.slidenumber+")") textasset; it turns out, way read fine. reads file correctly, encoding of file ascii, therefore resource loader cannot interpret none ascii characters, , drops them. thus, since bullet-point not standard ascii, extended ascii character, have specify encoding of text files. example, set encoding utf-8, , work. i used notepad++ set encoding, sure there many other ways can it. to set encoding in notepad++ click on tab named encoding ( fifth tab left on top default ), , select convert utf-8 .

reactjs - Keybindings in react -

i've been trying figure out keybindings in react , i'm bit stuck. i placed onkeypress , tried onkeydown on input. allowed me handle letters , enter key. however haven't been able find way handle arrow keys , esc key without creating document.addeventlistener('keydown'', this.onkeypress) anyone have better solution? you can use focus , blur events control lifecycle of event handler. render() { return ( <input ref={inputloaded} type="text" /> ); }, inputloaded(input) { input.addeventlistener('focus', this.addeventlisteners); input.addeventlistener('blur', this.removeeventlisteners); this.input = input; }, componentwillunmount() { this.input.removeeventlistener('focus', this.addeventlisteners); this.input.removeeventlistener('blur', this.removeeventlisteners); window.removeeventlistener('keydown', this.handlekey); }, addeventlisteners() { window.addeventlistener(

Angular 2: Get reference to a directive used in a component -

i have component template looks this: <div [my-custom-directive]>some content here</div> i need access mycustomdirective class instance used here. when want access child component, use ng.core.viewchild query. there equivalent feature access child directive? you can use exportas property of @directive annotation. exports directive used in parent view. parent view, can bind view variable , access parent class using @viewchild() . example plunker : @directive({ selector:'[my-custom-directive]', exportas:'customdirective' //the name of variable access directive }) class mycustomdirective{ logsomething(text){ console.log('from custom directive:', text); } } @component({ selector: 'my-app', directives:[mycustomdirective], template: ` <h1>my first angular 2 app</h1> <div #cdire=customdirective my-custom-directive>some content here</div> ` }) export class appcom

How do I make a progression with a variable in Java? -

i interested in how call variable changes, such customer1 , customer2 , customer3 , etc. these customer variables populated in particular class . program automatically type number when perform such customer1.returnname(); if user types 1 . without me making case case code. user type number of customer , automatically uses number. function best this? if have numbered variables, use list. arraylist<customer> customers = new arraylist<customer>(); customers.add(new customer("name")); customers.get(0).returnname();

javascript - Forced domain for Rickshaw.js slider -

we displaying graph rickshaw.js, in function of time. time can in local time, or universal time. the matter is: when reduce slider, switch time local universal (or inverse), slider change position. i looked how slider window determined , don't see ways modify it... does have idea ? thank !

swift - Is the method of using the | bitwise operator to mix two colours correct? -

i building app allows users select 2 colors , see result of mixing them. example, user selects red (#ff0000) , blue (#0000ff) , result purple (#ff00ff). i started trying writing 3 methods in uicolor extension: hexcolor converts int color intvalue returns color's integer representation. i.e. reverse of hexcolor hexdescription returns string representation of color, such "#ff00ff" here implementations, in case needed: public static func hexcolor(hex: int32) -> uicolor { return uicolor.init(red: cgfloat((hex>>16)&0xff) / 255.0, green: cgfloat((hex>>8)&0xff) / 255.0, blue: cgfloat(hex&0xff) / 255.0, alpha: 1.0) } public func intvalue() -> int { var hexstring = self.hexdescription() hexstring = hexstring.substringfromindex(hexstring.startindex.successor()) return int(hexstring, radix: 16)! } public func hexdescription() -> string { var rf: cgfloat = 0, gf: cgfloat = 0, bf: cgfloat = 0, af: