Linux HowTo: How to swap rows by just swapping the first cells?

Original Source Link

Say I have this table:

Occasionally I need to swap and add rows to reorganize my table. In this example, I put the row Cat at the bottom, and insert row Horse:

And then later decide to move row Mouse to the bottom again, and leave row 3 empty:

For convenience I just cut/copy/paste/move/insert the names only, and expect that the program understands that what I mean is to cut/copy/paste/move/insert the whole rows. Is there a way to make it understand that?

I can use any spreadsheet software.


Edit: I realize that I can select the whole row by pressing Shift + Space. This can be the answer for now. However, I’d like to leave this question open if anyone wants to go the hard way. This would benefit everyone.

Instead of cut/copy/paste/insert etc just the name, select the entire row by clicking on the numbered row header first, then do your action to move the entire row all day once.

Tagged : / /

Math Genius: Change in argument of sum of complex numbers along a closed path

Original Source Link

Let $a(t)$ and $b(t)$ be complex variables that travel along closed paths that end up at their original points, i.e. $a(0)=a(T)=a_0$ and $b(0)=b(T)=b_0$, with $Delta Arg(a) = Delta Arg(b) = 0$ over the paths. Is it possible for their sum $c(t) = a(t) + b(t)$ to have $Delta Arg(a) = 2pi k$ where $k$ is a non-zero integer? Any example? Also, let’s assume $a(t) neq 0, b(t) neq 0$, and $c(t) neq 0$ for any $0 leq t leq T$.

Tagged : /

Code Bug Fix: PGSQL – Change all columns of a specific datatype to text

Original Source Link

I’m trying to change all the USER-DEFINED columns to TEXT in a specific view using pgsql.
Is it possible to do that in a single alter table query ou do I need to check first what columns contain that dataype and then perform the dataype change one by one?

This is what I’m trying:

ALTER TABLE if exists "schemaName"."Table_A"
ALTER COLUMN (
select column_name 
from information_schema.columns inf
where table_name = 'Table_A' and inf.data_type = 'USER-DEFINED') 
TYPE TEXT;

I’m getting and error in the subquery start “(“

You need to do this one by one. Generally speaking such DDL statements cannot work on several objects in one statement.

For ALTER TABLE, see: https://www.postgresql.org/docs/12/sql-altertable.html.

FOR ALTER VIEW, see: https://www.postgresql.org/docs/current/sql-alterview.html

Tagged : / /

Making Game: Where is my Lock screen image file–

Original Source Link

  1. Apologies to the group. I got interrupted while I was working on the original, and decided to post it. On second look I see it was singularly uninformative. Original still quoted below:

  2. Here’s a more complete picture: I set the image as the lock screen image, in May 2013. In answer to one of the questions, at the time I saved it to my hard drive. My hard drive files are automatically backed up to NAS. The NAS backup is periodically copied and saved to another hard drive that is kept off line except when the off-line back-up process is being done. So, I’m confident that I still have the original image file backed up somewhere.

  3. When Windows 10 installed, the image still appeared. The problem occurred when I wanted to share the image with a friend, and discovered that I could not find the original file.

  4. I’ve been looking for a solution to this on-line for more than a month now. The on-line forums are flooded with variations of the basic question “where is my wallpaper/image file stored.” So far I’ve only see a couple of questions about a user-specified image. Nearly all of Q & A presume that the only images in question are MS Spotlight or Windows default. The more responsive answers involved searches for Transcoded files in various different subdirectories many levels down. These files are then copied and renamed with a .jpg suffix so they can be displayed. Insanely labor intensive (the block rename function does not appear to function the same way in W 10 as I remember it, and I haven’t taken the time to figure it out. At this point I estimate I have at least 60 hours of effort in this. (Yes, I’m Irish.)

In fact, the consensus on a couple of the forums is simply that “this information is not available in Windows 10.”

At this point, as noted in the original, I have exhausted all the suggestions.

  1. I also have the original file name from the e-mail. It has the original attachments, but the last time I tried to load them, the search process went on interminably. I have tried searching the entire C: Drive for the filename and no files were found. In the process of putting this edit together I tried again. The Windows search returned no file found. This time, the attachment image displayed. I can right click on it, and display File Info (which I surmise is what Properties have become in W 10. The Source is “This PC” and the Location is not specified.

  2. As to why I find this outrageous…The PC I am working on is my property. The picture is someone else’s intellectual property, but in an IP sense I “own” the rights to personal use of the image. Had I not saved the e-mail without detaching (as opposed to saving) I would have lost all further use of it. The fact that the image still appears as my lock screen shows that it is saved as part of the Windows 10 OS resources. The fact that the effect of the W10 update has effectively hidden a piece of intellectual property that had I saved on my own system prior to the update, and hid it so that I can’t find and use it, is what’s outrageous. And it’s outrageous whether or not I backed it up properly. But blaming the victim being all the rage. . .

  3. One of the respondents asked if I was saying that MS stole the image. Not at all. I am saying that the net result of the W10 update was to deny me my ability to access and use this image as I had previously.

Again apologies to the group for the inadequate initial post. Even though I was able to get the image by other means, I hope the group will still take on the question. This is a very real issue, and none of the suggestions that I’ve seen or tried have addressed it adequately. The vast majority simply assume that the user will never want to use anything but the Spotlight files and point them there.

James.

PS. Kudo’s on the design of this site. The real-time preview is a tremendous help. I don’t fully understand why seeing the same thing in a different context makes such a difference, but it does. The Register does something similar and it shows in the quality of the discussion. Thanks.

After many days, I have exhausted all options. My lock screen image is
a very special astronomical image, created by a close friend that I
went to high school with over 50 years ago. Have been through a couple
of dozen different “solutions” from the different “expert” forums.

The image an thumbnail shows up in t the Settings>Personalize>Lock
Screen, but the Right Click does not reveal properties.

This image was a gift for my personal use. Rights to it remain the
exclusive property of the originator. I cannot express how outrageous
this situation it.

I’ve been able to accomplish this by opening a folder here:

C:ProgramDataMicrosoftWindowsSystemData<SID>ReadOnlyLockScreen_A

In this path, the <SID> is the security identifier for the user in question. This could be found by executing the following in a Command Prompt assuming this user is currently logged on:

whoami /user

In the end, the path would look something like:

C:ProgramDataMicrosoftWindowsSystemDataS-1-5-55-555555555-555555555-5555555555-555555ReadOnlyLockScreen_A

Also note that the LockScreen_A could be LockScreen_B (or alphanumerically incremented) if this is not the first lock screen background.

Though I work for Microsoft, I’m posting this as a user and not as an official endorsement of this method.

Tagged : / /

Math Genius: n-ary generalizations of De Morgan’s Laws

Original Source Link

$a)$ State the n-ary generalizations of De Morgan’s Laws.

$b)$ Pick one of these generalizations and prove it by induction.

What does this even mean… I know what de morgan’s laws are but I have never heard of the $n$-ary generalizations.

de Morgan’s Laws express the negation duality between bivariate operators $lor$ and $land$. $$lnot(p_1land p_2)=lnot p_1lorlnot p_2\lnot(p_1lor p_2)=lnot p_1landlnot p_2$$

The n-ary extension of these Laws states that this duality also holds for n-tuple series of these operators.
$$lnotbigwedge_{k=1}^n p_k=bigvee_{k=1}^n lnot p_k\lnotbigvee_{k=1}^n p_k=bigwedge_{k=1}^n lnot p_k$$

Where $displaystyle{smallbigwedge_{k=1}^n} p_k = p_1wedge p_2wedge p_3wedgecdotswedge p_n$ and such.


Now it clearly the expressions shall hold for $n=1$.$$bigwedge_{k=1}^1 p_k=p_1qquad,qquadbigvee_{k=1}^1p_k=p_1qquad,qquad lnot(p_1)=lnot p_1$$

Also the expressions hold for $n=2$ because the 2-ary expressions are deMorgan’s laws.

Now you must prove that if they hold for any positive natural number $n$, they shall hold for its successor, $n+1$.
$$forall ninBbb N^+~left(left(lnotbigwedge_{k=1}^n p_k=bigvee_{k=1}^n lnot p_kright)toleft(lnotbigwedge_{k=1}^{n+1} p_k=bigvee_{k=1}^{n+1} lnot p_kright)right)\forall ninBbb N^+~left(left(lnotbigvee_{k=1}^n p_k=bigwedge_{k=1}^n lnot p_kright)toleft(lnotbigvee_{k=1}^{n+1} p_k=bigwedge_{k=1}^{n+1} lnot p_kright)right)$$

Tagged : / / / /

Server Bug Fix: NGINX – 404 redirect not working, returning an error code 500

Original Source Link

I’ve recently setup NGINX and had to implement various redirects to manage pages from our older websites that were still returning hits in Google (and other various linked pages).

Some of these links we have to redirect to explicit locations but the rest should just be redirected to the root directory /.

I have been asked to redirect any 404, 500 and 501 pages back to the root directory. I thought this would be fairly easy to achieve using the error_page directive. My server block contains the following

error_page 404 500 501 = @redir;

location @redir
{
    rewrite .* / redirect;
}

In my log files I see the following when I request random non existant files

x.x.x.x - - [02/Mar/2012:11:25:42 +0000] "GET /fgfg.jpg HTTP/1.1" 500 799 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11"

This now brings up two questions:

  1. Why is this returning a 500 error rather than a 404?
  2. Why isn’t the 500 redirecting as that’s being handled by the error_page section??

Here is the whole server block

server
{
    listen       x.x.x.x:80;
    server_name  www.blah.com;

    access_log  /var/www/www.blah.com/log/access.log;
    error_log   /var/www/www.blah.com/log/error.log;

    root /var/www/www.blah.com/public;
    passenger_enabled on;

    error_page 404 500 501 = @redir;

    location @redir
    {
        rewrite .* / redirect;
    }

    location ~* "/Managed Services"
    {
        rewrite .* /managed_services permanent;
    }

    location ~* /solutions_arch.asp
    {
        rewrite .* /arch permanent;
    }

    location ~* .*.(php|asp)$
    {
        rewrite .* / permanent;
    }
}

Any ideas?

I can answer my first question

It turns out the reason this wasn't working was because the requests were being passed through to rails and then the default controller was returning an error 500 because the view/page didn't exist!

I still don’t know why the 500 error wasn’t being picked up by NGINX. I did notice that the 500 error is still returning the default 500.html page. For me to work around it I’ve just done a meta refresh which is ugly but works for now.

Ideally I’d like a proper redirect though.

Tagged :

Ubuntu HowTo: This update does not come from a source that supports changelogs

Original Source Link

When I get an update via update-manager for a software like blender/vlc, I like to see what has been fixed/changed. But the software updater doesn’t show me the changes from a ppa added software.

I added the ppa for blender/vlc (this only applies to the software I added a ppa for)

sudo add-apt-repository ppa:cheleb/blender-svn
sudo apt-get update
sudo apt-get install blender

And vlc like this.

sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get install vlc

And when i run update-manager, or update manager pop-ups
I see that vlc/blender have updates but, I can’t see what has been changed/fixed

this is the message I get, the screenshot below is for mupen but it’s the same thing.
(I updated vlc and blender, didn’t wanna wait for the next update)

update-manager-ppa-update-error?

This update does not come from a source that supports changelogs.

(by the way I have a dutch Ubuntu, so the above text i Google translated it!)
It only shows which version you have and to which version you be upgrading to.

So my question is, how do I get the change-log tab of update-manager working. If it’s even possible?

PPA does not seem to support changelogs, there is even a bug reported in Launchpad about it:

Bug #253119 “PPA packages do not show a changelog in update-mana…” : Bugs : Launchpad itself

As saji89 mentioned in their answer, the bug is logged here: https://bugs.launchpad.net/launchpad/+bug/253119

And if you scroll down you can see that as of 2016, a fix was introduced that works only if you have python3-launchpadlib installed on your system. So I ran apt install python3-launchpadlib and the changelogs seem to be showing up for me now.

Tagged : /

Math Genius: Question about probability in a gacha game

Original Source Link

There is a gacha game I play that has a banner with 11 rainbow units. The pool has 116 units, all with equal chance to be pulled(dupes are allowed).
Let’s say I am interested in 11 units out of those 116, and if I pull on the banner I get 11 units.

If I want to calculate the chance to get at least one I’m interested in, in the 11 pulls, it would be 105/116(11 units are okay to get)^11(the number of units/chances I’ll get on the banner)=0,334=33%. Is this correct?

But my main question is: what if I want to know the probability of getting at least 3 units out of the 11 units I’m interested in, in 11 pulls? I have no idea how to calculate this.

TLDR: 11 units out of 116 are okay. Dupes are allowed(in all 11 pulls the total number of units in the pool will remain 116).Out of the 11 units I want, what’s the chance to get at least 3 of those in 11 pulls?

I would appreciate any help.
Sorry for the long question and thank you in advance!

Tagged :

Code Bug Fix: build.shibboleth.net gives wrong certificate for some regions

Original Source Link

One of our Jenkins builds is failing trying to connect to build.shibboleth.net. So I did some analysis.

Please look at these openssl results from 2 regions.

In South Asia region: It gives the cert of test.shibboleth.net, which is wrong.

$ openssl s_client -host build.shibboleth.net -port 443 -prexit -showcerts

CONNECTED(00000005)
depth=1 C = US, ST = Ohio, O = Shibboleth Consortium, CN = Shibboleth Project Intermediate CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=Ohio/O=Shibboleth Consortium/CN=test.shibboleth.net
   i:/C=US/ST=Ohio/O=Shibboleth Consortium/CN=Shibboleth Project Intermediate CA
...
...

In USA region: It gives the cert of shibboleth.net, which is correct.

$ openssl s_client -host build.shibboleth.net -port 443 -prexit -showcerts

CONNECTED(00000005)
depth=2 O = Digital Signature Trust Co., CN = DST Root CA X3
verify return:1
depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
verify return:1
depth=0 CN = shibboleth.net
verify return:1
---
Certificate chain
 0 s:CN = shibboleth.net
   i:C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
...
...

And resolveip build.shibboleth.net gives 3.213.250.186 from both regions.

Why is it giving a wrong certificate for one region? I have no clue how to fix this. Any ideas?

I’d speculate that the results above aren’t caused by region dependence but instead that you’re using a different version of openssl on the two client machines.

We used to run the different vhosts on different IP addresses. Now, one address is used for everything and we rely on SNI to distinguish requests so that the right certificate is returned.

If the openssl client doesn’t present the server name then you might get a default certificate instead of the one you expected. Whether openssl does that or not depends on the version of openssl in use (openssl version 1.1.1 does, earlier versions don’t).

You can try adding -servername build.shibboleth.net to your openssl command to see if that changes the behaviour.

Tagged : / / / /

Math Genius: Density function from chart

Original Source Link

I was trying to solve a problem for my class, and I don’t quite get how should I approach it. I’m supposed to find the distribution function and the moment generating function for a density function that looks like:

enter image description here

where A=50, b=60 and c=90.

I know I should get an increasing function for the interval (a,b) and a decreasing one for (b,c), but I don’t understand how to find those functions. I was hoping someone could at least point me in the right direction.

Thanks!

Tagged : / /