text:
Q: Enabling Bean Validation 2.0? I was trying to follow the instructions in the article below trying to implement a simple annotation just to test if a string was a certain length as a test.  My goal was to have this annotation thrown an exception at runtime if the String doesn't meet certain conditions.
https://dzone.com/articles/create-your-own-constraint-with-bean-validation-20
I'm able to add the annotation to the code and everything compiles & builds fine.  However, no matter what I do when I try to invoke it from a unit test I cannot get the validation to run.  I feel like I'm missing something obvious but I do not know what it is.  Note that this is a Java SE backend service so no UI component.  Let's take an example (which I know already exists of checking if a String is null or empty)
Here is the interface:
@Documented
@Constraint(validatedBy = {NotEmptyValidator.class})
@Target({METHOD, FIELD, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
public @interface NotEmpty {
    Class<?>[] groups() default {};
    String message() default "test message";
    Class<? extends Payload>[] payload() default {};
}

Here is the validator:
public class NotEmptyValidator implements ConstraintValidator<NotEmpty, String> {

@Override
public void initialize(final NotEmpty notEmpty) {
}

@Override
public boolean isValid(String notEmptyField, ConstraintValidatorContext constraintValidatorContext) {
    return !Strings.isNullOrEmpty(notEmptyField);

}

}
Note that retention is set to RUNTIME but it doesn't actually validate when I run a unit test on a String parameter that is an empty string.. how do I actually turn this validation on and get it to run?
for example if i have a random utility method
public static String testAnnotation(@NotEmpty final String foo) {
    return foo + "bar"
}

If I call that from a unit test even if the string is null or empty the validation doesn't run.  Any help would be appreciated!

A: If I understand it correctly, you expect to receive a validation exception when you call your testAnnotation() method in way similar to this example:
public void doThings(){
    // some code
    testAnnotation("");
    //no exception is thrown and code proceed to next statements...
    // more code
}

if that's so, then the problem is that validation will not occur but itself. You either need to perform validation explicitly on some bean:
public void doValidationManually() {
    Validator validator = Validation.byDefaultProvider()
            .configure()
            .buildValidatorFactory()
            .getValidator();

    MyObj obj = new MyObj();
    // some more initialization...

    Set<ConstraintViolation<MyObj>> violations = validator.validate( obj );

    // make any decisions based on the set of violations.
}

The validator can be initialized outside the method and not created each time when validation is required.
In case of validation of method parameters, Bean Validation does not support static methods, but in case of non static method you would need to either again run validation manually:
public void doMethodValidationManually() throws NoSuchMethodException {
    ExecutableValidator validator = Validation.byDefaultProvider()
            .configure()
            .buildValidatorFactory()
            .getValidator().forExecutables();

    Method testAnnotationMethod = MyObj.class.getDeclaredMethod( "testAnnotation", String.class );

    MyObj obj = new MyObj();

    Set<ConstraintViolation<MyObj>> violations = validator.validateParameters(
            obj, // an object on which a method is expected to be called
            testAnnotationMethod, // the method which parameters we want to validate
            new Object[] { "" } // an array of parameters that we expect to pass to the method
    );

    // make any decisions based on the set of violations.
}

Or you should be running your code inside a container and in that case validation on your methods will be delegated and performed automatically by container. For more info on this see Bean Validation with CDI, or using Spring.


text:
Q: Running ASP MVC web application as desktop application I am learning about creating web application with ASP MVC 5 for some time and i really like the MVC framework for making it easy. I personally consider my self as desktop developer, but i look with envy on rich user interface that web application provide.
I have an idea to create a desktop application using MVC framework. The idea is that my web application would be hosted by local iis epress. The server part would access all machine resources and present as rendered html. And i would like to rely heavily on MVC framework and Razor rendering engine for that matter.
I wander if anybody did it in the past and also think that this is not a bad idea. I know that i could run compiled mvc dll under iis express on my dev machine, but what should i do when i want to deploy my app to other machine that doesn't have either iis or iis express? Is there a way to run iis express without installation?

A: It is possible to self-host an ASP.NET 5/MVC 6 application by following the instructions. Perhaps you could have some sort of installation process add a shortcut so your application can be run by double-click.
Here is an answer about self-hosting MVC 5 with a hack of some sort.
Neither of the above solutions require IIS.
However, your best option for running a desktop application is to use WPF to build it. The stateless nature of the web makes it more difficult to deal with than a stateful desktop application.
Whichever UI option you choose, the important thing is to segregate the business logic from the UI so you can switch the UI later without too much effort.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I install Firefox Addons in Ubuntu? I am using Ubuntu 14.04 and I am browsing with the newest Firefox.
Where can I get addons/plugins (for example Adblock) and how do I install them?

A: Just google what plugin you want and it takes you to the firefox's official webpage for addons. You can simply just download from there and it automatically recognises which os you are using, so no need to worry all that. For example, the addon Adblock is right here


text:
Q: Cartopy incorrectly filling outside of Shapely polygon The Shapely polygon listed below as "mywkt" plots incorrectly in Cartopy; it fills the outside rather than the inside, despite being a valid polygon. In GIS software it plots correctly. The issue is occurring in many projections tested, including the one below. How can I correct it to fill the inside, as would be expected?

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.feature import ShapelyFeature
import shapely
import shapely.wkt as wkt

# Main plot setup, issue occurs regardless of projection used.
fig = plt.figure(figsize=[5, 5])
crs = ccrs.NearsidePerspective(central_longitude=-100, central_latitude=65, satellite_height=6200000)
ax = fig.add_subplot(1, 1, 1, projection=crs)

# Build and plot the polygon, valid
mywkt = "POLYGON ((-66.64127406774401 63.2679483443407, -66.48652697503979 63.1988718046901, -66.4817891045834 63.1004449790526, -66.379143168922 63.0115892305586, -66.1973803825985 62.9848443902565, -66.0559008189676 62.9537393506905, -65.97118398525259 62.9850694644843, -65.850509788396 62.9360773051236, -65.69642646101229 62.9192773820456, -65.6182098640938 62.8587266887857, -65.473922680887 62.8270608886491, -65.3890303678572 62.8197557451316, -65.31233201541011 62.7191354685271, -65.25006848777041 62.6268846390149, -65.12107061571631 62.5688402034127, -64.96662902810711 62.6103134144326, -64.52292746513029 60.3009837190234, -64.678588195289 60.3290634023542, -64.7726142595404 60.3596734442741, -64.8751520004644 60.2840499669325, -64.9515074450125 60.2243558221635, -65.0198404413832 60.1228099129471, -65.095375384966 60.0444670754952, -65.1483835964257 59.944148956709, -65.2920146315699 59.8405379513654, -65.453168021487 59.7919610620534, -65.47048148623151 59.6270483926692, -65.4267596751189 59.4696754279787, -65.49367684990671 59.3679086749455, -65.6342827626394 59.2531493848363, -65.6786190418353 59.1322782877129, -65.7005535515051 59.0241583127559, -65.8285595801605 58.9623716488326, -65.9420170341587 58.8275171137239, -66.0506960726655 58.7706855047323, -66.149750409254 58.7371845390353, -66.256134042452 58.7978006318937, -66.3347385322574 58.8311493351738, -66.45372349384409 58.800538690708, -66.49451082791229 58.7198367831411, -66.5676193169778 58.6466901412371, -66.6218795870732 58.5770604645689, -66.7814218532359 58.4949434629705, -66.88831340553919 58.4688908893032, -67.0380290656889 58.4144607966286, -67.1342663928796 58.3776258669403, -67.2353212911446 58.3398129542046, -67.33057432114791 58.3205410987927, -67.47232732814371 58.2854808444655, -67.5925217519772 58.1990972702229, -67.6903910465095 58.2706693512096, -67.7234163041191 58.3415155704872, -67.81171229568589 58.4379109661182, -67.9250695391279 58.4466397966894, -68.0271575596735 58.5408090366078, -68.1713938511453 58.5239214763951, -68.3308705567307 58.6276111553306, -68.37026229227089 58.7457949055105, -68.4149256971631 58.8196035851374, -68.5609516754794 58.8743733607421, -68.67261845427809 58.9022758569453, -68.8273157758023 58.9054559910013, -68.9202407883817 58.878506525256, -69.07570399414401 58.9052582049023, -69.2647591176391 58.8920751275651, -69.3652429760824 58.869404278185, -69.4899762315179 58.7899739103677, -69.6132537210823 58.7566270839728, -69.72686138794261 58.6796452157541, -69.842988449757 58.6732594077955, -69.8395047468465 58.8392757000136, -69.6917509226669 58.8574368306453, -69.5327113793267 58.8471842391614, -69.46260960175159 58.9405896192156, -69.4404513848235 59.0222669548561, -69.3474281644782 59.1017357623955, -69.3028958231836 59.2196576443848, -69.4281941172646 59.3568617410766, -69.5182813676909 59.3316304588787, -69.6520868841024 59.4400386197865, -69.65458094065789 59.5726276160716, -69.5578593654174 59.6813767639266, -69.5928206493534 59.798270974426, -69.70748724543991 59.9355825212164, -69.737201347664 60.0551376260007, -69.616491617694 60.15187842425, -69.6398101732009 60.2406957887797, -69.7022901640597 60.3436465118771, -69.7505086681404 60.4372696447783, -69.7298120033212 60.5385315013278, -69.6576941750461 60.635072446836, -69.58624424267749 60.736179235983, -69.5121017580896 60.7615279039897, -69.4052339964517 60.8147459704502, -69.4564300739886 60.9777373363091, -69.5537354306456 61.0800360797014, -69.67305901935821 60.9755718380699, -69.74723982315921 60.8975333096147, -69.84465196801381 60.847667578496, -69.99184594083739 60.836894867704, -70.1006539538168 60.9605688827478, -70.1916436091651 61.0764643475517, -70.3686452388866 61.0577015965515, -70.5324451896937 61.0420612242462, -70.66397847542621 61.043868155591, -70.8089575088819 61.0657154903776, -70.9218584021435 61.0859015570113, -71.1063331804318 61.1279448078067, -71.2168983247977 61.13527297217, -71.39589387470249 61.1518817695281, -71.5711726138249 61.2143165838433, -71.67622634576909 61.2783583103878, -71.7435230974129 61.4217185605632, -71.7156399546202 61.5457269912077, -71.745408594431 61.6792414618241, -71.84647644023541 61.7009009129468, -72.0093717180302 61.7027090727656, -72.1138114630285 61.768727955231, -72.22976980123519 61.8808668843993, -72.3646309526563 61.8955630162203, -72.4438507145388 61.911258570027, -72.5975236614877 62.0116845813784, -72.65332864939759 62.1237777818192, -72.751459880469 62.1445197697716, -72.903374167184 62.1482523240856, -73.0173601185745 62.183594747, -73.0963776310228 62.2126581636434, -73.1944329188441 62.2876760141368, -73.28965616150251 62.3318380343978, -73.42240349692371 62.3685538308947, -73.56754929616309 62.4005830290836, -73.73324404207889 62.4774707715589, -73.8655810825009 62.4501908903973, -73.9502095218519 62.3978956398719, -74.1022008669764 62.3374917528422, -74.2265877898945 62.3260057582592, -74.29980367420011 62.2777694125284, -74.42241445316439 62.2427918022999, -74.511257930409 62.2428908122612, -74.62888748866651 62.2598035705784, -74.7267889348615 62.2046664902664, -74.8163182386957 62.2027195416736, -74.9442040738588 62.2578310929307, -75.03847038480041 62.2674159350974, -75.1831341600134 62.2847549100112, -75.3442277576048 62.3174456539938, -75.5153162981086 62.2713303206378, -75.6416712506276 62.2500114445726, -75.8110834269585 62.3090148398631, -75.93677284069391 62.3500193062461, -76.10534289276021 62.3775115497183, -76.2125175210667 62.3952569876199, -76.3685719204577 62.4278825055732, -76.48766814167131 62.4468325304969, -76.6064638391348 62.4572315361066, -76.7061760154107 62.4969147689015, -76.8642309126265 62.5259033871317, -76.9682144998992 62.5369445167761, -77.0828220366076 62.5335578426204, -77.25888406544721 62.5470384120931, -77.3441128508273 62.5540247837169, -77.47945886273619 62.5781576537528, -77.5586235987 62.541063735503, -77.6682454270847 62.5150911061697, -77.81984122339369 62.4436013059556, -77.9415896901121 62.405578487857, -78.0408993361354 62.3642756102313, -78.1703715205291 62.2442638953625, -78.1610545162529 62.1223761632295, -78.14890860634701 62.0181106241061, -78.07967792379711 61.8977229845282, -78.05323718115091 61.8092322177927, -77.99494302809821 61.7128768347981, -77.9110333772885 61.6805678431315, -77.7752377331347 61.6529479256063, -77.68604436295691 61.5902604530575, -77.7464299002197 61.4447707602625, -77.7713878361796 61.2809443639912, -81.1208442837367 61.6343186366958, -85.9087502533215 61.4403863269675, -87.7835499471722 60.796390048462, -88.8519416879585 60.1195386784673, -89.8256929935368 59.1331428536598, -90.28917688060849 58.6636404579409, -90.67532027770859 57.2245717427917, -90.79091050271749 57.2407170808287, -90.9217394124439 57.2601567677207, -91.01806055105349 57.2568265287214, -91.1159991221617 57.249242901139, -91.2779177991671 57.2192479316468, -91.4525318115937 57.1780529852571, -91.5799427372674 57.1525440913368, -91.7268544003103 57.1197453081995, -91.8391362308523 57.0876751359988, -91.9249059071818 57.0659466097483, -92.0507985856861 57.049360294542, -92.13512631242941 57.04835702076, -92.25875306989821 57.0716991447998, -92.3518469706611 57.0584964685373, -92.4861090971571 57.0399379517752, -92.4857200468426 57.1999797751466, -92.4425224316648 57.3074512552713, -92.4497627547472 57.3881817001254, -92.5112404799642 57.5276470395793, -92.59639221412939 57.6298542247927, -92.65817509550421 57.7008037788714, -92.7342173331634 57.8130054717252, -92.77113601131779 57.8940105722302, -92.8201015390547 58.0647373586422, -92.874468654005 58.1538677627871, -92.97732059736759 58.2803554957096, -93.0559415825379 58.4189625249007, -93.1315794841059 58.5865955877163, -93.1591292778938 58.7012920988514, -93.2823669526727 58.7624760209517, -93.3608810776995 58.7592754812785, -93.4738800798018 58.7538242685752, -93.62835249617071 58.7846698986969, -93.71609056722581 58.7966098944312, -93.89549583566421 58.7730426754791, -94.0091280782981 58.7725887156967, -94.14890625412031 58.7425517739453, -94.24527317181941 58.7465228653381, -94.4130130857852 58.709989490023, -94.496623682337 58.803209247309, -94.605174776095 58.8845767350284, -94.668979477321 58.9607562380101, -94.7854498526285 59.019945075305, -94.8760642082965 59.0353373705233, -95.0288505271301 59.0589655922883, -94.9498328680923 59.0871371413661, -94.78415853948491 59.1531909238221, -94.75664135421501 59.3040141602254, -94.7311897255254 59.4165820732042, -94.8055229949902 59.5517024667955, -94.8188439536855 59.6357478828585, -94.7946054061145 59.7556094972806, -94.82640478525261 59.8905277160813, -94.7793129086637 60.072941390333, -94.73645838124919 60.2213475638391, -94.6762507910411 60.3269215005269, -94.6734126925416 60.423391387003, -94.6149944348452 60.513830240873, -94.5353359405012 60.6169071910141, -94.4341091386257 60.7222386291095, -94.37695735929471 60.8089810418417, -94.2591747562099 60.8856145118004, -94.2088665424568 60.964075215299, -94.117840250527 61.0820447451689, -94.04385803502031 61.2004110028656, -93.9886975318655 61.2938901704951, -93.9522824524732 61.3760549440805, -93.9426923501717 61.491502950301, -93.804676572166 61.5421430732443, -93.69641544681529 61.598573904762, -93.5824475313284 61.6549169984208, -93.4946942149659 61.6810438713776, -93.4563641740674 61.8020346349905, -93.4010892366789 61.9084074808207, -93.32190375965079 61.9974730456446, -93.1770367754268 62.0318396699648, -93.113697555198 62.1166098847385, -93.0654263904156 62.1899207446467, -92.9374432540029 62.2031119824321, -92.7967037820538 62.2611297306526, -92.68520018074371 62.3574088907078, -92.6355176019556 62.4841178883299, -92.5609097442893 62.5284408665528, -92.3973812421505 62.5429100292745, -92.29000511624299 62.5757202526876, -92.19575159456041 62.695326287878, -92.0960278026409 62.834230877553, -92.00510827732511 62.8504166473105, -91.8950160639401 62.8354172685921, -91.723606384527 62.8273682724279, -91.6037180224687 62.8120141273502, -91.51237887258679 62.8096223192147, -91.3764153861611 62.8267961003598, -91.195743643854 62.8759637552232, -91.0767021706686 62.9177041853999, -90.945301069089 62.9480195986257, -90.8332252075772 62.9270273293478, -90.7121848562461 63.0189462910386, -90.6908760112189 63.1564279904595, -90.75826653966899 63.2864176159803, -90.83001343447241 63.3706194286438, -90.8963892209857 63.4225221952432, -91.04234724652819 63.4645029278679, -91.0056193874247 63.5928255403664, -90.84331157107211 63.5712992167855, -90.734394298558 63.5932146644253, -90.57693117953031 63.6349169525554, -90.4958383024956 63.6178995949904, -90.3111839970437 63.6364504873002, -90.1911506903521 63.6513583348194, -90.0785332049434 63.7674586633867, -90.09151085913879 63.8706767468345, -89.987567986873 63.956850772745, -89.8510933464807 64.0146358231847, -89.6954002542183 64.07326773821561, -89.6150550465531 64.034685895238, -89.476774932617 64.0453088761038, -89.3606832879034 64.02033502574091, -89.2708623726004 63.986059977586, -89.12059375799549 63.9970920969228, -89.00106399340849 64.0190990964462, -88.819049435583 63.9913967794379, -88.66757537690209 64.0033367967558, -88.5629534490424 64.0129498434605, -88.4285540041639 64.0731839294948, -88.3423570797154 64.0983151648131, -88.1679795916847 64.1600140962736, -88.03858503766931 64.235651929493, -87.8977998100131 64.3457898877932, -87.8045304874919 64.486819262499, -87.67589122909681 64.52863598846019, -87.5598252258534 64.5852384789727, -87.4955704786946 64.6759901377348, -87.403468411438 64.72561935974581, -87.30076911360371 64.7830381954564, -87.2086212942372 64.8866224981298, -87.13297583926349 64.9438811151214, -87.04295660816079 65.01542958800511, -86.9738190351204 65.0813780841314, -87.0019258024338 65.214266882011, -87.1682314416277 65.2549620607506, -87.2687563954912 65.2654753576017, -87.3695407435104 65.2699766928702, -87.5550724563287 65.2932921070451, -87.672191344455 65.29336076218949, -87.8180730562265 65.28059677162381, -87.98862825109281 65.2838468774315, -88.10628882606839 65.2803831223832, -88.21958538595671 65.2826414135705, -88.3569145495667 65.28509043657439, -88.481838319183 65.29619119576709, -88.5829431100365 65.3128995606663, -88.7499735227598 65.3185834441707, -88.821048993616 65.3223828774679, -88.9447825770542 65.3325909965773, -89.03952443690309 65.32480137568299, -89.12854429728149 65.4086865640338, -89.2718930900939 65.47440615841749, -89.3944288907806 65.5483960190611, -89.47274469730991 65.61487855869861, -89.5859955023904 65.65442933124871, -89.6893509905557 65.7181347698038, -89.8548555487445 65.76428496358029, -89.892712677548 65.8680752478745, -89.8472491674151 65.9957913234109, -89.7289553357201 65.9677914549118, -89.58537003200129 65.908060935264, -89.4675644692248 65.8565320132419, -89.33667450902141 65.8462018255539, -89.1824996027743 65.7857999206299, -89.0757032607967 65.7328366707758, -88.9438901303252 65.6937665516851, -88.7899365049656 65.6880445198388, -88.6762889810516 65.6670560636864, -88.57616072353849 65.5965070586539, -88.4880335311225 65.56534098929529, -88.361385490448 65.50024700199759, -88.2690468664197 65.46194744811631, -88.1663932793262 65.3914518484241, -88.07439798857619 65.3724699218495, -87.9584234895524 65.33616164144669, -87.8748434303799 65.3235044831454, -87.7509648942145 65.3238249295769, -87.6514622896529 65.3308592395623, -87.5082279661476 65.3211317739123, -87.4191700041923 65.3224364078141, -87.3157687765078 65.3291045084663, -87.1970172123744 65.36031637310219, -87.0824203887553 65.391353511131, -86.19775771305351 64.85291030109521, -86.2442882170275 64.7571059717632, -86.32390094037601 64.66191400482749, -86.3809077265102 64.4934798466177, -86.35802712735 64.413348313374, -86.3106332449282 64.2786666072782, -86.22036216947841 64.187564008772, -86.2779869616289 64.0708571495379, -86.3801827380429 64.05316457378611, -86.47285701873631 64.0198469978407, -86.6226068279427 63.9899779037573, -86.724581347751 63.9622259702524, -86.8859964979399 63.916262666389, -86.9900538332177 63.8612318328829, -87.10030622305371 63.7731084958605, -87.1830012486087 63.7357053790001, -87.173403404943 63.5933752024037, -87.0755182139943 63.5522069946571, -86.9497552186285 63.5508222707313, -86.8146919967382 63.5675344721382, -86.71865315352009 63.6085844397202, -86.59764329460231 63.6556501865069, -86.5092567233191 63.6640196407939, -86.3792594076954 63.6473265355912, -86.2353155541694 63.6404715360327, -86.1552068852894 63.6621123217263, -85.9680806546985 63.6859389384313, -85.79514510006619 63.7071448542517, -85.6993351253158 63.7117873507057, -85.6090106328344 63.5890723529068, -85.63833798161259 63.4528800204966, -85.645616358608 63.2824965547723, -85.6180055296314 63.1828566588078, -85.509271323113 63.1111022070013, -85.3826309500583 63.1142798589284, -85.2088561543879 63.1131240196579, -85.05288839028699 63.1557685364888, -84.9375547940184 63.1815177526422, -84.80197278111891 63.2255660770129, -84.7200406927237 63.2648765408198, -84.6114133391543 63.2991477911377, -84.46032077738199 63.3875457892069, -84.42369971007351 63.4929153675502, -84.3627942522529 63.5631820996742, -84.2592480835322 63.6143906076405, -84.1496136358606 63.6134407571852, -84.0352337022735 63.6136810911095, -83.9035960978815 63.6852906027792, -83.7422038462304 63.7682183252156, -83.6065913472128 63.8946145224424, -83.584580587624 64.0302842417244, -83.49345508968059 64.1090348641677, -83.3827448918632 64.1013444420924, -83.1991129159284 64.1116136224708, -83.07296084596631 64.1778520384409, -83.0066231907077 64.0764802712476, -82.94601520883479 63.9640840289548, -82.7939841901181 63.9521097051988, -82.63841313855541 63.9574464782724, -82.5287557986411 63.9509996477156, -82.4869618965743 63.7920373903133, -82.3810886897912 63.6545404410886, -82.26029243334899 63.6605257089943, -82.1756061226244 63.6781000274944, -82.01801326829749 63.651164459872, -81.94321464463999 63.6374239242748, -81.80551926450239 63.6250948323607, -81.6371918333364 63.5614771325637, -81.5207443331844 63.5585512674271, -81.435592609811 63.5258631305791, -81.31211079517701 63.5023188263528, -81.1656187099354 63.4575228434045, -81.0769574713101 63.445498922937, -80.9414593750501 63.48022030912, -80.8146130266698 63.550197129494, -80.6725231372329 63.6020388779919, -80.5647197569111 63.6408458032913, -80.4219737436933 63.7144236988946, -80.4587932625989 63.8407779229629, -80.55911225372751 63.9453616638098, -80.6660459140877 63.9920268507587, -80.71445474596069 64.033819580696, -80.3046263074668 64.09006107806491, -79.0904559802441 64.2550682373605, -79.09042986435421 64.2550718099133, -77.9650089573083 64.4100325023033, -77.8272233003151 64.3721120512303, -77.6572174185489 64.3663442384959, -77.559309350646 64.3563802538457, -77.4368040945332 64.3257787581832, -77.2720472210024 64.2663305222359, -77.1466580675157 64.2855947513967, -76.9916744612073 64.2493932816747, -76.87635611024621 64.24878293698301, -76.70648755675521 64.2424047714631, -76.6052073099693 64.2889974937394, -76.4764535822669 64.27468475549711, -76.354238259488 64.2964437966439, -76.2682702053057 64.317554338462, -76.14462056818461 64.3744238565758, -76.0178810062034 64.3816412703284, -75.91278605023589 64.3963583797355, -75.7954459270877 64.4687918628542, -75.6769690338937 64.5719794368016, -75.50846613600331 64.54076759105151, -75.4066975852252 64.5199240885259, -75.26134990617309 64.47008125864321, -75.0765277296709 64.4542960505224, -74.94823938673829 64.4170035736561, -74.7806367614773 64.40159220471649, -74.6101197140535 64.4119147850394, -74.5589798963051 64.5428886124196, -74.4577606865064 64.6090049553145, -74.3456237853093 64.5845451205609, -74.213337660005 64.6295814464267, -74.0764433536777 64.5839271541149, -73.95660072664219 64.4317054692321, -73.8716550343523 64.5373344480264, -73.72642944636181 64.5669365082134, -73.6222652536385 64.4982948456307, -73.51404985072 64.42818834031971, -73.4140741991649 64.3656654517992, -73.2567178440532 64.2992439464511, -73.17885220036879 64.27727129293589, -73.0262184425271 64.2150154365133, -72.9183387403406 64.1730079913258, -72.89667121780241 64.0405388054216, -72.7271002005138 63.988319419006, -72.60951589254429 63.8962059231649, -72.4569584295878 63.8165321574332, -72.3577304779791 63.8243980678166, -72.210933226687 63.8205108975599, -72.1250872168016 63.7320747691354, -71.9750016879774 63.6924095506603, -71.8269303419616 63.7619553070918, -71.67220613160769 63.6913147447797, -71.51773368466171 63.5926056372404, -71.57384024313259 63.4262543043927, -71.6588241080461 63.417434720536, -71.7607070705748 63.3189354095415, -71.6622038781064 63.1676788411057, -71.558505089938 63.1224060151256, -71.4669980851935 63.0994415406946, -71.3256787294896 63.0382804991458, -71.1630733697401 63.0500068870083, -70.82220713335251 63.1167564776294, -70.92711897566021 63.0537643732273, -70.8385797831304 62.9195671310183, -70.7098413133258 62.8894119518002, -70.5622811212766 62.8754272763478, -70.4596046797122 62.8648834565064, -70.33521496080169 62.7985802021147, -70.171114228139 62.7537231812798, -70.0178777689438 62.7597580369039, -69.83246051104371 62.7897911583353, -69.6793842642724 62.7753449040441, -69.52267640938869 62.6744728622328, -69.41952693072319 62.583488513784, -69.27991656569679 62.5175133248801, -69.15217753766311 62.4323425763489, -69.08314674022979 62.4139709953652, -68.9529586846955 62.3789711493991, -68.7664275265091 62.3391762306986, -68.6182493455308 62.2785416181013, -68.50950753254649 62.2540474481313, -68.38235598124341 62.2433777438878, -68.3025677345132 62.2349472643049, -68.15387839597111 62.2275353119052, -68.04071152911369 62.2018738444024, -67.9512263199386 62.2076073381082, -67.7808847464339 62.1904335740502, -67.667031235503 62.1683731808777, -67.5475243460717 62.1769142932601, -67.4579933542098 62.1444474058232, -67.32158734378081 62.1284294945256, -67.2217414050418 62.0822869144096, -67.0966879360993 62.047626576905, -67.00144470690761 62.0415908840121, -66.8809755518802 62.0379386886197, -66.7458287362071 62.010521850603, -66.56848938137981 61.9408073255976, -66.38661301427911 61.8848849311947, -66.2605215757101 61.8666706344423, -66.1703828831634 61.8680953889911, -66.05410316772689 61.8776442043167, -66.00581322420081 61.9763169972317, -66.0284912942377 62.1202253086511, -66.0977332048235 62.22617411964, -66.15206509962459 62.3074199749519, -66.2784021682254 62.3385812068573, -66.39642556209 62.3532548951973, -66.49938548075529 62.4683787713633, -66.6196345500943 62.606103143845, -66.72430870248451 62.6434864261577, -66.8661701200549 62.6626958686195, -66.9795012193058 62.7005728337693, -67.11189343043741 62.8094941613265, -67.2228401454563 62.860798026208, -67.2971047148107 62.9185220279693, -67.40728086282149 62.9699250745826, -67.4872827372085 63.0039674330507, -67.6298914518289 63.0330010920268, -67.7365657036442 63.0789834534237, -67.8876354280325 63.1482202090954, -67.9837276999733 63.1604730142183, -68.1048443992495 63.1794435023158, -68.1727079036468 63.2291223048505, -68.2685407877272 63.3055345101096, -68.3723692770204 63.3671151690299, -68.49981075536201 63.4394761622952, -68.6105057015768 63.4779244946198, -68.7273270597959 63.5467111180237, -68.7948930207962 63.6070787039191, -68.6855256420946 63.7386590718588, -68.49940644894841 63.7373620803958, -68.35683587007929 63.6653329657439, -68.1920713792907 63.6187211814374, -68.06613289831461 63.5909959640925, -67.992333722723 63.5498315649748, -67.8937161140074 63.5086557228833, -67.7660381436453 63.558918182728, -67.5598460266726 63.5650407771102, -67.4963312776663 63.502723880103, -67.3908853549751 63.4287416394152, -67.27697079896311 63.3634721665073, -67.18624961642659 63.3173906233786, -67.0267875607972 63.2847291874022, -66.93208383220301 63.2137033357404, -66.85270756310349 63.1551935072746, -66.7301641604476 63.0855638369016, -66.5590520172367 63.0848581227043, -66.5560689390303 63.2054750444379, -66.64127406774401 63.2679483443407))"
p = shapely.geometry.Polygon(wkt.loads(mywkt))
print(p.is_valid)
shape_feature = ShapelyFeature([p], ccrs.Geodetic(), edgecolor='black', facecolor="red")
ax.add_feature(shape_feature)
plt.show()

A: The polygon does not have ccw sequence. To get it right, you need to reverse the sequence. Here is the relevant code that does the trick for you.
# Your code is OK up to this line:
p = shapely.geometry.Polygon(wkt.loads(mywkt))

# Add these lines to reverse vertices sequence
px = p.exterior
if px.is_ccw==False:
    px.coords = list(px.coords)[::-1]

# Continue your remaining code.

Hope this is useful.


text:
Q: Filtering arrays for use with UISearchBar I have a table view which displays a user's Name, Company Name and Photo (PFFile). Each tableView row I have has all of this information in it.
I am using UISearchBarDelegate and IB to implement a search function to filter by the user's Name. It is finding the correct user but I have not been able to also update the company photo.
How do I filter the other arrays? The items I need from the arrays will be at the same index as the ones taken from the user's Name array.
EDIT: I am trying a different data structure and am receiving array index out of range, updated code below:
var filterArray = [User]()  //<-- globally declared
var userArray = [User]() //< Global

class User {

var name: String?
var company: String?

init (name: String?, company: String?) {

    self.name = name
    self.company = company
    }
}
//In a class which populates the search arrays
for object in unwrappedSucceeded {

   let username = object.valueForKey("username") as! String
   let companyName = object.valueForKey("companyName") as! String
   let user = User(name: username, company: companyName)

    userArray.append(user)
}

//tableViewController

func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {

    filterArray.removeAll(keepCapacity: false)

    if searchText.characters.count != 0 {
        isSearch = true

        self.search(searchText)

    } else {
        isSearch = false
    }
}

func search(text: String) -> Void {

    filterArray = userArray.filter({$0.name == text})

}
//In cellForRowAtIndexPath
            cell.usernameCell.text = filterArray[indexPath.row].name //ARRAY INDEX OUT OF RANGE

A: Like I said you strongly recommend to group each user's info into one big container, therefore we could use array of struct or class, then it comes easier to filter.
schematic for the container:
struct Container
{
  var username:String?
  var companyName:String?
  var photo:UIImage?
}

your main array will be :  var arrayofData = [Container]()
Now when you are query your objects from parse, inside of your query function
// after you called the findObjectsWithBackgroundBlock()
// let's assume you check for error and if the [PFObject] is empty or not

 for one in objectsFromParse
 {
  let photoToget = one["Photo"] as! PFFile
 // next step should be to get the image data right :)
 {
    // let's assume that is the block when get the image data right:)
    // check your data and assign it to some UIImage
     // then
     let userRepresentation = Container()  //<-- we are creating a single object representation for each user

     let username = one["username"] as! String    //<--data we got from Parse
     let companyName = one["companyName"] as! String
     let userImage = //the UIImage which contains the data

     userRepresentation.username = username
     userRepresentation.companyName = companyName
     userRepresentation.photo = userImage

  // then we append
    arrayOfData.append(userRepresentation)
 }
}

Now we have all data into our array, so let's filter by username and also I hope you configure your tableView so when you have data from filter or regular array.
  var filterArray = [Container]()  //<-- globally declared

  func search(text: String) -> Void
 {
    filterArray = arrayOfData.filter(){ (Container) -> Bool in
       let range = Container.name!.rangeOfString(text,   options:NSStringCompareOptions.CaseInsensitiveSearch) return range != nil }
       // then you are good to go
 }

A: let arr1 = [10,20,40]
let e1 = arr1.enumerate()
let arr2 = ["a","b","c"]
let f1 = e1.filter { $0.element % 20 == 0 }
let f2 = arr2.enumerate().filter { j, _ in
    f1.contains { i, _ in
        i == j
    }
}

print(f1.map{$0.element}, f2.map{$0.element})
// [20, 40] ["b", "c"]

now you have both arrays "filtered". the best, what you can do is redesigning your data model!


text:
Q: does ('filename','w') replace or add If I had a file called 'file' that said
thing1

thing2

and I did
f = open('file','w')
f.write('hi'+'\n')
f.close()

would file become
thing1

thing2

hi

or
hi

edit : when testing this, i did a code saying
new_un = open('usernames', 'w')
for i in range(len(usernames)):
    new_un.write(usernames[i]+'\n')
new_un.close()

and it would write everything in the usernames list.
I thought that if it was overriding then it would just have the last thing in the list

A: f = open('file','w')
f.write('hi'+'\n')
f.close()

output: "hi" in file nothing else, this is because 'w' will overwrite the file causing it to be blank before entering the text,
f = open('file','a')
f.write('hi'+'\n')
f.close()

output whatever's in text file to begin with + "Hi", this will add the text to the file
f = open('file','r')
f.write('hi'+'\n')
f.close()

output error since you opened the file to read and therefore you cant add text


text:
Q: What is std::set::equal_range for? Since std::set cannot contain duplicate elements and is always sorted, std::set::equal_range will always return the range that has either none or 1 element. Technically, yes, that's still a range, but what is the purpose of this algorithm? For std::set it seems pretty unnecessary.

A: I'm only guessing. But, like count(), it has some value when you're in a template and don't want to have to determine whether you're operating on a std::set or some other associative container.
Basically, it's for consistency. The function does perform as advertised, it's just that yes it has questionable use versus something like find() if you take it in isolation. It does potentially save you one manual iterator increment if you really do want a half-open range out of the box though. :P

A: All of the associative containers support equal_range, which means you can write generic code which accepts a set, multiset, map or multimap and it will do the right thing.

A: Consider std::multiset. Despite practically identical in interface, it can contain equal_ranges of higher lengths.


text:
Q: How do i delete an element from an array in PHP I have multiple arrays which are coming from a foreach loop. (See my last question for more info: Array values in function)
Right here:
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Beheergroep,OU=Test,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Beheergroep,OU=Test,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Belangrijke Groep,OU=Test,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Belangrijke Groep,OU=Test,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Domeingebruikers,CN=Users,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Domeingebruikers,CN=Users,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Gebruikers,CN=Builtin,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Gebruikers,CN=Builtin,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Hoofdgroep,OU=Test,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Hoofdgroep,OU=Test,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Mailgroep,OU=Test,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Mailgroep,OU=Test,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Securitygroep,OU=Securitygroups,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Securitygroep,OU=Securitygroups,DC=stefan,DC=nl
        )

)
Array
(
    [count] => 1
    [0] => Array
        (
            [distinguishedname] => Array
                (
                    [count] => 1
                    [0] => CN=Testgroep2,OU=Test,DC=stefan,DC=nl
                )

            [0] => distinguishedname
            [count] => 1
            [dn] => CN=Testgroep2,OU=Test,DC=stefan,DC=nl
        )

)

Now I want to check all the arrays for a specific value.
I'm using this function to check an array.
if(strpos($check[0]['distinguishedname'][0], 'OU=Test') !== false) {

If one of the arrays contain the specific value ("OU=Test") the need to be displayed otherwise the array needs to be excluded or hidden. How can I accomplish this?
EDIT
This is my code with the foreach loop.
$result = $adldap->user()->groups('stefan.guth');

for ($i = 0; $i < count($result); $i++) {
    sort($result);
}
print_r($result);

foreach ($result as $value) {
    $check = $adldap->group()->info($value, array(
        'distinguishedname'
    ));
    print_r($check);

    if (strpos($check[0]['distinguishedname'][0], 'OU=Test') === false) {

    }
}

A: Is this what you want? You should change the foreach loop aswell..
foreach ($result as $key => $value) {
    $check = $adldap->group()->info($value, array(
        'distinguishedname'
    ));
    print_r($check);

    if (strpos($check[0]['distinguishedname'][0], 'OU=Test') === false) {
        unset($result[$key]);
    }
}


text:
Q: How to add github dependency in package.json if package.json of second project not in the root of the project I'd like to add dependency in package.json on github project, but that github project does not have package.json in root of the project. Is it possible to do that?
My package.json:
"dependencies": {
"seg-qa": "myname/seg-qa.git",
"lodash": "^3.5.0",
"bluebird": "^3.5.1",
"moment": "^2.8.4" }

structure of the project myname/seg-qa.git:
apps/package.json
.drone
.gitignore
readme.md

But that project "seg-qa": "myname/seg-qa.git" does not have package.json in the root and I'm getting error:

*

*Non-registry package missing package.json: seg-qa@

*npm can't find a package.json file in your current directory
Anyone knows how can I add that project as dependency( I google it, did not really find answer for that)

A: I also tries it and failed.
It seems to be a limitation.
Hack: you can clone the second repo locally, and state your dep as a local path

A: npm init
create a package.json file.


text:
Q: unrecognised selector sent to instance when attaching GLFW Cocoa Window to IPlugView (VST3SDK) I'm doing some work with the Steinberg VST3SDK and have bumped into an error I don't really understand:
[GLFWWindow window]: unrecognized selector sent to instance 0x7fe10430a830
2022-12-22 08:11:08.981 MyHost[1593:20791] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GLFWWindow window]: unrecognized selector sent to instance 0x7fe10430a830'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff37903a17 __exceptionPreprocess + 250
        1   libobjc.A.dylib                     0x00007fff70468a9e objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff37982e36 -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x00007fff37868190 ___forwarding___ + 1427
        4   CoreFoundation                      0x00007fff37867b68 _CF_forwarding_prep_0 + 120
        5   Digitalis                           0x000000010a9dc990 GetPluginFactory + 1922288
        6   Digitalis                           0x000000010a9dbb85 GetPluginFactory + 1918693
        7   Digitalis                           0x000000010a80db6e GetPluginFactory + 26318
        8   MyHost                              0x000000010a624641 _ZN6Plugin4loadERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 2065
        9   MyHost                              0x000000010a624e9d main + 61
        10  libdyld.dylib                       0x00007fff71608cc9 start + 1
        11  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

i guess this leads me to question whether the kPlatformType "NSView" is equivalent to glfwGetCocoaWindow()'s "NSWindow" return value?
heres the snippet of code thats causing me errors:
  if (!glfwInit()) {
    std::cout << "Failed to initialise Editor Window" << std::endl;
    return false;
  }
  auto view = controller->createView(Steinberg::Vst::ViewType::kEditor);
  Steinberg::ViewRect dimensions;
  view->getSize(&dimensions);
  editorWindow = glfwCreateWindow(dimensions.getWidth(), dimensions.getHeight(), "VST 3 SDK", nullptr, nullptr);
  view->attached(glfwGetCocoaWindow(editorWindow), Steinberg::kPlatformTypeNSView);

can also confirm that the windows equivalent of this works fine:
view->attached(glfwGetWin32Window(editorWindow), Steinberg::kPlatformTypeHWN

any type of explanation whether it be for debugging the error message itself or the VST3SDK side would be greatly appreciated!
i tried:
  view->attached(glfwGetCocoaWindow(editorWindow), Steinberg::kPlatformTypeNSView);

and expected the vst3 view to be attached to my GLFW window


text:
Q: How can i place tree in sidemenubar of codenameone Can I place a tree like structure in the sidemenubar.(i.e, I want to categorize the commands placed in sidemenubar). Something more like Accordion, expandable and collapsible.

A: I suggest you switch to Toolbar where you can use add component to side menu. This is also possible with the standard menu but a bit trickier see this for toolbar:
https://www.codenameone.com/manual/components.html#_toolbar
And this for side menu bar:
https://www.codenameone.com/blog/on-the-side-up-on-top.html


text:
Q: Cancel Alamofire file download if this file is already exists How to cancel Alamofire request if the downloaded file is already exists in documents folder?
Here is the code for request:
Alamofire.download(.GET, fileUrls[button.tag], destination: { (temporaryURL, response) in
    if let directoryURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0] as? NSURL {
        let fileURL = directoryURL.URLByAppendingPathComponent(response.suggestedFilename!)
        self.localFilePaths[button.tag] = fileURL
        if NSFileManager.defaultManager().fileExistsAtPath(fileURL.path!) {
            NSFileManager.defaultManager().removeItemAtPath(fileURL.path!, error: nil)
        }
        return fileURL
    }
    println("temporaryURL - \(temporaryURL)")
    self.localFilePaths[button.tag] = temporaryURL
    return temporaryURL
}).progress { _, totalBytesRead, totalBytesExpectedToRead in
    println("\(totalBytesRead) - \(totalBytesExpectedToRead)")
    dispatch_async(dispatch_get_main_queue()) {
        self.progressBar.setProgress(Float(totalBytesRead) / Float(totalBytesExpectedToRead), animated: true)

        if totalBytesRead == totalBytesExpectedToRead {
            self.progressBar.hidden = true
            self.progressBar.setProgress(0, animated: false)
        }
    }
}.response { (_, _, data, error) in
    let previewQL = QLReaderViewController()
    previewQL.dataSource = self
    previewQL.currentPreviewItemIndex = button.tag
    self.navigationController?.pushViewController(previewQL, animated: true)
}

I've also tried to create a request variable var request: Alamofire.Request? and then cancel request?.cancel() it if that file exists but it doesn't work.
Can someone help me to solve this issue?

A: Rather than cancelling the request, IMO you shouldn't make it in the first place. You should do the file check BEFORE you start the Alamofire request.
If you absolutely feel you need to start the request, you can always cancel immediately after starting the request.
var shouldCancel = false

let request = Alamofire.request(.GET, "some_url") { _, _ in
        shouldCancel = true
    }
    .progress { _, _, _ in
        // todo...
    }
    .response { _, _, _ in
        // todo...
    }

if shouldCancel {
    request.cancel()
}

A: TL; DR: Canceling a request is a bit cumbersome in many cases. Even Alamofire, as far as I know, does not guarentee that request will be cancelled upon your request, immediately. However, you may use dispatch_suspend or NSOperation in order to overcome this.
Grand Central Dispatch (GCD)
This way utilizes functional programming.
Here we enlight our way with low-level programming. Apple introduced a good library, aka GCD, to do some thread-level programming.
You cannot cancel a block, unless... you suspend a queue (if it is not main or global queue).
There is a C function called dispatch_suspend, (from Apple's GCD Reference)

void dispatch_suspend(dispatch_object_t object);
Suspends the invocation of block objects on a dispatch object.

And you can also create queues (who are dispatch_object_ts) with dispatch_queue_create.
So you can do your task in user created queue, and you may suspend this queue in order to prevent CPU from doing something unnecessary.
NSOperation (also NSThread)
This way utilizes functional programming over object-oriented interface.
Apple also introduced NSOperation, where object-oriented programming may be object, whereas it is easier to cope with.
NSOperation is an abstract class, which associates code and data, according to the Apple's documentation.
In order to use this class, you should either use one of its defined subclasses, or create your own subclass: In your case particularly, I suppose NSBlockOperation is the one.
You may refer to this code block:
let block = NSBlockOperation { () -> Void in
    // do something here...
}

// Cancel operation
block.cancel()

Nevertheless, it also does not guarantee stopping from whatever it is doing. Apple also states that:

This method does not force your operation code to stop. Instead, it updates the object's internal flags to reflect the change in state. If the operation has already finished executing, this method has no effect. Canceling an operation that is currently in an operation queue, but not yet executing, makes it possible to remove the operation from the queue sooner than usual.

If you want to take advantage of flags, you should read more: Responding to the Cancel Command


text:
Q: The product of a normal and Rademacher variables, independent from each other Let $X\sim N(0,1)$ and let $Z$ be a random variable independent of $X$ such that:
\begin{equation}
\Pr(Z=z) = \begin{cases}
\frac{1}{2} & \mbox{if $z = -1$ or $z=1$}, \\ \\
0 & \mbox{otherwise}.
\end{cases}
\end{equation}

*

*Define $Y = ZX$.

*Show that $Y \sim N(0,1)$.

*Determine $\operatorname{Cor}(X,Y)$.

*Are $X$ and $Y$ independent?

Progress:
I'm basically stuck at the beginning. I got as far as $P(ZX < y) = P(Z < y/X)$, which I'm not even sure is correct. I'm also not clear on what it means by defining $Y = ZX$ - does it mean I need to state the probability density function or something? And how do I show that $Y \sim N(0,1)$?

A: Let $Q(x)$ be the Q-function, i.e., $Q(x)=P(N\geq x)$, where $N$ is a Gaussian random variable with mean $0$ and variance $1$. Then
$$
\begin{align*}
P(Y \geq y) & =P(XZ \geq y) \\
&= P(Z=1)P(XZ \geq y|Z=1) + P(Z=-1)P(XZ \geq y|Z=-1) \\
&= \frac{1}{2}P(X \geq y|Z=1) + \frac{1}{2}P(-X \geq y|Z=-1) \\
&= \frac{1}{2}P(X \geq y) + \frac{1}{2}P(X \leq -y) \\
&= \frac{1}{2}Q(y) + \frac{1}{2}Q(y) \\
& = Q(y)
\end{align*}
$$
Hence $Y \sim \mathcal{N}(0,1)$. The fifth equality follows since Gaussian distribution with mean zero is symmetric around $y$-axis.
Next,
$$
\begin{align*}
Cor(X,Y) &= \mathbb{E}\left[ XY\right] \\
&=P(Z=1)\mathbb{E}\left[ XY|Z=1\right] + P(Z=-1)\mathbb{E}\left[ XY|Z=-1\right] \\
&=\frac{1}{2} \mathbb{E}\left[ X^2\right] + \frac{1}{2} \mathbb{E}\left[ -X^2\right]\\
&= 0
\end{align*}
$$
Finally, $X$ and $Y$ are not independent because conditioned on $X$, $Y$ can take only two different values, whereas its marginal distribution is $\mathcal{N}(0,1)$.
At first sight, the answers to parts $3$ and $4$ might seem contradictory, since uncorrelatedness implies independence for jointly Gaussian random variables (although this is not true for arbitrary random variables). However, $X$ and $Y$ are not jointly Gaussian distributed, hence this implication is not true in this case.

A: We have $Y\le y$ if and only if $X\le y$ and $Z=-1$ or if $X \gt -y$ and $Z=-1$.
If $f_X$ is the density function of the standard normal, then
$$F_Y(y)=\frac{1}{2}\int_{-\infty}^y f_X(x)\,dx+\frac{1}{2}\int_{-y}^\infty f_X(x)\,dx.$$
Differentiate, using the Fundamental Theorem of Calculus.  We get $f_X(y)$.


text:
Q: Update grid and form simultaneously My app has a grid and a form (for record detail).
when I update a record I intended to be simultaneously updated the grid and the form (before store.sync()).
Any idea how to do this?
In the case of my fiddle, after the update (edit button), the form only updates if you click in another grid row and re-click again on the edited row.
Fiddle: https://fiddle.sencha.com/#fiddle/12v7
EDITED: see comments.
https://fiddle.sencha.com/#fiddle/1303

A: Use data binding: Fiddle
Ext.define('ViewerModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.viewermodel',

    stores: {
        mystore: {

            fields: ['name', 'email', 'phone'],
            data: [{
                name: 'Lisa',
                email: 'lisa@simpsons.com',
                phone: '555-111-1224'
            }, {
                name: 'Bart',
                email: 'bart@simpsons.com',
                phone: '555-222-1234'
            }, {
                name: 'Homer',
                email: 'homer@simpsons.com',
                phone: '555-222-1244'
            }, {
                name: 'Marge',
                email: 'marge@simpsons.com',
                phone: ''
            }]
        }
    }
});

Ext.define('APP.HorizontalBox', {
    extend: 'Ext.container.Container',
    xtype: 'layout-horizontal-box',
    width: 800,
    height: 300,
    layout: {
        type: 'hbox',
        align: 'stretch'
    },

    viewModel: {
        type: 'viewermodel'
    },

    items: [{
        xtype: 'grid',
        flex: 1,
        margin: '0 10 0 0',
        bind: {
            store: '{mystore}',
            selection: '{user}'
        },

        columns: [{
            text: 'Name',
            dataIndex: 'name',
            flex: 1
        }, {
            text: 'Email',
            dataIndex: 'email',
            flex: 2
        }, {
            text: 'Phone',
            dataIndex: 'phone',
            flex: 2
        }],

        tbar: [{
            xtype: 'form',
            items: [{
                xtype: 'textfield',
                name: 'name',
                bind: '{user.name}'
            }, {
                xtype: 'textfield',
                name: 'email',
                bind: '{user.email}'
            }, {
                xtype: 'textfield',
                name: 'phone',
                bind: '{user.phone}'
            }]
        }],
    }, {
        xtype: 'form',
        flex: 1,
        margin: '0 10 0 0',

        items: [{
            xtype: 'displayfield',
            fieldLabel: 'Name',
            name: 'name',
            bind: '{user.name}'
        }, {
            xtype: 'displayfield',
            fieldLabel: 'Email',
            name: 'email',
            bind: '{user.email}'
        }, {
            xtype: 'displayfield',
            fieldLabel: 'Phone',
            name: 'phone',
            bind: '{user.phone}'
        }]
    }]
});

Ext.application({
    name: 'Fiddle',

    launch: function() {
        Ext.create('APP.HorizontalBox', {
            renderTo: document.body,
            width: 800,
            height: 400
        });

    }
});


text:
Q: certbot modifies the default nginx config I am following a mini-tutorial to install letsencrypt certificates. OS is ubuntu 22.04.
I had already installed nginx, and my own example.com config file to /etc/nginx/sites-available
/etc/nginx/sites-available/example.com

I left the /etc/nginx/sites-available/default unchanged.
I removed the pre-installed certbot
sudo apt remove certbot

Then I installed snap and classic certbot:
sudo apt install snapd
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Then I ran
sudo nginx -t
sudo systemctl reload nginx

Then I did
sudo certbot --nginx -d example.com

I accept the agreement, entered my email, and hit return.
Instead of modifying /etc/nginx/sites-available/example.com, /etc/nginx/sites-available/default was modified.
What am I doing wrong?


text:
Q: Nifi rest command to create new processor group from nifi-registry? I am trying to create a new Processor Group from the latest version of one of the Processor Groups in my Nifi-Registry. However, I want to do this via REST API, but I am not able to find the rest command that works.
As suggested online in one of the forums, I tried using chrome developer tools to check the REST calls, but when I use developer tools, the drag and drop feature does not work in the UI! I don't know what am I doing wrong in the developer tools.

A: There should be no reason why dev tools interferes with the application. Here is the request shown in dev tools when creating a PG and selecting to import from registry...

Here is the content of the request, it should be the same as creating a regular PG, except the version control information is specified:


text:
Q: How to search and download specific Windows updates on PowerShell? I have a list of specific updates that we want to install on computers that are not connected to the internet. We have been using PowerShell and would like to stick to it. I am open to other options. My question is how can I feed a list of updates to a program and then that program takes that list and searches and downloads the files from https://www.catalog.update.microsoft.com/
These files would then be transferred to an offline computer with a USB and updated with a different program.


text:
Q: Compare two ranges to find non match and exceptions using collections run-time error 1004 I've been following the example from this solution
Excel vba - Compare two ranges and find non matches and tried to combine it with this solution http://dailydoseofexcel.com/archives/2004/05/18/listing-unique-items-with-collections/
However, when I run the code included below, I get a run-time error '1004': Unable to get the Vlookup property of the WoorkSheetClass. How do I get past that error, so that I can remove the rows that does not exist in my cUniqueInput?
Sub RemoveYdelser()

'Get Range From Datark To get range of Ydelses Group
Set YdelsesStart = Worksheets("DATAARK").Range("O8")
Set YdelsesSlut = Worksheets("DATAARK").Range("P8")

Dim LastRow As Long
LastRow = Worksheets("INPUT_MASTERDATA").Range("L" & Rows.Count).End(xlUp).Row

'Variable to get ydelser from Input_masterdata
Dim cUniqueInput As Collection
Dim Rng As Range
Dim Cell As Range
Dim shInput As Worksheet
Dim vNum As Variant

Set shInput = Worksheets("INPUT_MASTERDATA")
Set Rng = shInput.Range("L2:L" & LastRow)
Set cUniqueInput = New Collection

'Get unique values from Input_masterdata, column L
On Error Resume Next
    For Each Cell In Rng.Cells
        cUniqueInput.Add Cell.Value, CStr(Cell.Value)
    Next Cell
On Error GoTo 0

'Add exceptions for master ydelser not listed in column L
cUniqueInput.Add "x", CStr("x")
cUniqueInput.Add "R63011209", CStr("R63011209")
cUniqueInput.Add "R63011206", CStr("R63011206")

'Variable to get ydelser from Summary
Dim cUniqueYdelser As Collection
Dim RngYdelser As Range
Dim CellYdelser As Range
Dim shOpsumering As Worksheet
Dim xNum As Variant

Set shOpsumering = Worksheets("Summary")
Set RngYdelser = shOpsumering.Range("C" & YdelsesStart, "C" & YdelsesSlut)
Set cUniqueYdelser = New Collection

'Get unique values from Summary, column C
On Error Resume Next
    For Each CellYdelser In RngYdelser.Cells
        cUniqueYdelser.Add CellYdelser.Value, CStr(CellYdelser.Value)
    Next CellYdelser
On Error GoTo 0

'Does the values from cUniqueInput exist in cUniqueYdelser
For y = 1 To cUniqueYdelser.Count
    'If the value of a row in cUniqueYdelser does not exist in cUniqueInput, then remove entire row
    'This is where I get the runtime error
    If Application.WorksheetFunction.VLookup(cUniqueYdelser(y), cUniqueInput, 1, False) = "#N/A" Then
        With Worksheets("OPSUMMERINGSARK").Cells
            .AutoFilter Field:=3, Criteria1:=cUniqueYdelser(y)
            .Range("C" & YdelsesStart, "C" & YdelsesSlut).EntireRow.Delete
        End With
    End If
Next y

A: Try changing:
If Application.WorksheetFunction.VLookup(cUniqueYdelser(y), cUniqueInput, 1, False) = "#N/A" Then
To
With Application
    If .ISNA(.VLookup(cUniqueYdelser(y), cUniqueInput, 1, False) Then
      ...whatever
End with

Untested in your context of the Collection

A: To determine if an item exists in a collection, try to retrieve the item by Key, and see if there is an error (#9 - subscript out of range).
You could also set a reference to Microsoft Scripting Runtime and use a Dictionary instead of a collection.  You can then use the Exists method to see if a key exists.

A: I found the solution. The problem was that I was trying to use Vlookup on a collection. Instead I looped through the collections like this
'Does the values from cUniqueInput exist in cUniqueYdelser
For Each ydelse In cUniqueYdelser
    Dim itemFoundYdelse As Boolean
    itemFoundYdelse = False

    For Each inputYdelse In cUniqueInput
        If ydelse = inputYdelse Then
            itemFoundYdelse = True
        Else
        'Item not found
        End If
    Next inputYdelse

    If itemFoundYdelse = False Then
            With Worksheets("Summary").Cells
                .AutoFilter Field:=3, Criteria1:=ydelse
                .Range("C" & YdelsesStart, "C" & YdelsesSlut).EntireRow.Delete
            End With
    End If
Next ydelse


text:
Q: Conda SSL error I'm having some issues getting conda to respect my proxy declaration. I've copied the proxy strings from the examples in the conda docs and replaced the urls with my own. I've also exported the HTTP_PROXY and HTTPS_PROXY with strings that I know work. My ~/.condarc file looks like:
proxy_servers:
    http: http://<proxyaddress>:<port>
    https: https://<proxyaddress>:<port>

Any suggestions?
EDIT:
conda version: 3.14.1
looks like the proxy string is actually fine. The real issue that didn't come up at first is that conda isn't using the ca-cert that I need for due to our corporate proxy. The specific error, which appears when I attempt to install a package, is:
Error: Connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581): ...

A: I faced the same problem on Mac OS X and with Miniconda. After trying many of the proposed solutions for hours I found that I needed to correctly set Condas environment (specifically requests that conda uses to make HTTPS connections) to use the Root certificate that my company provided rather than the generic ones that Conda provides.
Expanding on @LISTERINE's answer here is how I could solved it:

*

*Open Chrome, got to any website, click on the lock icon on the left of the URL. Click on «Certificate» on the dropdown. In the next window you see a stack of certificates. The uppermost (aka top line in window) is the root certificate (e.g. Zscaler Root CA in my case, yours will very likely be a different one).

*Open Mac OS keychain, click on «Certificates» and choose among the many certificates the root certificate that you just identified. Export this to any folder of your choosing.

*Convert this certificate with openssl: openssl x509 -inform der -in /path/to/your/certificate.cer  -out /path/to/converted/certificate.pem

*For a quick check set your shell to acknowledge the certificate: export REQUESTS_CA_BUNDLE=/path/to/converted/certificate.pem

*To set this permanently you have two options:
A. open your shell profile (.bshrs or e.g. .zshrc) and add this line: export REQUESTS_CA_BUNDLE=/path/to/converted/certificate.pem.
~~OR~~
B. run conda config --set ssl_verify /path/to/converted/certificate.pem which will add the location of the certificate to ~/.condarc
Now exit your terminal/shell and reopen. Check again. You should be set and Conda should work fine.

A: conda config --set ssl_verify false

A: I figured it out so I thought I'd come back and report.
I'm not sure how to make conda use a specific cert, but conda uses requests for it's web requests. You can inject a cert bundle into requests' path by setting the environment variable REQUESTS_CA_BUNDLE.
so I ran:
export REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/<my-cert-name>

and now conda can get through our proxy!

A: It worked for me, by editing .condarc file as below.
channels:
    - defaults
#ssl_verify: C:\Users\ravikumk\certs\ca.crt

ssl_verify: false

# Show channel URLs when displaying what is going to be downloaded and
# in 'conda list'. The default is False.
show_channel_urls: True
allow_other_channels: True


text:
Q: Why can't I move my weapons individually? I feel like I can barely move my weapons. Is there a way to move them individually from the body?

A: Yes, you can. Simply hold shift while moving your mouse. If you don't want to have to press shift all the time, disable Arm Lock.


text:
Q: I'll have the television working again soon In Oxford Dictionary, there is explained one of the meanings  of the structure "have sth/sb doing...". The meaning is "to cause sth to be done or happen". Here is the example of the usage:
I'll have the television working again soon. I would like to ask what what would happen with the meaning of the sentence when "working" changed into the bare "work".

A: I can see swapping the participle "working" with the infinitive "to work" with some other changes,

I'll soon get the television to work again

but there's no change in meaning.
The use of "have it working" feels particularly BrE to me, though.  An American might instead prefer "get it working".

A: It's similar to the difference between: I like to play tennis and I like playing tennis. Anglo grammarians often claim there is no difference. Intuitively we can see there is. (I won't bother with the technical explanation, it would take pages.)
He'll have the television working again soon.
He'll have the car running again soon.
For machines, etc. that would be have to be ing generally. As the ING form implies a working or functioning state of a machine. And just work can't be used here as it would imply that televisions or cars perform tasks. (mathewb pointed this out above.)
But let's look at some other example: Imagine a person breaks her leg.
|John will have her working again soon|. [John will cause the person to work again soon due to patience or generosity or some other quality]. Here working means executing some task(s). The focus is on the activity expressed as a gerund.
If, however, you say (or write):
|John will have him work again soon.| The focus is on what John will do.
This is exactly like:
Working is fun. [gerund, that is, a noun]
versus
Work is fun. [A noun also] but it is the notion that comes into play, rather than the activity per se]
In general, a gerund form implies the activity and a bare verb noun form implies the notion.
I don't expect many to agree with me, but if you think about these two forms operate in actual sentences, they usually account for the difference in meaning.


text:
Q: Android - Kill App from another App (on a rooted device) I have a rooted Android device. At one point I launch a secondary application from my primary application like so:
Intent intent = getPackageManager().getLaunchIntentForPackage("com.app.package");
startActivityForResult(intent, 100);

I want to be able to kill this secondary application from the primary application. I am trying the following general procedure:
// At an earlier point in time...
Runtime.getRuntime().exec("su");
// The user grants permission

// ...

// At a later point in time...
Runtime.getRuntime().exec("su am force-stop com.app.package");

Unfortunately, this does not kill the app, with no hint as to why from logcat.
If I try to run the killing command as "am force-stop com.app.package" instead of "su am force-stop com.app.package", logcat says that I don't have permission, even though I got superuser permission from running "su" earlier.

A: Found a solution:
Process suProcess = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());

os.writeBytes("adb shell" + "\n");

os.flush();

os.writeBytes("am force-stop com.xxxxxx" + "\n");

os.flush();


text:
Q: Image gallery with caption using CloudinaryImage on keystonejs I'm using keystonejs and CloudinaryImages to create an Image Gallery.
{ type: Types.CloudinaryImages }

I need the ability to add a caption to the images.
I was also reading this:
https://github.com/keystonejs/keystone/pull/604
but I could not figure out if this option is already in place or not.
Any idea?
Thanks.

A: I had a similar problem, I wanted to be able to give Images there own descriptions and other attributes, while also being included in a Gallery with a Gallery description.
This may be more than you are looking for but here is a Image model:
var keystone = require('keystone'),
Types = keystone.Field.Types;

/**
 * Image Model
 * ==================
*/

var Image = new keystone.List('Image', {
    map: { name: 'name' },
    autokey: { path: 'slug', from: 'name', unique: true }
});

Image.add({
    name: { type: String, required: true },
    image: { type: Types.CloudinaryImage, autoCleanup: true, required: true, initial: false },
    description: { type: Types.Textarea, height: 150 },
});

Image.relationship({ ref: 'Gallery', path: 'heroImage' });
Image.relationship({ ref: 'Gallery', path: 'images' });

Image.register();

And the Galleries that contain these images looks like this:
var keystone = require('keystone'),
Types = keystone.Field.Types;

/**
 * Gallery Model
 * =============
 */

var Gallery = new keystone.List('Gallery', {
    map: { name: 'name' },
    autokey: { path: 'slug', from: 'name', unique: true }
});

Gallery.add({
    name: { type: String, required: true},
    published: {type: Types.Select, options: 'yes, no', default: 'no', index: true, emptyOption: false},
    publishedDate: { type: Types.Date, index: true, dependsOn: { published: 'yes' } },
    description: { type: Types.Textarea, height: 150 },
    heroImage : { type: Types.Relationship, ref: 'Image' },
    images : { type: Types.Relationship, ref: 'Image', many: true }
});

Gallery.defaultColumns = 'title, published|20%, publishedDate|20%';
Gallery.register();

You will need to create Template Views and Routes to Handle this, but it isn't too much more work - these are just the Models - let me know if you would like me to post the routes I am using for this, I am using Handlebars for my views so that may not be as helpful.


text:
Q: Not able to analyze properties of text in git bash I have committed a few test text from my vim editor to a sample main branch.
When I use $cat (commit) to view various versions across branches, my editor simply clears as if I typed $clear.

A: You can use git show to see the content of a file in a different branch
git show somebranch:path/to/your/file

Or you can define a git cat alias
[alias]
  cat = "!git show \"$1:$2\" #"

Which means you can type git cat somebranch path/to/your/file.


text:
Q: Dynamically Describing Mathematical Rules I want to be able to specify mathematical rules in an external location to my application and have my application process them at run time and perform actions (again described externally). What is the best way to do this?
For example, I might want to execute function MyFunction1() when the following evaluates to true:
(a < b) & MyFunction2() & (myWord == "test").
Thanks in advance for your help.
(If it is of any relevance, I wish to use C++, C or C++/CLI)

A: I'd consider not reinventing the wheel --- use an embedded scripting engine. This means you'd be using a standard form for describing the actions and logic. There are several great options out there that will probably be fine for your needs.
Good options include:

*

*Javascript though google v8. (I don't love this from an embedding point of view,
 but javascript is easy to work with, and many people already know it)

*Lua. Its fast and portable. Syntax is maybe not as nice as Javascript, but embedding is
 easy.

*Python. Clean syntax, lots of libraries. Not much fun to embed though.
I'd consider using SWIG to help generate the bindings ... I know it works for python and lua, not sure about v8.

A: I would look at the command design pattern to handle calling external mathematical predicates, and the Factory design pattern to run externally defined code.

A: If your mathematical expression language is that simple then uou could define a grammar for it, e.g.:
expr = bin-op-expr | rel-expr | func-expr | var-expr | "(" expr ")"

bin-op = "&" | "|" | "!"
bin-op-expr = expr bin-op expr

rel-op = "<" | ">" | "==" | "!=" | "<=" | ">="
rel-expr = expr rel-op expr

func-args = "(" ")"
func-expr = func-name func-args

var-expr = name

and then translate that into a grammar for a parser. E.g. you could use Boost.Spirit which provides a DSL to allow you to express a grammar within your C++ code.

A: If that calculation happens at an inner loop, you want high performance, you cannot go with scripting languages. Based on how "deployable" and how much platform independent you would like that to be:
1) You could express the equations in C++ and let g++ compile it for you at run-time, and you could link to the resulting shared object. But this method is very much platform dependent at every step! The necessary system calls, the compiler to use, the flags, loading a shared object (or a DLL)... That would be super-fast in the end though, especially if you compile the innermost loop with the equation. The equation would be inlined and all.
2) You could use java in the same way. You can get a nice java compiler in java (from Eclipse I think, but you can embed it easily). With this solution, the result would be slightly slower (depending on how much template magic you want), I would expect, by a factor of 2 for most purposes. But this solution is extremely portable. Once you get it working, there's no reason it shouldn't work anywhere, you don't need anything external to your program. Another down side to this is having to write your equations in Java syntax, which is ugly for complex math. The first solution is much better in that respect, since operator overloading greatly helps math equations.
3) I don't know much about C#, but there could be a solution similar to (2). If there is, I know that there's operator overloading in C#, so your equations would be more pleasant to write and look at.


text:
Q: How to defined MPI_Type_struct where a generic pointer is involved in the struct Consider the following struct
    typedef struct{
       void *data;
       int len;
    }item_t;

It allows me to pass item_t to a function called map_functions(item_t dt , item_t (*f_ptr)(item_t) )
that accepts item_t and function pointer.
map_functions() will then call the function passed as argument by passing item_t to it.
Having in mind that there are different functions that will call map_functions() each with diffirent content of item_t and pass the corresponding function they want to call.
All this thing works well for me pretty fine.
Now, I want to do this same thing using MPI.
The first thing that comes to my mind is:
how can I define a user defined MPI_Datatype (specifically MPI_Type_struct)
where a generic pointer such as void* data is involved in the struct? i.e to convert the above struct to a user defined MPI Datatype equivalent.
thanks,

A: You can't pass pointers between processes, they do not share memory.
You have to pass real information, or nothing. Pointers are relative only to the process.


text:
Q: Detect a public IP change in C# Using forms and OpenVPN
I'm trying to make a section of the UI change when a user is connected, so far I can get the original IP, but updating IP doesn't change.
I thought that trying to use a Task would fix it, but alas it did not and I'm at a loss. As I can't really find a lot of information about this kind of issue, though maybe I wasn't looking in the right spots.
public static void start()
{
    Process process = new Process();
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = //redacted;
    startInfo.Arguments = // redacted;
    //startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    //startInfo.CreateNoWindow = true;
    process.StartInfo = startInfo;
    process.Start();
    string orginalip = getipaddress();

    Task f = Task.Factory.StartNew(() =>
    {
        while (stopupdating == false)
        {
            string updatingip = getipaddressloop();

            if (orginalip == updatingip)
            {
                //MessageBox.Show("Connecting...");
                MessageBox.Show(orginalip + updatingip);
            }
            if (orginalip != updatingip)
            {
                stopupdating = true;
                MessageBox.Show("Connected UDP");
            }
        }
    });
}

static string getipaddressloop()
{
    while (stopupdating == false)
    {
        string address = new WebClient().DownloadString("https://ipv4.icanhazip.com/");
        return address;
    }
    string lastaddress = new WebClient().DownloadString("https://ipv4.icanhazip.com/");
    return lastaddress;
}

static string getipaddress()
{
    string address = new WebClient().DownloadString("https://ipv4.icanhazip.com/");
    return address;
}

A: It looks like you need something like the following:
WebClient _client = new WebClient();

public static async void CheckForIpChange()
{
    orginalip = getipaddressloop();
    while (true)
    {
        await Task.Delay(5000);
        string updatingip = getipaddressloop();

        if (orginalip == updatingip)
            MessageBox.Show("No Change");
        else
            break;
    });
    MessageBox.Show("New IP " + updatingip);
}

static string getipaddressloop()
{
    return _client.DownloadString("https://ipv4.icanhazip.com/");
}


text:
Q: Responsive floats mess with classic floats I'm trying to mix "traditional" float usage for floating text around element with some adataptiveness for different resolutions. Fiddle: http://jsfiddle.net/jDTBs/5/

...image...

title

some long text

related content

Responsiveness here comes in flavour of moving related content below the text. Currently .related cannot move higher than end of .text, because .text is in normal flow. I tried to use relative positioning on float, but I don't know the height to offset it, so -100% does not work.
Common approach is to use float on .text, but it interferes with text floating around .cover. I also tried moving related content above text, but then in smaller window it comes before text, which is undesirable. Also, any kind of interference with overflow or display properties in .text make text block jump away from floating .cover.
The closest I could get to is to use position: absolute on .related with right:0px;top:0px. This gives the positioning I want, but produces a CSS-unsolvable problem: related content will go below end of article.
So I'm stuck. Is there any way to mix the two approaches? Highest CSS support and any changes to layout are acceptable. Bootstrap CSS is also available, but does not help a tiny bit.
Thsi is something I'd like to achieve:

A:

...image...

title

some long text

related content

A: Here you go:
http://jsfiddle.net/jjordanca/jDTBs/8/
Keep in mind that this will look okay on Chrome, but not in Firefox since the img elements will require display: block; in the CSS.  Some minor other adjustments may need to be made.
HTML:

            <time datetime="2013-08">Aug 2013</time>

Wo bewirtung zerfasert so kraftiger handwerke ri la kindliche

Was mehrere fur niemals wie zum einfand wachter. Wu gewohnt langsam zu nustern dankbar. Messer all erzahl las zopfen darauf. Oden sie denn froh ohne dus. Schlafer hin ansprach geworden gelernte lauschte zugvogel mir das. Ist hochmut gebogen wendete das zweimal. Hoffnungen augenblick vertreiben es da wo zueinander kindlichen. Weg uns sohn hoch bei flu eins.

Ei ku jawohl en mi fertig hangen konnen gesagt. Dazwischen nachmittag ein eigentlich ist sog tat. Was dazwischen launischen das vorsichtig verrichtet eigentlich wie ein. Wahres gerber gro ehe tal kannst. Naturlich in da nachgehen schwachem gegriffen ja. Gearbeitet bugeleisen birkendose neidgefuhl die das dienstmagd.

Empor hosen ich nur funfe szene seine. Wo ri so stuckchen kammertur pa bekummert schranken hemdarmel.

CSS:
article {
    position: relative;
    max-width: 480px;
}
figure {
    margin: 0em
}
img {
    border: 1px solid
}
.cover {
    width: 80px;
    text-align: center;
    font-size: 0.8em;
}
.cover {
    display: inline-block;
    margin: 0em 2em 1em 0em;
}
time {
    display: inline-block;
    width: 80px;
    text-align: center;
}
header {
    display: inline-block;
    width: 100px;
    float: left;
}
h1 {
    position: relative;
    width: 550px;
    margin-top: -180px;
    top: 50px;
    margin-left: 90px;
    padding-left: 10px;
    font-size: 1.6em;
}
.cover img {
    width: 80px;
    height: 120px;
}
.row {
    display: inline;
    position: relative;
    top: 110px;
}
.text {
    display: inline;
    position: relative;
    font-size: smaller;
}
.related {
    width: 200px;
    font-size: 0.8em;
    height: 100px;
    float: right;
    position: relative;
    left: 220px;
    top: -200px;
}
.related img {
    width: 200px;
    height: 100px;
}
* {
    border: 1px dotted #ccc
}

The problem with the way the HTML is structured is that this design is extremely limited in its responsiveness.  If you are able to change the HTML, the page can be made truly responsive.

A: Here's an example of how the HTML and CSS could be changed to yield a beautifully responsive layout.  I've added more paragraphs to the HTML so that it's easy to see that the amount of text does not affect the image position.  Perhaps the biggest caveat here is that figcaption is rendered really strangely in relation to figure (I'm guessing that has something to do with the standard's definition of the default stylesheet for those elements), so unless this possibly changes in the future, you'll need to specify enough margin underneath the figure to encompass the caption.
http://jsfiddle.net/jjordanca/jDTBs/10/

HTML:

        <time datetime="2013-08">Aug 2013</time>

Wo bewirtung zerfasert so kraftiger handwerke ri la kindliche

Empor hosen ich nur funfe szene seine. Wo ri so stuckchen kammertur pa bekummert schranken hemdarmel.

Was mehrere fur niemals wie zum einfand wachter. Wu gewohnt langsam zu nustern dankbar. Messer all erzahl las zopfen darauf. Oden sie denn froh ohne dus. Schlafer hin ansprach geworden gelernte lauschte zugvogel mir das. Ist hochmut gebogen wendete das zweimal. Hoffnungen augenblick vertreiben es da wo zueinander kindlichen. Weg uns sohn hoch bei flu eins.

Ei ku jawohl en mi fertig hangen konnen gesagt. Dazwischen nachmittag ein eigentlich ist sog tat. Was dazwischen launischen das vorsichtig verrichtet eigentlich wie ein. Wahres gerber gro ehe tal kannst. Naturlich in da nachgehen schwachem gegriffen ja. Gearbeitet bugeleisen birkendose neidgefuhl die das dienstmagd.

Was mehrere fur niemals wie zum einfand wachter. Wu gewohnt langsam zu nustern dankbar. Messer all erzahl las zopfen darauf. Oden sie denn froh ohne dus. Schlafer hin ansprach geworden gelernte lauschte zugvogel mir das. Ist hochmut gebogen wendete das zweimal. Hoffnungen augenblick vertreiben es da wo zueinander kindlichen. Weg uns sohn hoch bei flu eins.

Ei ku jawohl en mi fertig hangen konnen gesagt. Dazwischen nachmittag ein eigentlich ist sog tat. Was dazwischen launischen das vorsichtig verrichtet eigentlich wie ein. Wahres gerber gro ehe tal kannst. Naturlich in da nachgehen schwachem gegriffen ja. Gearbeitet bugeleisen birkendose neidgefuhl die das dienstmagd.

CSS:
* {padding: 0; margin: 0;}
article {
    position: relative;
}
img {
    border: 1px solid black;
}
.cover {
    width: 80px;
    text-align: center;
    font-size: 0.8em;
    display: inline-block;
    float: left;
    margin: 0 20px 10px 0;
}
time {
    display: inline-block;
    width: 80px;
    text-align: center;
}
header {
    margin: 20px 0 0 0;
}
h1 {
    position: relative;
    padding-left: 10px;
    font-size: 1.6em;
}
.cover img {
    width: 80px;
    height: 120px;
}
.row {
    display: inline;
    position: relative;
}
.text {
    display: inline;
    position: relative;
    font-size: smaller;
}
.related {
    display: inline-block;
    width: 200px;
    font-size: 0.8em;
    height: 100px;
    float: right;
    margin: 25px 0 50px 20px;
}
.figcaption {
    display: inline-block;
    float: right;
}
.related img {
    width: 200px;
    height: 100px;
}
* {
    border: 1px dotted #ccc
}


text:
Q: Better way to exit for loop when using sync.WaitGroup? Is there a better way to exit the for loop when using sync.WaitGroup? At the moment I am using bool e as a trigger to break out of the for loop at the end of the loop, which works. If I try to break the for loop where I check orders >= quantity I get all kinds of errors.
Is there a better way to break this loop than my bool code without causing panic?
package main

import (
    "fmt"
    "math/rand"
    "strconv"
    "sync"
)

func main() {
    var wg sync.WaitGroup
    var accounts int = 1
    var emails int = 1000

    for i := 0; i < accounts; i++ {
        wg.Add(1)

        go func(i int) {
            defer wg.Done()
            threads := 500 //Max subroutines to run at once
            var orderMutex sync.Mutex
            var quantity = 2
            var orders = 0
            sem := make(chan bool, threads)
            var wgnested sync.WaitGroup

            var e = false

            for x := 0; x < emails; x++ {
                sem <- true //block

                orderMutex.Lock()
                if orders >= quantity {
                    fmt.Println(strconv.Itoa(x) + " Quantity Exceeded Stopping")
                    e = true
                }
                orderMutex.Unlock()

                wgnested.Add(1)

                go func() {
                    defer wgnested.Done()
                    defer func() { <-sem }()

                    //Simulate orders
                    if rand.Intn(50) == 7 {
                        orderMutex.Lock()
                        orders++
                        orderMutex.Unlock()
                    }

                    fmt.Println(strconv.Itoa(i) + " Made to end ")

                }() //func

                if e {
                    break
                }
            } //x

            wgnested.Wait()

        loop:
            for {
                select {
                case <-sem:
                    fmt.Println("quit")
                    break loop
                default:
                    sem <- true
                }
            }
            fmt.Println(strconv.Itoa(i) + " Orders: " + strconv.Itoa(orders))

        }(i)
    } //i

    wg.Wait()
}

A: you use context.Context to stop a loop when the context is cancelled.
Example
package main

import (
    "context"
    "fmt"
    "math/rand"
    "strconv"
    "sync"
)

func main() {
    var (
        wg       sync.WaitGroup
        accounts int = 1
        emails   int = 1000
        //
        ctx, cancel = context.WithCancel(context.Background()) // create new context
    )

    for i := 0; i < accounts; i++ {
        wg.Add(1)

        go func(i int) {
            // when goroutine finish
            // cancel the context
            defer func() {
                wg.Done()
                cancel()
            }()
            //
            var (
                // threads    = 500 //Max subroutines to run at once
                orderMutex sync.Mutex
                quantity   = 2
                orders     = 0
                wgnested   sync.WaitGroup
            )

            for x := 0; x < emails; x++ {
                select {
                // case context is done.
                case <-ctx.Done():
                    return
                default:
                    // check context is cancelled
                    // exit for loop
                    if ctx.Err() != nil {
                        return
                    }

                    orderMutex.Lock()
                    if orders >= quantity {
                        fmt.Println(strconv.Itoa(x) + " Quantity Exceeded Stopping")
                        cancel() // signal cancel context
                    }
                    orderMutex.Unlock()

                    wgnested.Add(1)
                    go func() {
                        defer wgnested.Done()

                        //Simulate orders
                        if rand.Intn(50) == 7 {
                            orderMutex.Lock()
                            orders++
                            orderMutex.Unlock()
                        }

                        fmt.Println(strconv.Itoa(x) + " Made to end ") // i used "x" instead of "i"

                    }()

                    wgnested.Wait()
                }
            }

            //
            fmt.Println(strconv.Itoa(i) + " Orders: " + strconv.Itoa(orders))
        }(i)
    } //i

    wg.Wait()
}

Output
0 Made to end
1 Made to end
2 Made to end
3 Made to end
4 Made to end
5 Made to end
6 Made to end
...
...
...
88 Made to end
89 Made to end
90 Made to end
91 Made to end
92 Made to end
93 Made to end
94 Quantity Exceeded Stopping
94 Made to end


text:
Q: Фильтр по диапозону цены Есть такой небольшой фильтр:

var filterAll = $('.filter-all'),
    boxs = $('.box'),
    length = boxs.length;
filterAll.text(length);

// Checkbox
$('input:checkbox').on('change', function() {

   var
     filter = new RegExp($(":checkbox:checked")
                         .map(function() {
                           return this.value;
                         })
                         .get()
                         .join("|") );

  //console.log(filter);

  $(".box").each(function() {
    var $this = $(this);
    $this[filter.source != "" && filter.test($this.attr("class")) ? "show" : "hide"]();

  });
});

// Range Slider
var range = document.getElementById('range'),
    t = [],
    maximum = parseInt(range.attributes.max.value, 10),
    minimum = parseInt(range.attributes.min.value, 10),
    delta = (maximum - minimum) / 4,
    options = {
      min: [minimum],
      "25%": [minimum + delta * 1, 1e6],
      "50%": [minimum + delta * 2, 1e6],
      "75%": [minimum + delta * 3, 1e6],
      max: [maximum]
    };

//console.log(minimum + delta * 1, 1e6);

t.push(parseInt(range.attributes.min.value, 10)),
  t.push(parseInt(range.attributes.max.value, 10));
var n = parseInt(range.attributes.max.value, 10);
// i = parseInt(range.attributes.min.value, 10),

noUiSlider.create(
  range,
  {
    range: options,
    start: t,
    connect: !0,
    pips: {
      mode: "range",
      density: 2
    }
  }
);

$(".noUi-value-horizontal").each(function() {
  var range = $(this).text().split("").slice(0, -6).join("");
  $(this).html(range);
});

range.noUiSlider.on('change', function(values, handle){
  $(".box").each(function() {
    var $this = $(this);
        price = $this.data('price');

    var val1 =  values[0];
    var val2 =  values[1];

    if(price <= val2 && price >= val1 ) {
      $this.show();
    }else {
      $this.hide();
    }

  });
});

//   var filterSelect = $('.filter-select'),
//     boxs = $('.box'),
//     length = boxs.length;
//     filterSelect.text(length);
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

/* input[type="checkbox"] {
  display: none;
} */

li {
  display: inline-block;
}

.filter-item {
    border: 4px solid #ccc;
    margin: .1rem;
    padding: .5rem .95rem;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
}

input[type="checkbox"]:checked+label,
.filter-item.active,
.filter-item:hover,
.filter-item:not(.active):hover {
    background: #333;
    color: #fff;
}

.slider-wrapper {
  margin-top: 1rem;
  margin-bottom: 3rem;
  padding: 0 1rem;
}

.filter-res {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 1rem;
}

.filter-res span {
  color: red;
}

.box {
  width: 8rem;
  height: 8rem;
  background: #ccc;
  margin: 1rem;
  padding: 3rem 0;
  display: inline-block;
  text-align: center;
  font-family: monospace;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/10.1.0/nouislider.min.css" />

  Кол-во комнат

      <input type="checkbox" id="room-1" value="room-1">

        1

      <input type="checkbox" id="room-2" value="room-2">

        2

      <input type="checkbox" id="room-3" value="room-3">

        3

  Метраж

      <input type="checkbox" id="area-1" value="area-1">

        50-100

      <input type="checkbox" id="area-2" value="area-2">

        100-200

  Цена

    Выбрано 0 из 0

      room="1"
 area="70"
 6 140 000

      room="2"
 area="70"
 17 000 000

      room="3"
 area="70"
 27 000 000

Range Slider - noUiSlider
По чекбоксам работает все, но вот со слайдером загвоздка.
Смысл в том, что при перемещении ползунка, только попавшие в диапозон цены товары отображались (с учетом чекбоксов) и результат фильтра (количество отображенных товаров) записывались в .filter-select.
Сейчас, выбираю диапозон цены, потом выбираю кол-во комнат (чекбокс) - все работает, потом убираю выбор комнаты (снимаю чекбокс) и все сбрасывается.
Вопрос: Как реализовать фильтр товаров по range слайдеру с учетом чекбоксов и записать количество всех выведенных результатов?

A: Если правильно понял то что то типо того?

var filterAll = $('.filter-all'),
    boxs = $('.box'),
    length = boxs.length;
filterAll.text(length);
var count_box;

var filter =   filter = new RegExp($(":checkbox:checked")
                         .map(function() {
                           return this.value;
                         }).get().join("|") );

$('input:checkbox').on('load change', function() {

  filter = new RegExp($(":checkbox:checked")
                         .map(function() {
                           return this.value;
                         }).get().join("|") );

  $(".box").each(function() {
    var $this = $(this);

    if(filter.test($this.attr("class")) ) {
        $this.show();
    }else{
       $this.hide();
    }
    if(filter.source == ""){
       $this["show"];
    }
  });

   var values = [];
 values[0] = $(".noUi-handle.noUi-handle-lower").attr("aria-valuetext");
 values[1] = $(".noUi-handle.noUi-handle-upper").attr("aria-valuetext");
  range_change( values  );

  count_box();
});

// Range Slider
var range = document.getElementById('range'),
    t = [],
    maximum = parseInt(range.attributes.max.value, 10),
    minimum = parseInt(range.attributes.min.value, 10),
    delta = (maximum - minimum) / 4,
    options = {
      min: [minimum],
      "25%": [minimum + delta * 1, 1e6],
      "50%": [minimum + delta * 2, 1e6],
      "75%": [minimum + delta * 3, 1e6],
      max: [maximum]
    };

//console.log(minimum + delta * 1, 1e6);

t.push(parseInt(range.attributes.min.value, 10)),
  t.push(parseInt(range.attributes.max.value, 10));
var n = parseInt(range.attributes.max.value, 10);
// i = parseInt(range.attributes.min.value, 10),

noUiSlider.create(
  range,
  {
    range: options,
    start: t,
    connect: !0,
    pips: {
      mode: "range",
      density: 2
    }
  }
);

$(".noUi-value-horizontal").each(function() {
  var range = $(this).text().split("").slice(0, -6).join("");
  $(this).html(range);
});

function range_change(values, handle){
 $(".box").each(function() {
    var $this = $(this);
        price = $this.data('price');

    var val1 =  values[0];
    var val2 =  values[1];

    if(price <= val2 && price >= val1 && filter.test($this.attr("class")) ) {
      $this.show();
    }else {
      $this.hide();
    }

  });
}
range.noUiSlider.on('change', function(values, handle){
 range_change(values, handle);
 count_box();
});

function count_box() {
   countbox = $('.content').find(".box:visible").length;
   $(".filter-slect").text(countbox);
}

//   var filterSelect = $('.filter-select'),
//     boxs = $('.box'),
//     length = boxs.length;
//     filterSelect.text(length);
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

/* input[type="checkbox"] {
  display: none;
} */

li {
  display: inline-block;
}

.filter-item {
    border: 4px solid #ccc;
    margin: .1rem;
    padding: .5rem .95rem;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
}

input[type="checkbox"]:checked+label,
.filter-item.active,
.filter-item:hover,
.filter-item:not(.active):hover {
    background: #333;
    color: #fff;
}

.slider-wrapper {
  margin-top: 1rem;
  margin-bottom: 3rem;
  padding: 0 1rem;
}

.filter-res {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 1rem;
}

.filter-res span {
  color: red;
}

.box {
  width: 8rem;
  height: 8rem;
  background: #ccc;
  margin: 1rem;
  padding: 3rem 0;
  display: inline-block;
  text-align: center;
  font-family: monospace;
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/10.1.0/nouislider.min.css" />

  Кол-во комнат

      <input type="checkbox" id="room-1" value="room-1">

        1

      <input type="checkbox" id="room-2" value="room-2">

        2

      <input type="checkbox" id="room-3" value="room-3">

        3

  Метраж

      <input type="checkbox" id="area-1" value="area-1">

        50-100

      <input type="checkbox" id="area-2" value="area-2">

        100-200

  Цена

    Выбрано 0 из 0

      room="1"
 area="70"
 6 140 000

      room="2"
 area="70"
 17 000 000

      room="3"
 area="70"
 27 000 000


text:
Q: rails4 js response XSS I have a rails4 app. If I submit  in the form then alert gets displayed, so it doesn't escape js (despite of having <%= j render @post %>), so my app is not protected from XSS.
Why is this happening? What should I do?
controller
def create
  @post = current_user.posts.new(post_params)
  @post_comment = PostComment.new
  if @post.save
    respond_to do |format|
      format.html { redirect_to @post, notice: "Post saved!" }
      format.js
    end
  else
    .......

_form
<%= form_for @post, remote: true, method: :post, class: "post-create-form" do |f| %>

    <%= render 'layouts/error_messages', object: f.object %>

  <%= f.text_area :body, placeholder: "Share something useful..", class: "form-control post-create-body" %>

  <%= f.button "Share", class: "btn btn-primary btn-create-post", data: {disable_with: " Saving..."} %>

create.js.erb
$("ul.errors").html("");
<% if @post.errors.any? %>
    $('.alert-danger').show();
    $('ul.errors').show();
    <% @post.errors.full_messages.each do |message| %>
        $("ul.errors").append($("
").html("<%= message.html_safe %>"));
    <% end %>
<% else %>
    $('ul.errors').hide();
    $('.alert-danger').hide();
    $('.post-index').prepend('<%= j render @post %>');
    $('.post-create-body').val('');
    $('.btn-create-post').prop('disabled',true);
<% end %>


text:
Q: Proving arbitrary intersection of closed sets from closure axioms I am given the following axioms to define the closure of a sub-set $A$ in $X$:

*

*$\overline \emptyset$ = $\emptyset$

*$\overline X$ = $X$

*$A \subset \overline A$

*$\overline {A \cup B} = \overline A \cup \overline B$

*$\overline{\overline A} = \overline A$
From these I want to show that the definition of a closed set as a set $A = \overline A$ satisfies the axioms of a closed set in a topological space. But I am stumped on the axiom of arbitrary intersection:
Given a family $\{F_\alpha\}_{\alpha \in I}$ of closed sets $\bigcap_{\alpha \in I} F_\alpha$ is closed.

A: Let $F=\bigcap_{\alpha\in I}F_\alpha$. For each $\alpha\in I$ we have $F\subseteq F_\alpha$, so by (4)
$$\overline{F}\subseteq\overline{F}\cup\overline{F_\alpha}=\overline{F\cup F_\alpha}=\overline{F_\alpha}\,,$$
and therefore
$$F\subseteq\overline{F}\subseteq\bigcap_{\alpha\in I}\overline{F_\alpha}=\bigcap_{\alpha\in I}F_\alpha=F\,,$$
i.e., $F=\overline{F}$.


text:
Q: Cannot connect with docker MySQL server container with the host name specified in docker-compose file When I set hostname as localhost in MySQL Work Bench, It works. But when I use the hostname as msqldb it doesn't work and show that hostname msqldb cannot be resolved. What can be the issue?
Below is the docker-compose.yml
version: "3"
services:
    msqldb:
        image: mysql:8.0.20
        environment:
          MYSQL_ROOT_PASSWORD: psd
          MYSQL_PASSWORD: psd
          MYSQL_DATABASE: restaurantratingsystem
        ports:
            - "3315:3306"

    dj:
        container_name: dj
        build: django
        command: python manage.py runserver 0.0.0.0:80
        volumes:
            - ./django:/code
        ports:
            - "80:80"
        depends_on:
          - msqldb