jQuery UI switchClass() method is not working properly

Question: jQuery UI switchClass() method doesn't switch class, rather it performs some undesired animations and the class remains the same as the original one when I use jquery.animate-enhanced.js for hardware accelerated animations.

Any Idea about how can I fix it?
Comment: and why is it not working properly ? can you atleast explain the "not working properly" behaviour ?
Comment: it does not switch class. After some undesired animation, the class remains same.
Comment: Can you please post a jsfiddle that replicates the problem?
Comment: in the browser, go to networks tab on the browser debugger(F12) and make sure that it succeeds to load the css and js. if not, add http at the start of the href
Answer: I have encountered this problem before and wasted many hours trying to figure out what was going wrong.
I still don't know why switchClass sometimes doesn't work, but I do have a workaround:
Replace
switchClass('circle','square');

with
addClass('square').removeClass('circle');

Hope that helps.
Comment: There are definitely problems with the switchClass method. For me it takes about a second to take effect. Fortunately your solution works :)
Answer: $(function(){
   $('#circle').click(function(){
      $('.circle').switchClass('circle', 'square', 'slow');
      $('.square').switchClass('square', 'circle', 'slow');
      return: false
   });
});

In this Example on the click of the #circle Div I am removing the .circle class from all objects and replacing it with the .square class. If the .circle class is not there to be removed then the .square class is removed and replaced with the .circle class. It is a toggle effect.
If you do no want the toggle just remove the top or bottom one.
Answer: if the prb is

.switchClass is not a function

check if you are link the effects.core.js in your code
check that by using the Console in your navigator for js, good luck it's work fine for me :)
Comment: yes i already know, but take a look: [http://api.jqueryui.com/category/effects-core](http://api.jqueryui.com/category/effects-core/)

"Functionality provided by effect.js. In addition to the methods listed below, effect.js also includes several easings."
Answer: I am guessing you want to toggle between two classes. If that is the case you can do it with toggleClass function.
 //first you start with one of the classes in html:

    //then in js you do:
    var element = ...;
    $(element).toggleClass('foo bar');

This will toggle both 'foo' and 'bar'. Since foo is already present it will remove it and add bar. On the next call bar will be present so i will remove it and add foo. And so on.
If something is not clear here is a jsfiddle example: https://jsfiddle.net/09qs86kr/1/
Comment: To be honest the operation is so simple it would be better to just use plain js for this.
Answer: please check you are added the jQueryUi file

Answer: I faced this problem before but could not find the solution. Then I used      toggleClass() to solve the problem. Here is the example:
If an element has class X at the beginning, then write:
$(element).toggleClass("Y");

This will add class Y. If you do that again, it will remove class Y.
Reference: http://api.jquery.com/toggleclass/
Hope that helps.
Answer: Make sure the classes you are using doesn't have any "!important" properties.
I have invested and found that jquery UI switch class doesn't work for properties with "!important" tags.
Reason :
Consider that your previous class had style "padding : 0" and your new class has "padding:100". You have added switchClass duration for 100 ms.
What jquery will do for this is, it will add a style to your element by increasing padding by "1" in every 1 ms. But, as the previous class is still there in the element with a "padding : 0 !important", after 10 ms, "padding : 10" style added by jquery doesn't effect the UI. After 100 ms, jquery will execute removeClass("previousClass") and addClass("newClass"). this will result to a instant change in style reflected in the UI.
This is the explanation I find-out. Please let me know what you guys think about this.


Security Implications of setting passwd as suid

Question: When the passwd command is executed, it runs as the root user. Can't this be exploited? If not, why?
Answer: "Exploiting" an application means making it do, with the privileges under which it is running, some things that it was not meant to do. passwd runs as root because it needs to read and modify files (in particular /etc/shadow) that can be read and written only by root. The normal behavior of passwd is to alter the password of the user who runs it (passwd is SUID-root so it has the privileges of the root user, but it stills remembers who executed it) and there is code in passwd which enforces that rule. To exploit it, one would need to find a way to bypass that code, i.e. a bug in passwd.
Being SUID-root does not automatically imply being exploitable. Rather, a non-SUID-root application does not have extra privileges so there is no point in exploiting it.
Comment: And exactly since non-SUID applications *don't* run with privileges that the user invoking them already has, those often do not receive the same scrutiny. That does (sometimes) make them easier to exploit. The *hard* case to get right is complex software that needs to run as root. `passwd` is hardly complex in the grand scheme of things.
Answer: It can be if there is a buffer overflow in it, or the user has write access to the executable file or any number of similar situations. However security related apps like that tend to get stricter checking than a lot of the rest of the system and it's also a pretty simple application to check compared to most applications. Finally it's a very old application that has been tried and tested for years and so has been updated and matured. I expect there may have been exploitable bugs in earlier versions.
Answer: As others have said: many people have looked at passwd, for many years, over many distributions.  Here's an example of an advisory from the '90s.
http://www.cert.org/advisories/CA-1993-08.html
I guess you could look at all the different updates and patches, and check against the version of passwd in use.  Sysadmins have the ability to change what passwd will accept, and that can help attackers.
Also, passwd is interesting because it's (we hope) strong, and it writes to a (we hope) strong file, but it gets input from users.
Any dump of plain text passwords will show that many users chose hopeless passwords.  So, passwd gets lots of attention from people who want it to be stronger, but not so much from people wishing to attack it, because there's already a weak link there.


iPhone won't boot after installing higher capacity battery

Question: I wanted to upgrade my iPhone 5 to a higher capacity 2680mAh battery, but when I installed it the Apple flashes on and off and the phone will not turn on. I had to reinstall the old battery. Any solutions?
Answer: You should only use the battery that's for your phone. The phone is not meant to take a higher wattage battery, so it will malfunction.
To put that into context, it's like trying to put a V8 engine into a hairdryer. It won't work.


Gain of Basic Amp with FB network

Question: the goal is to find the gain of the circuit. I don't understand the Vi/Vs part. I know they used voltage divider, but why they included the second term(in Red) in the expression? where does that come from? can anyone elaborate on this please?
Thanks
Comment: A regular circuit diagram would help.
Comment: okay, I will add it up in a sec
Comment: I just added up the regular circuit diagram
Comment: OP, you got an answer (again). I see you are asking a lot of very basics questions, while I must say that you usually include everything that is needed to answer, and even your attempts, I think you should find another source of help, maybe your teacher, fellow students, or a nice book.
Answer: Not sure what you got so far, but in my opinion the fastest way to compute this is starting by changing your voltage generator with a current generator, with the help of Norton's theorem.
We are making the Norton equivalent of \$V_s\$ and \$R_s\$, this results in a current generator with \$I_s=\frac{V_s}{R_s}\$ in parallel with a resistor \$R_s\$.
Now \$V_i=R_{id}\cdot I_{Rid}\$, the current through the resistor can easily be found with the current divider formula:
$$
I_{Rid}=I_s\cdot\frac{R_s//2R_{ICM}}{R_s//2R_{ICM}+R_{id}+R\beta_0//2R_{ICM}}
$$
now substitute \$I_{Rid}\$ and \$I_s\$ and rearrange:
$$
\frac{V_i}{V_s}=\frac{R_{id}}{R_s}\frac{R_s//2R_{ICM}}{R_s//2R_{ICM}+R_{id}+R\beta_0//2R_{ICM}}=\\
=\frac{R_{id}}{R_s//2R_{ICM}+R_{id}+R\beta_0//2R_{ICM}}\frac{2R_{ICM}}{R_s+2R_{ICM}}
$$
There are a number of ways in which you can rearrange the latter result, and the one your book uses does not seem quite fit to me. The term you are unsure about seems like an easy voltage divider at the input, and indeed is there because you have a resistive divider there, but since the divider is loaded by the three rightmost resistors getting the right result is not so easy. In fact you find both \$R_s\$ and \$R_{ICM}\$ also in the first term, and not just because you have another \$R_{ICM}\$ on the right side of your circuit.
A student that is (quite properly) trying to grasp why a term is there, might see the voltage divider and say "ok that's easy I got it" and write down something like this:
$$
V_i=V_s\cdot\frac{2R_{ICM}}{R_s+2R_{ICM}}\cdot\frac{R_{id}}{R_{id}+R\beta_0//2R_{ICM}}
$$
this last formula is wrong, because as I said the loading effect of the rightmost resistors on the first voltage divider can't be neglected.
My point here is that you probably saw that term, thought of the voltage divider and thought that there is some fancy way of doing things here. There is not. Sometimes math is better than intuition.
It is nice to see that things adds up though: if the leftmost resistors are quite smaller than the rightmost, i.e. you have an "heavy voltage divider"*, the right formula can be simplified and it becomes the 'wrong' one. This happens if you neglect the \$R_s//2R_{ICM}\$ term with respect to \$R_{id}+R\beta_0//2R_{ICM}\$ in the denominator of the first part of the 'right' formula.
*that's Italian slang, not sure how you natives say that, we speak of "heavy voltage divider" when the loading effects are neglectable, i.e. when you bias a bjt base for a CE amplifier we say you have to make an "heavy divider" thus sizing it so that the current flowing into it is much greater than the transistor base current.
Answer: There level of detail needed to determine the gain depends on the assumptions you make in the opamp. Clearly in this question, the opamp isn't an 'ideal' one -- not only does it not have infinite gain, there is apparently and output impedance (Ro), and two input impedances -- a differential one (between the '+' and '-' inputs), and a common-mode one (to ground at the '+' input ?).
If you examine the model for the opamp, you'll find those components, and while they make the expressions more complex, writing the answer is just a case of solving KVL or KCL at the nodes.
Comment: thanks for the input, but that does not really answer my question.

Gain of Basic Amp with FB network


How to display markers (huge numbers) on a map which has been logically divided into segments?

Question: What i have done so far:
i'm developing an application where i have to display more than(50K) points/Markers on the Navteq map divided into different segments.
for example: if i have  50K points i will divide all points into different segments.
if i divide 50K points into 50 segments each segment would have 1000 points (may not be 50 segments , it may depend).
right now it is working but it takes long time and hangs to render all the points on the MAP.so that i would like to perform segmentation displaying   to display only few points with clustering.
so that i can get an idea of how the segment will look like.
but the problem here is  i should only perform the clustering based on the segments.otherwise points from different segments willbe mixed together and displayed
as single unit and that conveys the wrong information  to the user.
so here my question is: is it possible to perform the clustering based on the segment. so that only points from same segment will be clustered.
Note: if this is not possible, i would like to use Latest version of here-maps 2.5.3 (Asynchronous) may reduce some time while loading, so that i would like to use indexing functionality also while rendering the points
to improve the rendering time using nokia.maps.clustering.Index class.
i studied that indexing would reduce the time while rendering the points/markers on map. does it help in my case? could anybody please suggest how to perform indexing ?
This is the code with which i'm displaying points on map:
function displayAllLightPoints(arrLightPointCoordinats, totalLightPoints,
                    selectedSegmentId, totalSegmentsCount,segmentColorcode)
{
    var MyTheme1 = function () {
    };
    segmentColorcode = segmentColorcode.substring(2,segmentColorcode.length-1);

    MyTheme1.prototype.getNoisePresentation = function (dataPoint) {
            var markerLightPoint = new nokia.maps.map.Marker(dataPoint, {
            icon: new nokia.maps.gfx.BitmapImage("..//Images//Lightpoint//" +
                                                  segmentColorcode + ".png"),
            anchor: {
                x: 12,
                y: 12
            }
        });
        return markerLightPoint;
    };

    MyTheme1.prototype.getClusterPresentation = function (data) {
        var markerLightPoint = new
            nokia.maps.map.StandardMarker(data.getBounds().getCenter(), {
            icon: new nokia.maps.gfx.BitmapImage("..//Images//
                Segment/" + segmentColorcode + ".png", null, 66, 65),
            text: data.getSize(),
            zIndex: 2,
            anchor: {
                x: 12,
                y: 12
            }
        });
        return markerLightPoint;
    };

    var ClusterProvider = nokia.maps.clustering.ClusterProvider,
        theme = new MyTheme1(),
        clusterProvider = new ClusterProvider(map, {
            eps: 0.00000000001,
            minPts: 1000000,
            strategy: nokia.maps.clustering.ClusterProvider.
                                     STRATEGY_DENSITY_BASED,
            theme: theme,
            dataPoints: []
        });
    var lightpointsDataSet1 = new Array();
    for (var i = 0; i < totalLightPoints; i++) {
        lightpointsDataSet1[i] = { latitude: arrLightPointCoordinats[i][0],
             longitude: arrLightPointCoordinats[i][1], title:
            'LightPoint ' + (i + 1) };
    }

    clusterProvider.addAll(lightpointsDataSet1);
    clusterProvider.cluster();
}

Answer: To deal with a very large (50K+) data set , I would do all the heavy number crunching server side and send over a new JSON response whenever the map is updated. Something like the HTML page described here
The key section of the code is the ZoomObserver:
var zoomObserver = function (obj, key, newValue, oldValue) {
  zoom = newValue;
  if (zoom < 7)
    { zoom = 7;}
  if (zoom > 16)
    { zoom = 16;}
  // Define the XML filename to read that contains the marker data
  placeMarkersOnMaps('http://api.maps.nokia.com/downloads/java-me/cluster/'+ zoom + '.xml'
    + '?lat1=' + map.getViewBounds().topLeft.latitude
    + '&lng1='+ map.getViewBounds().topLeft.longitude
    + '&lat2='+ map.getViewBounds().bottomRight.latitude
    + '&lng2='+ map.getViewBounds().bottomRight.longitude);
};

map.addObserver("zoomLevel", zoomObserver );

Where the REST service returns a "well-known" data format which can be used to add markers and clusters to the map.
Now assuming you have two massive data sets you could make two requests to different endpoints, or somehow distinguish which cluster of data belongs to which so that you would just be returning information of the form:
{latitude':51.761,'longitude':14.33128,'value':102091},

i.e. using the DataPoint standard (which means you could use a heat map as well.
Of course, what I'm not showing here is the back-end functionality to cluster in the first place - but this leaves the client (and the API) to do what it does best displaying data, not number crunching.


Eog random slideshow from the terminal

Question: What is the best way to have Eye of Gnome Graphics viewer (EOG) open a folder full of images in a randomized slide-show from the terminal?
Comment: Is this for personal use or for a program you are making? If the former, then you can just call `eog /path/to/folder` and press Ctrl+M so as to have a random image displayed...
Comment: I was hoping to build a shell script.
Answer: sudo apt-get install eog-plugins -y

then start eye of gnome, (terminal or not, doesn't matter for now), click
edit / preferences / plugins
Scroll down and check the "slideshow shuffle" box. Close the program.
Then, via terminal you can:
eog /path/to/pictures -s

Where the " -s" switch triggers the slideshow and eog remembers the shuffle plugin.

Eog random slideshow from the terminal


salesforce1 look & feel in Visualforce

Question: How to make a vf page with the same look & feel as salesforce1, any ideas?
Answer: The best place to start with this is the Salesforce1 style guide at:
http://sfdc-styleguide.herokuapp.com/
This details colours, fonts and has sample code to create components that match Salesforce1, such as buttons, cards, lists.
Comment: You should be able to copy the resources from that site - if you are using chrome then right click to use the inspector.  The advice from SFDC is to copy the stylesheets as they are subject to change without notice so relying on their style names isn't safe.
Comment: Nice share.Good to know these are exposed on heruko
Comment: Bob, posting the style guide is great, but how are we meant to use the components within it? The default style sheets are not available in Visualforce pages within Salesforce1 and there is no link to download them for the style guide site. Now I could reverse engineer them from the style guide site source, but that doesn't seem the best way of going about things.
Comment: Like Alex, I'm a bit confused about taking that step to use the tools with what we have.

Essentially, I have a page of Visualforce, full of apparent nono's such as pageBlock, pageBlockSection etc.

The big question is how do I take this page and:

1) make it display as per desktop when viewing on desktop
2) make it display in a Salesforce1 fashion on the app

Very little in the way of first steps handholding out there on the net. Not sure if it is assumption, but most guides are glossing over what needs to be done.
Comment: Example:

http://www.salesforce.com/us/developer/docs/salesforce1/Content/vf_dev_best_practices_approaches_mixed.htm

Says what not to do but little guidance on how to use things properly. I started using  and  - besides the errors I was getting, the formatting was completely style free for the  aspect of things.

Really confused as to how you're meant to take existing development and recode it to work on both desktop and mobile.
Answer: I've written a jQuery plugin which will apply the styles from the style guide to simple HTML / Visualforce:
https://github.com/joshbirk/onestarter
There is a static resource in that repository that includes the CSS from the style guide as well as a jquery and related plugins to get started.  The plugin also has some functions to easily handle things like the submit button and resolve differences between Chatter in the browser and Salesforce1.
Note - this is basically a preview of the plugin, still a bit of a WIP.
Answer: A Salesforce1 Bootstrap theme was recently released by developers from the Salesforce Foundation. It is a quick and easy way to align with Salesforce1 style guidelines while using a framework that is quite familiar.
Getting started: http://developer.salesforcefoundation.org/bootstrap-sf1/index.html
Git repo: https://github.com/SalesforceFoundation/bootstrap-sf1
Comment: I really want to know the scope Salesforce1 bootstrap, is it cover all component?How about page that embed with Chatter.
Answer: Right now to apply CSS you have to reverse engineer it and copy to your visualforce page. Recently I have implemeted this by copying CSS for Salesforce1 pages and applying it to our custom visualforce pages.
Keep remember that custom visualforce pages open in iframe when accessed in Salesforce1 environment So you will not be able to access SFOne CSS by applying .selector or by Javascript.
All CSS applied in Salesforce1 is under the parent selector .oneStyle. So wrap your html code in a container div and apply .oneStyle class to it. This will make sure that all Salesforce1 css effects will we mobile compatible. And copy CSS style for each element from SFOne and copy it to you visualforce page.
Thats not the best way but little understanding of css may not require best method (if exists).
For more information here basic details has been provided to give Salesforce1 look and feel to pages: http://intmist.wordpress.com/2014/02/16/salesforce1-look-and-feel-customise-visualforce-pages-for-salesforce1/
Answer: You should now be able to use the lightning design system to do this - https://www.lightningdesignsystem.com.
You'll just have to download the static resource,  add the style sheets such as:
<apex:stylesheet value="{!URLFOR($Resource.slds0121, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
and then add the classes to your componenets. This has the advantage of being supported by Salesforce and you know that your page wil always have the same CSS that Salesforce uses internally

salesforce1 look & feel in Visualforce


Use ActionBar without Activity

Question: Is it possible to use ActionBar without activity? I want to use it in the StatusBar view, instead of view highlighted with purple color.
Answer: This screen shot, based on an image from the Android ui pages, labels the different components, just to make sure we're talking about the same thing.

You can't add an ActionBar outside of an Activity. You need an Activity to get an ActionBar reference. ActionBar references are retrieved via the Activity API, by calling the getActionBar() method inside the Activity.
So you can't use an ActionBar to replace the StatusBar. You can change the StatusBar's color, and possibly layout, but only on a rooted phone. See this forum discussion for some perspective on the issue.
AFAIK, there is no API for changing the Notification Drawer's layout and functionality. There are no API methods that allows us to place an ActionBar inside the drawer outside of the notifications e.g. at the top of the drawer like in your screenshot.
You can create custom layouts for notifications(the messages inside the drawer). The Android Developer pages have an example on how to do it (see "Creating a Custom Notification Layout" at the bottom of the page). Again, you can't use an ActionBar but you can add Views to a Notification layout.
Answer: Use notifications. You will see something in the status bar and no Activity will be involved.
Comment: I'm sorry, which notifications you mean?
Answer: There's GOT to be a way to change the ActionBar from a class declared within an Activity:
(1) create method in activity to .setTitle
(2) pass activity context to Controller class (MVC) declared in Activity
(3) have Controller class call activity method to modify actionBar
...what do you think?
Comment: ...or perhaps by message passing between the Controller class and the activity...?
Answer: You should make a custom rom to change that view.
That Purple View is not part of your application but a part of Android.
If you do not want an Activity, why not make it transparent.
How do I create a transparent Activity on Android?
Comment: I work in company, that creates Android-based OS, and my task is to modify the OS, so, I know it ;)

Use ActionBar without Activity


Does 那个公共汽车很红 sounds right?

Question: A friend told me all adjectives in Chinese are verbs. I am not so sure if it is right in general, especially when it comes to color. I ask him to give me examples and he said
1 天黑了
2 那个公共汽车很红
I think 1 is fine but 2 is not, but I don't how to explain these.
Can someone explain how you interpret the idea that all adjectives in Chinese are verbs and how you can use colors as verbs? thanks
Comment: "那个公共汽车真红" may be better.
Answer: It is not 'all adjectives in Chinese are verbs' but 'many adjectives in Chinese can also function as verbs' and most of the time you need a correct verb particle
Examples:
黑马 - Black horse (O)
天黑了 - The sky has darkened (O)
把墙黑了 -  to darken the wall (X) - the correct verb is 涂黑(to paint black) or 弄黑 (to make black)
瘦狗 - thin dog (O)
這狗瘦了 - This dog has thinned down (O)
瘦自己 - to thin oneself down (X) - the correct verb is 弄瘦 (to make thin)
強人 - strong person (O)
這人強了 - this man has grown strong (O)
強這攻势 - strengthen this attack (X) - the correct verb is 加強 (to strengthen)
攻势弱 - the attack is weak  (O)
攻势弱下來了 - the attack has weakened down (O)
弱他们的攻势 - to weaken their attack (X) - the correct verb is 減弱 (to weaken)

那个公共汽车很红 sounds right?

红(red) here is still an adjective for the noun 公共汽车 (this bus is very red)

红 (short for 火红 = popular and trendy) could function as a verb with an appropriate verb particle

Example:
那种公共汽车最近红了起來 = Recently, that kind of bus has become popular and trendy
Comment: I am wondering if it is a good translation for "this bus is very red". maybe you can also comment in here
https://chinese.stackexchange.com/a/42105/22375
Answer: Grammatically, unlike in English, adjectives can be predicate in Chinese. The sentences your friend gave are correct.
Other examples: 她很漂亮。你人真好。etc.  漂亮 and 好 are adjectives.
Besides verbs and adjectives, there are also some other words or phrases can be predicate in Chinese.  English learners should be aware of this difference while learning Chinese language.
Comment: @wada Yes, just like 那苹果很红, 她的皮肤很白,etc.
Comment: Are you sure 那个公共汽车很红 sounds right?
Comment: I don't think 那个公共汽车很红 semantically make sense, although it is allowed structurally. If I do a google search, 天黑了, 那苹果很红, 她的皮肤很白 give results, but this particular page is the only result by google for 那个公共汽车很红. As others have mentioned, 红 also means popular
Comment: @wada 那个公共汽车很红 makes sense, no matter 红 means red or popular. It can mean either in that particular sentence.

Does 那个公共汽车很红 sounds right?


salesforce1 lightning component learning

Question: I want to learn salesforce1 lightning component. I want to try it in my developer account for learning purpose. Can anyone provide me some useful link where I can learn basics of salesforce1 lightning components.
Answer: This is a tutorial by Jeff Douglas Lightning Frequently Asked Questions and at the bottom of the developer site under technical resources you will find a bunch more links here.

Technical Resources for Lightning Ready to start developing with
  Lightning or want to learn more? We've prepared a variety of technical
  resources that will help you get started building and deploying
  Lightning Applications and Components.
Lightning Components Developer Guide
Lightning Components QuickStart
Lightning Components Cheatsheet
Lightning Components Discussion Forums
Lightning Frequently Asked Questions

Trailhead has new Lightning badges!
Comment: Would like to add this link as well for basics: http://intmist.wordpress.com/2014/11/02/salesforce1-lightning-components-getting-started-with-salesforce1-lightning-components/
Answer: https://developer.salesforce.com/lightning has lots of links (at the bottom) with useful resources for learning.


Lining up .asc XY points with DXF using QGIS 2.0

Question: I've exported XY points (nodes of a polyline with attributes) (.asc) from Star APIC and attempted to import it into QGIS as a delimited text file. I cannot however get it to line up correctly with the corresponding DXF file I exported from the same database. My DXF lines up with aerial photographs, so I am sure it is correctly projected. The CSV should be in the same projection (since it comes from the same database). I am considering using the Affine Transformation plugin to rescale and transform. Is this the best solution?
Answer: Turns out APIC .asc exports its XY coordinates in centimeters. All I had to do was divide by 100 to get to meters again. This is why the CSV points didn't line up with the DXF (all coordinates were inflated, thus making the scale and location incorrect). Now that coordinates are in correct units, the two files line up in QGIS as expected.
Comment: This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
Comment: i ended up finding my own solution/mistake. I believe this is the answer to my question, as I fixed the problem as described.
Comment: Believe it or not, you ended up applying an affine transformation (scaling both axes) :)


£40k-£60k basic salary + double OTE, car allowance

Question: What is the meaning of "£40k-£60k basic salary + double OTE, car allowance". Is it mean Salary plus bonus or commission in total between £40k to £60k. Or Basic salary is £40k to £60k plus added bonus on top.In addition to it Car Allowance will be given separately.
Comment: Why don't you call and ask the HR personal. They might give you a definitive answer
Answer: I don't know it from personal experience but a quick research tells me this:
It basically means salary + bonus based on how well you do + car allowance.

OTE stands for on target earnings. These are sales related incomes where you are paid according to the number of sales you make and meeting certain (often quite optimistic) targets.

Similarly, the double keyword indicates the threshold of the bonus, i.e. 2 x your basic salary, that you can possibly get with time and performance. In this case £80k-£180k.

I have worked in IT&T sales for the last 20 years. In my experience, the OTE is usually double the basic salary.

You should be concerned on how you achieve it though and it probably varies:

You should expect to reach OTE within 3 months (except where long sale cycles are expected). If you don't, there is obviously an issue with company expectations or your suitability for the role.

Meaning that you should probably reach the lower boundary pretty soon unless there's something wrong with the company policies or your performance.
Sources: Wordreference & Yahoo Answer.
Comment: +1 Salary + bonus = bonus is in addition to salary. Otherwise, it would be salary including bonus (which I would run away from because you don't know what the guaranteed salary is).


I have an extra legroom seat- can I resell once on board

Question: Booked a Delta flight where husband and I are not sitting together.  I ended up with a preferred seat 26A on a MD-90 plane.  No seat in front of me- by window.  I would rather sit with husband.  Could I resell this seat once on board to someone closer to my husband.  Or is this in bad taste?
Comment: Think of it this way: *you're* the one who wants to switch seats. Why should the other person pay you anything? You don't *really* want money; you want to sit next to your wife. What seat you're in shouldn't really matter in this case, I think.
Comment: Not only is it in bad taste, it is likely **breach of contract** and you can and likely will be **kicked off the plane** for doing that, the same way you will be if you sell your frequent flyer miles or your seat on a flight you bought and can no longer fly. Call the airline and they'll show you the pertinent fine print.
Comment: Will you be accepting visa?
Comment: Anecdotally, it is in bad taste.  Kindly ask the other person if they would like your seat in exchange.
Comment: **Important missing information:** a) did you get adjacent seat assignments when you booked? b) did you book via the airline directly, or a third-party?  what do their TOS or CoC say? c) did you and your husband make separate bookings? via separate services? sounds like you did
Comment: Yes I booked separate. He had miles I did not.  Booked online thru Delta.  it is a full flight.   Not sure how I got a preferred seat was the only one left to pick from.  I think I will just wait till flight tomorrow and see what my options are then.
Comment: If you are sitting next to a beautiful person you could start a public auction.
Comment: I presume you would be less than thrilled if the person you are trying to extort for money comes back at you with "Sure I'll give you $20 for the extra leg room but I'll need $40 for my seat." Your want is probably far greater than their want and yes, the idea is in very bad taste.
Comment: Just ask politely "Hi, my husband and I got separated in our seating assignments, would you bee willing to switch with me? My seat has extra leg room." And the person might say "Sorry, I really don't feel comfortable sitting in an emergency exit seat due to medical reasons." So now person B overhears you guys and offers person A their seat so that you can have person A's seat and person B takes your seat.
Answer: The typical and widely expected scenario would be you offering your 'better' seat to the person sitting next to your husband as an enticement to switch.
You would essentially be paying them with the better seat.
Comment: And it doesn't even necessarily have to be a better seat. Plenty of people will agree to swap if they're travelling alone and you want to be with family even if your seat is no better than theirs.
Comment: @Johns-305: That depends. If a Preferred seat is categorized as such because of additional leg space, and if that leg space goes along with inability to store the cabin luggage under the seat in front (emergency exit row, or no seat in front (as indicated by the OP)), the so-called Preferred seat is rather a disadvantage than a premium in my view.
Comment: Yep, most people will do an even exchange.  But a Preferred seat is an obvious premium.
Comment: @DoktorJ: Having to put my stuff in the overhead bin (where i cannot access it without getting up, where it might get mixed with or buried under other passengers' belongings, and where I could easily forget it) is precisely the disadvantageous aspect I strive to avoid. I am referring to backpacks of a size that will just about fit underneath the seat in front and almost completely occupy that space.
Comment: @O.R.Mapper any time I've sat in such a preferred seat, there has always been an option to store the same amount of luggage; usually it's in the form of being able to put both your personal item and carryon in the overhead bins... though if your "personal item" is small enough (e.g. a reasonably-sized purse) they'll often just let you hold it in your lap.
Answer: This would, indeed, be in bad taste. I'm not sure there's a specific rule for the situation, but airlines generally frown upon soliciting their passengers, and they view seats as something they assign and do not guarantee, not property to be sold.
It is, however, not uncommon to offer to switch seats with someone in order to allow families to sit together, without any money changing hands. You could approach someone sitting by your husband and offer him your seat, explaining that it comes with extra legroom. He may take you up on the offer, but might have particular reasons to prefer his current seat (it might be next to his family).
There is an app called Seateroo that's intended to create an online marketplace for seat selling. I've never used it, find it pretty ridiculous, and would imagine that the odds of finding someone else who is sitting near your husband and wants to buy your seat on your particular flight is pretty darn low, but it does exist.
Answer: At many airlines, you can change your seat during the online check-in. Try this first to change your seat or to upgrade the seat of your husband if there is a free seat next to you.
Otherwise come early to the check-in and as the check-in agent if it is possible to swap the seat.


How to measure heavy water concentration?

Question: regular tap water contains small %   D2O , let say a distillation process remove small amount of H2O . how can one measure this change using tools available to average person.
Comment: Could you supply a source for the percentage of heavy water in ordinary tap water?
Comment: @DJohnM : https://en.wikipedia.org/wiki/Heavy_water
Comment: _tools available to [the] average person_?  This proably is available to the average person-who-has-the-cash.  http://www.perkinelmer.com/Catalog/Family/ID/Clarus%20600%20Gas%20ChromatographMass%20Spectrometer?gclid=CKe1osH8tccCFdIXHwodBqAKwQ
Comment: @jameslarge , how about light index , or adding a fish to the container?
Comment: I don't know about the refractive index of heavy water, but I seriously doubt that a fish will give you a useful _quantitative_ measure.  (That _is_ what you asked for---how can one _measure_ this change.)
Answer: Apart from $D_2O$ (heavy water), natural water also contains $HDO$ (semi-heavy water) and of course $H_2O$.
The physical properties of these substances do vary from one to another, as can be seen from this Wikipedia comparative table. For example, the melting point of $D_2O$ differs sufficiently from that of $HHO$ or $H_2O$ to be measurable by a hobbyist or amateur scientist.
The problem is that deuterium ($D$) has very low natural abundance: only 1 in 6420 hydrogen atoms is deuterium (in the world's oceans), according to Wikipedia.
At such low abundance of $D_2O$ and $HHO$ the influence of these substances on the bulk properties of tap water is beyond reasonable means of measurement by an "average person". And a single electrolysis has only a small effect on these low abundances.
The same is true on the effect such low abundances (and any small changes thereof) on biological systems, even though much higher concentrations of $D$ does have a strong negative effect on the metabolism of most animals (like fish).
Comment: HHO semi-heavy ?
Comment: perhaps DHO , or H-O-D
Comment: HDO of course, not HHO. A typo that's been corrected. Thank you for pointing it out.
Answer: In "ordinary" water, about 156 out of 1,000,000 hydrogen atoms are deuterium.
If you were to pick any instant in time, these atoms would be arranged in water molecules as follows:$$HHO---0.999688024$$ $$HDO---0.000311951$$ $$DDO---0.000000024$$
So only about 24 molecules of true heavy water exist in a billion molecules of ordinary water.
In addition, these hydrogen and deuterium atoms are rapidly exchanged in water.  If you were to watch a particular one of the tiny number of $D_2O$ molecules, (don't ask me how) you would see the D atoms swapped out (and possibly back in again)
very quickly.
I don't know any "kitchen-sink" method to detect the effect of removing a few of the super abundant H atoms...
Comment: @michael501 Tritium decays fairly quickly (12.3 years half life), so in nature, there's essentially no Tritium to speak of in oceans or tap water.   It's essentially a man made element, though stars might have tiny amounts of it, but the short half life keeps it from being present in nature.
Comment: how about tritium ?  is high concentration of DDO generates it ? or it naturally exists.


POW with Linear time to solve it?

Question: Any suggestions for A Proof-of-Work algorithm in literature so that the time required for solving it is linear with the puzzle difficulty ??
Comment: Could you not answer "yes" by taking any existing PoW algorithm with a time required for solving that is exponential with puzzle difficulty, and relabeling puzzle difficulty with $\text{difficulty}^\prime=\exp(\text{difficulty})$?
Comment: Instead of using eg leading zeroes you could also use "hash output must be smaller than x" which scales linearly in difficulty with $2^h-x$ with $h$ being the hash output size.
Comment: could you explain more,  or give me an example for a such a POW algorithm ?? to give you an example of problme I am working on:
 I am building an application that require the difficulty (the number of leading zeros) to be directly proptional in some way to the Time of solving the puzzle. For example if it takes to get d=0 , Time may be 10 second. But to get d=00 , time will be 20 seconds. I wanna a POW that is used as a time meter
Answer: I don't think an algorithm like that would exist. For PoW to facilitate a random slot leader for block generation, it has to be necessary that the PoW puzzle is really hard to solve by anyone and that no deterministic polynomial time algorithms exist which promise a solution to that puzzle, because if they would then I think that a person with a faster rig and a faster processor would solve the PoW puzzle the fastest and become the slot leader every time.
Since I have already stated that there shouldn't exist any deterministic algorithm to solve the puzzle in polynomial time, this means that the best that anyone contending for becoming the slot leader can do is to try the probabilistic approach and wish that their random nonce solves the puzzle faster than anyone else. It is just because of this randomized (probabilistic) nature of the solution to the puzzle that the very slot leader elected is random in nature.
If you know about complexity classes of P and NP, then you will realize that if PoW is linearly solvable then it lies in P, whereas it should lie in NP i.e. given an oracle which takes all the correct steps and makes all the correct choices (meaning that selects the random nonce correctly every time) every time, then the problem is polynomial time. This means that given a solution, you can verify that the nonce is correct in polynomial time but you cannot solve the puzzle in polynomial time.
Comment: But I if there is a way to know the time that is used to get an answer to the puzzle that is directly proportional to number of leading zeros in the Puzzle`s Solution.
Comment: The number of leading zeros will only tell you that how difficult the puzzle is i.e. how many of the random choices will succeed. The lesser the number of leading zeros the more the number of random nonces which will solve the puzzle and the easier it is to find the solution.
Comment: The number of leading zeros still don't give you a solution, it just tells how difficult will it be to find a solution.
Comment: Ok. I am building an application that require the difficulty (the number of leading zeros) to be directly proptional in some way to the Time of solving the puzzle. For example if it takes to get d=0 , Time may be 10 second. But to get d=00 , time will be 20 seconds. I wanna a POW that is used as a time meter

POW with Linear time to solve it?


Assign Custom permission to profile using Apex

Question: Are there any solutions that allow assigning Custom permission to Profiles using apex?
I know about the object SetupEntityAccess. But it is for linking Custom Permission and  Permission Set. But I want to avoid using the Permission Set
Comment: IMHO you really need to embrace Permission Sets and Permission Set Groups; Salesforce is on a journey to deprecate Profiles so the sooner you switch the sooner you get that transition out of the way, before you implement additional things like this that will make the transition harder for you.
Answer: I have a solution which will help you out.
Via Metadata Api using the library from FinancialForce, you can get it at - https://github.com/financialforcedev/apex-mdapi/tree/master/apex-mdapi/src/classes
All you need to do is copy the MetadataService class and save it into your org.
once done add the below method to your Apex class-
public class MetadataServiceExamples {

    public static void updateProfileCustomPermission()
    {
        MetadataService.MetadataPort service = createService();
        MetadataService.IReadResult readResult =
            service.readMetadata('Profile', new String[] { 'Gold Partner User' }); // profile name
        MetadataService.Metadata[] records = readResult.getRecords();
        MetadataService.Profile prfile =  new MetadataService.Profile();
        prfile.fullName = 'Gold Partner User';
        prfile.custom = false;
        MetadataService.ProfileCustomPermissions profileCustomPermission = new MetadataService.ProfileCustomPermissions();
        profileCustomPermission.name = 'StackExchange';// custom permission name
        profileCustomPermission.enabled = true;
        prfile.customPermissions  = new MetadataService.ProfileCustomPermissions[] {profileCustomPermission} ;
            List<MetadataService.SaveResult> results =
            service.updateMetadata(
                new MetadataService.Metadata[] { prfile });
        handleSaveResults(results[0]);

    }
    public static MetadataService.MetadataPort createService()
    {
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
        return service;
    }

    public static void handleSaveResults(MetadataService.SaveResult saveResult)
    {
        // Nothing to see?
        if(saveResult==null || saveResult.success)
            return;
        // Construct error message and throw an exception
        if(saveResult.errors!=null)
        {
            List<String> messages = new List<String>();
            messages.add(
                (saveResult.errors.size()==1 ? 'Error ' : 'Errors ') +
                'occured processing component ' + saveResult.fullName + '.');
            for(MetadataService.Error error : saveResult.errors)
                messages.add(
                    error.message + ' (' + error.statusCode + ').' +
                    ( error.fields!=null && error.fields.size()>0 ?
                     ' Fields ' + String.join(error.fields, ',') + '.' : '' ) );
            if(messages.size()>0)
                System.debug(' message '+messages);
            //throw new MetadataServiceExamplesException(String.join(messages, ' '));
        }
        if(!saveResult.success)
            System.debug(' failure ');
        //throw new MetadataServiceExamplesException('Request failed with no specified error.');
    }
}

Comment: Doesn't quite answer the question, though what you provided is valuable. Could you edit the answer to give a bit more info as to why you would take this approach, not just show the code?
Comment: What you can do is create a permission set which has the custom permissions that you want to give to a user.
And by following the above code you can just assign the permission set to the user which will give them the desired access.
Comment: Please edit the answer to provide these details.
Comment: @Vadym Please go through the updated answer.
Comment: Never just add the MetadataService class; make sure to also add the related unit tests to keep your code coverage up.
Answer: Hope you are doing well, using Apex you can assign permission set to any user.
Only we need that permission set 'Id' and the 'Id' of the User to be assigned.
/* Get the Id of the permission Set using Permission Set Name */
PermissionSetAssignment psa = [SELECT PermissionSetId, AssigneeId FROM
                               PermissionSetAssignment WHERE
                               PermissionSet.Name = 'permissionSetName'].Id;

/* Now you need to assign that permission set to the user, So first get the User using SOQL*/
List<PermissionSetAssignment> permissionSetList = new List<PermissionSetAssignment>();
for (User u : [SELECT Id, UserRole.Name,Profile.Name, IsActive FROM User WHERE  UserRole.Name LIKE '%UserRoleName%' AND Profile.Name Like '%UserProfileName%' AND IsActive = true])
{
    PermissionSetAssignment psa = new PermissionSetAssignment (PermissionSetId = psa , AssigneeId = u.Id);
    permissionSetList.add(psa);
}
try{
    upsert permissionSetList;
}catch(exception e){
    system.debug('exception caught' + e);
}

I hope you got you answer, if not feel free to ask.
Comment: This doesn't really answer the original question which stated they wanted to avoid permission sets. Additionally the existing answer already covers permission set assignments that are more aligned to the original question than this so I can't upvote what you have here.
Comment: You misunderstand me; the other answer already covers permission set usage (and I am aware of what can and cannot be done with custom permission assignment and Apex). I don't understand why you added this answer when the other answer already covers assigning a permission set (with the custom permission) to all users with a given profile.
Comment: Custom Permission cannot be assigned to the user directly. That could be done by means of assigning Permission Set to the user. Custom Permission should already be assigned to the Permission Set or assigning Custom Permission to the profile.

Assigning Custom Permission to a Profile or Permission Set can be done via salesforce UI, or via Metadata API.

Take a look at : https://help.salesforce.com/s/articleView?id=sf.perm_sets_custom_perms.htm&type=5  and https://help.salesforce.com/s/articleView?id=sf.perm_sets_custom_perms.htm&type=5
Comment: Thanks for your answers. But @PhilW is right. The original question was about how to avoid permission-set usage. We can do this manually. I mean edit Profile and add Custom Permission. I guess the solution via apex that I need doesn't exist


Downside deviation

Question: have any practitioners here worked with the downside deviation metric? I've looked a little into its concepts but wish to know its utility in practice (if any). Does it bring any value to risk measurement or allocation strategies?
Comment: I'm sure many have worked with it. It's utility depends on what you need to do. Yes, it can help with risk management.
Answer: To my knowledge, it's coherent risk measure, featured in Markowitz, 1959. And yes, it is used by practitioners, but as it seems to me - mostly for the purpose of performance evaluation.
Comment: I know that investment consultants use it as a tool to evaluate pension manager performance. But curious as to how portfolio managers or traders themselves might use it. Which Markowitz paper are you referring to?
Comment: they might use it instead of usual $\sigma$ in $R-\sigma$ space. I'm referring to Markowitz, H.M. (1959). Portfolio Selection: Efficient Diversification of Investments. New York: John Wiley & Sons. (reprinted by Yale University Press, 1970, ISBN 978-0-300-01372-6; 2nd ed. Basil Blackwell, 1991, ISBN 978-1-55786-108-5)

Downside deviation


Removing a Frame from a Vertical-Panel

Question: I need some help with removing a Frame from a VerticalPanel

I have a GWT Module in which I also used HISTORY.
I am using the MVP framework so I have initialized my mainPanel which
is a Vertical Panel of GWT.
I have added a Hyperlink to the main panel.
I have now added a Frame to that Panel.

After a few methods, I am trying to clear the Panel in order to reuse it.
When I call the clear method of the main panel, I see that the hyperlink stays the same, and that the Frame is now empty, but both are still showing on the screen.
Answer: You can call clear() on your VerticalPanel, or you can call removeFromParent() on these widgets.

Removing a Frame from a Vertical-Panel


Lead-Acid Battery: Standard Electrode Potential

Question: I'm making a lead-acid battery for an investigation. Since I only had sulfuric acid and lead electrodes, I decided to firstly run 2 lead electrodes through electrolysis in a sulfuric acid electrolyte. This would create the following half equations:
$$\ce{4H+ + 4e- -> 2H2}$$
$$\ce{Pb +2H2O->PbO2 +4H+ +4e-}$$
At this stage, I still need to perform some theoretical calculations of the required potential to run this electrolysis. Obviously, the standard reduction potential of the hydrogen ion is 0V. But I can't find the potential for the 2nd reaction. Could someone provide me with a source for it?
Answer: Your reactions are wrong.
$$\ce{Pb(s) + HSO^−_4(aq) -> PbSO4(s) + H+(aq) + 2e−}$$
$$\ce{PbO2(s) + HSO^−4(aq) + 3H+(aq) + 2e− -> PbSO_4(s) + 2H2O(l)}$$
Lead acid batteries are fairly reversible, hence their use as rechargable batteries. Anything that produces a gas, like in your reduction reaction, is unlikely to be reversible.
Answer: You can find the electrode potentials for a lot of reactions on Wikipedia:
https://en.wikipedia.org/wiki/Standard_electrode_potential_(data_page)
I also think your second reaction isn't entirely correct. Lead atoms don't react with water to create lead oxide. Instead it's lead and sulfate ions reacting with water to create lead oxide and sulfuric acid.


Why the electromagnetic wave transmits momentum in the direction of the movement?

Question: Ordinarily a transverse wave does not transmit momentum, as it is the case of the well-known sea wave phenomenon. But the electromagnetic radiation has both fields transversal to the movement of the wave. Anyway, the electromagnetic wave transmits momentum in the direction of the wave.
Comment: @lemon: EM waves carry momentum classically.
Comment: As can classical waves in a medium.
Answer: It's possible to prove that while the fields $E$ and $B$ oscillations are transverse to the direction of propagation of the e.m. wave, the momentum carried by the electromagnetic field moves along the direction of propagation of the field(in vacuum) since it is defined in units of area and time by the relation $$\vec{S}=\frac{\vec{E}\times\vec{B}}{\mu_0}$$ where $\vec{S}$ is the Poynting vector and the transferred momentum is $$\vec{P}=\frac{\vec{S}}{c}$$ that's a mathematical property of classical electrodynamics. Obviously a more precise explanation would require the concept of electromagnetic quanta, the photon which carries momentum $|p|=\frac{E=h\nu}{c }$ (from the special relativistic dispersion relation for massless particles $E=|p|c$) clearly along the direction of it's propagation and it's polarisation is transverse respect to it's direction of propagation since it is a massless particle.


How to get rid of mold on drywall

Question: This bedroom was converted from a garage attached to the house. There's some black mold where the bed used to be. What's the best way to get rid of it?
Answer: Wiping the the mold with some water-diluted bleach should eliminate the mold.  For good measure consider applying a mildew-resistant primer like "Kilz".
You will want to ensure the source of the moisture causing the problem has been fixed as well as check for mold behind the baseboard.  If you want to be extra thorough, cut out a small piece of the drywall and make sure there is not mold behind the wall surface you can see.

How to get rid of mold on drywall


What are good resources for how to play against the french as white?

Question: I have been looking all over the web for a good way to counter the french defense, but nothing really helps. If you have any suggestions please tell me.
Comment: Without further explanation, the answers can create be a catalog of various plausible lines against the French Defense. What kind of positions do you want to reach ? Have you considered getting a copy of one of the scores of opening books and dvd's on the French defense ?
Answer: The main problem you have playing against the French as white, particularly if you don't play it as black, is that there is just so much theory to learn. If you try and play either  the Tarrasch or the Winawer you don't know if you are going to get a wild tactical game or end up in a tame, boring Rubinstein. Your opponent makes the choice. Even if your opponent declines to play 3 ... de there are still many ways for black to play and they are ways where one small error can lead to an instant lost game.
Your best bet then is to either play the Advance variation with 3. e5 or the more boring Exchange variation with 3. ed. The Advance gives more scope for tactical play and the Exchange more scope for positional play, although you can still have sharp games in the Exchange. They just tend to have a longer fuse. Either one will leave you much less to learn than either the Tarrasch or Winawer with much less chance of a quick loss.
Whichever one you choose learn it thoroughly and stick with it.
Comment: Why did this answer get a downvote? It seems perfectly fine to me.
Comment: @Brandon_J I have a stalker who goes round gratuitously voting down my answers. It makes him feel better for a short period but doesn't provide the long term cure that proper professional psychological help would provide.
Comment: Huh. Doesn't a StackExchange algorithm detect that sort of thing?
Answer: The latest I am aware of is: "Grandmaster Repertoire: 1.e4 vs The French, Caro-Kann and Philidor"
by Parimarjan Negi
As with any opening, ultimately you would like to have 3 ways to play: 1. A non-theoretical line; 2. A must win line - might be highly theoretical; 3. A safe "draw or win" line.
And of course it comes down to playing positions you are comfortable with.
Most opening books are from the Black perspective but there are a ton of books on beating the French which suggests you are not the only one who finds it pesky.
Personally, I tried everything against the French, including creating a novelty line against it; and all the lines are good!  You just have to accept that the French is a solid opening and play chess.
3.Nc3 is thought to be the best line but this book suggests 3.Nd2:
How to Beat the French Defence: The essential guide to the Tarrasch
by Andreas Dr Tzermiadianos
Kasimdzhanov has 3(!) DVDs on beating the French
Answer: I don't even bother with the theory as white since if they are playing the french they probably know all the main lines. I even play the French as black.
I play exchange variation with castle queen side. That is most likely to get them out of book if they are not a strong player, and still leads to a sharp position.


Dimension of solution space has 3 vectors but 6 components?

Question: I am not understanding how this has dimension $3$, but there are six components in each vector.  If $3$ vectors span the space, why are there more than $3$ components in each vector?  I thought for a set to be a basis there should be $n$ vectors and $n$ components in the vectors so that we may express the set as a square matrix.
Answer: The space does have 6 dimensions as you pointed out.  The points that are solutions in that space, however, only make up a 3 dimensional subspace.
Using some smaller space examples we could look at the line y=x in 2-dimensions and note that the solution space is only 1 dimension (the solution is a 1 dimensional shape (a line) in a 2 dimensional world).
Or if we look at a plane z=x+y it'll be a 2-dimensional shape/solution in a 3-dimensional world.
Comment: So, its basically like a 3 dimensional object expressed in a 6 dimensional world? Like a sphere is a 2 manifold but it is expressed in a 3 dimensional world.


Disallow `rm` to remove `*`

Question: Note: If you googled this by the title of this question, don't use this script unless you know what it is supposed to do.
This is a script in bash 3+ that I have used for long for preventing rm * and rm -rf * from accidentally invoked and removing important files by mistake. I put it in my ~/.bash_aliases.
alias rm='set -f;rm'
rm(){
    if [[ "$-" == *i* ]]
    then
        if [ "$1" = "*" ] || [ "$2" = "*" ] || [ "$1" = "./*" ] || [ "$2" = "./*" ]
        then
            echo "Abort: refusing to remove *, please go to the parent folder and do rm <folder_name>/*" 1>&2
            set +f
            return 1
        fi
    fi
    set +f
    /bin/rm -i $@
}

set +f

I would like to know whether there are any vulnerabilities and whether it can be improved.
Answer: The vulnerability I see is that only the first two arguments are checked.  You could check all of them:
rm() {
    [[ $- == *i* ]] && for arg
    do
        if [[ $arg = "*" || $arg = "./*" ]]
        then
            # abort
       fi
   done
   # do the rm

This kind of checking will miss other dangerous wildcards like ** or ?*.  You can get safer checking by expanding * yourself, then see if the expanded arguments contain that same list of files:
# alias not needed here; we want globs to be expanded
rm() {
    declare -a star=(*)
    declare -a dotslashstar=(./*)
    if [[ "$@" == *"${star[@]}"*  ||  "$@" == *"${dotslashstar[@]}"* ]]
    then
         # abort

... but then you can't (for example) empty a directory full of temp files with rm *.tmp, if *.tmp and * match the same thing.
Comment: I love your idea of expanding `*` myself.
Answer: Double-quote variables used in command parameters
This is a bug:

/bin/rm -i $@

What will happen if you try to delete file a b (with space in the name)?
Most likely this:

rm: a: No such file or directory
rm: b: No such file or directory

Always write "$@" instead of unquoted $@.
Unfortunately, as you pointed out in a comment,
this will cause another problem:
arguments containing globs will be taken literally.
In short, it's difficult to have the cake and eat it too.
You could mitigate the problem by looping over the arguments,
and if you detect a glob, then expand it yourself:
for arg; do
    if [[ $arg == *[*?]* ]]; then
        expanded=($arg)
        echo rm -i "${expanded[@]}"
    else
        echo rm -i "$arg"
    fi
done

This still won't be perfect, because it doesn't handle the case when an argument contains both spaces and globs. A robust solution would take more effort, and not worth doing in Bash. (See this example delegating the hard work to Python.)
Use command to bypass aliases
Don't worry about the absolute path of commands. Use command to bypass aliases:
command rm -i "$@"

Redundant file descriptors
In echo "Abort: ..." 1>&2, the file descriptor 1 is redundant, you can safely omit it.
Preserving the user's environment
This is a minor nitpick.
When the alias is executed, it will do set +f,
regardless of whatever was the original setting in the shell,
which may not be the same.
This is really just a minor nitpick, for the record.
I wouldn't care about this tiny impractical detail either.
Comment: I had an issue with patterns containing asterisk (e.g. `rm -f .*.swp`) and that's why I didn't quote `$@`. Your other advices are taken.
Comment: @WeijunZhou That's a good point. See my updated answer.
Answer: Don't call your function rm
If you start depending on this safety net, you'll eventually have an accident on a system with a standard rm (e.g. when you become root and find yourself using dash for admin tasks).
I'd suggest
weijun_rm() {
    # your safer implementation
}

rm() {
     echo "Disabled - please use weijun_rm instead" >&2
     return 1
}

This will train you not to use rm for deleting files.  When your function isn't available and you have to use the real rm, you will be on alert and extra careful to check the arguments.
Comment: I guess anyone can accidentally brush Enter when typing `rm *~` or `rm *.o` or the like (I normally write `echo`, and only type the `rm` when I'm happy with the rest).  But perhaps my advice might be useful for others who aren't so disciplined.
Comment: Thank you for your suggestion. This is just an extra protection. I don't depend on this and I know what I am doing in most cases. Just in case I didn't get enough sleep and do sth silly ...
Answer: Restore options properly
Instead of set -f in our alias and unconditional set +f in the function, we can save the current shell options using set +o to print them as commands:
fun() {
    restore=$(set +o)

    set -f
    # ... and any other option changes
    # and perform the task

    # finally (instead of set +f)
    eval "$restore"
}

Answer: This is the version I am using after taking the advance of above answers. Only the core if is written.
if [[ $- == *i* ]]
then
    set +f
    for arg in "$@"
    do # We want to abort the whole command even if only some of the arguments contain dangerous patterns
        if [[ "$arg" == "*" || "$arg" == "./*" ]] # Can be replaced by a custom program written in Python etc. to detect dangerous patterns
        then
            #abort
            return 1
        fi
    done
    declare -a all
    for arg in "$@"
    do #We need to collect all arguments instead of `rm`-ing one by one otherwise `rm -rf file` does not work properly
        if [[ "$arg" == *[*?]* ]]
        then
            expanded=($arg)
            all+=("${expanded[@]}")
        else
            all+=("$arg")
        fi
    done
    command rm -i "${all[@]}"
...

Disallow `rm` to remove `*`


How do you create a custom stream wrapper?

Question: I am trying to create a new custom stream wrapper. How can I do that?
Answer: This is something I have worked on more than a year ago https://gist.github.com/ivanjaros/fcf7ed50fbb98024464a29cfdcb01167
I have written Google Cloud Storage stream wrapper last week which is much better than this but it is a bit different use case(I think that gist is 95% accurate to what I have now). Anyway, you'll need to provide the S3 service to it on your own. I'd suggest to go over the code and maybe get inspired but I wouldn't use it as is.
Also see this issue: https://www.drupal.org/node/2830828


Programmically populate select list with hook_form_alter

Question: I have no trouble populating other fields, but am struggling with populating a select lists #options. Anyone know of a slick way of going about that or have any good reference material?
Answer: I'm not sure to understand what do you want but here is a sample of code I've that may answer to your question.
<code>$form['remise'] = array(
    '#type' => 'select',
     '#options' => array(
        0 => t('Sur les catégories & les marques'),
        1 => t('Sur les catégories uniquement'),
        2 => t('Sur les marques uniquement'),
     ),
    '#title' => t('Remises'),
    '#required' => TRUE,
    '#default_value' => 0,
  );</code>
Comment: That is close. Will be able to make it work. Thanks for your answer.


Time Machine backup drive doesn't have enough room to back up to

Question: My MacBook Pro has a 1 TB drive with 750 GB used. I keep receiving a message from Time Machine saying I don't have enough room to backup and to remove files. The Time Machine disk is 1 TB as well and I'm at a loss to see what to do.
Answer: Time Machine stores multiple versions of file which change over time so if the backup drive has the same size as the source drive this situation does happen after some time (it also may happen if the backup drive is bigger but much more seldomly). At this point you have two options

swap your backup drive for a bigger one and start a new backup on that
accept the fact that older versions of your backup will get deleted by Time Machine


Does 2 Timothy 2:13 mean that a once saved person cannot lose his salvation?

Question: Does 2 Timothy 2:13 (if we are faithless, he remains faithful) mean that we cannot throw away our salvation?

If we believe not, yet he abideth faithful: he cannot deny himself. [2 Timothy 2:13]
Comment: Welcome David Ayer. I'm surprised that this question hasn't been asked before, but apparently not!
Comment: Why not say which Bible you're citing, please?
Comment: Which different versions gave you 'if we are faithless, he remains faithful' and 'if we believe not, yet he abideth faithful: he cannot deny himself'… or do you suggest they mean exactly the same?
Answer: 2 Timothy 2:11-13 NASB

11 The statement is trustworthy:
For if we died with Him, we will also live with Him; 12 If we endure,
we will also reign with Him; If we deny Him, He will also deny us;
13 If we are faithless, He remains faithful, for He cannot deny
Himself.

One interpretation of this verse says that God is always faithful to His promises, even when we have doubts or have fallen from the faith. Even when we struggle with our faith, God is faithful to our salvation and will never abandon us.
On the other hand, others focus in on the human reaction to God's grace and how we must continue to have faith and persevere in our Christian life. God's faithfulness is eternal, but we still have the power to reject or walk away from our faith, which can have consequences for our salvation.
Let me quote from NeverThirsty because they look at each line:
First Line —  "For if we died with Him, we will also live with Him."

The first class
"if" in the first line means that anyone who believes in Christ has
died with Him. That is, when a person truly believes in Christ, their
old self dies. Romans 6:4-8 says when a person believes, their old
self dies. At the moment of saving faith, a believer is regenerated
and transformed. When that happens, our old self dies and we are given
spiritual life or new life. Consequently, we will live with Christ
forever. That is the meaning of the first line.

Second Line — "If we endure, we will also reign with Him."

The second line says that true believers will endure. The Greek word
for "endure" literally means to "remain under." That is, true
believers will continue in the faith even in difficult times.
Throughout the New Testament, we are told that true believers will
endure or persevere. One proof that a person is not a true believer is
that they abandon Christ. That is the message of the Parable of the
Sower of the Seed. 1 John 2:19 summarizes the message.
They went out from us, but they were not really of us; for if they had
been of us, they would have remained with us; but they went out, so
that it would be shown that they all are not of us. 1 John 2:19 (NASB)
Consequently, those who truly have saving faith and continue in the
faith are true believers. It is these individuals who will reign with
Christ during the millennial kingdom.

Endure:

Cognate: 5278 hypoménō – literally, remaining under (the load),
bearing up (enduring); for the believer, this uniquely happens by
God's power (cf. 1 Thes 3:5). See 5281 (hypomonē).

Third Line — "If we deny Him, He also will deny us."

The third line says that if a person denies Christ, then He will deny
them. This is not referring to a temporary denial of Christ. For even
the apostle Peter denied Jesus three times, He denied Jesus
temporarily. His denial was not serious or an ultimate one. Again, 1
John 2:19 reminds us that those who deny Him never had saving faith. 1
Corinthians 15:1-2 tells us that that there are two types of faith.
One is saving faith and the other is vain or empty faith.Vain faith
does not last or continue. Vain faith will not save a person from
hell.

Fourth Line — "If we are faithless, He remains faithful, for He cannot deny Himself."

The fourth line says that if a believer is faithless, Christ will
remain faithful. The apostle Peter is an example of a believer who was
temporarily faithless. 2 John 9 is a good summary of a faithless
person. A faithless person "goes too far" and stops abiding in the
teaching!
Anyone who goes too far and does not abide in the teaching of Christ,
does not have God; the one who abides in the teaching, he has both the
Father and the Son. 2 John 9 (NASB)
This is the person who has vain or empty faith (1 Corinthians 15:1-2).
But if the person, has real saving faith, that person will never "go
too far." They will never finally abandon the teaching of Christ.
1 John 2:1 states that Christ, Himself, will defend believers against
accusations of sin.
My little children, I am writing these things to you so that you may
not sin. And if anyone sins, we have an Advocate with the Father,
Jesus Christ the righteous. 1 John  2:1 (NASB)
That is the meaning of the last part of line four.

Conclusion

This wonderful statement would have been an encouragement and a
warning to the early Christians who were suffering persecution. We can
imagine that some real believers might have temporarily lapsed in
their commitment to Christ under Roman persecution. This statement
should have motivated believers to endure persecution and to be
faithful. True believers will succeed. They will do that, and Christ
will ensure that they will. Philippians 2:12-13 summarizes this point,
So then, my beloved, just as you have always obeyed, not as in my
presence only, but now much more in my absence, work out your
salvation with fear and trembling; for it is God who is at work in
you, both to will and to work for His good pleasure. Philippians
2:12-13 (NASB)
Believers strive to endure and God ensures that they endure.
Comment: What are you quoting the conclusion from, or is it a stray `>`?
Comment: @OrangeDog Same as the others: NeverThirsty.
Answer: Most commentators understand this verse as meaning that God is faithful to Himself and his promises. While He will forgive most post-baptismal sins by Christians, this does not mean it is impossible for a Christian to apostatize or otherwise throw away his salvation.
Ellicott

Those who have understood these words as containing soothing,
comforting voices for the sinner, for the faithless Christian who has
left his first love, are gravely mistaken. The passage is one of
distinct severity—may even be termed one of the sternest in the Book
of Life; for it tells how it is impossible even for the pitiful
Redeemer to forgive in the future life. "He cannot deny
Himself"—cannot treat the faithless as though he were faithful—cannot
act as though faithfulness and faithlessness were one and the same
thing.

Those who hold to the doctrine of eternal security on the other hand, see this verse as supporting the idea that once a person is truly saved, they will not lose their status among the elect.
Thomas Watson

When God calls a man, He does not repent of it. God does not, as many
friends do, love one day, and hate another; or as princes, who make
their subjects favorites, and afterwards throw them into prison. This
is the blessedness of a saint; his condition admits of no alteration.
God's call is founded upon His decree, and His decree is immutable.
Acts of grace cannot be reversed. God blots out His people's sins, but
not their names.
Answer: The answer to this question is found in the previous verse!!  The KJV's antiquated language is not helpful so let me quote from a modern literal translation of 2 Tim 2:12b, 13 -

if we deny Him, He will also deny us;
13 if we are faithless, He remains faithful, for He cannot deny Himself.

Let us observe two things about Paul's teaching in this passage:

it is possible to deny Jesus, even for the saved, and, if this happens, Jesus will deny us and thus we can lose our salvation
if we are faithless, Jesus is still faithful.  That is, the promises of God depend on God's faithfulness, not on ours.

The latter teaching is consistent with the consistent teaching in other places:

Rom 3:22 - And this righteousness from God comes through faithfulness of Jesus Christ to all who believe. There is no distinction,
Rom 3:26 - in the forbearance of God, for the showing forth of His righteousness in the present time, for Him to be just, and justifying the one of the faith of Jesus.
Gal 2:16 - nevertheless knowing that a man is not justified by works of law, except through faithfulness of Christ Jesus, even we have believed in Christ Jesus that we may be justified by faithfulness of Christ, and not by works of the Law, because by works of the Law not any flesh will be justified.
Gal 3:22 - But the Scripture imprisoned all things under sin, so that by faithfulness of Jesus Christ, the promise might be given to those believing.
Rev 14:12 - Here is the endurance of the saints, those keeping the commandments of God, and the faith of Jesus.
Answer: This passage in 2 Timothy does not speak to the question of whether 'salvation' can be 'lost'.  Paul is giving his protege Timothy encouragement and practical advice for his mission.  Verse 13 is the last part of what seems to be a quotation of an early creed statement.  It seems to plainly mean, even if we become discouraged from time to time, God remains faithful.
While the question is commonly asked today, whether a person who is 'saved' can ever 'lose their salvation', I have concluded that this topic is far removed from how believers in the Apostolic era viewed the concept of salvation, and certainly far removed from how Jesus himself taught, and therefore it is probably not even a fully valid question.
Usually, salvation is referred to in the New Testament as a future event, or at the very least as a continuing process.  Jesus himself tends to refer to salvation in the future, and in Matthew 24:13 seemingly in the literal, non-spiritual sense of being saved from mortal danger.  I do not read anywhere in the New Testament a definitive statement that salvation is a binary status that each person is somehow assigned - 'unsaved' from birth and 'saved' when someone confesses Jesus as Lord.  This thinking seems to have emerged in the Protestant era, as Roman Catholicism has a completely different doctrine on the topic.
One possible exception to the treatment of salvation as being in the future is Acts 2:47, "And the Lord added to the church daily such as should be saved."  Some translations have, "those who were being saved".  But even here the verb tense implies that the salvation of these individuals is not yet complete at that time.
When the rich man asked Jesus what he must do to receive eternal life (Matthew 19), note the critical element of Jesus' answer: "Follow me."  The focus of the conversation was around earthly possessions, and how the man was unwilling to give his up, but consider why this was so hard for him.  The rich man seems to have expected to secure eternal life in a single afternoon.  Perhaps he was thinking of a massive donation to the cause, or a gift to the poor, or some other good deed he could do.  But he was unprepared to make the lifetime commitment to give up his wealth and join the ragtag ranks of Jesus' disciples.
It seems best to consider salvation as being a destiny, a journey, and not as a binary status or a single event in one's life.
Answer: If someone could lose salvation, how would they ever regain it, when it was by having faith alone that one obtains it?
We are taught to compare spiritual things with spiritual when discerning God's scriptural truths.
1 Corinthians 2:12-13

Now we have received, not the spirit of the world, but the spirit which is of God; that we might know the things that are freely given to us of God.
13 Which things also we speak, not in the words which man's wisdom teacheth, but which the Holy Ghost teacheth; comparing spiritual things with spiritual.

Ephesians 2:8-9

For by grace are ye saved through faith; and that not of yourselves: it is the gift of God:
9 Not of works, lest any man should boast.

Ephesians 1:12-14

That we should be to the praise of his glory, who first trusted in Christ.
13 In whom ye also trusted, after that ye heard the word of truth, the gospel of your salvation: in whom also after that ye believed, ye were sealed with that holy Spirit of promise,
14 Which is the earnest of our inheritance until the redemption of the purchased possession, unto the praise of his glory.

Ephesians 4:30

And grieve not the holy Spirit of God, whereby ye are sealed unto the day of redemption.

Salvation is the free unmerited gift of God that is received only by having faith in Jesus Christ.  Realizing that God forgave us of our trespasses on the cross is how we find the strength to now live more righteously for Him.  Knowing that we will not be punished or lose our salvation when we falter confirms how much God loves us.  We now desire to work from our salvation for Him...not for salvation.
So yes,  2 Timothy 2:13 does mean that God will keep His promise of salvation "unto the day of redemption"!
Romans 8:35-39

Who shall separate us from the love of Christ? shall tribulation, or distress, or persecution, or famine, or nakedness, or peril, or sword?
36 As it is written, For thy sake we are killed all the day long; we are accounted as sheep for the slaughter.
37 Nay, in all these things we are more than conquerors through him that loved us.
38 For I am persuaded, that neither death, nor life, nor angels, nor principalities, nor powers, nor things present, nor things to come,
39 Nor height, nor depth, nor any other creature, shall be able to separate us from the love of God, which is in Christ Jesus our Lord.
Answer:
"Most assuredly, I say to you, he who hears My word and believes in
Him who sent Me has everlasting life, and shall not come into
judgment, but has passed from death into life." (John 5:24).

Note that belief results in the immediate granting of eternal life ('has' eternal life, not 'will have' eternal life) and 'has' passed from death into life, not 'will' pass from death into life.
If it can end, it's not eternal. God is not a liar nor is He the author of confusion. The granting of salvation is not based on what we do, but what Jesus did for us. If we did nothing to earn salvation, we can do nothing which will remove it.
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: It means even after Christ redeems us, living a life of sinless perfection isn't required to be saved.  Note the versus stating:

But the one who endures to the end will be saved
(Matt. 10:22, ESV)

It means God's covenant is irrevocable:

For the gifts and the calling of God are irrevocable.
(Rom. 11:29, ESV)

See R. C. Sproul on Gen. 15:17.
The statement, once saved always saved, is often misunderstood.  It is based on the reform theology of the perseverance of the saints.  It does not mean you need not persevere to be saved.  That contradicts scripture.
Answer: The verse means that God is faithful to himself and his promises, as others have stated. He cannot deny himself or his Word. Some take that to mean that a Christian cannot lose their salvation, because they think that elsewhere, this is what God has promised. Others, however, say that God has promised to cut off anyone who persists in turning away. So the very same statement (i.e. "God is faithful to his promises") reinforces either view that you obtain from other verses.

In Romans 11:20-22, Paul wrote, "That is true. They were broken off because of their unbelief, but you stand fast through faith. So do not become proud, but fear. For if God did not spare the natural branches, neither will he spare you. Note then the kindness and the severity of God: severity toward those who have fallen, but God's kindness to you, provided you continue in his kindness. Otherwise you too will be cut off." (ESV)

This is one of God's promises. The same possibility was there in the first covenant too.

In Ezekiel 33:13, God says, "Though I say to the righteous that he shall surely live, yet if he trusts in his righteousness and does injustice, none of his righteous deeds shall be remembered, but in his injustice that he has done he shall die." (ESV)

This seems to teach then that when God says someone will live, it is under the assumption that that person will continue in faithfulness, i.e. that the "promise" of life to that person won't come to fruition if that person later turns away (or in other words, that a declaration of "he will live" is conditional).
As another example of someone who was in the state of "life" and then lost it, remember the parable of the unmerciful servant in Matthew 18:21-35. After he was forgiven his debt, when he did not forgive his fellow servant, he was required to pay off the debt that was already forgiven him. Jesus concluded by saying,

Matthew 18:35, "So also my heavenly Father will do to every one of you, if you do not forgive your brother from your heart." (ESV)

See also John 15:1-14 and Hebrews 10:26-31.
This answer does not comprehensively address the fact that there are perhaps at least a dozen verses that some consider to teach unconditional eternal security of believers. I have not attempted here to give alternate explanations for those verses. The following is a list of some of those verses that some think teach the Calvinist doctrine of perseverance of the saints (that you cannot lose your salvation):

John 6:39
John 10:27-29
Romans 8:38-39
1 Corinthians 1:8
Ephesians 1:13,14
Philippians 1:6
1 Thessalonians 5:23-24
Hebrews 3:14
1 Peter 1:4
1 John 2:19
Jude 1 & Jude 24
Answer: On the contrary! Paul differentiates the Incarnate God who, unlike angels and men who are created and thus fallible, is immune from falling, for God cannot cease to be God. Thus, Lord Jesus Christ did not only not sin, but in principle could not sin, because His Person is the uncreated divine Person and exactly this Person adopted human body, human face to be henceforth eternally His and eternally a part and expression of His Personality.
Thus, He cannot fall, but we can, and after having fallen, surely we can address Him in an act of a repentance and rejoin Him, who never falls, anew. However, if we sin and do not address Him in repentance, He will be unable to re-embrace us, for our repentance is the only means for that, and we shall be deprived of eternal salvation. Thus, for Christians, who so often fall, there is always open the way to re-embrace the unfalling Christ through repentance.
Otherwise, Paul warns that we can lose salvation unless we are diligent to the point of fear and tremble (Philippians 2:12).


(Blender) (Python)How can I animate the factor value in the mix node with Python code?

Question: What I want is a way to handle the 'factor' value in the mixRGB node like a normal  object, like for example a cube, so with fcurves, fmodifiers and so on.
All this via Python code made in the Text Editor
Answer: The first step is to find the mix node you want. Within a material you can access each node by name, while the first mixRGB node is named 'Mix', following mix nodes will have a numerical extension added to the name. The name may also be changed manually by the user (or python script). By showing the properties region (press N) you can see the name of the active node in the node properties.

To adjust the fac value you alter the default_value of the fac input. To keyframe the mix factor you tell the fac input to insert a keyframe with a data_path of default_value
import bpy
cur_frame = bpy.context.scene.frame_current
mat_nodes = bpy.data.materials['Material'].node_tree.nodes
mix_factor = mat_nodes['Mix.002'].inputs['Fac']

mix_factor.default_value = 0.5
mix_factor.keyframe_insert('default_value', frame=cur_frame)

Of course you may specify any frame number for the keyframe not just the current frame.
If you have many mix nodes, you can loop over the nodes and add each mix shader to a list
mix_nodes = [n for n in mat_nodes if n.type == 'MIX_RGB']

You can then loop over them and keyframe as desired.
for m in mix_nodes:
    m.inputs['Fac'].default_value = 0.5
    m.inputs['Fac'].keyframe_insert('default_value', frame=cur_frame)

Finding the fcurves after adding them is awkward for nodes. While you tell the input socket to insert a keyframe, the fcurve is stored in the node_tree so after keyframe_insert() you would use
bpy.data.materials['Material'].node_tree.animation_data.action.fcurves.find()

Knowing the data path you want to search for can be tricky, as the data path for the Fac input of node Mix.002 will be nodes["Mix.002"].inputs[0].default_value
If you want to find an fcurve after adding it to adjust values or add modifiers you will most likely find it easier to keep a list of them as you add the keyframes. After keyframe_insert() the new fcurve should be at
material.node_tree.animation_data.action.fcurves[-1]

Comment: And if I want to insert noise modifier to the f-curves?
Comment: The fcurves for materials can be found at `fc = material.node_tree.animation_data.action.fcurves.find(...)` and then use `fc.modifiers.new()`
Comment: Ok, thanks, didn't noticed that you answered me, sorry
Comment: didn't work, when I try to add a noise modifier it give me an error. This is my code: `tree = bpy.context.scene.node_tree   fc =tree.animation_data.action.fcurves.find('default_value')`
Comment: `bpy.data.scene.node_tree` is the compositing nodes. You want `material.node_tree.animation_data.action.fcurves` - the find is awkward for node fcurves - I'll add it to the answer.
Comment: And if I want to do that with the compositing nodes, not the materials one?