text:
Q: Create video from python plots to look like a moving probability distribution I generate i plots with the code:
for i in range(len(hlist)):

        p1 = np.array(hlist[i])

        kde = gaussian_kde(p1[:,0], bw_method=.4, weights=p1[:,1])
        x = np.linspace(0, 100, 1000)
        plt.plot(x, kde(x), color='crimson')

        plt.ylim([minmin, maxmax])

        plt.show()

The x-axis and the y-axis of all plots are the same
So I want to make a video from all plots and if its possible with transition between each plots so it looks like a moving probability distribution
Full hlist:
hlist = np.array([[[0.0, 0.9003079895267837],
[10.0, 0.000654274453636099],
[15.0, 4.8062543883990662e-05],
[20.0, 0.0078540048399245721],
[25.0, 0.00030775066073687057],
[30.0, 0.0069461270425554486],
[35.0, 0.00038747043199781708],
[40.0, 0.0040570022317705538],
[45.0, 0.01242208947573863],
[50.0, 0.00042730445196067818],
[55.0, 9.2094566445921082e-05],
[60.0, 2.3533619494819096e-17],
[65.0, 6.8535505965721361e-15],
[70.0, 2.3163309687227612e-12],
[75.0, 4.7244481305730235e-14],
[80.0, 3.946900273532476e-15],
[85.0, 1.387482842660183e-12],
[90.0, 1.169953999346581e-10],
[95.0, 9.405541221977168e-06],
[100.0, 0.00020815494180476587]],
[[0.0, 0.093092478749998001],
[10.0, 1.4053195886715078e-07],
[15.0, 2.4433977582117203e-05],
[20.0, 0.00082219857285037044],
[25.0, 2.6948063300386935e-05],
[30.0, 0.093959576222220995],
[35.0, 0.0001656191073324495],
[40.0, 0.0029118221893314833],
[45.0, 0.01564108273403109],
[50.0, 1.6648778174359671e-05],
[55.0, 2.8100410030581244e-07],
[60.0, 6.0753841480616879e-17],
[65.0, 9.8080692203972863e-15],
[70.0, 6.9694730549144334e-17],
[75.0, 5.8326312613461052e-15],
[80.0, 2.4139075497471945e-16],
[85.0, 5.9084558298527006e-13],
[90.0, 1.6711579730178305e-10],
[95.0, 1.5864098433225844e-08],
[100.0, 2.2572886039178069e-08]],
[[0.0, 4.7418107222805056e-05],
[10.0, 0.72289205649751387],
[15.0, 3.308651897500352e-07],
[20.0, 0.076673642863552008],
[25.0, 0.0001501767582823212],
[30.0, 0.03027984877348755],
[35.0, 0.00011292381988867554],
[40.0, 0.00016702076039256828],
[45.0, 0.00081579620071354846],
[50.0, 1.0458962769769357e-05],
[55.0, 5.5802811319507686e-08],
[60.0, 4.1253613398572781e-19],
[65.0, 9.4051858824518925e-18],
[70.0, 1.3368786287741004e-14],
[75.0, 5.9931111040137393e-14],
[80.0, 3.2539929633588511e-15],
[85.0, 1.047255336132784e-15],
[90.0, 1.4017813965595768e-12],
[95.0, 2.8511569193363785e-09],
[100.0, 1.0183773063292469e-10]],
[[0.0, 0.0045609821258978814],
[10.0, 0.0001917787950273313],
[15.0, 0.99771505193318455],
[20.0, 0.0055938427174407005],
[25.0, 0.013201240944903663],
[30.0, 0.018570016510629072],
[35.0, 0.012700626279918454],
[40.0, 0.019933344753975846],
[45.0, 0.15619609747558014],
[50.0, 0.031265415297255877],
[55.0, 0.42528804082092103],
[60.0, 1.3054822476679266e-18],
[65.0, 8.152405640596557e-18],
[70.0, 1.4328231368499457e-17],
[75.0, 1.3158371543509022e-15],
[80.0, 2.0369465623715189e-18],
[85.0, 1.1462339774892004e-13],
[90.0, 4.7664892870840778e-13],
[95.0, 7.2181814960747638e-06],
[100.0, 0.0011762750538733889]],
[[0.0, 1.4364539307817039e-05],
[10.0, 0.0002382809395285733],
[15.0, 1.1335942314786911e-05],
[20.0, 0.52821149082545871],
[25.0, 0.1355189607672023],
[30.0, 0.0013765391762318477],
[35.0, 0.01044957461521267],
[40.0, 0.00056647346484793787],
[45.0, 0.00076442899303849577],
[50.0, 0.032497831121074787],
[55.0, 0.00032304336212375635],
[60.0, 8.7317718742465198e-16],
[65.0, 6.539726198592529e-12],
[70.0, 9.2846001586370999e-08],
[75.0, 1.1275715667447136e-16],
[80.0, 9.3449145004368205e-16],
[85.0, 7.6700176188571133e-13],
[90.0, 3.6113266426134806e-09],
[95.0, 8.8657633159259348e-07],
[100.0, 1.0088131613242799e-08]],
[[0.0, 0.00010259026745556786],
[10.0, 2.8416604131363134e-05],
[15.0, 1.5265724585429075e-08],
[20.0, 0.00035572734341432835],
[25.0, 0.74774814405543055],
[30.0, 0.20170120434943195],
[35.0, 0.31688948032690523],
[40.0, 0.016495873067229414],
[45.0, 0.019452385467953772],
[50.0, 0.0063096344918544449],
[55.0, 1.4586177114635856e-07],
[60.0, 1.2622740425026807e-15],
[65.0, 1.6230117141451513e-13],
[70.0, 2.7328268483555935e-15],
[75.0, 5.9099377394502244e-17],
[80.0, 1.0947896137035609e-17],
[85.0, 2.2319783866749845e-12],
[90.0, 7.3069777072490827e-10],
[95.0, 1.2982219252486507e-07],
[100.0, 9.2703590554295812e-09]],
[[0.0, 5.6467274191670147e-06],
[10.0, 1.9311914301356571e-15],
[15.0, 0.00030373592016130291],
[20.0, 0.37222022990454917],
[25.0, 7.1237862206873578e-07],
[30.0, 0.016227799829528728],
[35.0, 0.33096651567634761],
[40.0, 0.00014104696271763757],
[45.0, 0.001730151916132917],
[50.0, 0.00019647094586097279],
[55.0, 1.61437439554684e-14],
[60.0, 7.1139359284635841e-65],
[65.0, 8.3871906097721264e-63],
[70.0, 1.2336993844192023e-53],
[75.0, 5.0051598531858931e-64],
[80.0, 2.9758606051614185e-62],
[85.0, 2.8460978574131379e-51],
[90.0, 2.8677742500204446e-37],
[95.0, 3.7194535849027315e-27],
[100.0, 2.3439805162091607e-24]],
[[0.0, 0.0001430560406790707],
[10.0, 6.2797052001508247e-13],
[15.0, 4.8114669550502021e-06],
[20.0, 0.0007443231772534647],
[25.0, 0.00061070912573869406],
[30.0, 0.48116582167944905],
[35.0, 0.24698643991977953],
[40.0, 0.016407283121225951],
[45.0, 0.2557158314329116],
[50.0, 1.1252231121357235e-05],
[55.0, 0.064666668633158647],
[60.0, 1.7631447655837744e-17],
[65.0, 1.1294722466816786e-14],
[70.0, 2.9419020411134367e-16],
[75.0, 3.0887653014525822e-17],
[80.0, 4.4973693062706866e-17],
[85.0, 9.0975358174005147e-15],
[90.0, 1.0758266454985257e-10],
[95.0, 7.2923752473657924e-08],
[100.0, 1.8065366882584036e-08]],
[[0.0, 8.4950625072720679e-07],
[10.0, 1.1421138441091606e-09],
[15.0, 4.5866299179754217e-05],
[20.0, 1.5172948619703533e-06],
[25.0, 0.00052404930089682738],
[30.0, 0.0013085043037665261],
[35.0, 0.0011664239519834339],
[40.0, 0.82750281205997822],
[45.0, 0.10132991062898908],
[50.0, 0.0085433968529198406],
[55.0, 1.4344253354768514e-09],
[60.0, 4.1465759737420333e-63],
[65.0, 8.8542318068147446e-61],
[70.0, 6.5220929006588264e-57],
[75.0, 4.8147063172017478e-62],
[80.0, 1.6649888561929801e-54],
[85.0, 5.8101309745184615e-51],
[90.0, 1.0489469511522901e-34],
[95.0, 1.4172891722901137e-26],
[100.0, 7.7737342215176175e-21]],
[[0.0, 3.1632028979839915e-05],
[10.0, 0.22111326362785799],
[15.0, 5.0749184816502276e-05],
[20.0, 0.0037647084552139601],
[25.0, 0.06595171605012351],
[30.0, 0.020353996100110065],
[35.0, 0.064862755938758426],
[40.0, 0.063464515818315706],
[45.0, 0.28662321979050187],
[50.0, 0.29871027240136533],
[55.0, 0.0080037249999781925],
[60.0, 4.7989170718538567e-08],
[65.0, 7.1337119197448125e-13],
[70.0, 2.1156334756020827e-14],
[75.0, 5.2206045634456785e-13],
[80.0, 3.4493997391226592e-14],
[85.0, 1.0500710333351341e-12],
[90.0, 3.6230960591527929e-10],
[95.0, 5.4508034466239748e-07],
[100.0, 1.113734841284331e-08]],
[[0.0, 2.1072826422141414e-05],
[10.0, 5.2005089026009156e-06],
[15.0, 0.00035632479168291582],
[20.0, 0.00020117324964893726],
[25.0, 0.025321662490265816],
[30.0, 0.019375041125499575],
[35.0, 0.0072489358231882196],
[40.0, 0.027646703948782582],
[45.0, 0.061781297188577035],
[50.0, 0.61650443678873623],
[55.0, 6.2548100028575296e-10],
[60.0, 4.3624321149810504e-14],
[65.0, 2.1028732991018519e-15],
[70.0, 7.8258766740408378e-09],
[75.0, 2.3541542464960154e-15],
[80.0, 7.1311782140494435e-18],
[85.0, 7.9730756880702952e-14],
[90.0, 8.2168425453267622e-12],
[95.0, 2.7060634831745863e-07],
[100.0, 2.5445845858147043e-06]],
[[0.0, 5.2908114997246604e-05],
[10.0, 0.01017193185840104],
[15.0, 1.9357672782766133e-07],
[20.0, 0.00033902736145621922],
[25.0, 2.6389276490704271e-05],
[30.0, 0.018976734061801625],
[35.0, 0.00019847993445041843],
[40.0, 0.0003987651813445142],
[45.0, 0.00077280097799644102],
[50.0, 7.0623545425863526e-06],
[55.0, 0.49987468099653093],
[60.0, 2.2781104904754321e-10],
[65.0, 3.6325273589160318e-08],
[70.0, 1.3537824953350784e-07],
[75.0, 1.6173509221250697e-06],
[80.0, 1.4416343176395238e-08],
[85.0, 4.1563319348145668e-08],
[90.0, 3.889471307678879e-07],
[95.0, 5.5104492670400779e-05],
[100.0, 2.7151502910109198e-05]],
[[0.0, 6.7973224793022393e-05],
[10.0, 2.4433844497448081e-05],
[15.0, 3.1104921306578064e-06],
[20.0, 0.00034408444849371377],
[25.0, 0.00023308492218191118],
[30.0, 0.011131477320772989],
[35.0, 0.00065907967432373565],
[40.0, 0.0021975971207933783],
[45.0, 0.0064663180932303744],
[50.0, 0.00022182805626473468],
[55.0, 3.0364808672527216e-05],
[60.0, 0.5088867111766856],
[65.0, 0.022878262885332335],
[70.0, 4.5920971324139236e-06],
[75.0, 0.0022218172448998821],
[80.0, 6.2738973247353222e-07],
[85.0, 0.00029845009911656876],
[90.0, 0.00010489918264551884],
[95.0, 0.00060753276898116491],
[100.0, 0.00022654293893088778]],
[[0.0, 3.9706684562645418e-06],
[10.0, 5.1270388737533639e-06],
[15.0, 5.262507305695827e-08],
[20.0, 2.5999077691490454e-05],
[25.0, 2.7813624200874083e-05],
[30.0, 0.0031991625978026266],
[35.0, 7.9249804143628584e-05],
[40.0, 0.00041177406702603777],
[45.0, 0.0011392701023576817],
[50.0, 8.0323465327795955e-06],
[55.0, 4.8154250431354482e-08],
[60.0, 0.49105543193823659],
[65.0, 0.7287168056069141],
[70.0, 0.001517224119720642],
[75.0, 0.011333832180200976],
[80.0, 1.72411085405819e-06],
[85.0, 0.0024773347817556406],
[90.0, 0.0051538392104878905],
[95.0, 0.0012157783163112316],
[100.0, 6.9627245730982824e-06]],
[[0.0, 0.0002912083712195997],
[10.0, 0.00010000827323660753],
[15.0, 1.3045847050921363e-05],
[20.0, 0.00076214254175277312],
[25.0, 0.00069053586992726265],
[30.0, 0.019496501720614564],
[35.0, 0.0015575117915095839],
[40.0, 0.0061672295672820353],
[45.0, 0.024249792592964857],
[50.0, 0.00032644214446402552],
[55.0, 7.7266514916862301e-06],
[60.0, 7.7205272501591181e-06],
[65.0, 0.017897081479520592],
[70.0, 0.99798778384755971],
[75.0, 1.8624562046616415e-05],
[80.0, 0.0011212071784075478],
[85.0, 1.4365766090813676e-05],
[90.0, 0.0032064950461695454],
[95.0, 0.0012746996733909491],
[100.0, 0.002184674454638652]],
[[0.0, 1.4875831960944082e-05],
[10.0, 0.044356141901610378],
[15.0, 6.2599114973306784e-07],
[20.0, 0.0001137512258409283],
[25.0, 0.00074658171939148493],
[30.0, 0.0026392679644018989],
[35.0, 0.00016209963633384973],
[40.0, 0.00078042928094971609],
[45.0, 0.0036289420011120584],
[50.0, 0.0015766136061278139],
[55.0, 1.0905709141111546e-05],
[60.0, 2.7323842104187985e-06],
[65.0, 3.3133452546150147e-05],
[70.0, 9.4042250154063172e-07],
[75.0, 0.97971055505602644],
[80.0, 0.072870311800762033],
[85.0, 0.00053021457261792214],
[90.0, 0.022423571257812192],
[95.0, 0.00070111679082283159],
[100.0, 3.6497263003914267e-05]],
[[0.0, 3.5864031562522839e-05],
[10.0, 8.3611261574776709e-07],
[15.0, 3.1900347488304889e-06],
[20.0, 0.00018123337202990332],
[25.0, 0.0002136705754060659],
[30.0, 0.0057251370200655845],
[35.0, 0.0012906924788080578],
[40.0, 0.0025502956186607153],
[45.0, 0.01424309136060831],
[50.0, 6.8216937833192329e-05],
[55.0, 5.6413951413567533e-06],
[60.0, 3.395689693128361e-05],
[65.0, 0.0032457520420234795],
[70.0, 8.3915675399849457e-09],
[75.0, 0.00013330080558625364],
[80.0, 0.91501828269209085],
[85.0, 0.0020937770133090659],
[90.0, 0.0012871409503378462],
[95.0, 0.00014758805743257718],
[100.0, 0.00086787665688324784]],
[[0.0, 4.1652247577331996e-06],
[10.0, 1.2212829713673957e-06],
[15.0, 6.5906857192417344e-08],
[20.0, 0.00016745946587138236],
[25.0, 0.0054431111796765554],
[30.0, 0.0067575214586160616],
[35.0, 0.00011856110316632124],
[40.0, 0.00032181662132509944],
[45.0, 0.001397981055516994],
[50.0, 0.0027058954834684062],
[55.0, 2.553142406703067e-06],
[60.0, 1.1514033594755017e-08],
[65.0, 0.21961568282994792],
[70.0, 2.4658349829099807e-08],
[75.0, 0.0022850986575076743],
[80.0, 3.5603047823624507e-06],
[85.0, 0.99406392082894734],
[90.0, 0.24399923235645221],
[95.0, 0.0013470125217945798],
[100.0, 0.042582366972883985]],
[[0.0, 5.5827483149344828e-06],
[10.0, 4.2094534384536198e-07],
[15.0, 5.723201102401161e-08],
[20.0, 4.1809740042541515e-05],
[25.0, 0.00049057556903029373],
[30.0, 0.0073861106939193556],
[35.0, 0.00025382321327730041],
[40.0, 0.0013088484764716428],
[45.0, 0.0026974167667276621],
[50.0, 3.069464890989831e-05],
[55.0, 5.8148299885777761e-06],
[60.0, 7.4621165800794304e-07],
[65.0, 0.002374761247356731],
[70.0, 7.989880181871685e-05],
[75.0, 0.0042580794657908335],
[80.0, 0.010965726532792501],
[85.0, 0.00032799281228739028],
[90.0, 0.72335894920682331],
[95.0, 0.0028560935416300647],
[100.0, 0.00023222597525614469]],
[[0.0, 1.1150563179140846e-05],
[10.0, 3.9137754880943888e-06],
[15.0, 2.6540828280675093e-07],
[20.0, 0.00030085951063170473],
[25.0, 0.00099029668428149789],
[30.0, 0.0040087490203686207],
[35.0, 0.00086288885669378408],
[40.0, 0.0012383336640490626],
[45.0, 0.0024569535179785368],
[50.0, 5.3078640889812177e-05],
[55.0, 3.655855476404959e-05],
[60.0, 1.135303263695363e-05],
[65.0, 0.0052337161196729541],
[70.0, 0.00038799120104653003],
[75.0, 6.6611573170762462e-07],
[80.0, 1.551926769812043e-05],
[85.0, 3.0383118936603649e-05],
[90.0, 0.00045596510625991982],
[95.0, 0.97142691361436007],
[100.0, 0.10797398637691005]],
[[0.0, 0.0011842207743420531],
[10.0, 0.00021255186566113124],
[15.0, 0.0014186746952926585],
[20.0, 0.0012807740120210007],
[25.0, 0.0017758699839103857],
[30.0, 0.02941486302872582],
[35.0, 0.0028808476159808511],
[40.0, 0.0053310120235299015],
[45.0, 0.030475142227338822],
[50.0, 0.00050901345787313437],
[55.0, 0.0016516486463798513],
[60.0, 1.288101329664901e-06],
[65.0, 4.7680039665889616e-06],
[70.0, 2.1300407821392148e-05],
[75.0, 3.6408560648746925e-05],
[80.0, 3.0263064939939249e-06],
[85.0, 0.00016351943738745334],
[90.0, 9.5136297575506478e-06],
[95.0, 0.020349612775663113],
[100.0, 0.84447466931781623]]])

A: With plt.savefig you can create an individual .png file from a plot. To get a smooth transition, you can interpolate the plots in a number of steps. To convert the .png-files to an animation, ffmpeg is a very useful tool.
Here is some code starting from the data of your previous question:
from matplotlib import pyplot as plt
import numpy as np
from scipy.stats import gaussian_kde

p1 = np.array([[5.0, 0.0001430560406790707], [10.0, 6.2797052001508247e-13], [15.0, 4.8114669550502021e-06],
               [20.0, 0.0007443231772534647], [25.0, 0.00061070912573869406], [30.0, 0.48116582167944905],
               [35.0, 0.24698643991977953], [40.0, 0.016407283121225951], [45.0, 0.2557158314329116],
               [50.0, 1.1252231121357235e-05], [55.0, 0.064666668633158647], [60.0, 1.7631447655837744e-17],
               [65.0, 1.1294722466816786e-14], [70.0, 2.9419020411134367e-16], [75.0, 3.0887653014525822e-17],
               [80.0, 4.4973693062706866e-17], [85.0, 9.0975358174005147e-15], [90.0, 1.0758266454985257e-10],
               [95.0, 7.2923752473657924e-08], [100.0, 1.8065366882584036e-08]])
p2 = np.array([[5.0, 4.1652247577331996e-06], [10.0, 1.2212829713673957e-06], [15.0, 6.5906857192417344e-08],
               [20.0, 0.00016745946587138236], [25.0, 0.0054431111796765554], [30.0, 0.0067575214586160616],
               [35.0, 0.00011856110316632124], [40.0, 0.00032181662132509944], [45.0, 0.001397981055516994],
               [50.0, 0.0027058954834684062], [55.0, 2.553142406703067e-06], [60.0, 1.1514033594755017e-08],
               [65.0, 0.21961568282994792], [70.0, 2.4658349829099807e-08], [75.0, 0.0022850986575076743],
               [80.0, 3.5603047823624507e-06], [85.0, 0.99406392082894734], [90.0, 0.24399923235645221],
               [95.0, 0.0013470125217945798], [100.0, 0.042582366972883985]])
x = np.linspace(0, 100, 1000)

hlist = [p1, p2, p1]
kdelist = [gaussian_kde(p[:, 0], bw_method=.4, weights=p[:, 1]) for p in hlist]

steps = 20

fig, ax = plt.subplots()
for i in range(len(kdelist) - 1):
    for s in range(steps + 1):
        plt.plot(x, kdelist[i](x) * s / steps + kdelist[i + 1](x) * (1 - s / steps), color='crimson')
        plt.ylim(0, 0.065)
        plt.savefig(f'kde_{i*(steps+1)+s:04d}.png')
        plt.cla() # needed to remove the plot because savefig doesn't clear it

An example way to convert the .png files to a .mp4 animation and then to an animated gif:
ffmpeg -i kde_%04d.png -c:v libx264 -r 25 -pix_fmt yuv420p out.mp4
ffmpeg -i out.mp4 out.gif


text:
Q: Google Apps Script - Using Sidebar form to append a row to spreadsheet This script should append a new row to my spreadsheet 'onclick' of the button, however it doesn't.  Ultimately I want to be able to add data to each textbox corresponding to a column and append a new row.  Not sure why this doesn't work.  How do I append a new row?  THis script works in the script editor when I run it, just not in the sidebar html.

    // Use this code for Google Docs, Forms, or new Sheets.
    function onOpen() {
      SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
      .createMenu('SideBar')
      .addItem('Open', 'openDialog')

      .addToUi();

    }

    function openDialog() {
     var html = HtmlService.createHtmlOutputFromFile("Index");
     html.setTitle('Gmf Sent Msg Form');
     SpreadsheetApp.getUi().showSidebar(html);

    }

   function insertRow(){
    var doc =     SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1RY3TZvU-        TFhlCyF9TKRk4Hb4b6Q1TnYa5K7ixyktykY/edit#gid=0");
     doc.getActiveSheet().appendRow(['700','9/12/16','PO 16-45789'])

    }

Use this form to enter information into the cells of the spreadsheet.

<form>

ID

<input type="text" name="txtID" />

Date

<input type="text" name="txtDate"/>

Subject

<input type="text" name="txtSub" />
<input type="button" value="Append Row" onclick="google.script.run
          .withSuccessHandler(insertRow)" />
</form>

A: At this line:
<input type="button" value="Append Row" onclick="google.script.run.withSuccessHandler(insertRow)" />

You're setting the callback function withSuccessHandler() but you're not calling any server-side function, to call it directly you need to use:
google.script.run.insertRow();

If you want to set the callback function to run if the server-side function returns successfully.
google.script.run.withSuccessHandler(onSuccess).insertRow();

For more information, see the guide of communicating with server functions and google.script.run.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Dataframe has NAs instead of values I have a dataframe loaded from an Excel file. It is similar to this:
Gender Country Effect Use Products

Male   UK      1      2   7
Female USA     2      4   6
Male   Russia  3      5   2
Female China   4      2   3
Male   China   3      1   6
Female USA     2      5   2
Male   UK      3      3   1
Female Russia  4      1   7

I want to calculate the mean per Country, like in the example below (excluding Gender):
Country Effect Use Products

UK      3      2   7
USA     2      4   4
Russia  3      5   5
China   4      2   4

I used the similar code to perform this operation (where "d" is name of the database):
country_avg <- aggregate(d[, 3:5], list(d$`Country `), mean)

However, instead of the desired output, the outcoming database looks like this:
Group1 Effect Use Products

UK      NA     NA  NA
USA     NA     NA  NA
Russia  NA     NA  NA
China   NA     NA  NA

The numbers in my dataframe are not identified as numeric values (I've tested that using is.numeric).
Moreover, R returns a lot of the following warning messages:
1: In mean.default(X[[i]], ...) :
  argument is not numeric or logical: returning NA

Please let me know how could I possibly fix this problem.

A: Remove the backquote as it also includes a space as suffix which may not be there in the original data column name.
aggregate(d[, 3:5], list(d$Country ), FUN =  mean)

Or use the formula method which gives the names as in the original data for the grouping column
aggregate(.~ Country, d[-1], FUN = mean)

data
d <- structure(list(Gender = c("Male", "Female", "Male", "Female",
"Male", "Female", "Male", "Female"), Country = c("UK", "USA",
"Russia", "China", "China", "USA", "UK", "Russia"), Effect = c(1L,
2L, 3L, 4L, 3L, 2L, 3L, 4L), Use = c(2L, 4L, 5L, 2L, 1L, 5L,
3L, 1L), Products = c(7L, 6L, 2L, 3L, 6L, 2L, 1L, 7L)),
class = "data.frame", row.names = c(NA,
-8L))


text:
Q: Redirecting to the last consuled page PHP I can't get the right solution for all methodes that i tried.
After successful login,the user doesen't use his account for a precise time,he must reconnect.
what i want is when the user reconnects it redirects directly to the last page he consulted and not in index page.
This's my code :
authentication form :
     <form action="login.php" method="POST">
         //input login and password
     </form>

Login
     <?php

       @session_start();

       if ($_POST['url'] == '')
        {
          $url = "index.php";
        }
       else
       {
           $url = $_POST['url'];
       }

       $login = $_POST['login'];
       $password = $_POST['password'];
       $password_hash = hash('sha256', $password);

       try
        {
     $connexion = new PDO('mysql:host=localhost;dbname=data1', 'data1', 'password');
      $sql_auth = "
                SELECT *
                FROM users_list
                WHERE
                login= :login AND password= :password
                LIMIT 1
            ";

$req_login = $connexion -> prepare("$sql_auth");
$req_login -> bindParam(":login", $login, PDO::PARAM_STR);
$req_login -> bindParam(":password", $password_hash, PDO::PARAM_STR);
$req_login -> execute();
$data = $req_login -> fetch();

 }
   catch(Exception $e)
   {
       die('Erreur : ' . $e -> getMessage());
    }

   if (!$data)
    {
      header("Location: authentication.php");
        exit;

     }

   else
   {

        $_SESSION['id_user'] = $data_login['id'];
        $_SESSION['login'] = $data_login['login'];
        $_SESSION['first_name'] = $data_login['name'];
        $_SESSION['id'] = $data_login['id'];
        $_SESSION['status'] = $data_login['status'];
        $_SESSION['logged'] = true;

     $req_conn = $connexion -> prepare("SELECT id_user FROM connexion_user     WHERE id_user='".$_SESSION['id']."'");
$req_conn -> execute();
$data_query = $req_conn -> fetch();

if (!$data_query)
{
    $insert_connexion = $connexion -> prepare ("INSERT INTO connexion_user(id_user, last_connexion, count) VALUES('".$_SESSION['id']."',NOW(), 1)");
    $insert_connexion -> execute();
}
else
{
    $update_connexion = $connexion -> prepare ("UPDATE connexion_user SET last_connexion=NOW(), count=count+1 WHERE id_user='".$_SESSION['id']."'");
    $update_connexion -> execute();
}

header("Location: $url");
exit ;

}
Logout :
    <?php

     session_start();

     $_SESSION = array();

     if (ini_get("session.use_cookies")) {

         $params = session_get_cookie_params();

         setcookie(session_name(), '', time() - 42000,

         $params["path"], $params["domain"],

         $params["secure"], $params["httponly"]

       );

       }

        session_destroy();

        header("Location: authentication.php");

       exit;

       ?>

I just want a simple solution.
Thanks

A: Returning to the last page is a bit tricky, especially when you destroy the session. But the really simple approach, without having server to remember your last URL, would be to lose header("Location: $url"); at the end of login.php and output this to user:

If -2 goes too far back in the history, try -1.
Another way would be to try:

but it might get you back to login page instead of the previous page. Although this line would work without a problem if you were doing authentication using AJAX.
(Note: If someone will want to do this while using AJAX authentication, you might want to check that document.referrer belongs to your domain and not redirecting outside your website).


text:
Q: How I can create this view in SQL? Hi I have a database of a social network; users can submit content and comment it. They can join in groups. And I want to make some views:
View for users who write over 1,000 comments
CREATE VIEW userPro
AS SELECT U.nick, C.id
FROM User.U, Comments.C
WHERE C.id> 1000

¿¿¿ How I can put the 'Count' ??? (I need id count > 1000)
View for users who are in 3 different groups and sended more than 10 content
CREATE VIEW userGroupArt
AS SELECT U.nick, Co.id, G.idg
FROM  User.U, Content.Co, Group.G
WHERE COUNT BY(idg > 3 AND content >10)

I have a lot of difficult working with Count by but I read a lot of documentation. Can you help me?
Thank you very much!

A: Looks like you have to learn more about sql having clause
CREATE VIEW userPro
AS SELECT U.nick, C.id
FROM `User` AS U INNER JOIN Comments AS C ON
U.id = C.user_id
HAVING COUNT(C.id) > 1000;

CREATE VIEW userGroupArt
AS SELECT U.nick
FROM `User` AS U INNER JOIN Content AS Co ON U.id = Co.user_id
INNER JOIN  UserGroup AS UG on UG.user_id = U.id
HAVING COUNT(DISTINCT UG.group_id) > 3 AND COUNT(DISTINCT Co.id) > 10

Also you need to clarify what fields you want from second view - if you want a list of unique users, you can't select id of user group or content, because user can have many groups and contents.


text:
Q: Share Extension Crash on reading Array from CoreData When I am trying to access my Array which is filled with data from CoreData. I get an EXC_BAD_ACCESS Error.
Here is my Code:
var endPointList: Array<SettingsModel> = []

override func viewDidLoad() {

    var context = getManagedObjectContext()

    let fetchRequest = NSFetchRequest(entityName: "SettingsEndpoint")
    endPointList = context.executeFetchRequest(fetchRequest, error: nil) as [SettingsModel]

}

I get the Error when I press a button which triggers the following IBAction:
@IBAction func showEndPointAlert(){
    let alertController = UIAlertController(title: "Endpunkte Auswahl", message: "Wählen sie einen Endpunkt", preferredStyle: .Alert)

    for endPoint : SettingsModel in endPointList {
         var endPointNameFromData:String = endPoint.name as String
    }

    let cancelAction = UIAlertAction(title: "Abbrechen", style: .Cancel) { (_) in }
    alertController.addAction(cancelAction)

    self.presentViewController(alertController, animated: true, completion:nil );
}

The debugger points to the following line:
var endPointNameFromData:String = endPoint.name as String

Strangely if I execute this code inside the viewDidLoad() method it runs. Why is this?
UPDATE:
Now with some edits from Mundi. I get a slightly different error:
2015-01-06 12:18:21.818 ShareExtension[1056:20857]
-[SettingsModel name]: unrecognized selector sent to instance 0x6080000b2fc0
2015-01-06 12:20:24.755 ShareExtension[1056:20857]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '
-[SettingsModel name]: unrecognized selector sent to instance 0x6080000b2fc0'

My SettingsModel class:
import UIKit
import CoreData

@objc(SettingsModel)
class SettingsModel: NSManagedObject {

    @NSManaged var name:String
    @NSManaged var webservice:String
    @NSManaged var service:String

}

A: When fetching from Core Data you usually need to cast the result to the correct type. Just declaring the variable of a certain type is not sufficient.
Preferably you should not be using AnyObject but a proper NSManagedObject subclass.
endPointList = context.executeFetchRequest(fetchRequest, error: nil) as [EndPoint]
for endPoint : EndPoint in endPointList {
   println(endpoint.name)
}


text:
Q: JavaScript execute a queue of audio file I want to play some audio files in a sequence defined by the array sNumbers.
My ideia is to execute the audio files when the prior ends, for that I'm using the ended event, if I don't all the audios will execute at the same time.
The code below works fine because the array does not repeat any number, but, if I repeat any number, the execution will enter in a endless loop.
Does anyone has a solution for that?
<audio src="http://189.109.43.206/images/0.wav" id="wav0"></audio>
<audio src="http://189.109.43.206/images/1.wav" id="wav1"></audio>
<audio src="http://189.109.43.206/images/2.wav" id="wav2"></audio>
<audio src="http://189.109.43.206/images/3.wav" id="wav3"></audio>
<audio src="http://189.109.43.206/images/4.wav" id="wav4"></audio>
<audio src="http://189.109.43.206/images/5.wav" id="wav5"></audio>
<audio src="http://189.109.43.206/images/6.wav" id="wav6"></audio>
<audio src="http://189.109.43.206/images/7.wav" id="wav7"></audio>
<audio src="http://189.109.43.206/images/8.wav" id="wav8"></audio>
<audio src="http://189.109.43.206/images/9.wav" id="wav9"></audio>
<script type="text/javascript">
    onload=function (){
        var sNumbers = ['1', '0', '4'];
        sNumbers.map(function(e, i){
            if ( i <= sNumbers.length-2 ) {
                document.querySelector("#wav"+sNumbers[i]).addEventListener("ended", function() {
                    document.querySelector("#wav"+sNumbers[i+1]).play();
                }, false);
            }
       });
       document.querySelector("#wav"+sNumbers[0]).play();
    }
</script>

A: I solved the problem by using JQuery to clone the audio object.
<script type="text/javascript">
    onload=function (){
        let sNumbers = ['N', 'S'].concat(window.location.search.replace("?", "").split(''));
        let audios = [];
        sNumbers.map(function(e, i){
            audios.push( $("#mp3"+sNumbers[i]).clone() );
        });
        audios.map(function(e,i){
            console.log(e);
            audios[i].on("ended", function() {
                audios[i+1].get(0).play();
            });
        });
        audios[0].get(0).play();
    }
</script>

</head>
<body>

</body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>


text:
Q: django - image isn't saving, all other fields are When I update the user profile via the view everything is saving to the db except the image. The forms are validating but image isn't being saved. I can log in the admin portal and successfully add an image to an existing instance. I assume my problem lies in my html template but I can't figure out what it is.
**Btw I've read multiple similiar post but none I believe addresses my issue.
form.py
class EditUserForm(forms.ModelForm):
    template_name='/something/else'

    class Meta:
        model = User
        fields = (
            'email',
            'first_name',
            'last_name',
        )

class EditProfileForm(forms.ModelForm):
    template_name='/something/else'

    class Meta:
        model = UserProfile
        fields = (
            'description',
            'city',
            'website',
            'phone',
            'image',

    )

views.py
@transaction.atomic
def edit_profile(request):
    if request.method == 'POST':
        form = EditUserForm(request.POST, instance=request.user)
        form2 = EditProfileForm(request.POST, instance=request.user.userprofile)
        if form.is_valid() and form2.is_valid():
            form.save()
            form2.save()
            return redirect(reverse('accounts:view_profile'))
    else:
        form = EditUserForm(instance=request.user)
        form2 = EditProfileForm(instance=request.user.userprofile)
        args = {'form': form, 'form2':form2}
        return render(request, 'accounts/edit_profile.html', args)

models.py
class UserProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    description = models.CharField(max_length=100, default='')
    city = models.CharField(max_length=100, default='')
    website = models.URLField(default='')
    phone = models.IntegerField(default=0)
    image = models.ImageField(upload_to='profile_image', blank=True)

    def __str__(self):
        return self.user.username

edit_profile.html

  {% if form.errors %}

      {% for field in form %}

 {% if field.errors %}
{{ field.errors|striptags }}
{% endif %}

      {% endfor %}

  {% endif %}

    <form method="post" enctype="multipart/form-data">
        {% csrf_token %}
        {{ form.as_p }}
        {{ form2.as_p }}
        <button type="submit">Submit</button>
    </form>

A: If you are uploading files, you must instantiate the form with request.POST and request.FILES.
form2 = EditProfileForm(request.POST, request.FILES, instance=request.user.userprofile)

See the docs on file uploads for more info.


text:
Q: DQCPError: The problem is not DQCP. while implementing a QSVM in IBM Quantum Experience I was trying to execute the following code in IBM QE (implementing a QSVM based classifier)
feature_dim = 2
feature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement='linear')
qsvm = QSVM(feature_map, training_input, test_input)
backend = BasicAer.get_backend('qasm_simulator')
quantum_instance = QuantumInstance(backend, shots=1024, seed_simulator=seed, seed_transpiler=seed)
result = qsvm.run(quantum_instance)
print(f'Testing success ratio: {result["testing_accuracy"]}')
I get the following error :
Traceback (most recent call last):
Input In [18] in <cell line: 8>
result = qsvm.run(quantum_instance)
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/quantum_algorithm.py:71 in run
return self._run()
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/qsvm.py:476 in _run
return self.instance.run()
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:135 in run
self.train(self._qalgo.training_dataset[0], self._qalgo.training_dataset[1])
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/algorithms/classifiers/qsvm/_qsvm_binary.py:82 in train
[alpha, b, support] = optimize_svm(kernel_matrix, labels, scaling=scaling, lambda2=lambda2)
File /opt/conda/lib/python3.8/site-packages/qiskit/aqua/utils/qp_solver.py:93 in optimize_svm
prob.solve(verbose=show_progress, qcp=True)
File /opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:473 in solve
return solve_func(self, *args, **kwargs)
File /opt/conda/lib/python3.8/site-packages/cvxpy/problems/problem.py:945 in _solve
raise error.DQCPError("The problem is not DQCP.")
DQCPError: The problem is not DQCP.
Use %tb to get the full traceback.
Is this because of deprecated packages like in the case of aqua, also the qiskit tutorials on QSVMs (both binary and multi-classifier ) are missing. Could someone help me out ?
Much thanks

A: Qiskit Aqua was deprecated, as you have seen, and is no longer supported.
I would suggest looking at the equivalent function in Qiskit Machine Learning where all the ML related function from Aqua was moved/refactored. There is a tutorial here showing kernel based algorithms https://qiskit.org/documentation/machine-learning/tutorials/03_quantum_kernel.html Here the QSVM is now called QSVC and extends sklearn SVC.


text:
Q: Option.Applicative: How to parse a combined parser with a flag? I have complicated command line options, as
data Arguments = Arguments Bool (Maybe SubArguments)
data SubArguments = SubArguments String String

I want to parse these subarguments with a flag:
programName --someflag --subarguments "a" "b"
programName --someflag

I already have
subArgParser = SubArguments <$> argument str <*> argument str
mainParser = MainArgs <$> switch
                  (long "someflag"
                   <> help "Some argument flag")
               <*> ???
                   (long "subarguments"
                   <> help "Sub arguments"

What do I have to write at the ???

A: Your question turned out to be more complicated than you think. Current optparse-applicative API is not supposed to be used with such cases. So you probably may want to change the way you handle CLI arguments or switch to another CLI parsing library. But I will describe most closest way of achieving your goal.
First, you need to read other two SO questions:
1. How to parse Maybe with optparse-applicative
2. Is it possible to have a optparse-applicative option with several parameters?
From first question you know how to parse optional arguments using optional function. From second you learn some problems with parsing multiple arguments. So I will write here several approaches how you can workaround this problem.
1. Naive and ugly
You can represent pair of strings as pair of String type and use just naive show of this pair. Here is code:
mainParser :: Parser Arguments
mainParser = Arguments
    <$> switch (long "someflag" <> help "Some argument flag")
    <*> optional (uncurry SubArguments <$>
                   (option auto $ long "subarguments" <> help "some desc"))

getArguments :: IO Arguments
getArguments = do
    (res, ()) <- simpleOptions "main example" "" "desc" mainParser empty
    return res

main :: IO ()
main = getArguments >>= print

Here is result in ghci:
ghci> :run main --someflag --subarguments "(\"a\",\"b\")"
Arguments True (Just (SubArguments "a" "b"))

2. Less naive
From answer to second question you should learn how pass multiple arguments inside one string. Here is code for parsing:
subArgParser :: ReadM SubArguments
subArgParser = do
    input <- str
    -- no error checking, don't actually do this
    let [a,b] = words input
    pure $ SubArguments a b

mainParser :: Parser Arguments
mainParser = Arguments
    <$> switch (long "someflag" <> help "Some argument flag")
    <*> optional (option subArgParser $ long "subarguments" <> help "some desc")

And here is ghci output:
ghci> :run main --someflag --subarguments "x yyy"
Arguments True (Just (SubArguments "x" "yyy"))

The only bad thing in second solution is that error checking is absent. Thus you can use another general purpose parsing library, for example megaparsec, instead of just let [a,b] = words input.

A: It's not possibile, at least not directly. You might find some indirect encoding that works for you, but I'm not sure.  Options take arguments, not subparsers.  You can have subparsers, but they are introduced by a "command", not an option (i.e. without the leading --).


text:
Q: Change the alert text on add to cart action without selected variation in Woocommerce in Wordpress I'm using Woocommerce v3.3.5 and in single product pages for variable products, When I click the add to cart button while I don't select a variation option it popups an alert that says :

Please select some product options before adding this product to your cart.

and that is logical so far ..
My question is How to change the alert text to something else to fit my business?

A: WooCommerce has a filter "woocommerce_get_script_data" for all data sent to JavaScript including translated texts.
So this is the proper way to change this text :
add_filter( 'woocommerce_get_script_data', 'change_alert_text', 10, 2 );
function change_alert_text( $params, $handle ) {
    if ( $handle === 'wc-add-to-cart-variation' )
        $params['i18n_unavailable_text'] = __( 'Your new alert text', 'domain' );

    return $params;
}

If WooCommerce change this translation, you will have a problem with the accepted answer, your condition will be false.

A: For those who cannot get the code to work, it's because the variable called by Keylies code is using the wrong variable.
The correct variable follows the same coding conventions and is incredibly adaptable.
Either you can edit public_html/YOURDOMAIN/wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php
Or drop the below code snippet (with relevant variables) into your themes functions.php file.
add_filter( 'woocommerce_get_script_data', 'change_alert_text', 10, 2 );
function change_alert_text( $params, $handle ) {
    if ( $handle === 'wc-add-to-cart-variation' )
        $params['###INSERT YOUR VARIABLE HERE###'] = __( 'Your new alert text', 'domain' );
    return $params;
}

Replace ###INSERT YOUR VARIABLE HERE### with any of the following (VARIABLE =>Default Message/Error/Text):

*

*'i18n_no_matching_variations_text' => 'Sorry, no products matched your selection. Please choose a different combination.'

*'i18n_make_a_selection_text' => 'Please select some product options before adding this product to your cart.'

*'i18n_unavailable_text' => 'Sorry, this product is unavailable. Please choose a different combination.'

You can replicate the code to replace multiple shopwide errors by using:
Custom Error 1: $params['i18n_make_a_selection_text'] = __( 'Hey, you... yeah you... make a selection!', 'domain' );
Custom Error 2: $params['i18n_unavailable_text'] = __( 'Oh no we've run out of that product but it's not the end of the world it'll be back soon', 'domain' );

A: Try this, it should solve your problem:
add_filter( 'gettext', 'customizing_variable_product_message', 97, 3 );
function customizing_variable_product_message( $translated_text, $untranslated_text, $domain )
{
    if ($untranslated_text == 'Please select some product options before adding this product to your cart.') {
        $translated_text = __( 'Here goes your custom text', $domain );
    }
    return $translated_text;
}

Code goes in function.php file of your active child theme (or active theme). It's tested and works.

A: Added to function.php this code
add_filter( 'woocommerce_get_script_data', 'change_alert_text', 10, 2 );

function change_alert_text( $params, $handle ) {
    if ( $handle === 'wc-add-to-cart-variation' )
        $params['Please select some product options before adding this product to your cart.'] = __( 'Your new alert text', 'sivona.ee' );
    return $params;
}
but still: https://prnt.sc/samecx


text:
Q: is it possible to fix phonegap inappbrowser to load in landscape? I want to use the phonegap inappbrowser but it should load in landscape. My whole app shoud run in portrait mode so autorotation is deactivated.
Another thing i want to do is deactivating the tabbar on the bottom in the inappbrowser and just have a little X to close the fullscreen view of the browser. Any way to do this?
I know the possibility of android plugins but the main device i am developing for is iphone


text:
Q: Leaflet nested layer control I'm trying to build an interactive game map with Leaflet and I would like to implement nested layer groups. I tried doing it the obvious way: putting some layer groups inside of a "master" layer group, and that does kinda work, but the control won't work with it even if I write custom event handlers.
I spent the past hour looking into the source of Leaflet trying to understand why this won't work, but I can't figure it out.
// Load markers
const overlay_materials = {};
const materials_lg = L.layerGroup();
overlay_materials["Materials"] = materials_lg;

for(let key in markers['materials']) {
    let material = markers['materials'][key];
    let layerGroup = L.layerGroup();
    for(let coords in material['coords']) {
        coords = material['coords'][coords];
        layerGroup.addLayer(
            L.marker(coords, {
                icon: L.icon({
                    iconUrl: markers['icon_base'] + material['icon'],
                    iconSize: material['size']
                }),
                title: key,
                alt: key
            }));
    }

    materials_lg.addLayer(layerGroup);
    overlay_materials[key] = layerGroup;
}

materials_lg.addTo(map);

// Add control for layers
L.control.layers(null, overlay_materials, {
    collapsed: false
}).addTo(map);

materials_lg.on('add', e => {
    materials_lg.eachLayer(lg => {
        map.addLayer(lg);
    })
});

materials_lg.on('remove', e => {
    console.log("Removed");
    materials_lg.eachLayer(lg => {
        console.log(lg);
        map.removeLayer(lg);
    })
});

If all the sub layers groups are not selected it does work fine, but it does not update the control checkboxes, so if one of the other layer groups is selected it won't work as expected.


text:
Q: Prohibit Office365 group members from editing SharePoint layouts on Sharepoint Teams and Microsoft Teams How do we avoid Office 365 group based Team channel or SharePoint Team guests/members from editing the SharePoint UI side of things (pages, navigation) while still participating in document library etc?  I'm more worried about guests, but team members can cause havoc too.
Example 1: Guests are included in Azure AD.  You create a new SharePoint Team site, which creates a new O365 group.  When you add Azure AD members and guests to this group, they can all edit the navigation / pages etc.  But we just want them to use the site as is.
Example 2: Guest access is on for Microsoft Teams.  You create a new Team, guests in Azure AD are included.  They use the web app, open the General Team channel and choose "Open in SharePoint".  At this point top navigation has the gear for Office 365 to add a page, site contents, site settings, etc.  They can do a lot of damage.
What step is necessary to add this restriction?  This looks to be the solution:
https://sharepointmaven.com/how-to-prevent-team-site-members-from-editing-sharepoint-pages/
But this is from a while back, and not part of the new Microsoft 365 admin UI.  Since these are brand new sites, I'm trying to create them as simply as possible without any artifacts or messing up new integration features.
If you have any ideas or have dealt with a similar situation, please advise.
thanks!!
[Edit - here's what worked for me based on alphaz18 suggested answer]:
1) Directly on the entire site collection level eg tenant.sharepoint.com/sites/teamname/ edit site permission levels

2) Remove some list permissions from "Edit": [Manage, add, edit, delete]. Submit.

3) Go back into "Edit" permission, at the bottom of this cloned permission, choose "Copy Permission Level", call new version (e.g.) "EditLists". RE-check the [add, edit, delete] options for this cloned permission level. Submit.

4) Go to a page you want edits to occur in (e.g.) Documents view (/Shared%20Documents/Forms/AllItems.aspx). Click top right gear, choose "Library settings".  Click "Permissions for this document library".

5) Break inheritance.

6) For Members group edit user permissions, set to cloned permission (eg) "EditItems"

A: You can absolutely change the permission levels for different users and groups in sharepoint online for msTeams Created Sharepoint sites and your own.
if you are a site collection owner, just click the gear on top, click site permissions.
then click advanced permissions, and you can have the classic permissions panel, then you click permission levels and create one that fits your needs, eg just allow them to add items from lists for example. or whatever it is you want to allow them to do.
as long as you dont allow them to edit pages and such should be fine.
then assign the permission level to either team members or add more groups or whatever you want.

Hopefully this is what you're after,
Regards,


text:
Q: Pointers and static variables in C I'm having some problems with pointers in a school task, since I haven't programmed in C in a long time. I'm trying to store a value called rssi on a device running Contiki-NG which is like an OS for IOT devices.
I initialized the variable rssi in the beginning of the code:
static int8_t *rssi;

Then, in a function called on_reception, I'm updating the variable:
void on_reception(const void *data,
    uint16_t len,
    const linkaddr_t *src,
    const linkaddr_t *dest)
{
   ....
   // Update variable
   rssi = &packetbuf_attr(PACKETBUF_ATTR_RSSI);
}

And then in the main loop I'm trying to store this value using a provided cfs_write function:
PROCESS_THREAD(receiver_process, ev, data)
{
   PROCESS_BEGIN();
   ....

   while(1) {
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer));
    etimer_reset(&periodic_timer);
    entry = akes_nbr_head();
    if(entry && entry->permanent) {
      akes_trickle_stop();
      break;
    }

    // Store rssi value
    r = cfs_write(fd, &rssi, sizeof(rssi));
  }
}

However I'm getting problems like:
"lvalue required as unary '&' operand"
I've tried using '*' instead of '&' and what not but I can't seem to get it to work. Could anyone point me in the right direction?
EDIT:
PACKETBUF_ATTR is a struct that contains a value according to the header file:
typedef uint16_t packetbuf_attr_t;

struct packetbuf_attr {
  packetbuf_attr_t val;
};

They gave me an example of printing the values:
  memcpy(&counter, data, sizeof(counter));
  printf("B,PING,%lu,%u,%lu,%i,0\n",
      clock_time(),
      (uint8_t)packetbuf_attr(PACKETBUF_ATTR_CHANNEL),
      counter,
      (int8_t)packetbuf_attr(PACKETBUF_ATTR_RSSI));

A: The function packetbuf_attr() returns value of type packetbuf_attr_t, which is just another name for uint16_t (unsigned 16 bit integer):
typedef uint16_t packetbuf_attr_t;
You don't need to use pointers. The important issue is that RSSI is a signed integer, usually below zero, and always fits in 8 bits. Taking this into account, you need to cast the return value of packetbuf_attr() to the correct type:
static int8_t rssi;
...
rssi = (int8_t)packetbuf_attr(PACKETBUF_ATTR_RSSI);


text:
Q: chrome extension keyboard command - press-and-hold behavior In my chrome extension manifest I have a command defined as such:
"commands": {
  "my-command": {
    "description": "my command",
    "suggested_key": {
      "default": "Ctrl+X",
      "mac": "MacCtrl+X"
    }
  }
},

So that if the user presses Ctrl and x, it will run the my-command handler that I have defined in my background page.
However, I want to differentiate between two types of keyboard actions:

*

*The user holds Ctrl and then presses x and then releases both of them. I'll call this "press-and-release". Ie. the usual way someone would press a keyboard shortcut

*The user holds Ctrl and then holds x for some long time (eg. 1 second). I'll call this "press-and-hold".

If the user does a "press-and-release" of the shortcut, I want to run a certain handler, whereas if the user does a "press-and-hold" of the shortcut, I want to run a different handler.
It doesn't look like the Chrome extension command API differentiates between different types of keypress events, it seems to run immediately upon keydown (not keyup) of the x.
How can I execute different handlers depending on the type of interaction, either "press-and-release" or "press-and-hold"?


text:
Q: How to upload only iMessage Sticker app? I want to make an only Sticker app, i built Sticker Extension in Xcode 8. Created new app id in developer portal also. But in iTunes Connect there's no option for New iMessage Sticker App ? How do i upload my sticker app build ?

A: You upload your iMsg extension like any regular iOS app, there is no specific option

A: Upload it like a regular one as they're just considered a New App according to this Apple page: https://developer.apple.com/app-store/imessage-app-submissions/
It looks like they're just considered Apps for the purpose of submission on iTC. It states, in part:

Sticker pack app. This is a basic sticker pack made up of images or animated images, which you don't need to use code to build. You can list it in the Stickers category and in relevant Stickers subcategories on the App Store for iMessage.
iMessage app. Your app can include stickers, text, video and audio. You can also use code to add functionality such as Apple Pay and in-app purchase. Choose to list your app in the Stickers category or another relevant category on the App Store for iMessage.

info. in FAQ page:

How do I create an iMessage app or sticker pack in iTunes Connect? From My Apps, click on the plus sign and choose New App. Then, select iOS app and complete the required metadata. You can find more detailed instructions in the Creating an iTunes Connect Record for an App section of the iTunes Connect Developer Guide. If you are unfamiliar with the Messages framework, but want to learn how to get started, you can read about it here.

Reference: https://apple.stackexchange.com/questions/251878/how-do-i-submit-sticker-apps-in-itunesconnect

A: I'm using fastlane to upload sticker pack app to app store. So my advice is you should try with fastlane.
Document refer:
Fastlane Tutorial
Automate Screenshots With fastlane
Good luck. Hope you enjoy with sticker pack app!


text:
Q: Is it a bad idea to learn Ruby and Python simutaneusly? I'm learning these Ruby and Python interactively and simultaneously. My goal is to learn them at the same time so that I can decide which one I like the most. Is it a bad idea to learn them simutaneusly?

A: Not really, but both (Python & Ruby) languages are somehow similar (scripting languages, dynamically typed, with powerful object & class systems). Learning a very different functional language like Haskell or Ocaml (in addition of Ruby or Python) will open more your mind.


text:
Q: Add text to empty label in div without adding height to div the problem is the following in have some inputs between css line separators, they are all alined vertically, and have labels beneath the inputs.
the problem is when there is a validation error , some text is put inside this labels, making them visible, this makes the div bigger and causes the container div to have bigger height therefore input is no longer aligned vertically.
is there a way so the label can already have height diferent from zero when there is no text?

A: Does this help?
jsfiddle : http://jsfiddle.net/thecbuilder/BKrHq/
Approach 1
in this solution, div containing label is given a fixed height according to font size.
html

    <input type="text" id="txt" value="label content"/>

    <input type="button" value="Show Content in label" id="showLab" />

css
#labDiv{
    height:18px;
}

Approach 2 in this approach, label is given text : a space character -   to get it to the actual height , same as when it will contain the text.
js fiddle :
http://jsfiddle.net/thecbuilder/4Bazb/
html

    <input type="text" id="txt" value="label content" />

    <input type="button" value="Show Content in label" id="showLab" />

quick implementation of approach 2 :
if you have a common class for all such labels then you can use :before in css to add a space quickly.
if the class is : errorLabels
.errorLabels::before
{
content:"\00a0";
}

A: Just set a min-height for label div in css. It means that even if there is no tag the label is going to have some height but if text increases then label will adapt to the height of the text inside it.
#labelDiv{
min-height:14px;
}


text:
Q: html form fade with more than one form As you guys know, the .fadeOut and .fadeIn command can be used to fade various elements in and out. My problem is that I have multiple forms and unlike paragraphs whose tags can be made unique through incrementation all forms have the exact same tag. I want to fade out 1 or more forms while leaving the others intact. What can I do? Can I create a custom form tag? Is there a fade command that allows the user to specify the id of the element?
For example:
<!DOCTYPE html>

<form id=form1>
<input id="check1" type="checkbox" />Print Design

</form>

<form id=form2>

<input id="check3" type="checkbox" />Web Design
</form>

This is a paragraph.

<button class="btn1">Fade out</button>
<button class="btn2">Fade in</button>

http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_eff_fadeout_fadein
Paste the above code into the compiler at w3schools. You will find that simply putting the ID number in as the argument  does not work. This is because the command is expecting a kind of tag like the  tag.

A: fadeIn and fadeOut would work with any selectors
$('#ID').fadeIn('slow', function() {
        // Animation complete
      });

A: The syntax for specifying the id is to add a # before the id name.
In your case, the id name is form1, so you should be doing
$('#form1').fadeIn();

A: Also, why separate fadeIn/Out? Use .fadeToggle().


text:
Q: Math Problem with Sets of words over alphabet I am looking for a book on Math Problems with words over alphabet.
For example:
Write in Set-theory Language a word:
ex.1 bbbbbbbb.....
ex.2 ba....
ex.3 bba.....
ex.4 bbba......
and so on
The formulation would be a word consisting out of b until the first transition of a.
But to learn i would need some exercise( with solutions if possible)
My solution so far is to create a automata and look for subwords which leads to the final state.


text:
Q: How to use Equivalence.wrap() to dedupe a Set? I must be missing something about Equivalence.wrap() but the following test fails for me - using guava 18.0 at the very last line only. Why? What am I doing wrong? My aim is to deduplicate equivalent objects by adding them to a set.
    @Test
    public void testEquivalenceWrap()
    {
        final Equivalence<Program2> eq = EquivalentIfIDsEven.INSTANCE;

        Program2 p1 = new Program2();
        p1.setId(2L);

        Program2 p2 = new Program2();
        p2.setId(4L);

        //sanity-test equivalence impl
        assertFalse(p1.equals(p2));
        assertTrue(eq.equivalent(p1, p2));
        assertTrue(eq.wrap(p1).equals(eq.wrap(p2)));

        //dedupe in set
        final Set<Equivalence.Wrapper<Program2>> set = new HashSet<>();
        set.add(eq.wrap(p1));
        set.add(eq.wrap(p2));

        assertEquals(1, set.size()); //FAIL: size == 2
    }

A: You'd get this behavior if your Equivalence doesn't implement hashing correctly.  Without seeing more code, I can't suggest something more specific, but that's almost certainly what's happening.

A: If I were you, I try to use this class (example EqualsEquivalence from javadoc in Equivalent class) in you test:
static final class EquivalentIfIDsEven extends Equivalence<Program2>
        implements Serializable {

    static final EquivalentIfIDsEven INSTANCE = new EquivalentIfIDsEven();

    @Override protected boolean doEquivalent(Program2 a, Program2 b) {
        return a.equals(b);
    }
    @Override protected int doHash(Program2 o) {
        return o.hashCode();
    }

    private Program2 readResolve() {
        return INSTANCE;
    }
    private static final long serialVersionUID = 1;
}


text:
Q: ordering keys from Javascript object I saw this topic and the answers, but it doesn't seem to work for me. I tried alll variants of the values in the Object and sort, but it doesn't seem to work. I want to get a list ordered on the keys (not their values) in the objects (the, in this example 2 objects are in in a json):
d3.json:
{
"TEST1":    {"purchase": ["yes", 2], "safety": ["no", 3], "quality": ["Carried by the husk", 1], "name": ["Eggs!", 0]},
"TEST2":    {"purchase": "yes", "safety": "no", "quality": "Carried by the husk", "name": "0"}

}
And the JavaScript:
d3.json("d3.json", function(root) {

  for (key in root) {
      console.log(root[key]);
      var test = root[key];
      var list = Object.keys(test).sort(function(a,b){ return test[a]-test[b] })
      console.log(list);
  }
});

EDIT: Apologies, I wasn't clear on the expected results: I was looking for the keys sorted, but return with their values as the answer of dlopez did.

A: Try with this:
var sortedByKeys = Object.keys(root)
    .sort(function(a,b) { return a - b; })
    .reduce(function(prev, curr) {
        prev[curr] = root[curr];
        return prev;
    }, {});

A: By using test[a] - test[b] in the sort call back function, you sort by the property values, not the keys. To sort by the keys you can use this:
  var list = Object.keys(test).sort(function(a,b){ return a.localeCompare(b) })

which is the default sorting order, so:
  var list = Object.keys(test).sort()

A: You could simply use
var list = Object.keys(test).sort();


text:
Q: Replace based on 2 columns I have a table where I'd like to replace data based on 2 columns.
My query currently looks like this:
$query = "REPLACE INTO `".$database."`.`".$table_extras."` (`id`, `multiverseid`, `rulings`, `printings`, `foreignNames`) ";
$query .= "VALUES (".$cardCount.",
    ".$multiverseid.",
    '".addslashes($rulings)."',
    '".addslashes($printings)."',
    '".addslashes($foreignNames)."');";

Currently with the above query things get replaced based on 'id'. How can I make it so it's replacing based on 'id' AND 'multiverseid'?
When I created my table it looked like the following:
CREATE TABLE IF NOT EXISTS `extras` (
  `id` int(10) unsigned NOT NULL,
  `multiverseid` int(10) unsigned NOT NULL,
  `number` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `rulings` text COLLATE utf8_unicode_ci NOT NULL,
  `printings` text COLLATE utf8_unicode_ci NOT NULL,
  `foreignNames` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`, `number`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

A: Create a unique index on id, multiverseid:
create unique index t_id_multiverseid on table_extras(id, multiverseid);

The only issue is the following.  If id is already unique or a primary key, then it will continue to be used by the replace.  You would need to drop this constraint.

A: REPLACE INTO replaces based on the primary key or unique index.
Create a unique index on id and multiverseid:
create unique index table_extras_id_multiverseid on table_extras(id, multiverseid);

The documentation says:

if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.

A: It sounds like the table's primary key is "id".  This makes it a little hard to parse your question :)
Perhaps your actual intention is to have a table with a primary key across both the id and the multiverseid columns, in which case your REPLACE would work as you require.


text:
Q: Firestore Security Rules Request Parameters In Firestore security rules, is there a way to access the parameters send as part of a list request?
GOAL: I want to retrieve a single post-document that is published, by using its slug property.
QUERY:
let postDoc = this.afs.collection( 'posts', ref => ref
    .where( 'published', '==', true )
    .where( 'slug', '==', slug )
    .limit( 1 )
);

RULE:
allow list: if ( resource.data.published == true )
            && ( resource.data.slug == request.resource.data.slug )
            && request.query.limit <= 1;

PROBLEM: This results in 'no permission' error. However, if I remove ( resource.data.slug == request.resource.data.slug ) it works fine. I assume the problem is that request.resource.data.slug only exists for write requests, not for read requests (see https://firebase.google.com/docs/reference/rules/rules.firestore.Request).
Is there a way to make this work?


text:
Q: Koch snowflake paradox: finite area, but infinite perimeter The Koch snowflake has finite area, but infinite perimeter, right?
So if we make this snowflake have some thickness (like a cake or something), then it appears that you can fill it with paint like this ($\text{finite area} \times \text{thickness} =\text{finite volume}$), but on the other hand, you can't paint its sides ($\text{infinite perimeter}\times\text{thickness}=\text{infinite surface area}$)... Is there something I am getting wrong? Is there a clever trick to it, or am I just misunderstanding something?
My teacher (I'm in middle school) told me that this is some higher-level maths I won't understand now.

A: You can fill the finite extruded Koch snowflake 3-D volume with a finite amount of 3-D paint.  But the Koch snowflake, while topologically a 1-D line, has Hausdorff dimension $\log_3 4 \approx 1.2618\ldots$, because each edge is made of 4 copies of itself each 3 times smaller.  The extruded cookie cutter Koch snowflake surface, while topologically 2-D, has dimension $1 + \log_3 4 \approx 2.2618\ldots$ because it is the Cartesian product of a 1-D line and a $\log_3 4$-D snowflake curve.  To paint this surface you would need $1 + \log_3 4$-D paint, not 2D paint or 3D paint, and how much of it you need would be determined by $1 + \log_3 4$-D Hausdorff measure of the surface.  What the precise value of this measure is, is still an open question, according to Wikipedia.
In short, to measure a n-D object you need an n-D ruler, and fractal objects often have fractional n.
Hausdorff dimension is defined in terms of Hausdorff measure: the dimension $s$ is the value at which the $t$-dimensional measure switches from $\infty$ (for $t < s$) to $0$ (for $t > s$).

A: What you've found is a fundamental property (or perhaps it would be better to say lack of property) of arc length in two dimensions — or going up one dimension, surface area in three dimensions: it's not 'continuous' with respect to small changes in shape.
You don't even need a Koch snowflake or similar fractal curve to see this; give me any shape — for instance, a circle — and give me an arbitrarily small box that its boundary passes through, and I can give you a shape that looks exactly the same outside the box but that has arbitrarily large arc length.  For an example of this, imagine starting with the curve $y=\sin^2(\pi x)$ between $x=0$ and $x=1$. Then the exact arc length of this curve is hard to compute, but we can put a lower bound on it: the curve goes from $y=0$ to $y=1$, then from $y=1$ to $y=0$ again, so it must have total length at least $2$. $(^*)$
But now consider the curve $y=\sin^2(2\pi x)$ between $x=0$ and $x=1$.  This is two copies of the sine curve placed next to each other, and its $y$ values take the 'path' mentioned above twice, so it must have total length at least $4$.  And more generally, $y=\sin^2(n\pi x)$ has arc length at least $2n$ between $x=0$ and $x=1$. But the curve is always within the rectangle $0\leq x\leq 1\pi$, $0\leq y\leq 1$.  So imagine that you tell me you want to get a continuous curve with minimum arc length $\ell$ that fits into a box of size (side length) $d$.  Then I know that if I create a curve with arc length $\ell/d$ within a $1\times 1$ box, I can scale it by a factor of $d$ and get a curve of arc length $\ell$ within the $d\times d$ box. But I also know that I can create a curve with arc length at least $\ell/d$ in the $1\times 1$ box by using the curve $y=\sin^2(2\pi\ell x/d)$ (for $0\leq x\leq1$).  So I can just "paste" this curve in wherever you tell me; I've only modified things within the $d\times d$ box, but I've made the arclength arbitrarily large.
As for what this has to do with 'painting' the snowflake, consider the thickness of the paint you're using to try and paint the sides of it. If you want your paint layer to have a finite thickness $\tau$, then we're not necessarily talking about the Koch snowflake itself, but just a curve that lies within a distance $\tau$ of it everywhere; since the paint 'hides' anything smaller than $\tau$, we can't tell the difference between the two anyway.  But for any $\tau$ there are curves that stay within distance $\tau$ of the snowflake but have finite length! So we only need a finite amount of paint to do the painting here.  And as your paint gets thinner and thinner, the length that you need to cover will increase — but that's all right, because your paint will spread farther and farther. In the limit, you're talking about 'painting' the infinite length of the snowflake itself — but now your paint layer is infinitely thin, so it shouldn't be too surprising that you can make it stretch as far as you need to.  (This is very much analagous to taking a one-square-unit 'bucket' of 2d paint and noting that you can paint a $1$ unit $\times 1$ unit square with it, or a $2$ unit $\times 1/2$ unit rectangle, or a $1000$ unit $\times 0.001$ unit rectangle, or...)
Meanwhile, I can't do the same thing with area (or in the 3d case, volume); it's clear to see that any modifications that are made within a $d\times d$ box can only change the area of the figure (one way or the other) by at most $d^2$. $(^*)$ So if you tell me that you want to increase the area bounded by your shape by a thousand square units but only give me a $1/10\times 1/10$ unit box to do it in, I can fairly tell you that that's impossible.
Incidnetally, this same lack of continuity for arc length is at play in another very similar 'paradox': The staircase paradox, or why $\pi\ne4$ . The fundamental explanation is the same: the fact that two curves are arbitrarily close to each other along their entire spans tells you nothing about how close their arc lengths are.
$(^*)$ Note that I haven't given you proofs of these assertions! You should be skeptical here, because you've already seen that behavior doesn't necessarily match what you might expect where these things are concerned. Fortunately, these assertions are true, but proving them would require going pretty far afield.

A:
but on the other hand, you can't paint it's sides (infinite perimeter×thickness=infinite surface area)... What am I getting wrong?

The assumption behind this formula is that painting the edges of some form means replacing each edge by a rectangle.
(One edge length of each rectangle is the "thickness" of the pen and the other edge length is the length of the edge which is replaced by the rectangle.)
However this assumption is not correct because at the corners of the original form the rectangles would overlap when painting like this.
To calculate the real area of the "painted edge" you first have to define how the corners of the form are painted. This image from the manual of a graphics program shows different examples how this can be done. And it is obvious that the "painted" area will be different in the three cases shown in the manual.
EDIT

Thickness appears to be the width of the curve in the Z dimension, in order to bring the problem into 3D space.

Sorry for me not having understood the problem correctly.
However you could also extend my answer into 3D space:
Why should it not be possible to paint a surface having an infinite area?
I think the assumption is that varnish (or whatever type of color is used) itself has some "thickness" and therefore "painting" an infinite area would require an infinite volume of varnish.
This means that that rectangles are replaced by cuboids.
However this assumption is equivalent to the assumption that painting the edges of some form in 2D space means replacing lines by rectangles.

A: You can see this paradox already with the "angel's bugle" obtained by rotating the curve
$$y(x)={1\over x^{3/4}}\qquad(x\geq1)$$around the $x$-axis. The volume
$$\pi \int_1^\infty y^2(x)\>dx$$
of this bugle is finite, whereas its surface area
$$2\pi\int_1^\infty y(x)\sqrt{1+y'^2(x)}\>dx$$
is infinite. The latter would indicate that you need an infinite amount of gold to gild it on the inside, even though the volume is finite. The resolution of the apparent paradox is the following: In the term "gilding" we are conveying the impression that every surface element is plated with the same thickness, however small. But for the inside of an "angel's bugle" this is not possible since the cross-sectional diameter of the bugle converges to $0$ when $x\to\infty$.

A: This seems to be a derivative of the well-known coastline paradox
When you "paint" the Koch snowflake with a line of nonzero width, you are effectively sampling the fractal at a resolution of the line width. By doing so, you do not obtain the length of the infinite fractal, but instead a fractal with finite iterations, therefore obtaining a finite length.
This is analogous to the coastline paradox, which states that sampling a coastline at a higher resolution will yield a longer coastline than when the coastline is sampled at a lower resolution. In the example given by Wikipedia, sampling the coastline of Great Britain at 50km resolution gives a coastline length that is 600km longer than if it is sampled at 100km resolution.

A: Take a half of a big sweet orange fruit of radius $R$ and a half of a mandarin of radius $r<R$.
Put them together with flat surfaces, aligning centers of both fruits.
The volume of the solid you created is half the orange volume plus half the mandarin volume: $\frac 12\cdot\frac {4\pi}3(R^3+r^3) = \frac {2\pi}3(R^3+r^3).$
The surface area, however, is half the external area of an orange fruit plus half the external area of a mandarin fruit PLUS the area of an annulus shape of the part of an orange not covered by a part of mandarin: $\frac 12\cdot 4\pi(R^2+r^2) \color{red}{+ \pi(R^2-r^2)}.$
Now split both half-fruits by halves and interleave resulting quaters.
The resulting solid has the same volume, equal half the sum of an orange volume and a mandarin volume, but the surface area increased by another $\color{red}{+ \pi(R^2-r^2)}.$
Every new split of two neighboring segments and swap of two resulting new sub-segments increases the area by $\color{red}{+ \pi(R^2-r^2)}$ while preserving the original volume. As a result you can get a bounded figure with a volume known in advance but arbitrarily large surface area – you just need to slice two half-balls into segments thin enough and interleave them!
By the way, this is a 3D analogue of a flat gear/cogwheel with increasing number of ever thinner teeth, while preserving a constant radius and a constant tooth length.
The important difference between the described figures and a Koch snowflake is that consecutive iterations of Koch's curve are in a well-defined sense convergent to some 'final' curve, while sliced citrus fruits or gears are not. In layman terms we can say the Koch's curve changes are smaller and smaller in every iteration, while gear teeth disappear where they were and reappear in a bigger number (but smaller width) in new places.
However, that can be circumvented by gradually reducing widths of teeth and preserving positions of those already added.
On the other hand, the important common property of all described shapes is that they finally have infinitely many infinitely narrow niches, so you actually can't 'paint' them – any physical paint consists of particles of finite sizes, so it can't fill those super-tight corners.
Mathematically speaking, though, we have what we aimed: bounded (finite-size) figures with finite interior volume but infinite surface area (in 2D: finite interior area and infinite boundary length, respectively).

A: Overlap
Paint paradoxes like this stems from the unspoken assumption that every surface will be painted with a layer of paint of a finite thickness.
There are two errors in this:

*

*Adjacent surfaces will have overlapping paint in concave corners.

*It is not certain there will be enough room inside the figure to reach the prescribed thickness of paint.
These errors may apply to every shape, no matter if fractal or not, finite or infinite.
For the paradox to work, every segment of the infinite path must be entirely covered with an evenly thick layer of paint. And if these segments were not joined but instead floating freely, then this condition could be fulfilled.

But these segments are not floating freely; they are joined. And with that, the layers of paint from neighbouring segments will bump into each other.

Even worse is when neighbouring paths start to interfere with each others' layers of paint, such that the paint ends up outside the shape.

With this the paradox has broken down and it is easy to see the faulty assumptions that led to its erroneous conclusion.

A: A fractal with an infinite perimeter isn't something we can physically produce -- it's only a concept. However, we can produce a physical approximation with a finite perimeter. The complexity or length of the perimeter is limited by the resources available to produce it, the materials used, and the laws of physics.


text:
Q: Is there a way to change the namespace of an android app or remove it from an internal test? Is there a way to change the namespace of an android app or remove it from an internal test on play store?
Background
We are helping a company adding our app with some small changes to their internal mobile platform. One of the steps we made was to change the namespace of the app so it would work for them. For example com.company.appname. Things where taking some time and we were eager to some internal testing of the via our play store login. That worked great but now when the company is trying to publish the app on their internal mobile platform via google play store it's that the namespace is used some where else.
•   I have tried to remove the app from our internal test play store.
•   I have tried to change the app namespace in our internal test play store. From com.company.appname to com.ourcompany.appname with out any success.

A: If the app is not published and no one has the app installed google play support can delete the application.


text:
Q: How-to: reset window "tab" in Haiku? I have been running Haiku in various environments now for several months, but have run across an interesting issue: WebPositive (the browser that ships with Haiku) has lost its yellow tab at the top of the window, and only displays in full-screen mode.
How can I reset that behavior? The yellow tab is highly useful, exspecially when needing to shrink the window, since right now I can't change the window size :-|
current "normal" window:

full-screened:

how it should look (fresh install):

A: I'm not sure if I understand this question correctly, but the full screen mode of WebPositive can be left via F11, or Alt-Enter. Furthermore, there is a small window icon in the top right corner when you move the mouse, that, when pressed, will let you leave full screen as well.

A: Open a Terminal and try
hey WebPositive SET Frame of Window 2 to BRect[100,100,600,600]

That should at least give you something small enough to drag the yellow tab back into view.


text:
Q: How to Make Simple Snake Game in c# console? I'm trying to do a basic snake game in c# console. But I it's not working as I want now. I'm trying to do the snake 5 * size but when I'm trying to do it something weird happening. It is working perfectly fine with 1 * size. But I'm trying to do it like when I press the s button it should go down and rest of the snakes body should be twisted as normal but in my snake game it's not twisting at all. I could only got that far.
using System;

namespace SnakeGame
{
    class App
    {
        public static void Main()
        {
            char ch;
            int col = 38, row = 15;
            System.Console.CursorVisible = false;
            System.Console.SetCursorPosition(col, row);
            System.Console.Write("*");
            for (; ; )
            {
                ch = System.Console.ReadKey(true).KeyChar;
                System.Console.SetCursorPosition(col, row);
                System.Console.Write(" ");
                switch (ch)
                {
                    case 'a':
                        --col;
                        break;
                    case 'w':
                        --row;
                        break;
                    case 's':
                        ++row;
                        break;
                    case 'd':
                        ++col;
                        break;
                    case 'q':
                        goto EXIT;
                }
                System.Console.SetCursorPosition(col, row);
                System.Console.Write("*");
            }
        EXIT:
            System.Console.CursorVisible = true;
        }
    }
}

A: One idea for creating a snake with a body is to store the snake body positions in a list. We can use a System.Drawing.Point to store the X and Y coordinates of a body part, so the snake would be a List<Point>.
Then, as we're moving the snake, we do two things:

*

*Draw the new head

*If the snake length (List.Count) is too long, remove the last character from the tail.

For example:
public static void Main()
{
    var snakeLength = 5;
    var snake = new List<Point> {new Point(38, 15)};

    Console.CursorVisible = false;
    Console.SetCursorPosition(snake.Last().Item1, snake.Last().Item2);
    Console.Write("*");

    while (true)
    {
        var ch = Console.ReadKey(true).Key;
        if (ch == ConsoleKey.Q) break;

        var tail = snake.First();
        var head = snake.Last();

        if (snake.Count >= snakeLength)
        {
            Console.SetCursorPosition(tail.X, tail.Y);
            Console.Write(' ');
            snake.RemoveAt(0);
        }

        switch (ch)
        {
            case ConsoleKey.A:
            case ConsoleKey.LeftArrow:
                snake.Add(new Point(head.X - 1, head.Y));
                break;
            case ConsoleKey.W:
            case ConsoleKey.UpArrow:
                snake.Add(new Point(head.X, head.Y - 1));
                break;
            case ConsoleKey.S:
            case ConsoleKey.DownArrow:
                snake.Add(new Point(head.X, head.Y + 1));
                break;
            case ConsoleKey.D:
            case ConsoleKey.RightArrow:
                snake.Add(new Point(head.X + 1, head.Y));
                break;
        }

        head = snake.Last();

        Console.SetCursorPosition(head.X, head.Y);
        Console.Write("*");
    }

    Console.CursorVisible = true;
}

Now this seems to work ok, but it puts all the burdon of moving a snake in our Main method, which is both messy and not portable. To improve upon this, we could make a Snake class that knows how to draw and move a snake, and we can give it properties like Length and Symbol that can be set by the user of the class.
To further encapsulate our code, we might want to make a SnakePart class as well, which knows how to draw or erase a single character of the snake, and then we can have a collection of these SnakePart objects stored in our Snake class.
For example:
public class SnakePart
{
    public char Symbol { get; set; }
    public Point Position { get; set; }

    public SnakePart(Point position, char symbol)
    {
        Position = position;
        Symbol = symbol;
    }

    public void Draw()
    {
        Console.SetCursorPosition(Position.X, Position.Y);
        Console.Write(Symbol);
    }

    public void Erase()
    {
        Console.SetCursorPosition(Position.X, Position.Y);
        Console.Write(' ');
    }
}

Now we can create a snake from these parts:
public class Snake
{
    public enum Direction { Up, Down, Left, Right }

    public char Symbol { get; set; }

    private readonly SnakePart[] _body;
    private SnakePart Head => _body.First();
    private SnakePart Tail => _body.Last();

    public Snake(Point startingPoint, int length, char symbol = '*')
    {
        Symbol = symbol;

        // Initialize our array with all parts starting at the head position
        _body = Enumerable
            .Range(0, length)
            .Select(x => new SnakePart(startingPoint, symbol))
            .ToArray();
    }

    public void Draw()
    {
        foreach (var snakePart in _body)
        {
            snakePart.Draw();
        }
    }

    public void Move(Direction direction)
    {
        // Create a new part that will be placed in the new head location
        SnakePart newHead = null;

        switch (direction)
        {
            case Direction.Up:
                newHead = new SnakePart(new Point(Head.Position.X,
                    Head.Position.Y - 1), Symbol);
                break;
            case Direction.Down:
                newHead = new SnakePart(new Point(Head.Position.X,
                    Head.Position.Y + 1), Symbol);
                break;
            case Direction.Left:
                newHead = new SnakePart(new Point(Head.Position.X - 1,
                    Head.Position.Y), Symbol);
                break;
            case Direction.Right:
                newHead = new SnakePart(new Point(Head.Position.X + 1,
                    Head.Position.Y), Symbol);
                break;
        }

        // Erase the tail, move all parts one index towards
        // the end of the array, add the new head and draw it
        Tail.Erase();
        for (var i = _body.Length - 1; i > 0; i--)
        {
            _body[i] = _body[i - 1];
        }
        _body[0] = newHead;
        Draw();
    }
}

After this, our Main method code is a little cleaner and easier to read and maintain:
private static void Main()
{
    Console.CursorVisible = false;
    var snake = new Snake(new Point(Console.WindowWidth / 2, Console.WindowHeight / 2),
        5, '*');

    snake.Draw();

    while (true)
    {
        var ch = Console.ReadKey(true).Key;
        if (ch == ConsoleKey.Q) break;

        switch (ch)
        {
            case ConsoleKey.W:
            case ConsoleKey.UpArrow:
                snake.Move(Snake.Direction.Up);
                break;
            case ConsoleKey.S:
            case ConsoleKey.DownArrow:
                snake.Move(Snake.Direction.Down);
                break;
            case ConsoleKey.A:
            case ConsoleKey.LeftArrow:
                snake.Move(Snake.Direction.Left);
                break;
            case ConsoleKey.D:
            case ConsoleKey.RightArrow:
                snake.Move(Snake.Direction.Right);
                break;
        }
    }

    Console.CursorVisible = true;

    GetKeyFromUser("\nDone! Press any key to exit...");
}

A: Please do not use GOTO statements, its considered bad practice. I would use a while loop with some exit condition that when met exits the loop, for example when the player wins/loses, it exits.
As far as the question goes, it looks like you are just erasing and rewriting the snake head when the player moves the snake. If you wanted it to behave like a traditional snake game, you would have to look at which direction the player moved it, look at all the current locations of the snake's * body parts, then calculate each body part's new position based on which direction the player is moving the snake to.
You could also just move the snakes head, then the 2nd part of the snakes body will be at the same position the head was just in, the 3rd part will be in the 2nd part's previous position, and so forth and so on until you calculate each body part's position, erasing and writing the new positions as you go along.
You may want to also think about encapsulating some of this logic into a snake class because its going to get messy trying to do it all in a for loop.
After that you can start to tackle more difficult issues like what happens when you move into a wall.


text:
Q: Single Axis Zoom in D3 & React I am currently trying to make a simple graph using D3 and React, where it is possible to zoom in/out on both axes, or on one of the two axes separately. An example of such a graph made only with D3 is available here (http://bl.ocks.org/jgbos/9752277).
I managed to get the same behaviour using D3 and React, as you can see in this sandbox (https://codesandbox.io/s/objective-cohen-b92pr). This example works almost perfectly, but I sometimes see a "jump" when, for example, I zoom in on Y, then X and then both (see gif below).

My guess is that d3 stores a zoomTransform object {k, x, y} for each container (x-axis-listener, y-axis-listener & svg) on which the zoom event is called.  I suppose we should be able to share the same instance of the object between all the containers, but so far I have not been successful.
Any guesses?
Thanks a lot !

A: There is a good reason why you can either have X and Y zoom separately, or have a single zoom factor in your graph (which applies to both X and Y), but you cannot have a situation where you can smoothly change them all. That's why:
A D3 zoom identity object has 3 attributes: x, y, k, where x and y are offsets from the initial pos (0,0) and k is the current zoom factor (1 by default).
Now, if you want to manage 3 separate zoom identities, you have actually 3 different objects {xV, yV, kV} for vertical zoom, {xH, yH, kH} for horizontal and {xG, yG, kG} for the global zoom. When you rescale, you can apply xV to xH, yH to yG and so on, but you cannot apply two different values (kV and kH) to one (kG), you will need to choose between them (otherwise you have a logical contradiction here).
UPD: You can, however, replace zoomBoth callback with mouseWheel event handler, take X and Y zoom identities, change both of them proportionally (divide or multiply to the same number) and then apply changed zoom identities to both X and Y scales. It's possible :)

A: I finally came up with a working solution, which can be found here: https://codesandbox.io/s/quirky-yalow-3y6q4. This is mainly a refacto in React of this code observable: https://observablehq.com/@d3/x-y-zoom.
I'm using only one global transform object in the dom, and using the useState hook to store the global transform previous value, and one transform object for each axis.
The actual and the previous global transforms object allows me to retrieve the parameters to pass to the transform.translate and transform.scale methods in order to update the axis transforms object accordingly to where my mouse is.
This feels really "hacky" to me and I there should be a more elegant way of doing this.


text:
Q: Cannot set variable to CURRENT_DATE() in MySQL trigger I am writing a trigger to insert tuples into a relationship table. In the process, I amm trying to insert the current date into one column, using the native CURRENT_DATE() function. I have tried multiple calls to CURRENT_DATE(), but there is a persistent problem getting the date into my today variable.
Here is my code:
DELIMITER //
CREATE TRIGGER AjouterChose
AFTER INSERT ON UneTable
FOR EACH ROW
BEGIN
DECLARE aujourdHui DATE;
SET @aujourdHui := (SELECT CURRENT_DATE());
INSERT INTO AutreTable ER (IdProfil,Chose2,DateDebut)
VALUES (NEW.Responsable, NEW.IdChose2, @aujourdHui);
END;//
DELIMITER ;

The MySQL error message is:
ERROR 1064(42000): You have an error in your SQL syntax; check the manual ...
for the syntax to use near ';

I've tried:
@aujourdHui
aujourdHui
(SELECT @aujourdHui)
(SELECT aujourdHui)
CURRENT_DATE()
(SELECT CURRENT_DATE())

None of these worked. Not sure what else is there to try.
Any help would be appreciated.

A: Are you saying that this does not work?
DELIMITER //

CREATE TRIGGER AjouterChose
AFTER INSERT ON UneTable
FOR EACH ROW
BEGIN
   INSERT INTO AutreTable ER (IdProfil, Chose2, DateDebut)
        VALUES (NEW.Responsable, NEW.IdChose2, CURRENT_DATE);
END;//

DELIMITER ;


text:
Q: Arrowheads are wrong color in svg graphic I have created a svg graphic with inkscape and use it in my LaTeX document. The graphic has a couple colorful lines with corresponding colorful arrowheads. Unfortunately pdflatex seems to arbitrarily assign the colors to the arrowheads. Exporting the svg to png in inkscape results in the correct arrowheadcolors, but then of course my math looks ugly. Has anyone experienced the same and knows of a way to get the correct arrowhead colors? There are already two different colors, so it's not like all arrowheads are treated the same.
Here is my minimal example
\documentclass{article}
\usepackage{svg}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\includesvg{arrowhead}
\caption{wrong colors of arrowheads in svg version}
\end{figure}
\begin{figure}
\includegraphics{pngarrowhead}
\caption{correct colors in png version}
\end{figure}
\end{document}

Here is the resulting pdf (screenshot thereof)

Here the png exported with inkscape (pngarrowhead.png)

And here is the original svg file. Sorry, but I cannot input it here directly, so I share it via a filehoster.
<svg width="98.852mm" height="46.58mm" version="1.1" viewBox="0 0 98.852 46.58" xmlns="http://www.w3.org/2000/svg">
 <defs>
  <marker id="Arrow1Mend" overflow="visible" orient="auto">
   <path transform="matrix(-.4 0 0 -.4 -4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
  </marker>
  <marker id="Arrow1Mstart" overflow="visible" orient="auto">
   <path transform="matrix(.4 0 0 .4 4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
  </marker>
 </defs>
 <g transform="translate(-35.241 -73.283)">
  <path d="m37.042 119.06 47.625-21.167" fill="#0f0" marker-start="url(#Arrow1Mstart)" stop-color="#000000" stroke="#008000" stroke-dasharray="8, 8" style="font-variation-settings:normal"/>
  <g>
   <path d="m84.667 95.25-47.625-21.167" fill="none" marker-end="url(#Arrow1Mend)" stroke="#f0f"/>
   <path d="m84.667 95.25 47.625-21.167" fill="none" marker-end="url(#Arrow1Mend)" stroke="#00f"/>
   <path d="m84.667 95.25 47.625 21.167" fill="#0f0" marker-end="url(#Arrow1Mend)" stroke="#0f0"/>
   <path d="m37.042 116.42 47.625-21.167" fill="#f00" marker-end="url(#Arrow1Mend)" stop-color="#000000" stroke="#f00" style="-inkscape-stroke:none;font-variation-settings:normal"/>
  </g>
  <text x="72.760414" y="82.020821" fill="#000000" font-family="sans-serif" font-size="10.583px" letter-spacing="0px" stroke-width=".26458" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="72.760414" y="82.020821" stroke-width=".26458">$x^2$</tspan></text>
 </g>
</svg>

A: As mrpiggi correctly suggested, this is a known issue in inkscape.
There is also a workaround listed, which is quite simple.
When selecting a marker for the path (like the arrow head in my example), be sure to always choose a fresh arrow marker from the drop down list, and not a previously used arrow marker which gets conveniently listed on top of the list.
To fix broken documents, simply select fresh arrow marker for all arrows in the document.

A: In Inkscape 1.2 if you save files as SVG version 1.1 you can fix the strange behavior by ticking the option under Preferences > Input/Output > SVG export > SVG 2 to SVG 1.1 use correct marker direction and use correct marker colors. This fixed the arrowhead color problem and arrowheads not shoving in Firefox issue for me.


text:
Q: create electron atom application via hardware information I need to create a desktop application.
Since lately I 've been using constantly javascript for my mobile html5 apps I was thinkning of using electron atom (former Atom Shell) to develop the desktop one.
The problem is that my client needs to be able to lock his application using hardware information like motherboard serial number or cpu id.
This is quite easy using usual desktop dev languages like c++, java e.t.c.
Can you imagine a way of fetching such information using javascript frameworks like electron atom?
For example cordova allows to develop plugins (using java for example for android apps). Is there something similar in electron atom.

A: That UUID is the best way to ID a machine, it exists in Windows, Mac and many other platforms. It is a 32 characters in length, universally unique identifier. You can run the above wmic command to get it.
You can make this using npm module called machine-uuid (https://www.npmjs.com/package/machine-uuid)
require("machine-uuid")(function(uuid) {
  console.log(uuid)
})


text:
Q: How do I import an external text file from a website and use a list from inside it I'm having trouble trying to make this work
import requests
import random
response = requests.get("https://cdn.discordapp.com/attachments/480168592164257792/557872162661335040/aaaaa.txt")
data = response.text
for line in data:
    print(line)

I am trying to pull a txt file from the internet, and be able to use the list inside of the text file.
Right now all it does is assume each letter is a different string(?)

A: response.text seems to be characters, if you loop over them you get each string. (Read about how Python handles strings).
In this case Python doesn't know what a "line" is. So split the data with newlines and try again:
import requests
import random
  response = requests.get("https://cdn.discordapp.com/attachments/480168592164257792/557872162661335040/aaaaa.txt")
data = response.text
for line in data.split("\n"):
  print(line)

A: The attribute response.text is a string, so iterating over it will give you individual chars. You can split the string by spaces (or maybe be newlines) to get what you need (I also added a few print statements to show the steps):
import requests
response = requests.get(
    "https://cdn.discordapp.com/attachments/480168592164257792/557872162661335040/aaaaa.txt")
print('response.text type:', type(response.text))
print('response.text len:', len(response.text))
print(response.text)

print()
print('splitting by spaces:')
for i, s in enumerate(response.text.split()):
    print(i, s)

print()
print('splitting by newlines:')
for i, line in enumerate(response.text.split('\n')):
    print(i, line)

The code gives this output:
response.text type: <class 'str'>
response.text len: 21
a = ["please","work"]

splitting by spaces:
0 a
1 =
2 ["please","work"]

splitting by newlines:
0 a = ["please","work"]

@bruno suggested in a comment to use str.splitlines(); this will work even if the response is bytes, since there also exists the method bytes.splitlines().


text:
Q: I'm unable to prove why maximum diffraction when wavelength = aperture size I know this is a popular topic, but I haven't read a similar argument to mine below, so here goes:
The phase difference between the top and the bottom of a slit of width $$,
for waves emerging at an angle $\theta$,
is $\phi$
Following the usual phasor construction to derive the result:
$I=I_0sinc{\frac{\phi}{2}}$
whose minima occur when $\phi = 2n\pi$
therefore
$\sin{\theta}=\frac{n\lambda}{a}$
With the construction shown here:

Considering the familiar statement:
diffraction is at a maximum when slit width = wavelength
I would say the following
As $0\leq\theta<90$ by definition, then for a certain order beam
$\theta\sim\arcsin{\frac{\lambda}{a}}$

*

*For $\lambda=a , \theta$ is maximised, as expected

*For $\lambda < a , \theta \rightarrow 0$, also as expected

but my question is: how do we account for $\lambda > a$, since arcsin is undefined for arguments outside $[-1,1]$?
I hope my questions has been laid out clearly - it's taken quite a while to write this out :) Thanks.