Power profiles and TLP conflict

Question: I just tried installing TLP to see if it would make my laptop more efficient and it did not. I then removed it by running sudo apt remove smartmontools sudo apt remove tlp tlp-rdw sudo add-apt-repository --remove  ppa:linrunner/tlp sudo ppa-purge ppa:linrunner/tlp and finally sudo apt-get update.
So now, TLP is supposedly no longer on my system which is good, but I also no longer have access to my Power profiles (battery saver, normal, performance) which is quite inconvenient... They are not in the POWER section of the settings nor in the quick panel.
Would someone have an idea on how to fix this?
PS: This is my first post so sorry if the presentation does not follow the right standard.
Comment: Welocome to AskUbuntu, the presentation is fine ... `upower` is the key package providing that functionality ... So, re-install it with `sudo apt reinstall upower`  and see if that gets fixed ... As a side note, why did you remove [`smartmontools`](https://packages.ubuntu.com/jammy/smartmontools)? Did you think it's part of TLP?
Answer: If installing TLP from the Ubuntu release-specific official repositories, then removing it afterwords shouldn't result in what you describe ... However, installing it from a none-official unsupported source like you apparently did from ppa:linrunner/tlp is untested and unknown whether it can cause that or not.
Always, install packages from your release-specific official Ubuntu repositories to avoid any possible issues ... Which if you don't, then you are on your own and third-party PPAs are not trusted by nature and not officially supported either.
That said, energy features rely on the key package of upower and energy profiles are provided/managed by the package power-profiles-daemon ... Therefore you might want to re-install those first like so:
sudo apt reinstall upower power-profiles-daemon

... and there is a good chance that you'll see your energy profiles come back.

Power profiles and TLP conflict


Software Updater failing with Requires installation of untrusted package in new Ubuntu 16.04 install

Question: When I click on

First I see

fyi I am definitely online.
When I click OK however I get this:

When I click Install Now I get this:

When I click ok the window just closes.
If I click on settings I have to authenticate and then I see this:

How can I get Software Updater working ?
Comment: Please show `grep -P '^[ \t]*[^#[ \t]+' /etc/apt/sources.list /etc/apt/sources.list.d/*.list`
Answer: Run sudo apt-get update and then sudo apt-get upgrade. Accept that you want to install from untrusted repositories, if prompted
This causes, because you have at least one untrusted repo (not certified repository).
All repositories need a valid certification key, maybe at least one of your repos in the list has no valid certification key
A repository of an outdated certification key is e.g. VirtualBox
Answer: I was able to get around this by unchecking all the other sources.
I don't know which one was really the culprit.  I started by unchecking all the xenial stuiff and the cd rom but that didn't work so in the end I unchecked everything except for Canonical

This is not an ideal answer.  More of a brute force / hack and I might want some of those sources back so this may not be ideal - but might still be useful for others experiencing this.  Given recent security hacks in the news I wanted to be sure I could get basic software updates just in case.


Clip-Path vs Border-Radius issue when window is resized

Question: I want to use an SVG as a clip-path to round the edges of an image. Yes, I must do it in this way for various reasons .
PROBLEM:
When the browser window is resized, the points and handles that form the rounded corners adjust to the changing size of the image (bounding box) because I'm using clipPathUnits="ObjectBoundingBox". This causes the rounded edges to loose their "roundness" and look overall really bad. The CSS border-radius property doesn't have this issue. No matter how you resize the browser window, the edges of a div clipped with border-radius never loose their round shape. The problem is most apparent when you resize the browser window to it's most narrow or widest possible state. Try that with this codepen and you'll see what I mean. The top image uses border-radius and the bottom image uses clip-path. Is there any way to force the ONLY rounded edges of the SVG clip-path to stay equally rounded no matter how the image is resized without sacrificing the responsiveness of the clip-path dimensions? Is this even possible? I'm totally open to a JavaScript solution if there is one. Thanks!
Answer: You can trick the <svg> element to have just the same dimensions as the image and then size the clip-path with relative units. The downside is that you cannot reuse these paths but have to define one for every individual image.

.box {
  left: 5%;
  height: 40%;
  position: absolute;
  background-color: blue;
  overflow: hidden;
}
#box1 {
  top: 5%;
  width: 50%;
  clip-path: url(#clipPath1);
}
#box2 {
  top: 55%;
  width: 90%;
  clip-path: url(#clipPath2);
}

.flower{
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

svg {
  width: 100%;
  height: 100%;
  position: absolute;
}

    <svg>
        <clipPath id="clipPath1" clipPathUnits="userSpaceOnUse">
            <rect width="100%" height="100%" rx="20" ry="20"/>
      </clipPath>
    </svg>

    <svg>
        <clipPath id="clipPath2" clipPathUnits="userSpaceOnUse">
            <rect width="100%" height="100%" rx="20" ry="20"/>
      </clipPath>
    </svg>

Comment: Beautiful! Seems like its working. Never thought of that. Thanks!


I have created a mobile app with Adobe Air 3.2., but its not working on iOS 6 iPad

Question: I have created a mobile app with Adobe Air 3.2., but its not working on iOS 6 iPad,
Even i Cant Install On Ipad.
please let me know how can i resolve this issue
Comment: My first attempt to solve that issue would be to use AIR 3.4 instead.
Comment: What do you mean by "can't install"?
Comment: @ Al_Birdy

i am tired to create app with 3.4 but my app is still not install in my ios6 ipad its work nicely in iOS 5.1 ipad si please solve this issue

@32bitkid I mean i cant install .ipa file on ipad i get some error like "my app name failed to install."
Answer: I don't think 3.2 will be supported on iOS 6. You'll need to use at a minimum 3.3 though I believe there are some issues with it as well.
Best advice is to upgrade to the most recent release (AIR SDK here) and use that, which as at writing is 184.108.40.2060. There have been a lot of mobile improvements in the latest releases see here for a list.
Comment: i am tired to create app with 3.4 but my app is still not install in my ios6 ipad

its work nicely in iOS 5.1 ipad si please solve this issue
Comment: Have you tried a simple application with not much code in it? Try to determine if it's something with your code or with the process.
Comment: hello
ok thanks for the reply and for helping us .
we have solve the issue to make a new certificate and remove from the ipd ios 5.1 and 6.0 version certificate you have to remove and once again you have make the certificate and provisioning profile and you have make ipa and install once again.
AIR 3.4 SDK is work nicely in iOS 6.
its really work  Have enjoy
love you adobe :)


Calculating the probability that more of a fair coin tosses will result in heads than in tails.

Question:

My thought was the probability is: $\frac{5}{8} + \frac{6}{8} + \frac{7}{8} + 1$ and the sum is $\frac{13}{4}$ but this is not one of the choices. and the correct answer is E. I do not know why my thought is wrong and why the right answer is E, could anyone explain this for me please?
Comment: Note:  $\frac {13}4>1$ so it can't be a probability.
Comment: Hint:  as the coin is fair $P(H>T)=P(T>H)$.  You still need to compute $P(H=T)$ though.
Answer: Hint 1:
$$P(\text{more heads than tails}) + P(\text{more tails than heads}) + P(\text{same number of heads and tails}) = 1$$
Hint 2:
$$P(\text{more heads than tails}) = P(\text{more tails than heads})$$
Hint 3:
$$P(\text{same number of heads and tails}) = \binom{8}{4}\frac{1}{2^8}$$
(by the binomial distribution).

Alternatively, the answer can be computed as
$$P(\text{5 heads}) + P(\text{6 heads}) + P(\text{7 heads}) + P(\text{8 heads}) =\binom{8}{5} \frac{1}{2^8} + \binom{8}{6} \frac{1}{2^8} + \binom{8}{7} \frac{1}{2^8} + \binom{8}{8} \frac{1}{2^8}$$
Comment: why the problem considered as a binomial distribution ?
Comment: @Intuition Check the definition of the binomial distribution: it counts the number of successes (number of heads) in eight independent trials (coin flips)
Answer: Your reasoning is incorrect because of one thing: combinations (also, \frac{13}{4} is bigger than $1$ and certainly not a probability).
We need to count the number of ways each coin toss can happen. Recall that the number of ways to select $k$ objects from $n$ is $\binom{n}{k} = \frac{n!}{k!(n-k)!}$. This counts, in this case, the number of ways we can have, say, five heads in eight, is $\binom{8}{5} = 56.$ Calculations for six, seven, and eight heads in eight are done similarly.
So how do we finish this out? Easy,
$$ P(H > T) = \sum_{j=5}^8 \binom{8}{j} \left( \frac{1}{2} \right)^j \left( \frac{1}{2} \right)^{8-j} $$
But let's be a bit clever and instead say
$$ P(H > T) = \sum_{j=5}^8 \binom{8}{j} \left( \frac{1}{2} \right)^8 $$
Can you finish it from here?
Answer: There is a $\frac {70}{256}$ chance of getting exactly 4 heads.
It is equally likely to get more than 4 head as less than 4 heads.
$\frac {128-35}{256} = \frac {93}{256}$


Show that $(1,2]$ is neither open nor closed by arguing from the definitions.

Question: I know that you can use the sequence $(x_{n})_{n=1}^\infty$ , $x_n = 1 + \frac{1}{n}$. We have $x_n \in (1,2]$ for all $n \in \mathbb{N}$, and $$\lim_{n\to\infty} (1+\frac{1}{n}) = 1 + \lim_{n\to\infty} \frac{1}{n}=1.$$ Hence $1$ is an accumulation point of $(1,2]$, but $1 \notin (1,2].$ Hence $(1,2]$ is not closed.
However I don't know how to then prove that it not open either.
Any help would be much appreciated.
Comment: Your sequence $(x_n)$ is not in $(1,2]$. Replace your sequence by $x_n=1+\frac{1}{n}$, and it will work.
Comment: so this is now correct?
Comment: yes it's correct !
Comment: The interval isn't open because every neighborhood $(2-\epsilon,2+\epsilon)$ of $2$ contains a point outside of the interval (specifically, it contains $2+\frac12\epsilon > 2$).
Answer: For all $\varepsilon>0$, $(2-\varepsilon, 2+\varepsilon)\cap (1,2]^c \neq \emptyset$, so $2\in cl((1,2]^c) = (int(1,2])^c$, i.e. $2\notin$ the interior of $(1,2]$, so $(1,2]$ is not open
Edited: as pointed out by Arthur, we can just conclude after the first line: since $(1,2]$ does not contain any open ball centred at $2$, $2$ is not an interior point. There is no need for everything that followed from there
Comment: I agree with you on the first line (up to and including "$=\emptyset$"). However, if we're arguing from the definitions, then (depending on the OP's definition) we're basically done there. No need to fuss with the interiors and exteriors and complements. But that's just my opinion.
Comment: @Arthur what kind of definition allows us to conclude after the first line?
Comment: "A set is open if it contains an open $\epsilon$-ball around any point." Do you have another definition?
Comment: @Arthur indeed there isn't. I wonder how the hell did I miss that
Comment: so up to and including that point will be sufficient in my answer to this problem?
Comment: @ConnorDavies why are you so worried about your answer? Did you understand the idea? If you did you should be able to reproduce a proof on your own. There isn't a standard or algorithmic way to solve these kinds of problems
Answer: The definition of an open subset E of a metric space is that every point of E be an interior point of E, and the definition of an interior point of a set E is a point around which there exists a neighborhood completely contained in E. (A neighborhood is an open ball of some radius $\epsilon$ around a given point.)
Every neighborhood of 2 contains points greater than 2, and no point greater than 2 is contained in $(1, 2]$. Therefore, 2 is not an interior point of $(1, 2]$, though it is a point of $(1, 2]$. Therefore, $(1, 2]$ is not open.


Enter data to particular column in sql

Question: I have a text box that retrieve email from membership table in database. User may edit their email and update the new email. My question is, how to replace the old email with the new one? What is the query for sql?
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
    SqlCommand cmd = new SqlCommand("Insert into aspnet_membership("i dont know how whether to write all columns or only email);

    cmd.CommandType = CommandType.Text;
    cmd.Parameters.AddWithValue("@email", Textbox2.Text);

Comment: Your question should be..How do i Update records instead of entering Data according to your question's content...
Answer:
My question is, how to replace the old email with the new one?

You need an UPDATE in this case, instead of an INSERT:
   SqlCommand cmd = new SqlCommand("UPDATE aspnet_membership SET
          email = @email WHERE userID = @userID", conn);

Comment: how to get userID? Should make a session to hold user id?
Comment: Yes, that is the common solution for this, but don't you have already a solution to identify and keep some info about the logged in user or something?
Comment: I only make a session that hold username during login session. How to make id session since the aspnet_membership doesnt have a username colum
Answer: It will work like any other simple update SQL Query:
update TableName set Columname = @Value where Username = @Value

Comment: +1 , since you were the first one with update idea, you may put some effort in code formatting, see [How do I format my code blocks?](http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks)
Answer: you need to use update query and not insert query.
see syntax here:
http://www.w3schools.com/sql/sql_update.asp
Answer: check this link from MSDN http://msdn.microsoft.com/en-us/library/ms186862.aspx
SELECT REPLACE('abcdefghicde','cde','xxx');
GO
Answer: As you want to Update EmailID so your query should be
SqlCommand cmd = new SqlCommand("Update aspnet_membership set email=@email where  UserID=@UserID");

This should work for you, because your Insertquery which you are trying, this will always insert a new record instead of updating older records..
Answer: Try this:
You may need UserId, and new Email to replace existing email address for the given existing user.
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection"].ConnectionString);
SqlCommand cmd = new SqlCommand("UPDATE aspnet_membership SET email = @newEmail WHERE UserID = @userID");

cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@email", Textbox2.Text);
cmd.Parameters.AddWithValues("@UserId", YourUserId);

conn.open();
cmd.ExecuteNonQuery();
conn.close();

Comment: There may be many ways, it depends on your solution. If a user is editing his info, then he might be loggdin, then put users UserId into session at login logic. So while updating email you may have UserId in session. If administrator is changing the email then create a listing of users. By clicking on users name, it shows users edit form and store UserId in hidden field, so on submit it would be available.
Comment: when i make session for userid protected void LoginButton_Click(object sender, EventArgs e)
    {     Session["id"] = Login1.UserId;
    } it gives me error: does not contain a definition for userid
Comment: Use this: int UserId = (int)Session["id"]; And on above code change this cmd.Parameters.AddWithValues("@UserId", UserId); Note: I have guessed that UserId is in int.
Comment: Guid UserId = new Guid(Session["id"].ToString());

Enter data to particular column in sql


Some way to "pre-construct" query with Entity Framework 6

Question: I'm developing a database application using Entity Framework 6. In one place, I need to assemble a query based on user input and then return that query to the caller. I can't run the query myself and return the result set because the caller needs to store the query to run again later if the UI is refreshed. I also can't return an IQueryable representing the assembled query because this is only valid for the context against which it was assembled.
I've looked at using CompiledQuery.Compile but this doesn't work with the DbContext base class in Entity Framework 6. I need to do something like that, pre-compiling/pre-assembling/pre-constructing a query that can be returned and run again later, but that works with Entity Framework 6. I don't care whether the query is returned in the form of a delegate or whatever, I just need something that represents the query independently of any specific context instance.
How can I pre-construct and return a query with Entity Framework 6 such that it can be run multiple times against different context instances?
Comment: precompiling past EF4 works with executing the query once - then the query is computed and cached. I don't think there will be a context independent solution though - your context contains mapping information that makes query calculation possible.
Comment: **All** queries are cached by Entity-Framework per Application Domain.  It doesn't matter what dbcontext you have, how many... etc it doesn't matter it will be cached until the engine determines it shouldn't or your application domain ends.
Comment: I'm not looking to cache the query specifically. Really I'm looking for a way to construct a query and return it from a function, then later execute it against a specified context.
Comment: I'm not sure a query makes sense independant of a context. Do all the possible contexts share a common type? Then you can use a lambda return.
Comment: @NetMage They're all instances of the same context class. What I want is to return a query designed to run against `MyDatabaseContext`, then when I load the UI I say `using (MyDatabaseContext context = new MyDatabaseContext())` and load the content for the UI using the query, then later when the UI is refreshed I want to again say `using (MyDatabaseContext context = new MyDatabaseContext())` and load the updated content using the same query as before (I can't reconstruct the query again at refresh because the query is constructed by the dialog that's long gone and is opaque to the caller).
Answer: What I ended up doing was creating a delegate type to encapsulate the queries, that takes MyDatabaseContext as a parameter and returns a List<T> where T is the type of the particular entity that I'm querying for.
So now the function that creates the query can simply return a function and whenever the query needs to be run the query is simply called as a function passing it the context instance to act upon as a parameter. The function returns from the given context a list of entities as applicable for the query that it represents.


Shared functionality between engines/addons Ember

Question: I am creating multiple Ember engines (which are like mini-apps) that lie within parent app. Each engine can define its own services/controllers/routes. But when you go to the landing page of an engine, for eg., there might be an exact same API call that each engine makes.
This API call might be defined in a service hosting this call, residing in the engine.
some-service.js
import  ...

export default Service.extend({
  store: service(),

  getlandingPageInfo(query) {
    validateQuery(query);

    return this.get('store')
      .queryRecord(some-model, query);
  },
});

Now my other engine's landing page also needs the same call. But for this, I will have to copy all of some-model some-service, some-adapter and some-serializer into that engine. How can I re-use the methods in one service in some other service DRY?
Ember doesn't allow services to be imported between engines.
Comment: I'd write an addon that will be imported in all 'engines'
Answer: You can define your engine's engine.js which services to make available from your host app in your engine. See http://ember-engines.com/guide/services
Engine.js
const Eng = Engine.extend({
  modulePrefix,
  Resolver,
  dependencies: {
    services: [
      'store',
      'session',
      'ajax',
      'router'
    ],
    externalRoutes: ['dashboard']
  }
});

However, if you have ServiceX in Engine B, and want to share that service with Engine A, you'd need to create a separate addon (likely an in-repo addon in the host app) to share those services accross


mutate_at (or across) and ifelse statement

Question: Similar to this question, given tmpp:
library(data.table)
library(tidyverse)
tmpp <- data.table(
  "ID" = c(1,1,1,2,2),
  "Date" = c(1,2,3,1,2),
  "total_neg" = c(1,1,0,0,2),
  "total_pos" = c(4,5,2,4,5),
  "H1" = c(5,4,0,5,-5),
  "H2" = c(5,-10,5,5,-5),
  "H3" = c(-10,6,5,0,10)
)
tmpp
#    ID Date total_neg total_pos H1  H2  H3
# 1:  1    1         1         4  5   5 -10
# 2:  1    2         1         5  4 -10   6
# 3:  1    3         0         2  0   5   5
# 4:  2    1         0         4  5   5   0
# 5:  2    2         2         5 -5  -5  10

I want to replace all variables starting with H, with NA where total_neg == 1 :
#    ID Date total_neg total_pos H1  H2  H3
# 1:  1    1         1         4  NA NA NA
# 2:  1    2         1         5  NA NA NA
# 3:  1    3         0         2  0   5   5
# 4:  2    1         0         4  5   5   0
# 5:  2    2         2         5 -5  -5  10

Why don't these work?
tmpp %>%
  mutate_at(vars(matches("H")), ~ifelse( .$total_neg == 1, NA, .))

tmpp %>%
  mutate_at(vars(matches("H"),
            .funs = list(~ ifelse(.$total_neg == 1, NA, .))))
#im guessing the first dot in the ifelse statements above is referring to the H columns so I tried:
tmpp %>%
  mutate_at(vars(matches("H"),
                 .funs = list(~ ifelse(tmpp$total_neg == 1, NA, .))))

Happy to see across version too, thanks
Comment: For your first option, just remove the `.$`...so it will be `mutate_at(vars(matches("H")), ~ ifelse(total_neg == 1, NA, .))`. But since you are defining a `data.table`, why not use `data.table` methods throughout?
Answer: You don't need to use $ in dplyr pipe. In mutate_at/across it refers to column value. Try :
library(dplyr)
tmpp %>% mutate(across(starts_with('H'), ~replace(., total_neg == 1, NA)))

#   ID Date total_neg total_pos H1 H2 H3
#1:  1    1         1         4 NA NA NA
#2:  1    2         1         5 NA NA NA
#3:  1    3         0         2  0  5  5
#4:  2    1         0         4  5  5  0
#5:  2    2         2         5 -5 -5 10

Answer: A simple data.table solution that updates all the columns at once & in-place only for the subset
tmpp[total_neg == 1, grep("^H", names(tmpp)) := NA]
tmpp
#    ID Date total_neg total_pos H1 H2 H3
# 1:  1    1         1         4 NA NA NA
# 2:  1    2         1         5 NA NA NA
# 3:  1    3         0         2  0  5  5
# 4:  2    1         0         4  5  5  0
# 5:  2    2         2         5 -5 -5 10

Answer: Your guess is correct: inside the purrr-style anonymous function (after your ~), . refers to the function argument, which is a single column, not the data frame you piped in. The solution is to simplify by removing the .$.
tmpp %>%
  mutate_at(vars(matches("H")), ~ifelse(total_neg == 1, NA, .))
#    ID Date total_neg total_pos H1 H2 H3
# 1:  1    1         1         4 NA NA NA
# 2:  1    2         1         5 NA NA NA
# 3:  1    3         0         2  0  5  5
# 4:  2    1         0         4  5  5  0
# 5:  2    2         2         5 -5 -5 10

If you want to modify "all variables starting with H", I'd strongly suggest using starts_with("H") rather than matches("H").
Answer: Maybe you can use starts_with() inside across(). Here the code:
library(data.table)
library(tidyverse)
tmpp <- data.table(
  "ID" = c(1,1,1,2,2),
  "Date" = c(1,2,3,1,2),
  "total_neg" = c(1,1,0,0,2),
  "total_pos" = c(4,5,2,4,5),
  "H1" = c(5,4,0,5,-5),
  "H2" = c(5,-10,5,5,-5),
  "H3" = c(-10,6,5,0,10)
)
#Code
tmpp %>%
  mutate(across(starts_with('H'),~ifelse(total_neg==1,NA,.)))

Output:
   ID Date total_neg total_pos H1 H2 H3
1:  1    1         1         4 NA NA NA
2:  1    2         1         5 NA NA NA
3:  1    3         0         2  0  5  5
4:  2    1         0         4  5  5  0
5:  2    2         2         5 -5 -5 10


What is the difference between a node.js express route and a controller?

Question: Is there anything that is different or more powerful with a traditional controller over an express route?
If you have an express app and define models, does it become an MVC application, or is there more necessary?
I'm just wondering if I'm missing out on extra/easier functionality in my node express apps by not upgrading to a more legitimate 'controller'.  If there is such a thing.
Thanks!
Edit:  To clarify, if you use a route like so:
// routes/index.js
exports.module = function(req, res) {
  // Get info from models here,
  res.render('view', info: models);
}

What makes it any different from a controller?  Is a controller able to do more?
Answer: First of all a route in express is middleware as defined in connect. The difference between express and other frameworks is that middleware mostly sits in front of the controller and the controller ends the response. An other reason why express uses middleware is due to the nature of Node.js being asynchronous.
Lets see what a controller might look like in Javascript.
var Controller = function () { };

Controller.prototype.get = function (req, res) {

  find(req.param.id, function (product) {

    res.locals.product = product;

    find(res.session.user, function (user) {

      res.locals.user = user;
      res.render('product');

    });

  });

};

The first thing you probably notice about this get action is the nested callbacks. This is hard to test, hard to read and if you need to edit stuff you need to fiddle with your indentation. So lets fix this by using flow control and make it flat.
var Controller = function () { };

Controller.prototype.update = function (req, res) {

  var stack = [

    function (callback) {

      find(req.param.id, function (product) {
        res.locals.product = product;
        callback();
      });

    },

    function (callback) {

      find(res.session.user, function (user) {
        res.locals.user = user;
        callback();
      });

    }

  ];

  control_flow(stack, function (err, result) {
    res.render('product');
  });

}

In this example you can extract all the different functions of the stack and test them or even re-use them for different routes. You might have noticed that the control flow structure looks a lot like middleware. So lets replace the stack with middleware in our route.
app.get('/',

  function (req, res, next) {

    find(req.param.id, function (product) {
      res.locals.product = product;
      next();
    });

  },

  function (req, res, next) {

    find(res.session.user, function (user) {
      res.locals.user = user;
      next();
    });

  },

  function (req, res, next) {
    res.render('product');
  }

);

So while it might technically be possible to have controllers in express.js you would probably be forced to use flow control structures, which in the end is the same as middleware.


If carpet has been dry for years is moisture level OK on slab?

Question: Should I be concerned about moisture with installing an Engineered Wood flooring over a concrete slab (on-grade)? We have been living in the house for 10+ years with carpet flooring and I don't recall the carpet ever being moist (except for spills of course). However the room does feel a bit humid on a rainy Summer day. Should I be concerned about moisture affecting my installation?
This is the product I am considering installing: SolidPlus® engineered Flooring by Somerset Floors
Answer: The difference is that carpet breathes, and padding doesn't (as much), so you wouldn't have noticed moisture beneath the padding.
One good test is to securely tape down a sheet of plastic, say two feet square, and leave it for a few days. See how much vapor accumulates under it.
Comment: You can buy breathable padding now.  There is padding specifically designed for engineered that will probably be the norm in 10 years.  Even if you aren't install on slab if you have traditional padding and it doesn't breath , liquid from a spill from above can also take days to dry.   There is a lot of stuff out now, just not at big box yet.
Answer: You have to put something between the concrete and the engineered flooring.  Whether this is a thermal barrier or plywood depends on what type of engineered flooring you put in and how much moisture the floor has.
All concrete floors have moisture.  This might be next to nothing or a considerable amount, even in an unnoticeable way.  To make matters worse the engineered flooring you are getting might be pretty closed system or rather breathable it is really hard to tell.  Also with an on-grade install the moisture levels of the concrete can vary by season or year.  Heavy rains for a month might cause a slight issue after 5 years of no moisture at all.
I have two pieces of advice:

If putting engineered on an on-grade slab make sure the backing of the flooring is a real wood - in a hard plywood form.  No mdf/mush/particle-board type of back - period.  They will warp on you.  I mention this because most stuff that is a decent price at most local stores will be made out of crap backing (don't care if it has padding or not).  These products are only for the simplest of installs - on commercial type concrete or in a residential above grade.  An easy test is take samples and put them in a bucket of water for a few hours, let them dry and see how they look.   The other option is getting pure vinyl click lock which is getting pretty damn close to engineered in the way it looks.  You have to look pretty close to tell its not a wood product for the good ones - which can also mimic tile.
Follow the manufacturers instructions - call them if you need to.  Not the store's instructions, the manufacturer's.  If they tell you, you can install it directly on the floor but they suggest a 1/2" plywood - do the plywood.   I personally haven't heard of many manufacturers of engineered flooring that will OK direct concrete install that is on-grade but who knows.  Got to hit their website and call them.  20 mins of research can save you time and headache.
Comment: This is what I am thinking about installing, it is not cheap and they say it can be used below grade even. http://www.somersetfloors.com/pages/specialty.html#../images/collections/roomScenes/specialty/room_specialty_tumbleweed.jpg?v=1
Comment: I looked at some vinyl floors and according to this link http://www.americasfloorsource.com/12-things-you-need-to-know-before-buying-vinyl-flooring/  they only last 10 - 20 years. That is not long enough in my opinion.
Comment: The specs on that look really good.  You have 3/4" thick which to me is the perfect thickness for engineered (I buy only 5/8-3/4") and you have the 8 plies.  I am gathering from the 8 plies it is a pine or birch layered plywood.  I would be more than happy with what you have picked.


Conformal Killing vectors and Spheres

Question: Consider $S^n\cong SO(n+1)/SO(n)$. Thus we have an homogeneous space, whose isometry group is $SO(n+1)$. We have the round metric (the tensor preserved by the isometry group) and the generators of this group are the $\frac{n(n+1)}{2}$ Killing vector fields $v_{ij}$, antisymmetric in $i,j=1,\ldots,n+1$.
One can embed the sphere in $\mathbb{R}^{n+1}$ by spherical coordinates:
$$x_i = R y_i(\alpha_j)$$
The $y_i$ are functions of the angles $\alpha_j$ (they are products of sines and cosines) and they satisfy the relation $y_iy_i = 1$ (sum over repeated indices).
With these notations I can write explicitly the Killing vectors as follows,
$$v_{ij} = y_i k_j - y_j k_i$$
where $k_i$ are the Conformal Killing vectors, i.e.
$$\mathcal{L}_{k_i} g = - y_i g\, .$$
The question now is the following,
given the algebra of $\mathfrak{so}(n+1)$ satisfied by $v_{ij}$, is there any algebra for the Conformal Killing vectors?
Comment: Sounds like the title of a spy thriller...
Answer: The conformal Killing vectors on $S^n$ form the Lie algebra $\mathfrak{so}(n+1,1)$ of a Lorentzian orthogonal group. The best way to see this is to identify $S^n$ with the projectivized Light cone (i.e. the space of isotropic lines) in the Lorentzian vector space $\mathbb R^{(n+1,1)}$. If you realize this as points $(x,t)$ with $\langle (x,t),(y,s)\rangle=\sum_ix_iy_i-ts$, you see that $(x,t)$ is isotropic if and only if the Euclidean norm of $x$ equals $|t|$. Hence any isotropic line contains a unique point $(x,1)$ with $x\in S^n$.
Then the standard action of orthogonal group $O(n+1,1)$ on $\mathbb R^{(n+1,1)}$ maps isotropic lines to isotropic lines and thus descends to an action on $S^n$ which is easily seen to be by conformal isometries. Infinitesimally you get a Lie algebra of conformal Killing fields isomrophic to $\mathfrak{so}(n+1,1)$.
Comment: Thanks, however, I don't get one thing: the algebra $\mathfrak{so}(n+1,1)$ has dimension $(n+2)(n+1)/2$ however I only have $n+1$ conformal Killing vectors. How can they form such an algebra?
Comment: Sorry, probably I have not read the question carefully enough. I was just describing the algebra of all conformal Killing vector fields on $S^n$.

Conformal Killing vectors and Spheres


Creating and writing to a log file using morgan in express

Question: So I am trying to create a log file if it doesn't exist, and if it does exist then I want morgan to write the logs to it. Here is the code
  // Function to write a file in a non-existing directory
  function writeFile(path, contents, cb){
    mkdirp(getDirName(path), function(err){
      if (err) return cb(err);
      fs.writeFile(path, contents, cb);
    });
  }

  // Check if log file exists, if it does not, then create it
  fs.exists(__dirname + '/log/access.log', function(exists){
    if(exists){
      app.use(logger('common', {
        stream: fs.createWriteStream(__dirname + '/log/access.log', {flags: 'a'})
      }));
      console.log('access.log exists!');
    } else {
      writeFile(__dirname + '/log/access.log', {flag: 'wx'}, function(err){
        if (err) throw err;
        console.log('access.log created!');
      });
    }
  });

The first function creates the log directory and access.log file. The problem is when I hit a route it doesn't log anything to access.log. It was working before when the app.use call was not in fs.exists so I don't know if thats the problem or not, but when It's not in fs.exists it will error out due to the file not having been created yet.
Comment: fs.exists is asynchronous, it's likely that by the time it runs, the middleware is being added so far down the line that it isn't catching the requests before they are ended.
Comment: Additionally, if it doesn't exist it creates it, but never attaches the middleware.
Answer: Looks like you need to use fs.existsSync. The reason being that the app.use call is executing further down the event loop due to the asynchronous call to fs.exists. My guess is that by the time the fs.exists callback is invoked, your express app is already configured and has begun listening. Try this:
var fs = require('fs');
var path = require('path');
var logPath = path.join(__dirname, 'log', 'access.log');

if (fs.existsSync(logPath)) {
  app.use(logger('common', {
    stream: fs.createWriteStream(logPath, {flags:'a'});
  }));
  console.log('access.log exists!');
} else {
  fs.mkdirSync(path.dirname(logPath));
  fs.writeFileSync(logPath, {flags:'wx'});
  console.log('access.log created!');
}

Since this appears to be code that runs during application startup, making it synchronous shouldn't be very costly. I'm sure you could make the asynchronous setup work by restructuring how your express app and all it's middleware is constructed, but it won't save you much since these operations clearly need to happen in order before app.listen anyway.
Comment: I have created a logger using winston , morgan and daily rotate file. The problem is that if i save the code only the log folder and files are generated. if i try to hit the route the folder is not creating basically http req is taken care of morgan but eventhough i combined it it is not working any idea on this issue


How do I get a non-nil serverTrust value when creating a URLAuthenticationChallenge programmatically?

Question: I have public key pinning code in my Swift iOS application that works great.
I'm now working on building unit tests that will test the public key pinning code without the need for network connectivity / real live server.  I've got this almost working, but I can't figure out how to create a URLAuthenticationChallenge programmatically that has a non-nil serverTrust?  All the Apple documentation states that this should be non-nil if your authentication method is NSURLAuthenticationMethodServerTrust.  I'm using the p12 and cer files generated from my local machine to build the URLCredential in the example below.  No matter what I do, challenge.protectionSpace.serverTrust always comes back nil.
let protectionSpace = URLProtectionSpace(host: "mockSession",
                                                 port: 0,
                                                 protocol: "https",
                                                 realm: nil,
                      authenticationMethod: NSURLAuthenticationMethodServerTrust)

var urlCredential:URLCredential?
if let p12Data = try? Data(contentsOf: URL(fileURLWithPath: Bundle.init(for: type(of: self)).path(forResource: "cm7justindomnit", ofType: "p12") ?? "")),
    let cerData = try? Data(contentsOf: URL(fileURLWithPath: Bundle.init(for: type(of: self)).path(forResource: "cm7justindomnit", ofType: "cer") ?? "")){
    let options: NSDictionary = [kSecImportExportPassphrase:"password"]
    var items: CFArray?
    let _ = SecPKCS12Import(p12Data as CFData, options, &items)
    if let items = items {
        let objectsData = Data.init(from: CFArrayGetValueAtIndex(items, 0))
        let objects = objectsData.toArray(type: CFDictionary.self).first
        let secIdentityData = Data.init(from: CFDictionaryGetValue(objects, Unmanaged.passUnretained(kSecImportItemIdentity).toOpaque()))
        if let secIdentity = secIdentityData.toArray(type: SecIdentity.self).first {
            if let secCertifiate = SecCertificateCreateWithData(kCFAllocatorDefault, cerData as CFData) {
                urlCredential = URLCredential(identity: secIdentity, certificates: [secCertifiate], persistence: .forSession)
            }
        }
    }
}

let challenge = URLAuthenticationChallenge(protectionSpace: protectionSpace,
                                                   proposedCredential: urlCredential,
                                                   previousFailureCount: 0,
                                                   failureResponse: nil,
                                                   error: nil,
                                                   sender: self)

I have a Data extension to handle the UnsafeBufferPointers.
extension Data {

    init<T>(from value: T) {
        var value = value
        self.init(buffer: UnsafeBufferPointer(start: &value, count: 1))
    }

    func to<T>(type: T.Type) -> T {
        return self.withUnsafeBytes { $0.pointee }
    }

    func toArray<T>(type: T.Type) -> [T] {
        return self.withUnsafeBytes {
            [T](UnsafeBufferPointer(start: $0, count: self.count/MemoryLayout<T>.stride))
        }
    }
}

Answer: I realise that this is an older question but I ran into the same issue today while writing tests for my SSL pinning code. I solved it by subclassing URLProtectionSpace
private class TestURLProtectionSpace: URLProtectionSpace {
    var internalServerTrust: SecTrust?
    override var serverTrust: SecTrust? {
        return internalServerTrust
    }
}

let protectionSpace = TestURLProtectionSpace(
        host: "myhost.com",
        port: 443,
        protocol: "https",
        realm: nil,
        authenticationMethod: NSURLAuthenticationMethodServerTrust
)
protectionSpace.internalServerTrust = serverTrust

Comment: And how did you initialize `serverTrust`, `SecTrust` has no accessible initializer?
Answer: You can always move didReceive challenge-method away from the class you are testing and link it with some protocol communication. Then just call its methods when it is needed. For example:
protocol CheckerProtocol {
    // or event simplier
    func isOkCertificate(_ certificate: ) -> Bool
}

If you need to test some logic with certificate just pass it to your checker dependency directly:
if let serverTrust = challenge.protectionSpace.serverTrust {
    var secresult = SecTrustResultType(kSecTrustResultInvalid)
    let status = SecTrustEvaluate(serverTrust, &secresult)

    if status == errSecSuccess {
        if let certificate = SecTrustGetCertificateAtIndex(serverTrust, 0) {
            if self.checker.isOkCertificate(certificate) { ... }
        }
    }
}

Move checking code to
class Checker: CheckerProtocol { ... }

Meenwhile in your test target:
let certificate = // init right/wrong one
let checker = Checker()
XCTAssert[True|False](checker.isOkCertificate(certificate))

Comment: Thank you for your answer, but your suggestion still doesn't allow me to test the code doing the certificate extraction and comparison. That is what I'm I'm trying to test.  When I get to the lines where I call SecTrustEvaluate and SecTrustGetCertificateAtIndex (not shown as this is proprietary code) I need a non-nil serverTrust so I can examine the leaf certificates.  Thanks again though!
Comment: @JustinDomnitz updated. Look, you don't need to use only certificate to link two classes together, It's necessary to use protocols, so you can substitute it with mocks in your unit tests.
Comment: Thanks for the follow up.  I need to noodle on your answer for a bit to see if it will help me.  I'll make some more notes here once I've done so.  In the meantime, I've awarded you the bounty.  Thank you!
Comment: @JustinDomnitz did you ever get this resolved? I'm currently facing the same issue while writing tests for pubkey pinning.


Find the area of a particular pentagon associated to a given triangle

Question: Let $ABC$ be a triangle with base $AB$. Let $D$ be the midpoint of $AB$ and $P$ be the midpoint of $CD$.
Extend $AB$ in both direction. Assuming $A$ to be on the left of $B$, let $X$ be a point on $BA$ extended further left such that $XA = AD$. Similarly, let $Y$ be a point on $AB$ extended further right such that $BY = BD$. Let $PX$ cut $AC$ at $Q$ and $PY$ cut $BC$ at $R$.
Let the sides of $ABC$ be $AC = 13$, $BC = 14$, and $AB = 15$.
What is the area of the pentagon $PQABR$?
Comment: Any tries or ideas you have
Comment: Try to draw a incircle
Comment: @Archis Welankar area of triangle ABC=84.so area of triangle PAB=42.i want to find area PQA and PRB.
Comment: A picture would help...
Answer: Area $CPQ=PQD=a$
Area $XQA=AQD=b$
Area $CRP=PRD=c$
Area $RDB=BRY=d$
The reason being that each such pair of triangles has the same base length and height.
Triangle $ABC$ has area $\Delta=2a+b+d+2c$
Triangle $XPY$ also has area $\Delta$ since the base is doubled and the height is halved (compared to $ABC$).
Therefore we also have the equation $2b+a+c+2d=\Delta$
Adding these equations gives $$3(a+b+c+d)=2\Delta$$
Hence the required area of the pentagon is $a+b+c+d=\frac 23 \Delta$
It remains just to calculate the area $\Delta$ of the triangle $ABC$ using Heron's Formula, giving $\Delta=84$, so the final answer is $56$


RDLC Report with a List of Lists as its Datasource

Question: I have a list of objects whose members each have a list of objects. For example, given the following 2 classes:
Class Phone
 string AreaCode
 string Description
 string Number

Class Employee
 string FirstName
 string LastName
 List<Phone> Phones

I then have multiple Employees, each with multiple Phones:
List<Employee> Employees

I'm tasked with creating an RDLC report to list the data. The format would be similar to:
First  Name   Last Name   Phone.Description-1   Phone.Description-2  ...  Phone.Description-n
FirstName     LastName     Phone.Number-1           Phone.Number-2          ...  Phone.Number-n
FirstName     LastName     Phone.Number-1           Phone.Number-2          ...  Phone.Number-n
FirstName     LastName     Phone.Number-1           Phone.Number-2          ...  Phone.Number-n
I don't know how many Phones (in this example) are going to be returned from the database.
Note that the header above the Phone.Number columns are also from
List<Phone>

While these are from the database as well, they will be the same across all members of
List<Employee>.List<Phone>

(i.e. Employee1-Phone1, Employee2-Phone1, and Employee3-Phone1 will all have the same Phone1 header).
I can create an RDLC report using a
List<Employee>

as its datasource, but have been unable to find a way to then incorporate the
List<Employee>.List<Phone>

on the same row as its parent Employee.
Is this doable in an RDLC Matrix? Or is there an "auto-generate columns" type of functionality that can be utilized?
Thank you for any help/direction/suggestion you can provide.
Addendum:
I should mention that the DataSet returned from the database is exactly the format I need. However, as I don't know how many "Phone" columns will be returned, I don't have a definable schema, therefore, I cant create the report in the designer. By the same token, I can't set the datasource to the DataSet programatically, as there is no schema/grid defined on the report.
Comment: Is there a limit on number of phones one can have ? If not I would suggest you to include phones as rows instead & use hierarchy. Also can you elaborate more on your scenario ? Where is the report displayed ? Console application ? Web application ?
Comment: Thanks. I didn't include application type, I guess, because I didn't think it mattered. However, it's an MVC app replacing a console app. It uses the console app's stored procs. The data is returned exactly the way the console grid expects it. I don't know how many "phone" columns will be included for each "employee" (not a great example I know). So, you're suggesting a list of employees, each with a single phone number in its row (lots of duplicate employee data)? That can then be rolled up into a tablix with each row being unique employee data followed by an unknown number of phone columns?
Comment: Precisely. Only other options are weird ones - like generating rldc xml file/stream on the fly and add all columns you see in the dataset. See http://stackoverflow.com/questions/28898087/generate-columns-dynamically-in-rdlc for reference.
Comment: Thank you for the advice, I was able to make that work. If you want to throw up a proper Answer, I'll accept it. Thanks for your help.
Answer: Dynamic columns can be tricky - especially since you have no limit on how many phones can individual poses. There are ways around that - like generating/adjusting the rdlc xml file/stream on the fly by application serving the report. More such references can be found here Generate columns dynamically in RDLC
I would like to suggest instead to right-join employees with phone numbers and use hierarchy (tablix) with employee data being the "parent" and phone data being the "child".
Comment: Thanks again for your help


Automatically generate list of tor exit nodes

Question: I want to automatically generate a list of tor exit nodes that can reach a certain IP address. I scoured the internetfor a while and came across this piece of code from http://sjoerd-hemminga.com/blog/2012/10/block-tor-exit-nodes-using-iptables/
if [[ -z "$1" ]]; then
  echo Usage: $0 "<your host's ip>"
  exit 1
fi

hostip=$1

for i in $(wget https://check.torproject.org/cgi-bin/TorBulkExitList.py\?ip=$hostip -O- -q |\
    grep -E '^[[:digit:]]+(\.[[:digit:]]+){3}$'); do
  sudo iptables -A INPUT -s "$i" -j DROP
done

Can someone please help me understand this code better, because every time I try to run it, it produces errors.
Any alternate answers are welcomed but I would like if they are in Python.
Answer: import os
import re
import sys
import urllib

if len(sys.argv) != 2:
    print "Usage {} <your host's ip>".format(sys.argv[0])
    sys.exit(1)

hostip = sys.argv[1]

u = urllib.urlopen('https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=' + hostip)
for ip in u:
    ip = ip.strip()
    if re.match('\d+(\.\d+){3}$', ip):
        #print ip
        os.system('sudo iptables -A INPUT -s "{}" -j DROP'.format(ip))
u.close()

Answer: If you have configured Tor to have a control port and server descriptors...
ControlPort 9051
CookieAuthentication 1
UseMicrodescriptors 0

... then you can easily enumerate the exits using stem...
from stem.control import Controller

with Controller.from_port(port = 9051) as controller:
  controller.authenticate()

  for desc in controller.get_server_descriptors():
    if desc.exit_policy.is_exiting_allowed():
      print desc.address

That said, if your real question is 'how do I do something using every Tor exit' then please don't! Repeatedly making circuits is harmful to the Tor network, for more about about this see stem's FAQ.
Answer: Here(https://github.com/RD17/DeTor) is a simple REST API to determine whether a request was made from TOR network or not.
The request is:
curl -X GET http://detor.ambar.cloud/.
The response is

{
  "sourceIp": "126.96.36.199",
  "destIp": "126.96.36.199",
  "destPort": "8080",
  "found": true
}


Problem framer motion component in NEXTJS

Question: I am using NEXTJS and SanityIO. I am getting this error when adding this Framer motion component? "TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component"  or it just fails to refresh.
My code causing the problem is below and below the code is a picture of my folder layout. If it is helpful to know, the Header component  works if I just render an h1 alone. Any help or feedback is greatly appreciated.

    import React from 'react'
    import { SocialIcon } from 'react-social-icons';
    import {motion} from "framer-motion";

     type Props = {}

        function Header({}: Props) {
      return (

            <motion.div
             initial={{
               x:-500,
              opacity:0,
            scale:0.5
           }}
            animate={{
            x:0,
            opacity: 1,
            scale: 1
         }}
         transition={{
            duration:1.5,
         }}
         className="flex flex-row items-center">
            {/*Social Icons*/}
            <SocialIcon
                url="https://www.youtube.com"
                fgColor="gray"
                bgColor="transparent"
            />
                 <SocialIcon
                url="https://www.youtube.com"
                fgColor="gray"
                bgColor="transparent"
            />
                 <SocialIcon
                url="https://www.youtube.com"
                fgColor="gray"
                bgColor="transparent"
            />
        </motion.div>

        <motion.div
         initial={{
            x: 500,
            opacity: 0,
            scale: 0.5,
         }}
         animate={{
            x:0,
            opacity:1,
            scale:1,
         }}
         transition={{duration:1.5}}

            className="flex flex-row items-center text-gray-300 cursor-pointer">
           <SocialIcon
                className="cursor-pointer"
                network="email"
                fgColor="gray"
                bgColor="transparent"
            />

 Get In Touch

           </motion.div>

     )
    }

    export default Header

Answer: I got the same problems when using Framer Motion. I think this problem is becoming from the new AppDir of Next.js 13. I read the beta documents here: https://beta.nextjs.org/docs/rendering/server-and-client-components
For fixing this issues, I added 'use client'; in the first line before import libraries.
Answer: As Phong and the error msg are saying, just adding the "use client" directive at the very top of the file will fix the issue.
By default, Next13 (React18) is introducing a server-side component, which means the component is rendered on the server and shipped to the client
and
the general rule of thumb is that if you are using third-party libraries or you are using hooks, or some interactivity ( e.g. onClick ) - you need to set this "use client" directive.
Basically, if it's possible to make a server component, I'd consider doing it over the client side because less code will be shipped to the client.


How can I create a keystore using an existing CSR file?


List four elements of each of these sets

Question:
I am currently having trouble understanding these sets.
I am on letter a and I worked out that k is an element of P, where p is composed of positive integers, such that "k-1 is a multiple of 7." No clue what to do with this part.
Comment: Is $\Bbb P$ the set of all prime numbers?
Comment: @RSerrao In the book it says that P is a set of positive integers.
Comment: $k-1=n \times 7$ i.e. $k=(n \times 7) +1$. Then calculate for $n=1,2,3,4$
Answer: $\mathbb{P}$ is weird notation for positive integers. (I would read it as the primes). Anyway, you just need to find four positive integers $k$ such that $k-1$ is a multiple of 7. This means $k$ is one more than a multiple of 7. 7 is a multiple of 7, so $k=8$ is in the set. Just think of a few other multiples of 7 and proceed accordingly.
Comment: So we are actually solving k??
Comment: @keving A multiple of 7 is any integer times 7. So 0,7,-7,14,-14, etc.
Comment: @keving The set consists of all positive integers that are one more than a multiple of 7. The set notation says that for k to be in the set, k-1 must be a multiple of 7. So you can write $k-1 = 7n$ for some integer $n$ so that $k = 7n+1.$ So you can get different numbers in the set by plugging different integers $n$ into the right-hand-side of is equation. (Provided it comes out to a positive number.)
Comment: Still a bit confused as to why k would equal 8 as it is not a multiple of 7..
Comment: @keving k does not equal a multiple of 7. k-1 equals a multiple of 7. So if k = 8, then k-1 =7. 7 is a multiple of 7.
Comment: So going off k=7n+1,{8, 15, 22, 29} ?
Comment: @keving Yes. That is right.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/51546/discussion-between-keving-and-spaceisdarkgreen).
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/51548/discussion-between-keving-and-spaceisdarkgreen).
Answer: Let us say that the set $A$ is as defined in a):
$$A = \{k \in \Bbb P | k-1\ \text{is a multiple of 7}\}$$
The part that is left of the vertical bar, $k \in \Bbb P$, reads: "elements that are in the set $A$ are the values $k$ that come from $\Bbb P$, the set of all positive numbers". The vertical bar can then be read as "such that". The part to the right of it reads "$k-1$ must be a multiple of $7$". Putting it all together, you have:
$$A = \{\text{set composed of all positive numbers $k$ such that $k-1$ happens to be a multiple of 7}\}$$
So for example, $2$ will not be in $A$ because even though $2$ is positive, $2-1 = 1$ is not a multiple of $7$. $8$ on the other hand will be there because $8$ is positive and $8-1 = 7$ is a multiple of $7$.
Answer: This is my answer:
a)
$\mathbb{P}$ is a notation used for positive integers (and a lot of times a notation for prime numbers), I would take it as prime numbers. So you need to find $4$ prine numbers $p_i,~i\in\mathbb{N},1\le i\le 4$ such that $7\mid(p_i+1)$ so you need to $7q+1,~q\in\mathbb{N}$ be a prime number.
Obviously if $q$ is odd then $7q+1$ is even then it is prime if $7q+1=2\Rightarrow7q=1$ and this is not possible because $q\in\mathbb{N}$.
So $q$ is even lets find $p_i$:
$q=2\Rightarrow7k+1=7\cdot2+1=15$ and it is not prime $(3\mid15)$.
$q=4\Rightarrow7k+1=7\cdot4+1=29$ and it is prime, so $p_1=29$.
$q=6\Rightarrow7k+1=7\cdot6+1=43$ and it is prime, so $p_2$=43.
$q=8\Rightarrow7k+1=7\cdot8+1=57$ and it is not prime $(3\mid57)$.
$q=10\Rightarrow7k+1=7\cdot10+1=71$ and it is not prime $(3\mid57)$.
$q=12\Rightarrow7k+1=7\cdot12+1=85$ and it is not prime $(5\mid85)$.
$q=14\Rightarrow7k+1=7\cdot14+1=99$ and it is not prime $(3\mid99)$.  $q=16\Rightarrow7k+1=7\cdot16+1=113$ and it is prime, so $p_3=113$.  $q=18\Rightarrow7k+1=7\cdot18+1=127$ and it is prime, so $p_4=127$.
Then this are your four elements: $k\in\{29,43,113,127\}$.
b)
$x\in\{$apple, strawberry, pear, peach$\}$
c)
$\displaystyle x\in\left\{1,\frac{1}{2},\frac{1}{3},\frac{1}{4}\right\}$
d)
$n\in\{-1,-2,-3,-4\}$
e)
Again $\mathbb{P}$, lets take $n\in\{2,3,5,7\}$.


Angular Leaflet custom marker icon

Question: I'm trying to override existing default marker icon with the custom one.
I've defined parameters in a variable:
var ratIcon = L.icon({
    iconUrl: 'http://andywoodruff.com/maptime-leaflet/rat.png',
    iconSize: [60,50]
});

and the icon is applied to the through the pointToLayer option, which specifies a function:
pointToLayer: function(feature,latlng){
  return L.marker(latlng,{icon: leafIcon});
}

but there are still default marker icons -> Plunker
What I'm doing wrong?
In the last example is what I want to show.
Comment: Please refer to the similar answer here:
https://stackoverflow.com/a/26831200/4292656
Comment: Thanks @KyrosKoh, it's similar answer, but unfortunately it still doesn't work :( [plunker](http://plnkr.co/edit/fKb0YuQZeqen3peDBbaI?p=preview)
Comment: You are defining `ratIcon`, but using `leafIcon`
Answer: Sorry that I can't help you much. I use AngularJS-Leaflet-Directive + Ionic Framework, here's my part of my sample code (for my 2 maps) for your reference:
var greenIcon;
var greenIcon2;

$scope.closeAddMarker = function()
  {
    $scope.modal.hide();
    $scope.clearFile();
    $scope.removeGreenIcon();
  }

  $scope.addMarker = function(locationEvent)
  {
    $scope.newLocation = new Location();
    $scope.newLocation.lat = locationEvent.leafletEvent.latlng.lat;
    $scope.newLocation.lng = locationEvent.leafletEvent.latlng.lng;

    var markerIcon = L.icon(
    {
      iconUrl: 'lib/leaflet/images/location-marker.png',
      shadowUrl: 'lib/leaflet/images/marker-shadow.png',
      iconSize:     [25, 41], // size of the icon
      shadowSize:   [41, 41] // size of the shadow
    });

    //check valid user

    if(localStorage.getItem("username"))
    {
      leafletData.getMap("map1").then(function(map1)
      {
        greenIcon = L.marker([Number($scope.newLocation.lat), Number($scope.newLocation.lng)], {icon: markerIcon}).addTo(map1);
      });

      leafletData.getMap("map2").then(function(map2)
      {
        greenIcon2 = L.marker([Number($scope.newLocation.lat), Number($scope.newLocation.lng)], {icon: markerIcon}).addTo(map2);
      });
    }

    $scope.modal.show();
  }

  $scope.removeGreenIcon = function()
  {
    leafletData.getMap("map1").then(function(map1)
    {
      if(greenIcon != null)
      {
        map1.removeLayer(greenIcon);
        greenIcon =null;
      }
    });

    leafletData.getMap("map2").then(function(map2)
    {
      if(greenIcon2 != null)
      {
        map2.removeLayer(greenIcon2);
        greenIcon2 =null;
      }
    });
  };

Angular Leaflet custom marker icon


Java: What does the following method do?

Question: public static void main(String[] args)
{
 String[] months = ("jan","Feb", "March", "April", .... , "Dec");
 System.out.println(months[Integer.parseInt(args[0]-1)]);
}

Why args[0]-1 ?
Comment: this is an outright off-topic, totally ignoring what Programmers is **[about]**. Why didn't you ask at Stack Overflow? http://meta.stackexchange.com/a/129632/165773
Comment: Thank u I did. But even Java tags don't exist there. Sorry for the trouble.
Comment: Have you run the code?  Looked at the `months[]` array in a debugger?
Comment: What is that language? It looks similar to, but not quite, Java.
Answer: You pass the month number (a number between 1 and 12) and print out the corresponding name. Since array indices start at zero you subtract 1 so that running the program with an argument of 1 will print "jan" and not "Feb".
And yes you do have a typo in the capitalization. And yes I suspect this needs moving to SO.
Answer: you need to pass args[0] - 1, assuming that you want "January" as result for 1.
even though logic states that January is the 1st element of the array, arrays in Java are 0-based, meaning the indexes go from 0 to numberOfElements-1
Answer: You are taking input for the month, 1-12 . But since arrays start at 0 so we have to minus 1 from the input otherwise if we enter 1 for Jan it will show Feb instead. Because in Array Jan is at 0. Hence args[0]-1
String[] months = ("jan","Feb", "March", "April", .... , "Dec"); //Create array of months

Integer.parseInt(args[0]-1) parses the input into integer (Since the input from console in java is always in string format , so it converts string numbers into int)
System.out.println(months[Integer.parseInt(args[0]-1)]);//prints out the month[] array value according to the index input, to the console.


Backup sump pump discharge too big

Question: After living in a house for a year, I noticed my backup sump pump discharge pipe is 1 1/2", but then changes to 2" before it goes outside.  It changes to 2" about 2/3 up the vertical section.  The pump runs OK when tested but I'm worried in case of a real emergency that it'll burn out quick.
Am I being paranoid?  Has anyone seen a battery backup pump with a 2" discharge?
Answer: I fail to see a problem here. Increasing the discharge pipe diameter does not increase the load on the pump. Unless you have a pump manual that specifically forbids this (which seems very unlikely) relax and stop worrying about it - or worry about the battery running out, which is far more likely to be a problem in any extended power outage.
If you have such an unlikely manual, replace the pipe that offends you/it.
Comment: Indeed. If anything the larger pipe diameter reduces the load on the pump by reducing the frictional losses in the pipe, and therefore reducing the backpressure.

Backup sump pump discharge too big


How to get tar and caulking off brick?

Question: What's the best method for removing dried tar and caulking from brick and getting the brick's surface flat again?
I have a rotary polisher and thought maybe a disc of some kind would work.
Comment: Are you sure you don't want to just paint that with a nice new coating? Or flash over it? Removal seems like (a) work, and (b) potentially damaging to the brick.
Comment: Sandblasting, maybe?
Comment: @keshlam That's not an option (legally) in my area.
Comment: Wire brush, then?
Comment: Do you know what was adhered there, and why? You might want to consider replacing it.
Comment: Unless your flashing work is incomplete, I'd be more worried about the interface between the chimney and shingles, as there are huge unsealed gaps there that will let a lot of water inside.
Answer: Get a chisel and scrape the bulk of the material off the bricks. then get a portable grinder to finish off the smoothing process. You can usually rent them at your home store if you don't have one. I doubt you will be able to safely mount a grinding disk to your rotary polisher.
Comment: Thanks @JACK. Any disc type in particular I should look for to out on the grinder?
Comment: @eclipsis A [Diamond Cup Grinding Disc](https://www.google.com/search?q=diamond+cup+grinding+disc) should do the job nicely.
Comment: Thanks @brhans!
Comment: I think I'd consider a flap wheel before using a diamond cup wheel.

How to get tar and caulking off brick?


Android SDK: Create image on touch

Question: I'm a bit stumped here, I'm trying to make it so an image (already in the drawable folder) gets created everytime you touch the screen and removed when the finger is lifted. I have the touch part coded already, overriding the onTouch method with a couple switch cases that handle each type of action (down, up, move, etc). But I can't for the life of me figure out how to make the image appear and then disappear with the coordinates (matrix?) of where the finger is.
Any help would be greatly appreciated!
Answer: You could use an object of the ImageView class to draw the image.
Get the co-ordinates of the touch event using the MotionEvent.getX(), MotionEvent.getY() or MotionEvent.getRawX(),  MotionEvent.getRawY() functions (use the appropriate one depending on the kind of layout you are using, linear/relative).  Use these co-ordinates as your ImageView object's left and top margins respectively.
Regrds,
Anirudh.
Comment: I would add that using a FrameLayout may be beneficial in this scenario.  get a reference to your layout view, and there should be a method on it similar to addView(), you could then call something like removeView() to remove the image when the touch is ended.
Comment: Thanks! This was basically what I did, I was just having a but of trouble making the imageview's overlap. I was using LinearLayout, that was my problem.

Android SDK: Create image on touch


How to track the number of changes from 'x' to 'o' in a cell that only contains the characters 'x' and 'o'?

Question: I am using a tally of 'x' and 'o' to track occurrences in a single cell.
In the sample cell A1 with value "xxxoxxo" I would like a formula (or two separate ones) that tells how many times the values changes from 'x' to 'o' and separately from 'o' to 'x'.
Above, it would output 2 changes from 'x' to 'o' and 1 change from 'o' to 'x'.
I've been trying to use LEN and SUBSTITUTE but can only get the amount of times each letter occurs, not the number of changes from one to the other. This is what I currently have:
For X: =LEN(A1)- LEN(SUBSTITUTE(A1,"x",""))
For O: =LEN(A1)- LEN(SUBSTITUTE(A1,"o",""))
Answer: try:
<code>=LEN(REGEXREPLACE(SUBSTITUTE(A1, "xo", "×"), "[xo]", ))
</code>
and:
<code>=LEN(REGEXREPLACE(SUBSTITUTE(A1, "ox", "×"), "[ox]", ))
</code>
Answer: You can use these formulas:
For counting changes from x to o we must count the number of occurrences of 'xo', so that we write this formula in col B1:
<code>=(LEN(A1)-LEN(SUBSTITUTE(A1;"xo";"")))/2
</code>
For counting changes from o to x in col C1:
<code>=(LEN(A1)-LEN(SUBSTITUTE(A1;"ox";"")))/2
</code>
According to your manner, this method finds the number of occurrences of xo to determine the change from x to o. The division by 2 is because of the length of string 'xo'.


How do I get Realtek RTL8723BE wireless card to work on 18.04?

Question: I have an HP Probook 455 G2 with a Realtek RTL8723BE wireless card. Restarting the network manager doesn't do anything. The Probook also has a hard button to toggle the wireless off and on. I've checked that as well. It doesn't do anything. When I check wireless from the tool tray icon no wireless access points show up.
This is a fix I've used before, which I found on Stack Exchange. Up until 18.04 I was able to follow the instructions in Stack Exchange's answer to this question here - How do I get a Realtek RTL8723BE wireless card to work?. That fix worked very well, but I'm being blocked on the newest LTS.
I cannot use these instructions with 18.04 because of apt-secure. Can you help me either get around apt-secure so I can add the repository or help me get the card to work in another way? This is what I get when I try to add the repository in Bionic Beaver:
.....
Err:28 http://ppa.launchpad.net/hanipouspilot/rtlwifi/ubuntu Xenial Release
  404  Not Found [IP: 18.104.22.168 80]
Err:29 http://ppa.launchpad.net/hanipouspilot/rtlwifi/ubuntu bionic Release
  404  Not Found [IP: 18.104.22.168 80]
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/hanipouspilot/rtlwifi/ubuntu Xenial Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://ppa.launchpad.net/hanipouspilot/rtlwifi/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Here is the information on my card:
lshw -C network
  *-network
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: enp1s0
       version: 10
       serial: (redacted)
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168g-3_0.0.1 04/23/13 ip=10.1.105.62 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:35 ioport:4000(size=256) memory:d5804000-d5804fff memory:d5800000-d5803fff
  *-network
       description: Wireless interface
       product: RTL8723BE PCIe Wireless Network Adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wlo1
       version: 00
       serial: (redacted)
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=rtl8723be driverversion=4.15.0-20-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:40 ioport:3000(size=256) memory:d4800000-d4803fff

Any advice you can give me would be appreciated.
Thank you,
Comment: I have same problem with my HP latop. I tried those step and i think the process is run as the description above. After i finisih the step then i restarted my laptop. The pop up show which indicate that the installation is crash. Do you have any idea what is going on? I have similar laptop specs. I used to change the antenna setting by give command in terminal below: sudo modprobe -rv rtl8723be
sudo modprobe -v rtl8723be ant_sel=1 It was successful in ubuntu 16.04. But those command doesnt work in my ubuntu 18.04.
I confused what is the real problem in ubuntu 18?
Is there any solution to solve
Answer: I was able to answer my own question. I should have taken more time to think through what the ppa was doing in the first place. Here are the steps:

Go to the the webpage:
https://launchpad.net/~hanipouspilot/+archive/ubuntu/rtlwifi/+packages
Expand the arrow to the left of the listed driver:
rtl8192eu-dkms - 22.214.171.124.11320.20140505~trusty1
Scroll down to the third driver listed under "Packages" named:
rtl8192eu-dkms_126.96.36.199.11320.20140505~trusty1_all.deb (1.0 MiB)
click on it to download it.
change directory in terminal so you are in the same folder as the downloaded deb file and add executable rights with chmod +x rtl8192eu-dkms_220.127.116.11.11320.20140505~trusty1_all.deb
Then run the command sudo dpkg -i rtl8192eu-dkms_220.127.116.11.11320.20140505~trusty1_all.deb (it will produce an error)
Next execute sudo apt --fix-broken install
Then run the command sudo dpkg --configure -a
Now rerun the command sudo dpkg -i rtl8192eu-dkms_126.96.36.199.11320.20140505~trusty1_all.deb this time will it will get a lot further. However it still produces an error.

Even though there were errors when I followed the above steps my card started working. I found my access point and joined it. It is working normally now. I hope this helps anyone having similar issues with the realtek cards.
Comment: Very mysterious as you have no rtl8192eu device. Weird.


How to prevent a new user from doing anything dangerous?

Question: I recently installed Ubuntu server on my server to try out the linux as a new user.  I followed a tutorial on how to set up the web server which said I need to chmod 777 the web server dir so that it can be written into.
Anyway, I created a new account for one dude to allow him to see some  files on the server which I placed in his home dir:
adduser francis

After creating the account I checked what access he has with
groups francis

It said "francis : francis", so not a problem I thought, the ubuntu hasn't included him in any groups by default, which makes sense, it created him with no extra permissions security-wise, so everything is fine and dandy.
A week later, in absolute and utter horror, I found out that even though he couldn't do things like SUDO or mess around in system directories, he had full access to almost everything else on the server. For example he had full read/write access to my web server files at /var/www (and thus passwords stored in php configs files etc) even though that directory is NOT in his home directory and I never added him into any groups which could access that directory, nor I granted him any special access to anything ever after doing the adduser.
Anyway, what is going on here? How do I kill his access to anything important?  He should not be able to access stuff like /media or /var/www. I thought that new users were by default prevented from doing anything dangerous or snooping where they shouldn't be.
So the sum it up, I only need to allow him access to directories which I manually specify + to directories which he needs to function properly (his home dir, vim, nano etc..)
Thank you
Comment: You're doing chmod 777 and asking why everyoone can read write there? read the man page for chmod
Comment: @Askerman - Nope, when you give 777, **everyone** can access **everything**, please give this a read: https://www.linux.com/learn/understanding-linux-file-permissions
Comment: Yeah, 777 is your problem, for multiple reasons.
Comment: We all make mistakes, especially when we're learning in an entirely new environment. This is a good one to learn from, it's definitely wise to shed your notions of how things work in Windows when using a Linux based OS. After reverting your permissions, you should notice that the user can't change anything that they shouldn't be able to. If you used `chmod` elsewhere, you may have other problems though.
Comment: FYI- I am upvoting this question because it's actually a good one for new people to find.  And this misconception is probably more common than we think.  This is also a good example of why you shouldn't just copy commands you find on the internet (even here) without knowing what they do.
Comment: @cat Some passwords, like the passwords to connect to SQL servers, have to be in plaintext because they have to be used.  That being said, your question of why they are stored ... in files anyone can read is a valid question.  I think it's answered by the chmod 777 issue
Comment: does this help?  http://askubuntu.com/questions/386928/default-permissions-for-var-www
Comment: Thanks (+1). It would be nice if the OP would update the question, otherwise much of this discussion including ***the answer is meaningless*** and of no help whatsoever to people finding this question in future. @Askerman - can you do that, please?
Comment: What permissions do you have on those directories? 755?
Comment: I followed some tutorial on how to set up the web server which said I need to chmod 777 the web server dir so that it can be written into
Comment: Also, why are passwords stored unhashed, in plaintext, in files anyone can read??
Comment: On my server you need sudo to write to var/www.I think you have serious permission issues on your setup.
Comment: @Askerman Please provide the link to this tutorial so we can attempt to fix it.
Comment: Yeah the first 7 is for the owner, the second 7 is for the owner's group, and the third 7 is for *everyone*.  And since 7=R+W+X, you gave *everyone* read, write, and execute permissions on that directory.
Comment: @Mawg It's in the (probably hidden by default) comments.
Comment: @dryman I know that, you know that, but someone new to doing this doesn't. I'm in no way defending what the OP did, but don't think it's constructive for people to come on and make negative comments about them, without attempting to contribute any knowledge or solution. Also aren't many members of botnets just compromised routers?
Comment: @Aaron - Exactly, which is why I suggested they read: https://www.linux.com/learn/understanding-linux-file-permissions
Comment: @dryman I know what you mean, I feel like having a server with ports open to the internet is actually a big responsibilty, and one I'd not try until fully informed. I agree that the proliferation of dodgy youtube tutorials is a bad thing. I have a feeling that they're talking about a bare metal home server though.
Comment: Not the webserver where the (linux variant of) exe files and stuff are, but rather  the /var/www where the web page files are stored
Comment: @edwinksl it wasn't on this website, it was a video youtube tutorial, i don't have the link anymore. I assumed that chmod wasn't a problem because I thought the usergroups work the same way i used them in windows: it doesn't matter if the file is 777 or not because it won't even let you access it in the first place if you aren't in the owner group
Comment: Hmm.  640 comes to mind
Comment: Has the question been editted? I see no mention in it of `chmod` or `777`
Comment: @Arronical the problem is not that he made a mistake but that he makes mistakes with a server in the internet. People keep wondering why there are bots everywhere DDOSing around like in the case of Krebs and the solution is because there are a ton of guys who try out stuff with Youtube tutorials from who knows who.
Comment: @Arronical You are right but it is simply frustrating. And no, not everybody who is new to this does not know this. When I was new to this I didn't think about renting a potential 100mbit capable server there for the taking though I could have. I still personally only have a little box at home available through VPN only. And yes most DDOS devices nowadays seem to be routers and network cameras and stuff but they at least don't have such fast connections and so much power like the ghostships idling around the internet. Not to talk about warez ircs and alle the other nasty stuff around.
Comment: @Arronical If this is the case and it is only a home server I admit I overreacted though it is still a bad idea to have it directly connected to the internet. I feel the same about the responsibility. As a developer a vroot server is of course tempting but since I can not guarantee the appropriate maintenance I refrain from doing so.
Comment: Coming here after so many comments, it wasn't obvious why everyone was talking about `chmod 777`.. I've upvoted @Askerman's comment for this reason, but maybe it should be part of the question.
Answer: This is as designed. And worse. chmod 777 means... "I'd like the owner, anyone in his group, and anyone at all to have read, write and execute permissions"
Which is pretty terrible.
And for a web server, 777 is not optimal. 755 (Owner has full permissions group and others have read + execute)  is a common default but from what you've said you want at least read-write, or read-write execute for the owner (the web server user), and maybe the group, and no permissions for the user. There's a more complete questions on what appropriate permissions levels are on serverfault but consider something like 640 or 740.
that said, you could also put the user in his own little world - setting up chroot to keep the user in his own space in the system. There's guides floating around for doing this - for example oli's excellent answer here which may be an option depending on your needs.
Comment: Minor point: "the owner, anyone in his group..." - the file owner doesn't necessarily have to belong to the file group.
Comment: The historic jargon for this situation is "**world** readable/writable".
Comment: Nice. I like that you referred to the canonical answer on servfault.
Answer: Essentially, it breaks down like this:
R = 4 (read)
W = 2 (write)
X = 1 (execute)

So, read permissions only would be 4, read and write would be 6, read and execute would be 5, and all (read, write, execute) is 7.  This is how you compute a permission octet value for an owner, owner's group, or everyone.
When applying those permissions with chmod to a file or directory location, the numbers computed above are applied like this, with an octet each for owner, group, and everyone:
     $ chmod _ _ _ <file or directory>
             | | |
owner--------  | |
owner's group--  |
everyone---------

So if I wanted to give myself and my group read, write and execute permissions to a folder that I owned, but I didn't want everyone to even be able to read it, I'd use:
$ chmod 770 myDirectory

For more information, check the man page for chmod:
$ man chmod

Comment: If you can't remember the bits to add together to make the right permissions in the right order, you can also use the arguably easier to read `chmod ugo+rwx <...>`.

The characters stand for **u**ser, **g**roup, **o**ther; **r**ead, **w**rite, e**x**ecute. You can use '-' to remove ( eg: `chmod go-wx <...>`).

Just note that this only adds or removes exactly what you type. `chmod ugo+rwx ; chmod u+rwx ` **does not** remove access for group/other.
Comment: @ReactiveRaven That's a great point.  But the OP was obviously confused about what `chmod 777` did, so that was where I directed my explanation.
Comment: @Zanna Good call!
Answer: As others have mentioned you should not have permissions set to 777
Here's a helpful reference sheet that i use.
+-----+---+--------------------------+
| rwx | 7 | Read, write and execute  |
| rw- | 6 | Read, write              |
| r-x | 5 | Read, and execute        |
| r-- | 4 | Read,                    |
| -wx | 3 | Write and execute        |
| -w- | 2 | Write                    |
| --x | 1 | Execute                  |
| --- | 0 | no permissions           |
+------------------------------------+
You can use the octal notation, where the three digits correspond to the user, then group, then other.
Perhaps this might help
+------------+------+-------+
| Permission | Octal| Field |
+------------+------+-------+
| rwx------  | 700  | User  |
| ---rwx---  | 070  | Group |
| ------rwx  | 007  | Other |
+------------+------+-------+

Comment: Nice!  This is a big help to people (like me) who are visual learners.
Answer: In order to share files with a person you gave a login to, you don't need to do anything in particular. On a default Debian installation, users have access to each others' home directories.
For instance,
$ ls -ld ~
drwxr-xr-x 65 zwets zwets 4096 Sep 29 12:06 /home/zwets

Permissions on my home directory are read (r) and access (x) for any user on my system.  Only I additionally have write (w) access.
Also, the default umask on Ubuntu is such that files and directories that users create are world readable by default. You could set the umask to 077 if you didn't want that.
What this means that in a default setup, if user you wants to share document ~/README.txt with me, then there's nothing you needs to do. I can simply view it:
$ who am i
zwets    pts/26       2016-09-29 08:05 (:pts/19:S.6)
$ ls -l ~you/README.txt
-rw-r--r-- 1 you you 24 Sep  8 11:23 /home/you/README.txt
$ cat ~you/README.txt
You's shared thoughts.

I can't edit or remove the file, but I can copy it to a location where I have write permission.  Then I own the copy:
$ echo "Adding my thoughts." >> ~you/README.txt
bash: /home/you/README.txt: Permission denied
$ rm ~you/README.txt
rm: remove write-protected regular file '/home/you/README.txt'? yeah!
rm: cannot remove '/home/you/README.txt': Permission denied
$ cp ~you/README.txt ~zwets
$ ls -l ~/README.txt
-rw-r--r-- 1 zwets zwets 24 Sep  29 14:09 /home/zwets/README.txt

There are good reasons why most of the system is world readable by default, as I've explained in another answer on AskUbuntu.  However, on a shared system it may make sense to make home directories inaccessible to non-owners:
$ chmod o-rwx ~
$ ls -l ~
drwxr-x--- 65 zwets zwets 4096 Sep 29 12:06 /home/zwets

... as many users apparently aren't aware of the default - QED ;-).  It would be wiser though to make users aware that file permissions don't protect secrets.
Answer: In Ubuntu, any user has superuser privilege who are added in the group 'sudo', Please check it to ensure that no other user are added in this group.
To secure your files and directory from other users you can set permission as suggested by Mr. Journeyman Geek in above answer.
You can also use special permissions to secure your files and directories from others.


can you play minecraft with your freinds on Xbox one slim when I'm on Xbox one?

Question: My friends on xbox one s and I'm on Xbox one and we don't know if we can play together, we have always wanted to play together, but he needed a Xbox, but he got a Xbox one s, so pls message if you can help.
Comment: They are the same consoles.  The Xbox One Slim is just a "face lifted" Xbox One.
Answer: Yes. As far as gaming is concerned an Xbox One and an Xbox One Slim are the same thing, just different releases of the same system. You will both need an internet connection, an Xbox Live account, and a copy of the game, but the fact that one is an original and the other is a slim will not stop you from playing together.


Is a formal language an algebraic structure?

Question: I am having trouble confirming whether or not a formal language is an abstract structure or algebraic structure.
As far as I am aware, a formal language is a set $W$ of well-formed formulae.  On Wikipedia it is written that:

A formal language is an abstract structure, but a natural language is not, because its rules of grammar and syntax are open to debate and interpretation.

But I believe I can show that $W$ is an algebraic structure (also see Wikipedia).

For a countable set $P$ of atomic propositions $\alpha,\beta,\gamma,\ldots$, I could let $P\subset W$ and let there exist a set $\{\neg,\land,\lor,\to,\leftrightarrow\}$ of $n$-ary operators where $n\in\mathbb N^+$ and $n<\infty$. Define:
$$\forall \alpha,\beta\in P,\quad \big(\{\alpha,\beta\}\subset W\big) \to \big(\{\neg\alpha, \alpha\land\beta,\alpha\lor\beta,\alpha\to\beta,\alpha\leftrightarrow\beta\}\subset W\big).$$ Now define a mapping $v:P\longrightarrow\{0,1\}$ such that its relation $R\subseteq P\times\{0,1\}$ obeys: $$\forall\alpha\in P\;\forall p\in \{0,1\}\;\forall q\in \{0,1\},\quad \big((\alpha,p)\in R\land (\alpha,q)\in R\big)\to (p=q).$$
Then we define an extension of $v$ to $v:W\longrightarrow \{0,1\}$ by inductively defining:
$\big(v(\alpha)=1\big)\leftrightarrow \big(v(\neg\alpha)=0\big)$,
$\big(v(\alpha\lor\beta)=1\big)\leftrightarrow \big(v(\alpha)=1\lor v(\beta)=1\big)$,
$\big(v(\alpha\land\beta)=1\big)\leftrightarrow \big(v(\alpha)=1\land v(\beta)=1\big)$,
$\big(v(\alpha\to\beta)=1\big)\leftrightarrow\big(v(\alpha)=0\lor v(\beta)=1\big)$,
$\big(v(\alpha\leftrightarrow \beta)=1\big)\leftrightarrow\big(v(\alpha)=1=v(\beta)\lor v(\alpha)=0=v(\beta)\big)$.
Therefore: there exists a nonempty set $W$, there exists a collection of operators on $W$ with finite arity, and there exists a finite set of identities that the operators satisfy.

By the conclusion above, shouldn't a formal language be defined as an algebraic structure? Or perhaps it is an example of a structure that is both algebraic and abstract.
Comment: None of the terms "formal language," "abstract structure" or "algebraic structure" is entirely precise (especially the second): different sources may use them in different ways. Broadly speaking, it is certainly true that many things called formal languages can fruitfully be construed as algebraic structures; see e.g. Blok/Pigozzi's book *Algebraizable logics*.
Comment: Compared to natural language (French, Swahili, etc.) a set of wffs is quite abstract.
Answer: Your language is definitely an algebraic gadget. It's context free, and any context free language can be viewed as a kind of "algebra".
This paper of Chomsky and Schützenberger (The Algebraic Theory of Context-Free Languages) is a nice (and readable) historically relevant view of the subject, and discusses a tight (and very interesting!) connection between formal languages and formal power series. This is analogous to the connection between a sequence of integers and its generating function, but there's actually something more overtly algebraic you can do. I'll summarize that here, but you can read more in any decent text on universal algebra.
We think of a grammar as telling us which words we can build from pre-existing words. For your example, we have a fairly simple grammar:

$x$ is a word for every variable/atomic proposition $x$
If $\varphi$ is a preexisting word, $\lnot \varphi$ is a word
If $\varphi$ and $\psi$ are preexisting words, then $\varphi \land \psi$, $\varphi \lor \psi$, $\varphi \to \psi$, etc. are words

Now, as you've expected, these form an algebra (indeed a free algebra) which is often called the "algebra of terms" because the elements of this algebra are terms :P.
Formally, we look at the set of all words generated by this grammar, which you're calling $W$. Then we can add operations for each constructor. So for us, there is a unary operation $\lnot : W \to W$, a binary operation $\land : W^2 \to W$, etc. (NB: for general context free grammars, some of our operators might only be partially defined. We can get around this by working with multi-sorted algebras), and while we could stop here, we almost certainly want to consider some of these words "equal". That is, we should probably think of $\varphi \land (\psi \land \theta)$ as the same as $(\varphi \land \psi) \land \theta$, even though they're technically different words. Similarly, we might want to identify the words
$\varphi \land (\psi \lor \theta)$ and $(\varphi \land \psi) \lor (\varphi \land \theta)$, since in applications these are usually equivalent formulas. So we can quotient our term algebra (that is, $W$) by the equivalence relation saying that these words are equivalent. It turns out that this is also a computable thing to do, if you're interested in such things, but I won't say more about that here.
Now, this particular algebraic structure (one with operators $\lnot$, $\land$, $\lor$, etc. satisfying some natural axioms) is very well studied. It's called a Heyting Algebra, and what we've built here is the free heyting algebra on our variables!
I won't say more here, but you should know that this is an extremely useful construction in mathematical logic.
If you have more general context free languages (where we possibly identify words) we again get very useful things, oftentimes "free" structures (free groups can be constructed in this way), and we actually formally describe programming languages in this way!
Lastly, one reason to care about free algebras/term algebras is because it's very easy to define functions out of them. We have this nice recursive definition, so if we have any other algebra of the same type, all we need to do is say what happens to the variables. You've actually partially rediscovered this yourself in your extension of $v$. Since our syntax is our intended semantics, if we have any heyting algebra $H$, any (set theoretic) function $v : \mathsf{Variables} \to H$ extends uniquely to a homomorphism of heyting algebras $v : W \to H$. Indeed, we recursively do exactly what you expect:

$v(x) = v(x)$
$v(\lnot \varphi) = \lnot v(\varphi)$
$v(\varphi \land \psi) = v(\varphi) \land v(\psi)$
etc.

I hope this helps ^_^
Comment: Oh, and [regular languages](https://en.wikipedia.org/wiki/Regular_language) are even more overtly algebraic. See, for instance, the idea of the [syntactic monoid](https://en.wikipedia.org/wiki/Syntactic_monoid), [kleene algebras](https://en.wikipedia.org/wiki/Kleene_algebra) and Conway's (excellent) book _Regular Algebra and Finite Machines_
Comment: Yes, that's much better. It seems to me that the question itself is an abuse of definition; nothing in it applies to *formal languages* as a whole. I don't know if OP is aware of that.
Comment: Thank you for your answer. I was a bit confused haha, but I trust that with your answer I can acquire a more meaningful understanding.
Comment: @JozefMikušinec a good search term would be [lindenbaum-tarski algebra](https://en.wikipedia.org/wiki/Lindenbaum%E2%80%93Tarski_algebra). This is the start of a subject called [algebraic logic](https://en.wikipedia.org/wiki/Algebraic_logic). Unfortunately I don't know of a reference that shows how to compute these objects... In general they're extremely complicated, and I'm not an expert. You should consider asking a question of your own (linking to this one) asking for more information. Others on the site know more than me, and will be in a better position to give you references ^_^
Comment: A [formal language](https://en.wikipedia.org/wiki/Formal_language#Definition) doesn't have to be context-free.
Comment: @rici -- I know that. However, the language brought up by the OP _is_ context free. I'll edit my answer to make it more clear that that's what I meant
Comment: @rici I was not aware of that, but I am now (and I took the time to look into it further).
Comment: @HallaSurvivor could you please give me a reference for these quotients of algebras and how to compute them? (Or at least relevant search words? Mine bring up basic school math :°) )
Answer:
But I believe I can show that $W$ is an algebraic structure

This does not make sense. $W$ is not defined as an algebraic structure (at least, not ordinarily; there is a rather clean definition of $W$ as the initial algebra of a certain functor, but this is not the sense in which you're using the term). It is possible to put an algebraic structure on $W$. Saying you can show it's an algebraic structure does not make any sense.

Define: $\forall \alpha, \beta \in P, (\{\alpha, \beta\} \subseteq W) \to (\{\alpha, \alpha \land \beta, \alpha \lor \beta, \alpha \to \beta, \alpha \leftrightarrow \beta\} \subseteq W)$

This is not a definition of anything, so I have no idea what this statement means.

Now define a mapping $v : P \to \{0, 1\}$ such that its relation $R \subseteq P \times \{0, 1\}$ obeys: $\forall \alpha \in P \forall p \in \{0, 1\} \forall q \in \{0, 1\}, ((\alpha, p) \in R \land (\alpha, q) \in R)) \to p = q$.

You did not define any particular mapping $v$. The condition that you are demanding $R$ satisfy is part of the definition of being a function, so I am confused as to why you included it here.
As for your definition of extending $v$ to $W$, this is the standard way of defining the semantics of the language. But the semantics of a given language are distinct from the syntax of the language. The language is defined by its syntax and is given meaning through its semantics. There can be more than one way of giving semantics to a given syntax.
Comment: By "define" I think I just meant "let" or "allow to be the case that". Also, when I claimed that "I can show $W$ is an algebraic structure", I said this with the intention of translating that: my goal was to construct an *algebraic system* that contains $W$. The algebraic structure more precisely is: $(W,\neg,\land,\lor,\to,\leftrightarrow,v)$.
Answer: When one creates a language, there are certain steps to be taken.
The first step is to provide an alphabet for the language, i.e. the set of the symbols that we are allowed to use in order to form words, in your case, the set of variables and operators.
Next, we need a grammar for the language, which we can think of as a way to distinguish words from nonsensical sequences of symbols. In your case, that corresponds to the (recursive) definition forming well formed formulae.
Next, and this step is implicit in your construction, is to provide a syntax, a way of forming sentences from words. You can read more about syntax, a good starting point is "natural deduction systems with double negation elimination".
Last, but definitely not least, is providing (semantics) "meaning" for our newly formed language. In your case, the algebraic structure you provide plays the role of semantics. It is called two-valued Boolean algebra.
Making the distinction between what is syntactical and what is semantics answers your question. The thing that is confusing you is that the language you have created appears to BE an algebraic structure. That is because this language is sound and complete. A sound language is one where everything syntactically correct has meaning. A complete language is one where everything that has meaning can be syntactically represented. So in a sound and complete language, meaning and syntax are two sides of the same coin, sort of.


Ubuntu and Windows 7 are installed in same Drive, is it safe?

Question: I installed, Ubuntu using windows installer in Windows 7 OS, will it create any problem, if I create partition of same drive.
Comment: No. Not if you do it right.
Comment: Not at all! Adding to @mikewhatever's comment, you can 'do it right' by following the prompts on the wubi.exe installer!
Comment: Windows 7 can shrink the `C:` drive http://technet.microsoft.com/en-us/magazine/gg309169.aspx Just make sure you don't switch to 'dynamic' volumes. Don't create new partitions in the space from Windows - if you want to create linux partitions, create them from linux.
Answer:
The Windows-based Ubuntu Installer (Wubi) allows you to install and uninstall Ubuntu from within Microsoft Windows. It lets a Microsoft Windows user try Ubuntu without risking any data loss due to disk formatting or partitioning.

Source: https://help.ubuntu.com/community/Wubi
No, it wont make any problems, and you are not really creating another partition.
Comment: Actually, I wanna create another partition(Drive), all 450GB is getting used for C: Drive. Please share your idea...
Answer: I have both Linux and and 2 installs of Windows 7 (in both 32 and 64-bit versions) installed on my desktop.
The 32-bit version of Windows 7 shares the same physical drive as Linux, but obviously on different partitions. The Windows 7 64-bit version is installed on another drive.
For linux I have 3 partitions:

A filesystem partition,
A swap partition, and
One for data.

I use a utility by diskinternals to manipulate Linux files from within Windows 7.
This setup is quite stable. However, earlier versions showed some problems.
Comment: An "it works for me" comment is not quite an answer in my opinion.