Posts

arrays - Strings are not sequence of characters in java? -

in java, why not possible convert string char array , vice versa? why aren't comparable? char matrixc[][] = {{'s', 't','a', 'c','k'}, {'o','v','e','r'}, {'f','l','o','w'}}; string [] matrixs = {"stack", "over","flow"}; // matrixs=matrixc //not allowed... if (matrixs.equals(matrixc) || matrixc.equals(matrixs) ) { system.out.print("true"); } else system.out.print("false"); //output edited: after research , digging, found answer of first question (why not possible convert string char array , vice versa?) in below link, explained roger_that. hint james. immutable string immutable. meaning? so, have separate string pool in java heap, stores , creates new string literals each time , refer them string objects accordingly. still, have doubts comparison (i talking simple ...

bash - Perl to substitute string with a string containing spaces and double quotes -

my bash script builds string variable $arraylmes , containing string like: var availabletags=[ "01 east bering sea", "02 gulf of alaska"]; i need put string in javascript code, replace placeholder. thinking use like: perl -i -pe 's/placeholder/'"${arraylmes}"'/' filename but command complains, because of double quotes found in string, messing bash command , in consequence perl command. how can fix command keep spaces , double quotes? use -s switch pass variable perl: perl -spe 's/placeholder/$var/' -- -var="$arraylmes" filename the -- signifies end of command line arguments. -var="$arraylmes" sets perl variable value of shell variable $arraylmes . alternatively, use awk: awk -v var="$arraylmes" '{sub(/placeholder/, var)}1' filename a nice side-effect of using awk replacement simple string, metacharacters in original string won't interpreted.

python - Difference between math.exp(2) and math.e**2 -

this question has answer here: why floating point numbers inaccurate? 3 answers while programming noticed difference between result of math.exp(2) , math.e**2. can see below, difference not arise when calculating e^1. not being experienced programmer, wondered why differs? assume has rounding up. python docs math.exp(x) return e**x , appears not precisely correct. how come math.exp(x) operation differs math.e**x ? >>> math.exp(1) 2.718281828459045 >>> math.e**1 2.718281828459045 >>> math.exp(1)==math.e**1 true >>> math.exp(2) 7.38905609893065 >>> math.e**2 7.3890560989306495 >>> math.exp(2)==math.e**2 false >>> math.exp(100) 2.6881171418161356e+43 >>> math.e**100 2.6881171418161212e+43 >>> math.exp(100)==math.e**100 false it's different due differences in implementatio...

javascript - How import a React component from github? -

i'm trying understand how react works. i want use react-chartjs library. ( https://github.com/jhudson8/react-chartjs ). how can import in project? i tried in way: in file mycomponent.js: var lc = react.createclass({ render: function(){ var xfield = this.props.xfield; var yfield = this.props.yfield; var data = { labels: xfield, datasets: [ { label: "my first dataset", fillcolor: "rgba(220,220,220,0.2)", strokecolor: "rgba(220,220,220,1)", pointcolor: "rgba(220,220,220,1)", pointstrokecolor: "#fff", pointhighlightfill: "#fff", pointhighlightstroke: "rgba(220,220,220,1)", data: yfield }] } return( <linechart data={data} width="600" height="250" /> ); }}); var mycomp...

entity framework - EF Code First - Multiple Application Versions Sharing A Database -

we have application developed using code first in ef6. running quite happily on our live infrastructure. i have made changes required schema alterations , i've generated appropriate migrations. since application deployed our release process live environment has changed , applications deployed prelive area can validate interaction other applications/services , run tests before application files released live location. the problem migrations alter database schema when application run in prelive , live version of application choke on model compatibility check. how have other people approached issue? is there way of safely running multiple versions of code first application against same database? if can disable model checking, migrations still run when application first starts or have go generating sql change scripts , running them manually? i faced same problem. nick disabled migration in dbcontext , created different project database migration. added below c...

php - SQL future dates in request -

i'm trying execute sql request future events. so far, looks : $dql = "select aofvhflybundle:flight precisedate >= now()"; $query = $em->createquery($dql); but following error: line 0, col 59: error: expected known function, got 'now' how can future flights ? the dql function looking current_timestamp() . described in doc .

matlab - How to define a regex that matches whole words treating "." like a normal letter -

i trying read several numbers string in matlab. aim str2num does, without using eval (and less advanced). i have regex matching valid double number: '([-+]?([0-9]*\.[0-9]+|[0-9]+\.|[0-9]+)([ee][-+]?([0-9]*\.[0-9]+|[0-9]+\.|[0-9]+))?)' which works fine valid substrings such "1.15e2.4". problem want avoid matching invalid substrings such "1.15.e2.4" (which splits "1.15" , "2.4"). when match whole words (using \< , \> ), invalid string split "1.15" , "4"), because decimal point considered word binary. for using look-around expressions: '((?<=^|[ :,])[-+]?([0-9]*\.[0-9]+|[0-9]+\.|[0-9]+)([ee][-+]?([0-9]*\.[0-9]+|[0-9]+\.|[0-9]+))?(?=$|[ :,]))' but wonder if there easier , more general way. is possible redefine characters considered word boundaries? you cannot redefine word boundary means. can achieve same effect using negative lookarounds: (?<!\.)\< first regex he...