KML size reduction

Question: enter image description here
I need help to reduce the KML file size, when i created the KML from xl macro, it is generating large KML file, is there any way to reduce the kml size, please....,
The KML code is....
It is creating the 350+ coordinates for each sector, may be this is causing higher file size.
 { << ? xml version = "1.0"
    encoding = "Windows-936" ? > < kml >
    xmlns = "http://earth.google.com/kml/2.0" > < Document > < description > < ![CDATA[Total >
        339 sectors 3 / 22 / 2018]] > < /description> < Style >
    id = "my_style2" > < LineStyle > < color > ff0000ff < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style3" > < LineStyle > < color > ff00ffff < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style4" > < LineStyle > < color > ff00aa00 < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style5" >
    >
    < LineStyle > < color > ffff0000 < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style5" > < LineStyle > < color > ffff0000 < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style6" > < LineStyle > < color > ffff00aa < /color><color>ffff00aa</color > < width > 2 < /width></LineStyle > < PolyStyle > < fill > 0 < /fill></PolyStyle > < /Style> < Style >
    id = "my_style8" > < LineStyle > < color > ffff0ff0 < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style9" > < LineStyle > < color > ffaa00aa < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Style >
    id = "my_style10" > < LineStyle > < color > ffffff00 < /color><width>2</width > < /LineStyle><PolyStyle><fill>0</fill > < /PolyStyle></Style > < Placemark > < name > < ![CDATA[Palu_Infill_1_31]] > < /name><description><![CDATA[

    border = "1"
    padding = "0" >
  Sector >
    Name 	Palu_Infill_1_31

Longitude	  119.877

  Latitude 	-0.886656

Bearing	  0

  Cell >
    ID 	1

Beamwidth	  60

  LAC 	7777

CI	  7777

  DL Frequency 	7777

MAXTXPOWER	  7777

  PCPICHPOWER 	7777

RNC >
    Name 	7777

Frequency_Carrier	  F1

  U2000 	7777

ACTSTATUS	  7777

  Antenna Height 	7777

Antenna >
    Downtilt 	7777

Equipment	  7777

]]></description > < styleUrl > #my_style1 < /styleUrl><Polygon><outerBoundaryIs><LinearRing><coordinates>119.877,-0.886656,0119.87675,-0.886222987298108,0119.876751260639,-0.8862222619106,0119.876752523382,-0.886221540193205,0119.87675378822,-0.88622082215203,0119.876755055141,-0.886220107793152,0119.876756324134,-0.886219397122614,0119.87675759519,-0.88621869014643,0119.876758868296,-0.886217986870583,0119.876760143443,-0.886217287301023,0119.87676142062,-0.886216591443669,0119.876762699815,-0.88621589930441,0119.876763981018,-0.886215210889102,0119.876765264219,-0.886214526203571,0119.876766549405,-0.886213845253609,0119.876767836567,-0.886213168044979,0119.876769125693,-0.886212494583411,0119.876770416773,-0.886211824874603,0119.876771709796,-0.886211158924223,0119.87677300475,-0.886210496737906,0119.876774301625,-0.886209838321254,0119.87677560041,-0.886209183679838,0119.876776901093,-0.886208532819199,0119.876778203665,-0.886207885744843,0119.876779508113,-0.886207242462246,0119.876780814427,-0.88620660297685,0119.876782122595,-0.886205967294068,0119.876783432607,-0.886205335419277,0119.876784744452,-0.886204707357825,0119.876786058118,-0.886204083115026,0119.876787373594,-0.886203462696161,0119.876788690869,-0.886202846106482,0119.876790009933,-0.886202233351204,0119.876791330773,-0.886201624435513,0119.876792653379,-0.886201019364562,0119.876793977739,-0.886200418143469,0119.876795303843,-0.886199820777324,0119.876796631678,-0.886199227271179,0119.876797961235,-0.886198637630057,0119.876799292501,-0.886198051858948,0119.876800625466,-0.886197469962807,0119.876801960117,-0.88619689194656,0119.876803296444,-0.886196317815096,0119.876804634436,-0.886195747573274,0119.87680597408,-0.886195181225918,0119.876807315367,-0.886194618777822,0119.876808658284,-0.886194060233744,0119.87681000282,-0.886193505598411,0119.876811348963,-0.886192954876515,0119.876812696703,-0.886192408072717,0119.876814046028,-0.886191865191643,0119.876815396926,-0.886191326237887,0119.876816749387,-0.886190791216009,0119.876818103398,-0.886190260130537,0119.876819458948,-0.886189732985964,0119.876820816025,-0.886189209786751,0119.876822174619,-0.886188690537326,0119.876823534718,-0.88618817524208,0119.876824896309,-0.886187663905376,0119.876826259383,-0.886187156531539,0119.876827623926,-0.886186653124863,0119.876828989928,-0.886186153689607,0119.876830357377,-0.886185658229998,0119.876831726262,-0.886185166750227,0119.87683309657,-0.886184679254454,0119.876834468291,-0.886184195746803,0119.876835841412,-0.886183716231366,0119.876837215923,-0.8861832407122,0119.876838591811,-0.886182769193329,0119.876839969064,-0.886182301678743,0119.876841347672,-0.886181838172397,0119.876842727622,-0.886181378678213,0119.876844108903,-0.886180923200081,0119.876845491503,-0.886180471741852,0119.87684687541,-0.886180024307349,0119.876848260613,-0.886179580900356,0119.8768496471,-0.886179141524626,0119.876851034859,-0.886178706183876,0119.876852423879,-0.88617827488179,0119.876853814148,-0.886177847622018,0119.876855205653,-0.886177424408175,0119.876856598384,-0.886177005243842,0119.876857992328,-0.886176590132566,0119.876859387473,-0.886176179077859,0119.876860783809,-0.886175772083199,0119.876862181322,-0.886175369152031,0119.876863580002,-0.886174970287763,0119.876864979836,-0.886174575493771,0119.876866380812,-0.886174184773396,0119.876867782919,-0.886173798129943,0119.876869186145,-0.886173415566683,0119.876870590477,-0.886173037086855,0119.876871995905,-0.886172662693661,0119.876873402416,-0.886172292390269,0119.876874809998,-0.886171926179811,0119.876876218639,-0.886171564065387,0119.876877628328,-0.886171206050061,0119.876879039052,-0.886170852136862,0119.8768804508,-0.886170502328785,0119.876881863559,-0.88617015662879,0119.876883277318,-0.886169815039801,0119.876884692065,-0.88616947756471,0119.876886107787,-0.886169144206372,0119.876887524473,-0.886168814967607,0119.87688894211,-0.886168489851202,0119.876890360688,-0.886168168859908,0119.876891780193,-0.88616785199644,0119.876893200614,-0.88616753926348,0119.876894621938,-0.886167230663674,0119.876896044155,-0.886166926199633,0119.87689746725,-0.886166625873934,0119.876898891214,-0.886166329689117,0119.876900316033,-0.88616603764769,0119.876901741695,-0.886165749752122,0119.876903168189,-0.886165466004851,0119.876904595502,-0.886165186408276,0119.876906023623,-0.886164910964765,0119.876907452538,-0.886164639676647,0119.876908882237,-0.886164372546218,0119.876910312707,-0.886164109575739,0119.876911743936,-0.886163850767434,0119.876913175911,-0.886163596123494,0119.876914608621,-0.886163345646073,0119.876916042054,-0.886163099337291,0119.876917476197,-0.886162857199231,0119.876918911038,-0.886162619233944,0119.876920346566,-0.886162385443441,0119.876921782767,-0.886162155829702,0119.876923219631,-0.88616193039467,0119.876924657144,-0.886161709140252,0119.876926095294,-0.886161492068319,0119.87692753407,-0.88616127918071,0119.876928973459,-0.886161070479224,0119.87693041345,-0.886160865965629,0119.876931854028,-0.886160665641655,0119.876933295184,-0.886160469508996,0119.876934736904,-0.886160277569313,0119.876936179176,-0.886160089824229,0119.876937621988,-0.886159906275334,0119.876939065328,-0.886159726924179,0119.876940509184,-0.886159551772284,0119.876941953543,-0.886159380821129,0119.876943398393,-0.886159214072162,0119.876944843722,-0.886159051526793,0119.876946289518,-0.886158893186398,0119.876947735768,-0.886158739052316,0119.876949182461,-0.886158589125852,0119.876950629583,-0.886158443408275,0119.876952077124,-0.886158301900816,0119.87695352507,-0.886158164604675,0119.876954973409,-0.886158031521012,0119.876956422129,-0.886157902650954,0119.876957871217,-0.886157777995591,0119.876959320663,-0.886157657555978,0119.876960770452,-0.886157541333133,0119.876962220574,-0.886157429328042,0119.876963671015,-0.88615732154165,0119.876965121763,-0.88615721797487,0119.876966572807,-0.886157118628579,0119.876968024133,-0.886157023503617,0119.87696947573,-0.886156932600789,0119.876970927586,-0.886156845920864,0119.876972379687,-0.886156763464576,0119.876973832022,-0.886156685232623,0119.876975284578,-0.886156611225665,0119.876976737344,-0.886156541444331,0119.876978190306,-0.886156475889209,0119.876979643453,-0.886156414560855,0119.876981096772,-0.886156357459788,0119.876982550252,-0.88615630458649,0119.876984003878,-0.88615625594141,0119.876985457641,-0.886156211524959,0119.876986911526,-0.886156171337512,0119.876988365522,-0.88615613537941,0119.876989819616,-0.886156103650957,0119.876991273797,-0.886156076152422,0119.876992728051,-0.886156052884036,0119.876994182367,-0.886156033845998,0119.876995636732,-0.886156019038468,0119.876997091134,-0.886156008461571,0119.876998545561,-0.886156002115397,0119.877,-0.886156,0119.877001454439,-0.886156002115397,0119.877002908866,-0.886156008461571,0119.877004363268,-0.886156019038468,0119.877005817633,-0.886156033845998,0119.877007271949,-0.886156052884036,0119.877008726203,-0.886156076152422,0119.877010180384,-0.886156103650957,0119.877011634478,-0.88615613537941,0119.877013088474,-0.886156171337512,0119.877014542359,-0.886156211524959,0119.877015996122,-0.88615625594141,0119.877017449748,-0.88615630458649,0119.877018903228,-0.886156357459788,0119.877020356547,-0.886156414560855,0119.877021809694,-0.886156475889209,0119.877023262656,-0.886156541444331,0119.877024715422,-0.886156611225665,0119.877026167978,-0.886156685232623,0119.877027620313,-0.886156763464576,0119.877029072414,-0.886156845920864,0119.87703052427,-0.886156932600789,0119.877031975867,-0.886157023503617,0119.877033427193,-0.886157118628579,0119.877034878237,-0.88615721797487,0119.877036328985,-0.88615732154165,0119.877037779426,-0.886157429328042,0119.877039229548,-0.886157541333133,0119.877040679337,-0.886157657555978,0119.877042128783,-0.886157777995591,0119.877043577871,-0.886157902650954,0119.877045026591,-0.886158031521012,0119.87704647493,-0.886158164604675,0119.877047922876,-0.886158301900816,0119.877049370417,-0.886158443408275,0119.877050817539,-0.886158589125852,0119.877052264232,-0.886158739052316,0119.877053710482,-0.886158893186398,0119.877055156278,-0.886159051526793,0119.877056601607,-0.886159214072162,0119.877058046457,-0.886159380821129,0119.877059490816,-0.886159551772284,0119.877060934672,-0.886159726924179,0119.877062378012,-0.886159906275334,0119.877063820824,-0.886160089824229,0119.877065263096,-0.886160277569313,0119.877066704816,-0.886160469508996,0119.877068145972,-0.886160665641655,0119.87706958655,-0.886160865965629,0119.877071026541,-0.886161070479224,0119.87707246593,-0.88616127918071,0119.877073904706,-0.886161492068319,0119.877075342856,-0.886161709140252,0119.877076780369,-0.88616193039467,0119.877078217233,-0.886162155829702,0119.877079653434,-0.886162385443441,0119.877081088962,-0.886162619233944,0119.877082523803,-0.886162857199231,0119.877083957946,-0.886163099337291,0119.877085391379,-0.886163345646073,0119.877086824089,-0.886163596123494,0119.877088256064,-0.886163850767434,0119.877089687293,-0.886164109575739,0119.877091117763,-0.886164372546218,0119.877092547462,-0.886164639676647,0119.877093976377,-0.886164910964765,0119.877095404498,-0.886165186408276,0119.877096831811,-0.886165466004851,0119.877098258305,-0.886165749752122,0119.877099683967,-0.88616603764769,0119.877101108786,-0.886166329689117,0119.87710253275,-0.886166625873934,0119.877103955845,-0.886166926199633,0119.877105378062,-0.886167230663674,0119.877106799386,-0.88616753926348,0119.877108219807,-0.88616785199644,0119.877109639312,-0.886168168859908,0119.877111057889,-0.886168489851202,0119.877112475527,-0.886168814967607,0119.877113892213,-0.886169144206372,0119.877115307935,-0.88616947756471,0119.877116722682,-0.886169815039801,0119.877118136441,-0.88617015662879,0119.8771195492,-0.886170502328785,0119.877120960948,-0.886170852136862,0119.877122371672,-0.886171206050061,0119.877123781361,-0.886171564065387,0119.877125190002,-0.886171926179811,0119.877126597584,-0.886172292390269,0119.877128004095,-0.886172662693661,0119.877129409523,-0.886173037086855,0119.877130813855,-0.886173415566683,0119.877132217081,-0.886173798129943,0119.877133619188,-0.886174184773396,0119.877135020164,-0.886174575493771,0119.877136419998,-0.886174970287763,0119.877137818678,-0.886175369152031,0119.877139216191,-0.886175772083199,0119.877140612527,-0.886176179077859,0119.877142007672,-0.886176590132566,0119.877143401616,-0.886177005243842,0119.877144794347,-0.886177424408175,0119.877146185852,-0.886177847622018,0119.877147576121,-0.88617827488179,0119.877148965141,-0.886178706183876,0119.8771503529,-0.886179141524626,0119.877151739387,-0.886179580900356,0119.87715312459,-0.886180024307349,0119.877154508497,-0.886180471741852,0119.877155891097,-0.886180923200081,0119.877157272378,-0.886181378678213,0119.877158652328,-0.886181838172397,0119.877160030936,-0.886182301678743,0119.877161408189,-0.886182769193329,0119.877162784077,-0.8861832407122,0119.877164158588,-0.886183716231366,0119.877165531709,-0.886184195746803,0119.87716690343,-0.886184679254454,0119.877168273738,-0.886185166750227,0119.877169642623,-0.886185658229998,0119.877171010072,-0.886186153689607,0119.877172376074,-0.886186653124863,0119.877173740617,-0.886187156531539,0119.877175103691,-0.886187663905376,0119.877176465282,-0.88618817524208,0119.877177825381,-0.886188690537326,0119.877179183975,-0.886189209786751,0119.877180541052,-0.886189732985964,0119.877181896602,-0.886190260130537,0119.877183250613,-0.886190791216009,0119.877184603074,-0.886191326237887,0119.877185953972,-0.886191865191643,0119.877187303297,-0.886192408072717,0119.877188651037,-0.886192954876515,0119.87718999718,-0.886193505598411,0119.877191341716,-0.886194060233744,0119.877192684633,-0.886194618777822,0119.87719402592,-0.886195181225918,0119.877195365564,-0.886195747573274,0119.877196703556,-0.886196317815096,0119.877198039883,-0.88619689194656,0119.877199374534,-0.886197469962807,0119.877200707499,-0.886198051858948,0119.877202038765,-0.886198637630057,0119.877203368322,-0.886199227271179,0119.877204696157,-0.886199820777324,0119.877206022261,-0.886200418143469,0119.877207346621,-0.886201019364562,0119.877208669227,-0.886201624435513,0119.877209990067,-0.886202233351204,0119.877211309131,-0.886202846106482,0119.877212626406,-0.886203462696161,0119.877213941882,-0.886204083115026,0119.877215255548,-0.886204707357825,0119.877216567393,-0.886205335419277,0119.877217877405,-0.886205967294068,0119.877219185573,-0.88620660297685,0119.877220491887,-0.886207242462246,0119.877221796335,-0.886207885744843,0119.877223098907,-0.886208532819199,0119.87722439959,-0.886209183679838,0119.877225698375,-0.886209838321254,0119.87722699525,-0.886210496737906,0119.877228290204,-0.886211158924223,0119.877229583227,-0.886211824874603,0119.877230874307,-0.886212494583411,0119.877232163433,-0.886213168044979,0119.877233450595,-0.886213845253609,0119.877234735781,-0.886214526203571,0119.877236018982,-0.886215210889102,0119.877237300185,-0.88621589930441,0119.87723857938,-0.886216591443669,0119.877239856557,-0.886217287301023,0119.877241131704,-0.886217986870583,0119.87724240481,-0.88621869014643,0119.877243675866,-0.886219397122614,0119.877244944859,-0.886220107793152,0119.87724621178,-0.88622082215203,0119.877247476618,-0.886221540193205,0119.877248739361,-0.8862222619106,0119.877,-0.886656,0</coordinates > < /LinearRing></outerBoundaryIs > < /Polygon></Placemark > < /Document></kml >
    >
}

Comment: Please format your code and data as text and StackOverflow's formatting capabilities.
Comment: In other words, are you trying to reduce the number of points for a polygon or line ? The example above shows the HTML for the description not the KML content for geometry, etc.
Comment: yes, actually im trying to plot the polygon by directional based,(In one location i need 3 polygon in different direction) when im doing for more sites, the resulted file size is heavy, is there any way to reduce the no of points to get accurate directional polygon,/Thanks
Comment: after KML conversion, by using genereated kml, is there any way/tool to reduce the file size, one i know that is: in google earth itself, when we save in kmz, it automatically reduce the file size, i need even smaller file, kindly help me if there is any tool to reduce the KML file size,/Thanks
Comment: Why would you post a picture of the KML?
Answer:
Remove all the unneeded styles (you are putting 10 styles in the file, but only using one).
remove the optional altitude from the coordinates [longitude,latitude,[optional altitude]]

119.87675,-0.886222987298108,0

is the same as:
119.87675,-0.886222987298108

only output 6 digits after the decimal point for the numbers (that will give you millimeter accuracy, should be good enough):

119.87675,-0.886222

KML size reduction


Forecasting aircraft flights per month

Question: I'm trying to solve a time series forecasting problem, specifically I want to use historical data with an aspect of COVID-19 impact on global and regional aviation, number of new COVID-19 cases per country of origin (country of registration for the aircraft), and monthly average temperature in said country.
I wanted to ask for input on a tool that blends support datasets with a historical time series well? Ideally, the average temperature and 2-4 week lag of COVID-19 cases in a country would be input to the model along with each aircraft 12-24 month history.
I'm specifically looking at Tensorflow Probability and their Structural Time Series: https://blog.tensorflow.org/2019/03/structural-time-series-modeling-in.html and https://www.tensorflow.org/probability/examples/Structural_Time_Series_Modeling_Case_Studies_Atmospheric_CO2_and_Electricity_Demand#model_and_fitting
SK Time could also be an option: https://www.sktime.org/en/latest/examples/01_forecasting.html#Detrending
Facebook's Prophet also seems to be able to model this: https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#seasonalities-that-depend-on-other-factors
It could probably also be seen as a regression problem, by engineering features of all the time series datasets and feeding it into a regression model to predict monthly flights?
Anyway, I'm asking this question looking for some inspiration and possibly a tool that I haven't seen before could provide other options.
Answer: I'll go ahead and plug something I have been messing around with I am calling LazyProphet . Definitely takes a lot of influence from fbprophet but it measures trend via binary segmented regressions then measures seasonality then exogenous factors then uses gradient boosting to create more splits of the trend and regularize/adjust the other coefficients.  It boosts until the global cost function (controlled via the regularization parameter) stops decreasing. One nice thing it has over fbprophet (I think, pretty sure prophet doesnt have this) is trend dampening on your forecasted trend which can be controlled via a parameter.  Also you have a few different estimators for trend such as a mean changepoint/ linear changepoint/ global polynomial ridge regression.  There are some examples in the readme in the link!
Like I said this was mostly me just messing around and adding stuff so it is quite messy code wise but is is pip installable and the class object is easy enough to work with.  I do have a much cleaner implementation coming sometime soon with a lot more trend/seasonal estimators since the procedure itself is quite general and can work with an ARIMA or ETS or whatever measure of trend.
As a quick example of something you are interested in (although this is a dumb example in regards to our variables, just using what is easy):
<code>import quandl
import pandas as pd
import matplotlib.pyplot as plt
import LazyProphet as lp

#Get bitcoin data
data = quandl.get("BITSTAMP/USD")
#let's get our X matrix with the new variables to use
X = data.drop('Low', axis = 1)
X_train = X.iloc[-930:-50,:]
X_test = X.iloc[-50:,:]
y = data['Low']
y_train = y[-930:-50,]
y_test = y[-50:,]

#create Lazy Prophet class
boosted_model = lp.LazyProphet(freq = 365,
                            estimator = 'mean',
                            max_boosting_rounds = 200,
                            approximate_splits = True,
                            regularization = 1.2,
                            verbose = 1,
                            exogenous = X_train)
#Fits on just the time series
#returns a dictionary with the decomposition
output = boosted_model.fit(y_train)
forecast = boosted_model.extrapolate(len(y_test), X_test)
plt.plot(np.append(output['yhat'].values, forecast), label = 'Predicted')
plt.plot(np.append(y_train.values,y_test.values), label = 'Actual')
plt.vlines(len(X_train), 0, 13000, linestyles='dashed', color = 'red')
plt.legend()
plt.show()
</code>

Forecasting aircraft flights per month


System and database leveled users in Oracle Database

Question: I'm using the Oracle Database EX 126.96.36.199.0 and I hava a quite simple database created there.
Now the issue is i would like to have multiple users with different privileges set up. I have found that topic: How to create a user in Oracle 11g and grant permissions
but I cannot find anywhere the basic thing about users accounts:
what are the difference between creating system-leveled and particular database-leveled user?
I've logged in sqlplus as SYSTEM and executed the following commands:
CREATE USER TEST IDENTIFIED BY password;
GRANT CONNECT TO TEST;

and now the problem is that my databse is actually called let's say BASE with one table called PAYMENTS and to give any privileges to a newly created user I cannot execute:
GRANT SELECT ON PAYMENTS TO TEST;

but I have to type in:
GRANT SELECT ON BASE.PAYMENTS TO TEST;

so I suppose I missed something. Is it any way of connecting the created user to a particular database? So that the newly created user will be visible as a database user in Oracle APEX?
Answer: Users and schemas are synonymous in Oracle - basically. A schema is the collection of objects owned by a user.
To get what you want, you would need to create users lacking the privs to create anything and only have the ability to select from the objects of others.
Answer: When referencing objects in other schemas, you must provide the schema name. An other user might have a table with the same name. Currently you are logged in with the system user, which is not advisable. When creating objects in the BASE schema (another name for user in de Oracle DB), why not give the user some extra rights (like granting privileges)?
The core of your problem is that you want to grant privileges to user A on object owned by B, logged in as user C. You have to be very specific in that case to Oracle what privileges are granted to whom ;)
Comment: Thank you for answering. So it means I have to be logged as the BASE's owner and create a new user there? I've tried, but how to logon on that user from the console then? Using sqlplus that user is not visible.
Comment: I'm not sure if I understand what you want to achieve. It's ok to create users and do other administrative tasks as system. Once you set those up, it's best practice to login to SQL*Plus as that user.
Comment: logon to sqlplus with the following command:
sqlplus base@xe
where base is your user and xe the name of the  database. Then you are logged in as user base.
If you want to know what users are in the database, simply execute the query
select username from all_users;
Comment: The core of my problem is that I'm connecting to database using JDBC with the following "jdbc:oracle:thin:@localhost:1521/XE". So XE is default database in Oracle, and my BASE is only schema? I have all my tables in that "BASE" thing (whatever it is) and would like to set up a few users with different privileges. When I create user of "BASE" being logged to Oracle APEX and trying to logon with command 'sqlplus username@base' it says "ORA-12154: could not resolve the connect identifier specified".
Comment: and also when I use "jdbc:oracle:thin:@localhost:1521/XE" to connect to a database I can logon as SYSTEM or any user created at "SYSTEM level"; I would like to connect to the database and then be able to logon to the database BASE only as the BASE users, not the global users like SYSTEM or any user I created being logged as SYSTEM.
Comment: The database mentioned in the jdbc connection string is XE. I do not know what BASE is, but I'm still guessing it's the user you connect with.Check http://www.orafaq.com/wiki/JDBC for explanation on jdbc syntax.You can use jdbc:oracle:thin:[USER/PASSWORD]@[HOST][:PORT]:SID
for instance jdbc:oracle:thin:base/pwd@localhost:1521:xe or any other user instead of base.When using sql connect string the syntax is sqlplus username/password@SID , so base/pwd@XE in your case


Is any generator for a topology a subbase for the generated topology?

Question: Let $X$ be a set, and $S \subset P(X)$. Let $T(S)$ be the topology generated by $S$, i.e. the smallest topology containing $S$. Is $S$ a subbase for $T(S)$?
Definition of subbase: $B$ is a subbase if the collection of open subsets consisting of all finite intersections of elements of $B$ together with $X$ forms a basis.
It does not seem obvious to me. Let $U \in T(S)$ be an arbitrary open. If $S$ is indeed a subbase, then $U$ is a union of (finite) intersections of elements in $S$. I.e. we only need one iterarion of taking intersections and unions of $S$.
But to form $T(S)$ we need at least infinite iterations of taking (finite) intersections and unions of $S$.
Note: there seemed to be two definitions of subbase: subbase. With the one definition the question is true obviuous, by the other it is not.
Comment: Yes, then $S$ is a subbase of $T(S)$.
Comment: Yes, this is true. But what have you tried for prove it?
Comment: @rldias $S$ is by definition a subbase of the topology generated by $S$, so there is nothing to prove.
Comment: @drhab I was using a different definition of Subbase, which I added above.
Comment: I added the definition in the question; it is the second definition from wikipedia. So ultimately the question boiles down to establishing the equivalence of the two definitions.
Comment: I have edited my question and gave a verification of that. Also have a look at [this question](https://math.stackexchange.com/q/2254414/75923).
Answer: If $X$ is a set and $\mathcal S\subseteq\wp(X)$ then it always generates a topology in the sense that a smallest topology that contains $\mathcal S$ as subcollection exists.
This merely because the intersection of all topologies on $X$ that contain $\mathcal S$ is again a topology that contains $\mathcal S$.
In that situation $\mathcal S$ is by definition a subbase of the generated topology $\tau(\mathcal S)$.
So a proof that $S$ is a subbase of $\tau(\mathcal S)$ is actually not needed.
What can be proved is that in this situation the topology $\tau(\mathcal S)$ can be described as the collection of sets that can be written as a union of finite intersections of $\mathcal S$.
For that it is enough to show that the latest collection is indeed a topology that contains $\mathcal S$ and secondly that every topology that contains $\mathcal S$ as a subcollection will also contain this collection as a subcollection.

edit:
Let $\tau(\mathcal S)$ be the smallest topology that contains $\mathcal S$ as a subcollection, and let $\mathcal B$ denote the collection of finite intersections of elements of $\mathcal B$. Then it is obvious that $\mathcal B$ is closed under finite intersection. Further it contains the empty intersection which is by convention the set $X$, so $\mathcal B$ covers $X$. These two conditions are exactly what is needed to ensure that the set of all unions of subsets of $\mathcal B$ is a topology on $X$, and $\mathcal B$ will serve as a base for that topology. The sets of this topology will be the unions of elements of $\mathcal B$.
Now since $\tau(\mathcal S)$ is a topology that contains $\mathcal S$ it will also contain $\mathcal B$ as a subcollection and will also contain the unions of sets that are in $\mathcal B$ as elements. Then as smallest topology that contains $\mathcal S$ it must coincide with that topology.
As said the collection of finite intersections of $S$ serves as a base for it, so also according to the alternative defintion $\mathcal S$ is a subbase for $\tau(\mathcal S)$.


Programmatically setting video_embed_field URL

Question: I am trying to populate nodes programmatically from a feed (migrating earlier site to Drupal 9). So far I have managed to get everything else to move, but I can't figure out, how to set video_embed_field or rather the URL-value of the video. I found an example, but it caters just youtube, but there are also other video providers used.
I have tried the following ideas:
<code>$node->set("field_video", $videourl);

$node->field_video = ['input' => $videourl];

$node->field_video = ['value' => $videourl];
</code>
but so far nothing works.
Could anyone hint me to the right direction?
Answer: Actually, the last try in my choices seems to work after all.
<code> $node->field_video = ["value" => $item["video"]];
</code>
I must have done something dumb with my editor like not saving the changes...
Well, maybe someone else finds the info here...


Error 1118: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126

Question: Estou com este erro ao adicionar tabelas a minha base de dados.
Alguém me saber ajudar neste situação?
Pois os dados já estão como Barracuda.
Os campos que estou a adicionar são do Tipo: Text, Varchar(20), Longblob.
Comment: Pelo jeito que falou sua tabela tem realmente MUITOS campos. Depois de alterar os tipos das colunas, se o erro persistir, talvez valha a pena é separar em mais de uma tabela os seus dados. Se são tantos campos assim, provavelmente você não vai fazer uma consulta que envolva todos esses dados mesmo, pode até conseguir separar deixando juntos os campos que são buscados juntos.
Answer: Com base em Row size too large error in mysql create table query, no SO, texto tradução:

O tamanho total de todos os campos da tabela é mais do que o limite, 65535, é por isso que você está recebendo este erro.
  Você deve usar o tipo de texto em vez de varchar para cadeias longas. Substituir todos varchar (8000) com o texto, e ele deve funcionar.
  Ou, melhor ainda, usar tipos de dados apropriados, em vez de os "muito grande". Você realmente não precisa de 8000 caracteres para armazenar moeda, não é?

Tente seguir essa orientação e nos de um feedback, posteriormente, eu mesmo nunca passei por isso, mas, sempre tem a primeira vez.
Comment: Criar uma tabela tambem com muitos dados?
Mas em vez de ser varchar ser text correcto?
Comment: Sim deu.. penso que tava a dar erro por causa do barracuda
Comment: e tenho de alterar tudo o que tem varchar para text..
Comment: Boa pergunta @ChrisAdler, eu faria o seguinte criaria uma tabela teste e ia mudando para ver o que acontece, é o único jeito de você realmente tirar a sua dúvida, e com isso postar aqui o que aconteceu!
Comment: Isso, @ChrisAdler, como teste ... depois se vai observando o comportamento
Comment: Pronto testei uma tabela a parte substituir todos os varchar por text. Até ver resultou.
Comment: Deu certo @ChrisAdler ???


Angular Material fixed side bar header not a fixed

Question: Im tried to crate Angular material Fixed side nav , but I face some conflict on my projects, My issue is side bar header not fixed, i added content details and scrolls the content  then header is hide,
Stack blitz code here
how can I fix this issue
please help me to fix this one
Thanks.
My code
sidenav-fixed-example.html
 <mat-toolbar class="example-header">Header</mat-toolbar>

  <mat-sidenav-container class="example-container">
    <mat-sidenav #sidenav mode="side" opened class="example-sidenav">
    <mat-nav-list>

Home

Categories

Customers

Orders

Sales Items

Announcements

    </mat-nav-list>
    </mat-sidenav>

    <mat-sidenav-content >

     Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.Sprint from Zero to App
Hit the ground running with comprehensive, modern UI components that work across the web, mobile and desktop.
    </mat-sidenav-content>
  </mat-sidenav-container>

  <mat-toolbar class="example-footer">Footer</mat-toolbar>

.css
.example-container {
  position: absolute;
  top: 60px;
  bottom: 60px; height: 100%;
  left: 0;
  right: 0;
}

.example-sidenav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  background: rgba(255, 0, 0, 0.5);
}

.example-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.example-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

Answer: As stated by @Deepu in his answer, adding z-index:2 will make sure that the header remains on top of the sidenav.
However it will create an issue if the Links in sidenav are more than what it can accommodate. So calculating the height of the sidenav is a better choice along with setting the z-index.
To achieve it, just add height: calc(100% -120px); in .example-container class. I'm deducting 120px from 100% height because that's the sum of height of Header and height of footer.
Here is the working stackblitz demo and code link.
Answer: You have to set fixedInViewPort property.
[fixedInViewport]="true"
<mat-sidenav #sidenav mode="side" opened class="example-sidenav"  [fixedInViewport]="true" >

Comment: Hi, Thanks for the solution but i want to fixed header ,look my code https://stackblitz.com/edit/angular-khnxwz
Answer: Give z-index value as 2 for class example-header
.example-header {
 position: fixed;
 top: 0;
 left: 0;
 right: 0;
 z-index: 2;
}

stackblitz link


Sorting predicates

Question: I have this predicates,
date(YYYY,MM,DD).
immigrant(IdPerson,Date).

and I want to know the IdPerson of the most recent immigrant. I saw the solution and I got this:
most_recent_immigrant(IDPerson):-
    findall(immigrants1(Data,IdPerson), immigrant(IDPerson,Data), ListOfImmigrants).
    sort(ListOfImmigrants,List),
    last(List, immigrants1(Data,IDPerson)).

So, if I understood well this exercise, we need to sort by date, however how can the sort alone do that? Or do I need something else to do the job?
Comment: Please update the code in your problem statement to fix the issue with capitalized functors (you still have some in error in the code, such as `Immigrant(IDPerson, Data)`. An aside, if you use `setof/3` instead of `findall/3`, the result will already be sorted and you won't need a separate `sort/2`. Finally, sorting, in either case, is "smart" enough to know that, `a(X1,Y1)` is greater than `a(X2,Y2)` if `X1` > `X2`. So sorting a list of `immigrants1/2` will do what you want. Or, use `keysort/2` as @TudorBerariu indicates.
Comment: Put pairs in `ListOfImmigrants` instead of `immigrants1/2` terms and see if [`keysort/2`](http://www.swi-prolog.org/pldoc/doc_for?object=keysort/2) helps you.
Comment: Predicates cannot start with capital letters. Correct `Date/3` to `date/3` and `Immigrant/2` to `immigrant/2`.
Comment: Sorry for the typo. Already changing.
Answer: You could try something like this:
most_recent_immigrant( Immigrant ) :-
  findall( immigrant(X,D) , immigrant(X,D) , L ) ,
  predsort( immigrant_compare , L , [Immigrant|_] ) .

immigrant_compare( = , immigrant(_,X) , immigrant(_,X) ) :- X = Y .
immigrant_compare( < , immigrant(_,X) , immigrant(_,Y) ) :- X > Y .
immigrant_compare( > , immigrant(_,X) , immigrant(_,Y) ) :- X < Y .

But, since you might have multiple immigrants on any given date, I'd probably do something like this:
most_recent_immigrants( Immigrants ) :-                   % to find the most recently arrived immigrant(s)...
  setof( D , immigrant(_,D) , Ds ) ,                      % get the [ordered] set of dates
  last( M , Ds ) ,                                        % the last item is the most recent dates
  findall( immigrant(N,D) , immigrant(N,D) , Immigrants ) % find all the immigrants on the specified date
  .

Sorting predicates


React-Router How to access to useParams in custom private route

Question: How can I access useParams in my custom private route? Private route is written to check for authentication purposes. Right now I am getting undefined. Code:
interface RegistrationToken {
  registration_token: string;
}

import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { RootState } from '../redux/rootReducer';
import Loading from '../layout/Loading';

const PrivateRoute = ({ component: Component, ...rest }: any) => {
  const isAuthenticated: boolean = useSelector(
    (state: RootState) => state.user.isAuthenticated,
  );
  const isPending = useSelector((state: RootState) => state.user.isPending);
  const { registration_token } = useParams<RegistrationToken>();

  return (
    <Route
      {...rest}
      render={(props) => {
        if (!isAuthenticated && isPending) {
          return <Loading />;
        } else if (!isAuthenticated) {
          return <Redirect to="/signin" />;
        } else {
          return <Component {...props} />;
        }
      }}
    />
  );
};
export default PrivateRoute;

App.tsx:
<Switch>
        <PrivateRoute exact path='/:registration_token/sign-up' component={SignUp} />
</Switch>

Comment: what's undefined exactly? also your code doesn't have `useParams` anywhere
Comment: Sorry, I have updated. I will provide screenshot from debugger
Comment: spelling error? `registraction_token` ?
Comment: I find that in order to access, component should be child. But In that case how to make it private?
Comment: @azium I checked there is no spelling error
Comment: @azium If I change from `PrivateRoute` to default `Route`, it is possible to access
Comment: oh I see because the route is nested. screw params then just grab what you want using `location.pathname` ? useparams is just for convenience. if you wanted to you could wrap your PrivateRoute in a route but that seems wasteful
Comment: @azium I got `"/c123c123c/sign-up"`. Is it okay to parse it using string manipulation or there is better way?. I think I should create a code sandbox next time.
Comment: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/230282/discussion-between-jasurbek-nabijonov-and-azium).
Answer: It turns out that, in order to accesss you should wrap the component into <Route> otherwise, you cannot access with useParamas() because in my case it was undefined.
But there is solution, using useLocation()
in my private route:
const location = useLocation();
const registration_token = getRegistrationTokenFromLocation(location.pathname);

where getRegistrationTokenFromLocation. Logic is to parse path and get desired values in my case is localhost:3000/:registration_token/sign-up:
export function getRegistrationTokenFromLocation(pathName: string) {
  const firstRange = pathName.indexOf('/');
  const secondRange = pathName.indexOf('/', firstRange + 1);
  return pathName.slice(firstRange + 1, secondRange);
}


Javascript problem I'm trying to extract a string from a textarea

Question: This is my code:
        var input = document.getElementById("input").value;
        var string = input.toString();

        var m = new RegExp('Stipendio' + '(.*?)' + 'D', 'gm');
        var match = string.match(m);

I've to extract this string:
Stipendio + some text some text some text + D
Hi, I'm trying to extract a string from a textarea, but my var match is always null!
where am i wrong? In another script it works perfectly.
thanks
Comment: Your code is ok, maybe your input is wrong. Just a guess, is your element id really "input"?
Answer: I am assuming that your input string is Stipendio + some text some text some text + D, as you stated in your question.
Your RegExp is faulty (your two + were concatenating the strings, they were not actually part of the RegExp, and the g RegExp flag was not suitable here).
Your RegExp can be created in several ways:

new RegExp(/Stipendio \+ (.*?) \+ D/m);
new RegExp(/Stipendio \+ (.*?) \+ D/, "m");
new RegExp("Stipendio \\+ (.*?) \\+ D", "m"); (double escaping \\ needed)

You could also use it directly in .match() like this: string.match(/Stipendio \+ (.*?) \+ D/m)
hhh was right when saying that your use of .toString() is superfluous.
Altogether, your code could be:

const string = document.getElementById("input").value;
const m = new RegExp("Stipendio \\+ (.*?) \\+ D", "m");
const match_result = string.match(m);
console.log(match_result === null ? null : match_result[1]);
<textarea id="input">Stipendio + some text some text some text + D</textarea>


Degree of extension concerning p-adic numbers.

Question: We define
$$\mathbb{Z}[[X]]_{conti}:=\{t:\mathbb{R}_{\geq 0}\rightarrow \mathbb{Z}\ (t\in \mathbb{Z}^{\mathbb{R}_{\geq 0}})|\forall M\geq 0\ \{r\in\mathbb{R}_{\geq0}|r\leq M\land t(r)\neq0\}\ are \ finite\ sets\}.$$
Let $\mathbb{Q}_p^{ext}$ be $\mathbb{Z}((X))_{conti}/(X-p)$ for prime number $p$.
Then, what is the degree of extension of algebraic closure over $\mathbb{Q}_p^{ext}$?
Comment: It would be helpful if you could explain, in words, the context in which this arose, and your thoughts on it. Also, a verbal paraphrase of the peculiar condition on which coefficients can be non-zero would help. Also, from my present parsing of the situation, you are asking to take "real" powers of $p$, which are not likely to be algebraic over $\mathbb Q_p$... though, then, too, I wonder what you mean by $\mathbb Q_p^*$. Can you clarify? :)
Answer: I guess you meant $$A=\Bbb{Z}[[X]]_{conti}/(X-p),\qquad K=Frac(A)$$
The elements of $A$ are formal series $\sum_{j\ge 0} c_j p^{e_j}$ with $c_j\in 0\ldots p-1$ and $e_j\in \Bbb{R}_{\ge 0}$ strictly increasing and $e_j\to \infty$,
with addition and multiplication defined similarly to the ones on the $p$-adic series definition of $\Bbb{Z}_p$.
$K$ is the field of formal series $\sum_{j\ge 0} c_j p^{e_j}$ with $e_j$ allowed to include finitely many negative terms, ie. $K=A[p^{-1}]$.

This is the first time I see those rings, interesting for sure.

There is a natural non-archimedian valuation on $K$, namely $$v(\sum_{j\ge 0} c_j p^{e_j})=\inf_{c_j\ne 0} e_j$$
The valuation ring is $A$ and the residue field is $\Bbb{F}_p$, whose algebraic closure is an infinite extension.
So $[\overline{K}:K]$ is infinite.
Is there a chance that $K\otimes_{\Bbb{Q}_p[p^{1/\infty}]} \overline{\Bbb{Q}}_p$ is a field and algebraically closed? If it is algebraically closed then $[\overline{K}:K]$ would be countably infinite.


Jekyll YAML data file variables grouping

Question: I'm trying to group some variables in YAML but I can't display them in HTML.
I need to group the variables in a certain way. So, I have this in a data file (facultate.yml):
an1:
  - sem1:
    - materie: Example 1
      pdf: nimic
    - materie: Example 2
      pdf: nimic
  - sem2:
    - materie: Example 3
      pdf: nimic

an2:
  - sem1:
    - materie: Example 4
      pdf: nimic
  - sem2:
    - materie: Example 5
      pdf: nimic

And I have this in the HTML file:
---
layout: compress
---
<!DOCTYPE html>

PDF-uri facultate

{% assign nrani = 0 %}{% for an in site.data.facultate %}{% assign nrani = nrani | plus: 1 %}An: {{ nrani }} {% assign nrsem = 0 %}Sem:{% for sem in an %}{% assign nrsem = nrsem | plus: 1 %}{{ nrsem }} {% endfor %}
{% endfor %}

{% for item in sem %}{{ item.materie }}{% endfor %}

And I can't display the contents of materie or pdf variables from facultate.yml. I tried different approaches like nesting {% for item in sem %} inside the other for loops.
Answer: Try setting up you yml like this:
- an:
  - sem:
    - materie: Example 1
      pdf: nimic
    - materie: Example 2
      pdf: nimic
  - sem:
    - materie: Example 3
      pdf: nimic

- an:
  - sem:
    - materie: Example 4
      pdf: nimic
  - sem:
    - materie: Example 5
      pdf: nimic


Parse error: syntax error, unexpected 'echo' (T_ECHO) in /home/senseiofcp/public_html/aa.php on line 63

Question: Can any one help about this error?
Thanks.
        echo $baslik.' yazı eklendi. ID = '.$postid;

you can see previous lines below thanks.
     $postid=wp_insert_post( $my_post );
      add_post_meta($postid, 'target', $md5);
      add_post_meta($postid, 'psp_meta', 'a:19:{s:5:"title";s:13:"'.stripslashes($baslik).'";s:11:"description";s:15:"'. $HaberOzet.'";s:8:"keywords";s:27:"'. $etiket.'";s:13:"focus_keyword";s:0:"";s:17:"facebook_isactive";s:2:"no";s:14:"facebook_titlu";s:0:"";s:13:"facebook_desc";s:0:"";s:14:"facebook_image";s:0:"";s:23:"facebook_opengraph_type";s:7:"article";s:12:"robots_index";s:7:"default";s:13:"robots_follow";s:7:"default";s:8:"priority";s:1:"-";s:9:"canonical";s:0:"";s:21:"psp_twc_post_cardtype";s:7:"summary";s:20:"psp_twc_app_isactive";s:2:"no";s:22:"psp_twc_post_thumbsize";s:7:"120x120";s:13:"psp_twc_title";s:0:"";s:19:"psp_twc_description";s:0:"";s:13:"psp_twc_image";s:0:"";}')

      echo $baslik.' yazı eklendi. ID = '.$postid;
}else{
  echo 'DAHA ÖNCE EKLENMİŠHABER';
}

Comment: What is __before__ this line?
Comment: As u_mulder said, make sure to check the previous line - sometimes this error occurs because you are missing a **semicolon** so the interpreter doesn't know that the previous line ended
Comment: @Yasin: see this question, you have the same issue the asker did. You need to install the mbstring extension, enable it during compilation, or ask your host to do the same: http://stackoverflow.com/questions/17204437/fatal-error-call-to-undefined-function-mb-detect-encoding
Answer: You had no semicolon at the end of the line before it, the massive call to add_post_meta(...)
The correct code would be:
     $postid=wp_insert_post( $my_post );
      add_post_meta($postid, 'target', $md5);
      add_post_meta($postid, 'psp_meta', 'a:19:{s:5:"title";s:13:"'.stripslashes($baslik).'";s:11:"description";s:15:"'. $HaberOzet.'";s:8:"keywords";s:27:"'. $etiket.'";s:13:"focus_keyword";s:0:"";s:17:"facebook_isactive";s:2:"no";s:14:"facebook_titlu";s:0:"";s:13:"facebook_desc";s:0:"";s:14:"facebook_image";s:0:"";s:23:"facebook_opengraph_type";s:7:"article";s:12:"robots_index";s:7:"default";s:13:"robots_follow";s:7:"default";s:8:"priority";s:1:"-";s:9:"canonical";s:0:"";s:21:"psp_twc_post_cardtype";s:7:"summary";s:20:"psp_twc_app_isactive";s:2:"no";s:22:"psp_twc_post_thumbsize";s:7:"120x120";s:13:"psp_twc_title";s:0:"";s:19:"psp_twc_description";s:0:"";s:13:"psp_twc_image";s:0:"";}');

      echo $baslik.' yazı eklendi. ID = '.$postid;
}else{
  echo 'DAHA ÖNCE EKLENMİŠHABER';
}

PS: unless you know that stripslashes($baslik) will always be 13 characters long, and that $HaberOzet will always be 15 characters long, your code may be prone to bugs.


Does the addition of two matrices yield the the addition of the corresponding eigenvalues?

Question: Assume  $Z,B \in C^{2 \times 2}$ and that $c \in C$ is an eigenvalue of $Z$ and $u \in C$ is an eigenvalue of $B$. Then $c+u$ is an eigenvalue of $Z+B$.
Is this statement true or false?
It seems to be false, since the eigenvalues are determined by solving the characteristic equation.
Comment: Try some random matrices.
Comment: clearly false as you actually eliminate entire eigenvalues. It is impossible to determine the eigenvalues for Z+B from Z and B

In short, adding matrices together will seriously change the geometry of their corresponding linear map's linear subspaces.
Comment: Let $Z$ be the matrix with $1$ in the upper-left corner and zero elsewhere and $B$ the matrix with $1$ in the lower right corner and zero elsewhere. What so you observe?
Comment: This is almost ever false.
Answer: Let $Z=diag(1,-1)$ and $B=diag(0,1)$, it is possible to form $4$ distinct sums but $Z+B$ only have two eigenvalues.
Hence the statement is false.
Answer: Maybe if the two matrices were diagonal in respect with the same basis. Then the matrix which is the addition of these two matrices will have its Eigen values as the addition of the two earlier matrices.
Comment: It's true that all the EV of the new matrix are sums of EVs of the old ones, but not each sum is necessarily an EV. See the other answer.


What is the connection between equivalence relations and groups?

Question: I have taken a group theory course, and we initially learned about equivalence relations. But I do not see the connection between equivalence relations and groups in group theory.  Can someone please explain to me why they are related?
Comment: The main usage is in defining the quotient group.
Answer: You know that the set of non-zero real  numbers form a group under multiplication.
You also know from high school the following rules about sign, for multiplication :
$$+\times + = +;\quad +\times -= -\times+= -;\quad -\times - = +  $$
One can restate this as $\{-, +\}$ forms a group (of order 2) with the above rules for multiplication.  (with $+$ as the identity element).
Go back to the original group of non-zero numbers, and consider the equivalence relation that puts all positive numbers in one class and the negative numbers in another class; give names to these classes  (symbolically) as $+$ and $-$. Now multiplication of real numbers leads to multiplication of the equivalence classes. The rules are already stated.
One looks for equivalence classes in groups such that  group operation on them leads consistently to group operation of the equivalence classes.
The equivalence classes given by cosets of a normal subgroups are precisely such ones.
Answer: Two application of equivalence relations to group theory:
1) Being in the same left-sided coset of a subgroup is an equivalence relation.
2)  Belonging to the same orbit under a group action is an equivalence relation.  If the group acts on itself by conjugation, the equivalence classes are called conjugacy classes and play a role in linear representations of groups (see Serre's Linear representations of finite groups).
Comment: Of course, $(1)$ is a special case of $(2)$...
Comment: You can drop *normal* in case 1).
Comment: Will do, thanks.  (Haven't dealt with this in a while.)


iptables: trying to block port 53 but not working

Question: I'm messing around with IP tables and I'm trying to do the following:
I have several hosts on the same network: 192.168.1.0/24. The DNS server is 192.168.1.1.
I'm trying to prevent all the hosts from making any DNS requests, either to 192.168.1.1 or to the internet (i.e. 184.108.40.206 Google DNS). I tried the following:
iptables -A OUTPUT -d 192.168.1.1 -p udp --dport 53 -j DROP
iptables -A INPUT -d 192.168.1.1 -p udp --dport 53 -j DROP
iptables -A FORWARD -d 192.168.1.1 -p udp --dport 53 -j DROP
iptables -A OUTPUT -d 192.168.1.0/24 -p udp --dport 53 -j DROP
iptables -A INPUT -d 192.168.1.0/24 -p udp --dport 53 -j DROP
iptables -A FORWARD -d 192.168.1.0/24 -p udp --dport 53 -j DROP
iptables -A OUTPUT -d 192.168.1.1 -p tcp --dport 53 -j DROP
iptables -A INPUT -d 192.168.1.1 -p tcp --dport 53 -j DROP
iptables -A FORWARD -d 192.168.1.1 -p tcp --dport 53 -j DROP
iptables -A OUTPUT -d 192.168.1.0/24 -p tcp --dport 53 -j DROP
iptables -A INPUT -d 192.168.1.0/24 -p tcp --dport 53 -j DROP
iptables -A FORWARD -d 192.168.1.0/24 -p tcp --dport 53 -j DROP

But none of them seem to work. Any ideas?
Comment: You'll need to post your entire iptables ruleset, not just random things you tried. Please edit your question and include the output of `iptables-save`.
Comment: There is nothing in iptables. I ran iptables -F before issuing the commands.
Comment: Are the other hosts on the network routing through this host? If you do a `tcpdump`, can you see the DNS traffic being passed?
Comment: Yes, if i run tcpdump on this host, they pass through it.
Comment: Are you sure they go through it?  They'd all be in the same collision domain as the DNS server so would not need a router at all.  You would be able to see arps between them even if the packets aren't passing through the firewall system
Comment: We also need a network diagram.   Does 192.168.1.1 act both as firewall and router, or do you have 2 seperate boxes?   Also, we may need to see the IPTABLES rules - I suspect there is a problem with ordering - please provide the output of iptables -vnL
Answer: All you need is to add one rule (as shown below) to the OUTPUT table.
iptables -A OUTPUT -d 220.127.116.11 -p udp --dport 53 -j DROP

Here is a example where I tried to resolve my domain with and without the rule to illustrate it.
arul@cheetah:~$ dig +short selvans.net @126.96.36.199
22.214.171.124
arul@cheetah:~$ sudo iptables -F
arul@cheetah:~$ sudo iptables -A OUTPUT -d 126.96.36.199 -p udp --dport 53 -j DROP
arul@cheetah:~$ dig +short selvans.net @220.127.116.11
;; connection timed out; no servers could be reached
arul@cheetah:~$ sudo iptables -F
arul@cheetah:~$ dig +short selvans.net @188.8.131.52
22.214.171.124

Comment: Sorry, this is wrong - the OUTPUT table does not work with packets which are traversing through it - only traffic originating from the address - This would have worked if you are testing from a local machine, but not a router - which requires both output (for the router to be blocked) and forwarding (for everything else) chains to be modified
Comment: Actually, I don't think this is wrong. This is actually the easiest way to accomplish the intent of the OP without going through networking changes as explained by @mfarver
Comment: This assumes that all the hosts are Linux boxes - and that the OP controls all the hosts.  If he did, why would he need to ask this.  Also, using "-A" rather then "-I" would mean the rule is appended, and probably not seen - for the same reason the OP's rules probably don't work - Centos - and almost certainly others have an explicit rule blocking traffic, rather then rely on the default.  Further it does not block port 53 traffic to 192.168.1.1 as requested by the OP - and the equivalent rule for that host fails as the OP has pretty much stated.
Answer: If the DNS server and the hosts are on the same subnet (192.168.1.0/24) it is extremely unlikely that the packets traverse the machine that you are setting IPtables rules on.  Devices on the same subnet normally send packets directly without the use of a router.
You will need to either set the IPtables output rule on all devices, or you will need to restructure the network by placing either the clients or the DNS server) on separate subnets with the iptables machine in between.
Once you get the packets crossing the iptables machine this rule will work:
iptables -A FORWARD -d 192.168.1.1 -p udp --dport 53 -j DROP

or you can set this rule on every client machine:
iptables -A OUTPUT -d 192.168.1.1 -p udp --dport 53 -j DROP


Endereços de memória

Question: Minha arquitetura é de 32 bits então meus endereços de memoria são de 32 bits? pois estava usando um debug vendo uns códigos assembly e chegou em uma parte onde tinha um loop , e ele ia pegando byte por byte de uma string e cada caractere da string tinha um endereço para ela exemplo:
<code>0x78650 -> A
0x78651 -> B
</code>
Como assim os tamanho do meu endereço então é 1 byte ou 4 bytes?
Comment: resposta resolveu seu problema? Ache que pode aceitá-la? Veja o [tour].
Answer: São dois conceitos completamente diferentes. O endereço é 4 bytes (em arquitetura 32 bits). O tamanho do dado pode variar de acordo com seu tipo. Em geral 1 é usado para representar um caractere, mas isto também pode variar. Um caractere é algo abstrato e pode ser definido com vários tamanhos e formas de compor.
Fazendo uma analogia, endereço é a localização de onde fica a casa, o dado é a casa. Sempre tem o mesmo padrão em uma cidade para dizer qual é o endereço, mas as casas tem vários tamanhos e formatos.

Endereços de memória


ad hoc query tool patterns

Question: I'm looking for common patterns of implementing ad-hoc querying capabilites graphically. I've looked at SQL query builders in Access and TOAD, but I'm interested if anyone is aware of products that have build such a tool against a domain specific data warehouse (e.g. clinical databases).
Thanks,
Answer: Beyond Tableau (mentioned by Arthur), I would suggest either Qlikview or Spotfire, both of which allow for ad-hoc graphical querying in in-memory databases.  These applications are much more powerful than something like Crystal or Jasper reports.
Answer: I have no specific answer but there are reporting tools that help you do stuff that I think you might be interested in.
One pay one that I tried out myself and liked quiet a bit was Tableau  It is pay software and the server can be expensive, but I liked the desktop app.  You will have to know enough database to figure out how to draw data out of it.  Once that is done though you can reuse it.  Once you draw out the dataset though you can 'play' with it graphically.
You can get into more complicated Reporting tools like Crystal Reports, Jasper Report and I think IBM has something that deals with 'Cubes' or whatever.  You can look up all that by looking into Business Intelligence software.  (I hate that name)
The problem with having domain specific stuff is that databases can be different.  And even if you use a common vendor tool then the the query tool would have to be built specific to the db.
So maybe this doesn't answer your direct question but hope it is a little helpful.

ad hoc query tool patterns


Webgl Vector Array

Question: I am trying to make A cube of triangles using JavaScript and Webgl. The cube will use face edge vertex structure using arrays , but when I use arrays there is nothing drawn to screen.
This how I declare the array.
function Vector(x,y,z){
this.x = x;
this.y = y;
this.z = z;
}

var V = new Array;
V[0] = new Vector(0.0,  1.0,  0.0);
V[1] = new Vector(-1.0, -1.0,  0.0);
V[2] = new Vector(1.0, -1.0,  0.0);

function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer);
    var vertices = [
        V[0],
        V[1],
        V[2]
    ];
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
    triangleVertexPositionBuffer.itemSize = 1;
    triangleVertexPositionBuffer.numItems = 3;

I am not sure why it doesn't draw to screen if anyone can help it would be appreciated.
Comment: Is that all your code? Have you setup the GL context correctly? Can you create a jsFiddle so we can see all of your code?
Comment: I have never used jsFiddle but here is a link with my code on jsFiddle http://jsfiddle.net/J8Wkg/1/
Answer: The problem is the following line:
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);

new Float32Array(vertices) is returning [NaN, NaN, NaN]. This is because the Float32Array contructor expects an array of Numbers and not an array of Vectors.
You'll need to pass new Float32Array() a single one dimensional array of Numbers
If you want to fix it you'll have to write a function to convert your array of Vectors into a Float32Array. Something like this:
function vectorsToFloatArray(vertices) {
    var numbers = [];

    for(var i = 0; i < vertices.length; i++) {
        numbers.push(vertices[i].x);
        numbers.push(vertices[i].y);
        numbers.push(vertices[i].z);
    }

    return new Float32Array(numbers);
}

And remember to update the gl.bufferData() and item size:
    gl.bufferData(gl.ARRAY_BUFFER, vectorsToFloatArray(vertices), gl.STATIC_DRAW);
    triangleVertexPositionBuffer.itemSize = 3;

Comment: Thanks for the help I now have it working do you know how to make an array that will take two vectors E[0] = [V[0], V[1]]; and then use that to draw to the screen

Webgl Vector Array


Como sincronizar escrita de arquivo

Question: Olá, estou desenvolvendo um aplicação ASP clássico e preciso gravar um JSON num arquivo data.json. Problema é que vários usuários poderão requisitar a gravação neste arquivo, gostaria de saber qual melhor solução para este problema? Queria que evitasse o erro que dois usuários requisitem a gravação no arquivo ao mesmo tempo. Sei que é difícil de ocorrer mas não é impossível. Então haveria alguma maneira de sincronizar a escrita evitando que vários usuários requisitem a escrita ao mesmo tempo fazendo um de cada vez colocando-os em uma fila?
Eis o código:
dim filesys, filetxt

Dim path,pastalocal
pastalocal = split(Request.ServerVariables("script_name"),"/")
path = Server.MapPath("/"&pastalocal(1))

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim lineData
Set fso = Server.CreateObject("Scripting.FileSystemObject")
set fs = fso.OpenTextFile(path&"\data2.json", ForReading, true)
Do Until fs.AtEndOfStream
    lineData = fs.ReadLine
Loop

fs.close: set fs = nothing

Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile(path&"\data2.json", ForWriting, True)
If lineData = "" Then
    filetxt.Write(Request.Form("dataJson"))
Else
    filetxt.Write(lineData&","&Request.Form("dataJson"))
End If
filetxt.Close

Comment: Apresente o código de como você está abrindo o arquivo para escrita
Comment: Já inclui o código @LeandroAngelo
Answer: Olá,
A partir do momento que fazes este código:
Set filetxt = filesys.OpenTextFile(path&"\data2.json", ForWriting, True)

qualquer outra tentativa de fazer outra abertura para escrita no ficheiro vai dar erro, para poderes abrir novamente para escrita tens de fazer
filetxt.Close

se colocares algo deste género :
on error goto erroAbertura
Set filetxt = filesys.OpenTextFile(path&"\data2.json", ForWriting, True)

Assim parece-me que resolve o teu problema

Como sincronizar escrita de arquivo


Limpar Form1 e adicionar novas coisas, como o sistema de rooms do game maker

Question: Opa! Galera, como eu faço pra limpar um form e colocar novos elementos dentro? Por exemplo: Algo parecido com uma tela de instalação quando clicamos em Next.
Edit1:
Por exemplo, essa tela:

Virar essa tela ao clicar em algum ícone de boneco:

De maneira que uma não fique em cima da outra, simplesmente se alternem.
Comment: Por favor, seja mais específico. Limpar um form é `form.Components.Clear()`, mas não parece que é isso você quer...
Comment: Vou editar e mostrar um projeto que eu fiz no game maker
Comment: Prontinho, fiz a edição.
Comment: Crie um tabcontrol e vá alterando de abas ao clicar, ou então crie vários panels e vá mudando a visibilidade. São as únicas formas.
Comment: Porém nenhuma das duas formas é parecida com oque eu quero, o TabControl até seria se tivesse uma forma de retirar as abas que ficam em cima
Comment: E quem disse que não tem como? **=)** Vou criar um exemplo pra você.
Comment: Beleza obrigado aew, fico no aguardo
Answer: Você pode simular isso usando um TabControl.

Mude as propriedades ItemSize e SizeMode do TabControl
tabControl.ItemSize = new Size(0, 1);
tabControl.SizeMode = TabSizeMode.Fixed;

Também é possível mudar usando a janela Properties no design do form.
Provavelmente isso vai deixar uma bordinha no canto do TabControl, você pode mudar a propriedade Appearance para fazer essa bordinha desaparecer.
tabControl.Appearance = TabAppearance.FlatButtons;

Crie os eventos dos botões mudando a TabPage selecionada.
private void btAnterior_Click(object sender, EventArgs e)
{
    tabControl.SelectedTab = tabPage1;
}

private void bProximo_Click(object sender, EventArgs e)
{
    tabControl.SelectedTab = tabPage2;
}

Observação: você pode usar a janela document outline (Ctrl + W, U) para trocar a aba vísivel em tempo de design.
Comment: Mas mesmo assim permanece as abas, elas eram pra ser invisíveis
Comment: Então você fez algo errado, porque pra mim não aparece nada. Tem como mostrar um print?
Comment: https://scontent.fcpv1-1.fna.fbcdn.net/v/t35.0-12/13589097_1005138562937900_351858082_o.png?oh=5196e21e5b4f1c7ee2fa24f91a54ddea&oe=57857B74
Comment: Você alterou as propriedades que eu falei por onde?
Comment: Pela tela de propriedades mesmo, mas oque você fez foi esconder, eu quero realmente que não exista entendeu?
Comment: Como assim que **não exista**? Elas não vão aparecer, isso é suficiente. Não tem outra forma de fazer, jovem.
Comment: Ow! Aprendi a usar o Panel direitinho! Resolvi meu problema :D
Comment: Graças a você <3


Find $\frac{d}{dx} f^{-1}(x)$ at $x=1$ if $f(x) = e^x +x$

Question: I realize that we don't have to find the inverse explicity.
Do I set $f(x) = e^x +x$ equal to $1$ and find the formula for $x$ and differentiate?
Comment: [This](http://www.sosmath.com/calculus/diff/der08/der08.html) might help.
Answer: Let $g(t)$ be the inverse function. This function exists, since $f$ is increasing. We want $g'(1)$. Note that since $f(0)=1$, we have $g(1)=0$.
We use the fact that
$$f(g(x))=x.$$
Differentiate, using the Chain Rule. We have
$$g'(x)f'(g(x))=1.$$
Now put $x=0$.
Remark: The above reasoning can be used to find a general formula for the derivative of an inverse function. We chose to go through the full derivation. Note that there is a gap in the proof: we did not show that the derivative of the inverse function exists.
Answer: HINT: $$\frac{d}{dx}f^{-1}(x)=\frac1{f'(f^{-1}(x))}$$ You can also use implicit differentiation but this is a useful formula to know.
Answer: Let $y=f(x)=e^x+x$.
Then $\frac{dy}{dx}=e^x+1=\textrm{derivative of f wrt x}$.
Now, use the fact that $$\frac{dx}{dy} \equiv \frac{1}{\left(\frac{dy}{dx} \right)},$$ where $\frac{dx}{dy}$ is the derivative of $f^{-1}$ wrt $x$.
Answer: Here's my hint
$$f(x)=e^x+x\rightarrow f(f^{-1}(x)) = e^{f^{-1}(x)}+f^{-1}(x)$$
$$x = e^{f^{-1}(x)}+f^{-1}(x)$$


How can I query by node title?

Question: In Drupal 7 I had this code to query node fields and its respective title:
$query = db_select('node', 'n');
$query->join('field_data_field_internal_institute_paper_i', 'iipi', 'n.nid = iipi.entity_id');
$query->fields('n', array('nid'));
// some other conditions
$query->fields('n', array('title')); // <- working fine for D7
$result = $query->execute()->fetchall();

which was working fine. I know imported to D9 and I need to rewrite this accordingly:
$db = \Drupal::database();
$query = $db->select('node', 'n');
$query->join('node_revision__field_internal_institute_paper_i', 'iipi', 'n.nid = iipi.entity_id');
$query->fields('n', array('nid'));
// some other conditions
$query->fields('n', array('title')); //<- not working for D9
$result = $query->execute()->fetchall();

for some reason array('title') isn't a field anymore as seen above. How can I get the title here?
Comment: I think you need to provide a little bit more detail, because that query should work fine in Drupal 9. Do you have an error that you can share? Or are you just not getting any results back? I also don't see why you are joining the revision table without a `WHERE` condition, so if not needed, just grab the titles from the `node_field_data` table as you say.
Comment: @baikho I managed to make this work via `node_field_data`. This was different in D7 as I mentioned in my commend above.
Answer: This works fine in Drupal 9 for titles only from the node_field_data table:
$ drush php
Psy Shell v0.10.4 (PHP 7.4.13 — cli) by Justin Hileman
>>> $db = \Drupal::database();
=> Drupal\Core\Database\Driver\mysql\Connection {#767
     +"_serviceId": "database",
   }
>>> $query = $db->select('node_field_data', 'n');
=> Drupal\Core\Database\Query\Select {#4281}
>>> $query->fields('n', ['title']);
=> Drupal\Core\Database\Query\Select {#4281}
>>> $result = $query->execute()->fetchall();
=> [
     {#4254
       +"title": "Foo",
     },
     {#4257
       +"title": "Bar",
     },
   ]

Or for only an array of titles use fetchCol():
>>> $result = $query->execute()->fetchCol();
=> [
     "Foo",
     "Bar",
   ]

Node Field Data table:
mysql> describe node_field_data;
+-------------------------------+------------------+------+-----+---------+-------+
| Field                         | Type             | Null | Key | Default | Extra |
+-------------------------------+------------------+------+-----+---------+-------+
| nid                           | int(10) unsigned | NO   | PRI | NULL    |       |
| vid                           | int(10) unsigned | NO   | MUL | NULL    |       |
| type                          | varchar(32)      | NO   | MUL | NULL    |       |
| langcode                      | varchar(12)      | NO   | PRI | NULL    |       |
| status                        | tinyint(4)       | NO   | MUL | NULL    |       |
| uid                           | int(10) unsigned | NO   | MUL | NULL    |       |
| title                         | varchar(255)     | NO   | MUL | NULL    |       |
| created                       | int(11)          | NO   | MUL | NULL    |       |
| changed                       | int(11)          | NO   | MUL | NULL    |       |
| promote                       | tinyint(4)       | NO   | MUL | NULL    |       |
| sticky                        | tinyint(4)       | NO   |     | NULL    |       |
| default_langcode              | tinyint(4)       | NO   |     | NULL    |       |
| revision_translation_affected | tinyint(4)       | YES  |     | NULL    |       |
+-------------------------------+------------------+------+-----+---------+-------+
13 rows in set (0.00 sec)

Comment: Thanks for the answer. I have found this but it will be helpful for other people to know. I didn't know that field has changed. In D7 the `title` was on the node field.
Answer: If you want to get a node entity, you can use the loadByProperties method in the node storage.
  $nodes = \Drupal::entityTypeManager()
      ->getStorage('node')
      ->loadByProperties(['title' => $title]);
    // Load the first node returned from the database.
    $node = reset($nodes);

Comment: Thanks for your commend. I want to do this in a DB query, not via entityTypeManager.

How can I query by node title?


Fetch node value in Rules

Question: I am trying to get option value from node in drupal rules. I have a form-group which consists of fields. The field in question is a select list - it consists of different names, with every option there is an email. They are stored in this way:
<code>0|NONE
email@example.com|EXAMPLE
firstname.lastname@example.com|EXAMPLE2
</code>
So option value for EXAMPLE is firstname.lastname@example.com
Let us call this field operator.
So I want to send/get email from this node
What I have atm in rules is
    [node:field-operator:value]
which does not work.
    [node:field-operator]
for example just fetches the name e.g EXAMPLE.
 I have tried tons of ways by now but I know that solution must be simple, it's just my first time using drupal and been looking for an answer for hours.
Thank you for your help.
Comment: You may have a bit more luck searching for an answer if you refer to the email storage as a 'key' because that is the standard term for it, each of those items will be stored in an array with the text on the left of the pipe forming the key and the text on the right forming the value.
You may even find there is a token for [node:field-operator:key]
Answer: Make sure you already have the Token module  installed in your site. The Token module.

on your site go to /admin/config/workflow/rules
Select send an email on the action section of the rule
Click switch to data selection
Click DATA SELECTORS and find your select list Eg:(node:field-select-list) token and add it into To box.

Hope it help
Comment: Thank you everyone, tried all solutions but token module worked rightaway. Can't add multiple values with data selector but it sends the email now!
Comment: @Dreamscaper Glad to know that your problem is solved now, could it be possible to accept the suggested solution.
Answer: I duplicated your scenario and also could not get the key to be used in rules. There is no token for :key.
However, if you go to the display settings for you content type, you can change the format of your list text field to 'Key' (by default it is Default). Now your rule will use the key value of the pair, instead of the value. This means that when viewing said node it will also display the key (ie. email) part of your field, and only when editing or adding said content will the list box use the value part of the pair.

Fetch node value in Rules


DNS server not resolving github page properly after two days

Question: I had GitHub pages set up at mypage.github.io. I changed it to mynewpage.github.io with a new account and repository.
I deleted the old CNAME and configured another CNAME in DNSimple to point to the new location:
CNAME    www.example.com    mynewpage.github.io

Now when I run dig www.example.com in the terminal it returns
;; ANSWER SECTION:
www.example.com.        3600    IN  CNAME   mynewpage.github.io.

But when I visit the domain www.example.com directly in the browser it still shows the old page at mypage.github.io instead of the page at mynewpage.github.io.
I thought it might be the ISP caching or something, but it has persisted for two days now and on different machines in different locations.  What needs to change?
Comment: Do you have an actual *reason* for obscuring your domain name? You might get quicker and better results if you include it. See also http://meta.serverfault.com/a/6063.
Comment: did you try interrogating a DNS (e.g. with `host`, `dig` or `nslookup`) to see what it actually returns? using a browser to test a DNS leaves many doubts about what can be actually wrong.
Comment: Have you ensured everything in the DNS is okay? intodns.com is generally a good place to look to see if things are broken or not.

It's a lot easier to troubleshoot with the actual domain, since the problem is specific to your configuration. If you can't find an error through intodns, have you tried it from a proxy? If not, do you want to share your domain so we can look at it as well?
Comment: Is it possible that github hasn't properly updated the change?
Comment: @Ale yes I did a `dig` and it returns the new CNAME record, see the middle of the question above.  Edit: `host`, `dig`, and `nslookup` all point to the new CNAME record (`mynewpage.github.io`)
Comment: Did you try then using another browser, or completely clearing the browser's cache?
Comment: @Ale, yes I have tried it in separate browsers, separate machines, and through a proxy. No difference; everything shows old page...
Comment: @tyler If the DNS entry is ok and you observe the problem from multiple machines, the issue might indeed be on github. Did you double check the config on github side? (see https://help.github.com/articles/setting-up-a-custom-domain-with-github-pages/)
Comment: @Ale yes it looks like the problem is likely that I had to delete the previous CNAME file in the old repository... go figure.  https://help.github.com/articles/adding-a-cname-file-to-your-repository/.  If you want to write up as an answer I'll accept it.  Thanks for your help.
Answer: As the information on the DNS seems to be ok (see output from dig), and the issue is visible from different machines, the problem has to be on the other side, i.e., on GitHub. Make sure that the configuration on that side is correct (see https://help.github.com/articles/setting-up-a-custom-domain-with-github-pages/ for info about how to correctly configure a custom domain name).


Botão com texto caixa alta no Android API < 14

Question: Vemos que no lançamento do Android 5.0 Lolipop veio Material Design que por sim mudou muita coisa no Android e junto com isso, o componente de Dialogs que por padrão vem com o botão com texto caixa alta como mostra abaixo na imagem:

Porém tenho uma aplicação com Android 2.3.3 Gingerbrend, que eu gostaria customizar para ficar próximo ao material. Aí caí nesta questão do texto em caixa alta (UPPERCASE). Vi que existe o android:textAllCaps que neste caso só pode ser usado a partir da API 14.  Quando eu inseri esta propriedade ao meu botão apareceu a seguinte alerta:

Attribute "textAllCaps" is only used in API level 14 and higher
  (current min is 10)

Existe algum método que substitui esta propriedade?
Answer: O ideal é fazer como o colega @ramaral sugeriu e usar o AppCompatButton, já que ele faz parte de uma biblioteca oficial, testada, depurada etc. Mas, para quem tem alguma restrição quanto ao uso das bibliotecas Support, uma solução simples é criar uma Custom View que herda de Button e acrescenta o comportamento que você quer. Um exemplo de como ficaria o código da Custom View:
package com.minhaempresa.ui.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;

public class AllCapsButton extends Button {

    public AllCapsButton(Context context) {
        super(context);
    }

    public AllCapsButton(Context context, AttributeSet attrs) {
        super(context, attrs);

    }

    public AllCapsButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setText(CharSequence text, BufferType type) {
        super.setText(text.toString().toUpperCase(), type);
    }

}

Com isso, basta, no XML, em vez de Button, usar com.minhaempresa.ui.customview.AllCapsButton. Por exemplo:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.minhaempresa.ui.customview.MainActivity">

    <com.minhaempresa.ui.customview.AllCapsButton
        android:id="@+id/botao"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Texto que era minúsculo"/>

</RelativeLayout>

Resultado:

Testado no Android 2.3.3 e no 5.0
Comment: @ramaral Eu tinha feito primeiro usando getText() ai depois alterei.
Comment: @ramaral Vivendo, apanhando e aprendendo! Obrigado aí por compartilhar suas experiências.
Comment: @ramaral Ah, blz. :)
Comment: Blz, foi dessa forma que fiz hoje de manhã! Abraços.
Comment: Eu tinha pensado em fazer o override do `getText()` mas o `setText()` também serve.
Comment: @ramaral Nos testes que eu fiz, não consegui o resultado com o `getText`, daí fui pro `setText` e funcionou. Não parece certo alterar o valor real que está lá só para exibir de forma diferente, mas foi o jeito. :/
Comment: Eu testei e funcionou, tanto em xml como em java. `return super.getText().toString().toUpperCase();`
Comment: Em qual versão? Você tirou as referências ao tema `AppCompat` no AppTheme do styles.xml? Com o tema herdando de `AppCompat`, ele estava deixando em maiúsculo aqui mesmo sem fazer nada.
Comment: Tem razão, a forma como testei não garante pois foi na API23.
Comment: @PabloAlmeida eu só fiz uma pequena alteração, dentro da view. Criei uma função `setTextAllCaps(String str)`, para não mexer em todos os `setText`... ta funciando beleza.
Comment: @CleidimarViana Não entendi. Onde você chama esse `setTextAllCaps`?
Comment: @PabloAlmeida ali no `public void setText` default onde você chama o `super.setText` , eu acabei não utilizando. Eu criei um novo método chamdao `setTextAllCaps` onde passo a mesma configuração `text.toString().toUpperCase()`. Está funcionando beleza, relaxa! =)
Comment: @CleidimarViana OK. É que eu pensei que talvez você tivesse cometendo o mesmo erro que eu na primeira solução que tentei, que era criar um método parecido com o seu e chamá-lo em todos os construtores em vez de sobrepor o `setText`. Isso funciona para o texto definido via XML, mas se você fizer botao.setText no Java, ele não funciona mais (porque o botão já foi construído e o construtor não é mais chamado).
Answer: Use o AppCompatButton.
Acrescente
xmlns:app="http://schemas.android.com/apk/res-auto"

ao layout raíz
e declare o botão assim:
<android.support.v7.widget.AppCompatButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:textAllCaps="true"
    android:text="uppercase"/>

Comment: À mão já está, mas não queria permanecer assim porque as vezes eu uso o a mesma chave da string em outras situações, daí então não é legal. Mas vou ver aqui o uso da biblioteca, caso o pessoal não concorde,  eu crio varias strings com uppercase e sem. Mas obrigado pela ajuda.
Comment: @CleidimarViana Você pode criar uma CustomView que extende Button, e faz esse trabalho de deixar em caixa alta na hora de exibir.
Comment: @PabloAlmeida Boa ideia até porque é fácil de implementar. Coloque uma resposta.
Comment: @ramaral Vou colocar assim que sobrarem uns minutos aqui.
Comment: @ramaral tem que lembrar que  temos que colocar o suporte à API em dependencies  `compile 'com.android.support:appcompat-v7:25.0.0'`
Comment: Neste caso eu precisaria da biblioteca `android.support.v7` que hoje a gente não usa (ainda). Este app que estou trabalhando foi finalizado em no inicio de 2013, então tudo ainda adaptado para api 10, nada de material, nada de padrão, tudo estilo anos 90, estilo aquelas aquelas fontes do word 2003 sabe?!  (hehe) Teria alguma outra forma ou vou ter que baixar a biblioteca?
Comment: Onde estão os textos dos botões? Se estão na declaração do botão, adicionar o atributo ou mudar o texto à mão para maiúsculas dá o mesmo trabalho. Se estão num "resource" o trabalho de os alterar é até menor.
Comment: é um app de uso interno da empresa, e neste projeto eu cheguei e peguei o bonde andando, e andando faz tempo, no entanto eu até ja sugeri a gente fazer uma melhoria, considerando que hoje a quantidade que usa Android 2.3.3 é minima. Eu até criei um serviço para obter informações do dispositivo na hora da instalação, porém ainda não foi para produção. Com isso a gente terá uma estatística de uso, assim a gente poderá tomar alguma decisão de melhoria.
Comment: Estão no `resource`. Inglês, português e chinês. Até vamos disponibilizar para a Africa, mas vão continuar usando como Inglês lá.
Comment: Eu não conheço outra alternativa, ou instá-la a biblioteca ou altera à mão.
Comment: @PabloAlmeida sua ideia foi bacana, eu já implementei! Se você quiser inserir aqui a resposta, vou te dar os méritos. Mas se você não tiver muito tempo, eu postarei a resposta pois poderá ajudar alguém que precise.
Comment: @CleidimarViana Beleza. Se eu não tiver tempo até hoje à noite, eu te dou o OK aqui.
Comment: @PabloAlmeida Ok.
Comment: @CleidimarViana Escrevi uma resposta com a estratégia que sugeri. Veja se ficou parecido com a sua solução ou se precisa de alguma melhoria. :)
Answer: Recomendo você utilizar o AppCompatDialogFragment para fazer isso!
Essa classe está disponível dentro do appcompatv7, e já irá fazer todo o trabalho de utilizar o tema correto para a sua aplicação.
Para utilizar, basta criar uma classe que herde de AppCompatDialogFragment:
public class ConfirmDialogFragment extends AppCompatDialogFragment {
    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(title)
            .setMessage(message)
            .setPositiveButton(R.string.alguma_string,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        //Fazer algo
                    }
                }
            )
            .setNegativeButton(R.string.outra_string,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        //Fazer algo
                    }
                }
            )
            .create();

        return dialog;
    }
}

E, para exibir:
ConfirmDialogFragment dialog = new ConfirmDialogFragment();
dialog.show(getSupportFragmentManager(), dialog.getClass().getName());

Refs:
https://developer.android.com/reference/android/support/v7/app/AppCompatDialogFragment.html
Comment: Legal cara, mas eu queria fazer isso sem usar a lib `appcompatv7`. Nosso no comentário d @ramaral deu uma ideia bacana para resolver o problema. Obrigado pela ajuda!


Problemas com criação de campos not null com FluentNHibernate

Question: Estou com um problema na criação dos campos utilizando FluentNhibernate e Postgres.
Classe Usuario:
public class Usuario {
    public virtual int idUsuario { get; set; }
    public virtual string nome { get; set; }
    [NotNullNotEmpty]
    public virtual string login { get; set; }
    [NotNullNotEmpty]
    public virtual bool ativo { get; set; }
    [NotNullNotEmpty]
    public virtual string senha { get; set; }
}

UsuarioMap:
public UsuarioMap() {
    Table("usuario");
    Id(x => x.idUsuario).GeneratedBy.Identity().Column("id_usuario");
    Map(x => x.nome).Column("nome").Length(50);
    Map(x => x.login).Column("login").Not.Nullable().Length(30);
    Map(x => x.ativo).Column("ativo").Not.Nullable();
    Map(x => x.senha).Column("senha").Not.Nullable().Length(50);
}

Se a tabela não existe, ele cria normalmente todos os campos, com tamanho correto e validação not null:
CREATE TABLE public.usuario
(
    id_usuario integer NOT NULL DEFAULT nextval('usuario_id_usuario_seq'::regclass),
    nome character varying(50),
    login character varying(30) NOT NULL,
    ativo boolean NOT NULL,
    senha character varying(50) NOT NULL,
    CONSTRAINT usuario_pkey PRIMARY KEY (id_usuario)
)

Porém se a tabela existe e adiciono um campo na classe map, ele apenas cria o campo sem as validações:
**Class Usuario**
[NotNullNotEmpty]
public virtual string teste { get; set; }

.
**Class UsuarioMap**
Map(x => x.teste).Column("teste").Length(60).Not.Nullable();

.
CREATE TABLE public.usuario
(
    id_usuario integer NOT NULL DEFAULT nextval('usuario_id_usuario_seq'::regclass),
    nome character varying(50),
    login character varying(30) NOT NULL,
    ativo boolean NOT NULL,
    senha character varying(50) NOT NULL,
    teste character varying(60),
    CONSTRAINT usuario_pkey PRIMARY KEY (id_usuario)
)

Se alguém já passou por isso e puder me ajudar, agradeço porque já estou dois dias pesquisando e não consegui resolver.
Answer: Faltou configurar o valor padrão para esse campo e passar um valor, porque, ao criar um novo campo em uma tabela existente se não for passado nenhum valor ele tem que ser null, por padrão. Logo isso ele colocará as regras e validações apropriadas para esse campo.
Map(x => x.teste).Column("teste").Default("teste").Length(60).Not.Nullable();

Referente: SOen - Specifiying Default Value for Datetime property in FluenNhibernate mapping class
Comment: Opa, falha básica de lógica criar um campo notnull com valor nulo não vai mesmo.[
Comment: Não entendi?...
Comment: Só não consigo colocar caracteres como defaut, apenas numeros dessa forma:

    Map(x => x.teste).Column("teste").Length(10).Default("12345").Not.Nullable();

Desde já muito obrigado pela ajuda, acho que eu ia demorar um bom tempo para descobrir esse erro
Comment: @ElieltonBitencourt coloca qualquer tipo de caracter essa afirmação sua está estranha, porque eu fiz o teste com a palavra "teste" e funcionou de primeira!, estranho


Probability question on dice

Question: A fair die is rolled. Each time the value is noted and a running sum is maintained. What is the expected number of runs needed so that the sum is even?
Comment: More generally, if the die produces an odd value with probability p(odd) and an even value with probability p(even)=1-p(odd), then the expected number of runs for an even sum is (1+p(odd))/(1-p(odd)p(even)).
Answer: Before each throw you have a "desired parity". Let $E$ be the expected number of throws until your first success. The first throw is a success or not with probability ${1\over2}$ each, and if it's a failure you are right where you started. Therefore
$$E={1\over2}\cdot 1 +{1\over2}(1+E)\ ,$$
which gives $E=2$.
Answer: If we get an even number immediately (probability $1/2$) the waiting time is $1$.
If the first toss gives an odd number (probability $1/2$), the waiting time is $1$ plus the waiting time until the second odd number. This last waiting time is $2$, since it is the same as the waiting time until the first head in a series of tosses of a fair coin.
Thus the expected waiting time is $(1/2)(1)+(1/2)(1+2)$, which is $2$.
Added Comment:  The waiting time turns out to be the same as the waiting time for a geometric distribution where the probability of success is $1/2$.  We can see this without computing, by modifying the standard coin tossing game. Imagine tossing a fair coin. We are waiting for a head (H).
If the first toss is unsuccessful, write T on the head, H on the tail, and keep tossing.
The waiting time for H in the modified coin tossing game is the same as the waiting time for an even sum in the original dice game. And the waiting time for H in the modified coin tossing game is obviously the same as the waiting time for H in a plain coin tossing game, since the coin does not know its H from its T.

Probability question on dice


How to set Password protected for downloaded PDF file using Javascript

Question: I am working jsPDF.js functions and create simple PDF using jsPDF.But i need to set password for downloaded pdf while i need to modify that pdf without password encryption.And I have developed a tool in javascript along with pdf preview download.

Now i need an answer that "how i(admin) want to keep a password to my
  pdf preview download like an encrypt .because user can`t modify that
  downloaded PDF

Here i attached  sample code for create pdf.
<code>var doc = new jsPDF();
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
doc.save('sample.pdf');
</code>
How to achieve to set password for downloading pdf section.Kindly advise me.
Comment: you have to make the file disabled until it makes some call to a backend script with a login, or possibly have a login occur before and then don't allow download unless they are properly logged in. none the less, you will need a server side script to call with a password.
Comment: Not JavaScript alone if you include front end only. The password would never be secure. You would have to store the password on the client side. And just have some fake check which isn't really password protecting
Comment: @Geohut.I need to view that download pdf but i need to modify in adobe illustrator and so on , it will reply password for modify that downloaded pdf. Is it possible in javascript that jspdf..?
Comment: @Geohut then how to achieve it..bcz i customized entire pdf and create vector format PDF using JSPDF.js using server side.I need to download that PDF with password protected...
Comment: To answer the question, I would need to know what technologies you are using client side and server side. are you using Angular, Jquery, Extjs, or pure javascript clientside? are you using PHP, Perl, Python, Ruby, or Node server side?
Answer: If you are using node.js then you can use node-qpdf. This is a wrapper around qpdf which supports AES 256, AES 128, RC4 128 & RC4 40 encryption all supported by Adobe Reader.


Variable is not statistically significant in single variable linear regression but is significant in multiple regression

Question: I had a friend ask me about this question, and I'm not 100% sure about the data she's using due to the sensitivity/privacy of the data (other than it's medical data). Sorry for not providing context, but hopefully you can think of scenarios or conditions in which the following results would happen.
She was telling me that in her analysis, when she tried to model Y just using variable X, it was not statistically significant. However when she modeled Y using both X and Z, both variables were statistically significant. Why/when does this happen? Is it because of the interaction of variables X and Z, even though X alone would not be statistically significant? Would appreciate any insights!
Thank you!
Answer: It depends on what you mean by the word interaction, which is a technical term in statistics with a very specific meaning. In that sense, no, it's not necessarily because of an interaction (though it could be). It is very commonly due to simple correlation between your features (variables).
For example, say $Y$ is related to two features $X_1$ and $X_2$ like:
$$ Y = X_1 + X_2 + \epsilon_1 $$
Where $\epsilon$ is some random noise term. If you estimate a linear model with both features, you'll get coefficients of about $1.0$.
Now suppose that $X_1$ and $X_2$ are correlated, say something like:
$$ X_2 = - X_1 + \epsilon_2 $$
Where, again, $\epsilon_2$ is another random noise term. Then the univariate relationship between $Y$ and $X_1$ is:
$$ Y = X_1 + (-X_1 + \epsilon_2) + \epsilon_1 = \epsilon_1 + \epsilon_2 = \text{noise} $$
So if we estimate a model with just X_1, we get a coefficient of about 0.0, probably insignificant.


Error opening socket ssl://api.nodesquirrel.com:443

Question: I am using Backup and Migrate on D7. I am unable to backup to NodeSquirrel due to the following error:
TYPE    backup_migrate

The NodeSquirrel server returned the following error: Error opening socket ssl://api.nodesquirrel.com:443

Could not run backup because the file could not be saved to the destination.

Please see below a screenshot of the error-

Apparently, it is a bug with the Backup and Migrate module as mentioned in the answer.
Comment: I would appreciate it more if people who are downvoting the post can mention their comment/suggestion to do so...
Comment: Apparently, it is a bug with the `Backup and Migrate` module as mentioned in the answer.
Answer: https://www.drupal.org/project/backup_migrate/issues/3037038

Update April 10: Workaround
Per e5sego, the "nodesquirrel_default_endpoint_urls" variable can be changed to "18.104.22.168/services/xmlrpc" to avoid the current DNS problems we're seeing, e.g.
drush vset nodesquirrel_default_endpoint_urls "126.96.36.199/services/xmlrpc"
Just make sure to delete the variable once the DNS problems are resolved (drush vdel nodesquirrel_default_endpoint_urls).
Comment: Thank you very much for the suggestion. I don't have `drush` installed since the website is running on shared hosting. Can you tell me any alternative to achieve the same, please?
Comment: I edited `_get_endpoints` function inside `backup_migrate/includes/destinations.nodesquirrel.inc` file. I commented line number 824 and added the following line `$servers = array('18.104.22.168/services/xmlrpc');` I also replaced `api.nodesquirrel.com:` with `220.127.116.11` inside the same function.