postgresql – Hint: There is a column named “pma_timestamp” in table “table_a”, but it cannot be referenced from this part of the query

hi i want to use a user defined function so that while inserting values in column i want to insert last_day of the month in one column by referencing other column in same table.

my code is-

insert into table_A
(id,pma_timestamp,monthend)
values
(103,’2017-08-15′,last_day(pma_timestamp));

but getting error.
how to resolve this

sharepoint online – Suggestions for creating an app or a web part in a Team Site

I would like to develop a user control with a text box where the user will enter his/her UserID and click the button to see some info which is populated by my own REST API.

Is there a web part out of box which I can leverage to do this kind of functionality?

I have a SharePoint site collection created by Teams. I’m the site collection admin of this team site. I would like to deploy in this site.

dnd 5e – Can Darkness be cast on a part of an object?

From the description of the darkness spell:

Magical darkness spreads from a point you choose within range to fill a 15-foot-radius sphere for the duration. The darkness spreads around corners. A creature with darkvision can’t see through this darkness, and nonmagical light can’t illuminate it.

If the point you choose is on an object you are holding or one that isn’t being worn or carried, the darkness emanates from the object and moves with it. Completely covering the source of the darkness with an opaque object, such as a bowl or a helm, blocks the darkness.

As you can see, darkness does not target the object itself; it targets a point you choose within range, which can be on an object. If you covered the entire object except for that one point, the darkness would still emanate and would not be blocked. On the other hand, if you block that one point on the object, then the darkness is blocked even if you don’t block the rest of the object.

In your example: you could cast darkness on a point on the blade of your dagger and then sheathe it, which would block the darkness from emanating from that point until uncovered.

Note that for the second paragraph of the spell description to apply, it has to be a point on either an object you are holding, or an object that isn’t being worn or carried. Technically, those parts of the spell would not apply if you cast the spell on any other point.

(To clarify why I say darkness originates from a point on the object rather than the object as a whole: The entire object can’t be “a point” that the darkness emanates from. The point of origin of the spell is a single point. If that point is on an object you’re holding or an object that’s not worn/held, then the point of origin “sticks” to that point on the object – but the entire object can’t serve as the spell’s single point of origin.)

What is the hardest part of managing your company’s finance? | Proxies-free

Personally,I wouldn’t want someone to manage my business finance for me.A lot of persons have got themselves burnt badly in the process of hiring some dubious cashiers, account officers and Accountants.

If these employees don’t abscond with your money,they double or triple the prices of expenditures, which is totally unhealthy for a growing business.

The best bet is to handle every financial transaction yourself,so as to reduce cost and conserve more money for future use.

Then bring in experts like the auditors to vet the account books,this way you will be fully aware of the company’s financial state.

Generating and Using SSH Keys, Part 2

In the previous tutorial, we showed you how to generate an SSH key pair.  In this tutorial, we’ll show you how to use it to login.

In this tutorial:

  • Your ssh key file is called “my-ssh-key”.
  • The server is “myserver.example.com” and your user account there is “example”.
  • SSH is running on port 22, the default.

If you were to connect to the server without using a key, you’d be prompted for a password.  We will now configure your account to use SSH key as its preferred authorization.

Note that you don’t need to be root to do this.  Assuming your server is configured with reasonable defaults, this method will work on any Unix-based server (Linux, BSD, etc.). 

We are not specifically setting up ssh keys for root, but these instructions will work for root as well.  Normally you do not want to directly login as root but rather as an unprivileged user, and then either su to root or use sudo.

We can use the very handy OpenSSH utility ssh-copy-id to save a lot of time.  Invoke it as follows.

    $ ssh-copy-id -i ~/.ssh/my-ssh-key example@myserver.example.com
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/example/.ssh/my-ssh-key.pub"
    The authenticity of host 'myserver.example.com (x.x.x.x)' can't be established.
    ECDSA key fingerprint is SHA256:HIi6F+IIkSOLHWUNR8l70WgdNrFlTORdZoZcrD5s4p4.
    Are you sure you want to continue connecting (yes/no/(fingerprint))? yes
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    example@myserver.example.com's password: (enter your password here)
    Number of key(s) added:        1
    Now try logging into the machine, with:   "ssh 'example@myserver.example.com'"
    and check to make sure that only the key(s) you wanted were added.

Now let’s try to login:

    $ ssh -i ~/.ssh/my-ssh-key example@myserver.example.com
    Enter passphrase for key '/home/example/.ssh/my-ssh-key': (enter your SSH passphrase)
    (example@my-server~)$ 

And you’re good to go!  If you want to see what ssh-copy-id did, take a look at ~/.ssh on your server:

    $ ls -ld ~/.ssh
    drwx------ 2 example example 4096 Apr  2 23:18 /home/example/.ssh
    $ ls -l ~/.ssh/
    total 4
    -rw------- 1 example example 580 Apr  2 23:18 authorized_keys
    $ cat ~/.ssh/authorized_keys 
    ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGPw+oAB0cfuJAaHWaEmXsgJzVm1B4+OP8Qr3ZL9nJf0 ssh key for your@email.com

ssh-copy-id has done the following:

  1. Created a directory in your home directory called .ssh and set ownership to you
  2. Set permissions on ~/.ssh to mode 700 (drwx——)
  3. Copied your public key to a file called ~/.ssh/authorized_keys
  4. Set the authorized_keys file permissions to mode 600 (rwx——)

Unfortunately, PuTTY does not come with the handy ssh-copy-id utility, so we’ll need to do the server setup manually.

You’ll need your *pastable public* key file handy.  You may recall in the last tutorial we copied the section of puttygen called “Public key for pasting into OpenSSH authorized_keys file” and saved it to a file called “my-ssh-key pastable.txt”.  That is the file you need here.  It’s small enough you can copy/paste the contents.

Login to your server and type the following commands to create the .ssh directory:

    ( ! -d ~/.ssh ) && mkdir ~/.ssh
    chmod 700 ~/.ssh

In that directory, either create or edit a file called authorized_keys (note there is no extension).If it already exists, then you can can edit it and paste the contents of your public key to the end of the file.  If it doesn’t exist, just paste in your public key.  Save the file and quit your editor.

When you’re done, set permissions:

    chmod 600 ~/.ssh/authorized_keys

Now try to login using PuTTY.  We’ll start by setting up an entry for this host.  Scroll down to the SSH section on the left and click Auth.  Then browse for your SSH *private* key:

PuTTY Browse for Private Key

Next click on Connection->Data on the left and enter your username under “Auto-login Username”.  This is so you don’t have to type the username every time.

PuTTY Username

Now go back to Session on the left menu and enter the hostname (or IP) at the top.  Enter a name for this session under “Saved Sessions” and click Save.

PuTTY Save Session

Now go ahead and try logging in.  Answer Yes to the warning about the host key – this simply means it’s not cached in your local list of known hosts.

PuTTY Login 1

PuTTY Login 2

The vast majority of issues logging in with ssh keys are a misconfiguration on the server.  All of the following must be true for SSH key authorization to work:

  1. You must have a directory called .ssh in your home directory (the name can be reconfigured by root but is very rare).
  2. This directory must be owned by you and set to mode 700 (drwx——) so only you can enter it.
  3. You must have a file in this directory called authorized_keys that contains the public key.  Note that if you’re using puttygen.exe, it’s the *pastable* publickey.
  4. This authorized_keys file must be mode 600 (rw——-) so only you can read it.

If you get a Password: prompt instead of being prompted for your SSH keyphrase, check that all of these four conditions are true.

In the next Tutorial, we’ll show you how to significantly harden your server by disabling password authentication so that only SSH key authentication is accepted.

raindog308

I’m Andrew, techno polymath and long-time LowEndTalk community Moderator. My technical interests include all things Unix, perl, python, shell scripting, and relational database systems. I enjoy writing technical articles here on LowEndBox to help people get more out of their VPSes.

typescript – Storing localStorage data as part of rxjs reducer?

I use ngrx in my Angular app to state management. At a certain time I was asked to save some variable to local storage and retrieve it with first load.
That made sense to make it as part of the effects, instead of managing one logic for localStorage and another logic for the selectors. So this is what I did;

I extended ngrx Action class as following:

import { Action } from '@ngrx/store';

export class StorableAction implements Action {
    type: string;
    payload?: any;
    localStorageKey?: string;
}

Implemented it in the actions (snapshots.actions.ts):

export class ChangeResolutionWidth implements StorableAction {
    public readonly type = ESnapshotsActionType.ChangeResolutionWidth;
    public readonly localStorageKey = LocalStorageKey.SnapshotsResolutionWidth;

    constructor(public payload: number) { }
}

Then in snapshots.effects.ts:

constructor(
    private channelsService: ChannelsService,
    private actions$: Actions,
    private store: Store<SnapshotsState>
) {
  this.actions$.subscribe(
    (action: StorableAction) => {
      if (action.localStorageKey && action.payload){
        localStorage.setItem(action.localStorageKey, JSON.stringify(action.payload));
      }
    })
  }

Now, whenever I load a component, I do this.store.select with take(1) to selectResolutionWidth (in the example above). If the value is undefined, then I take it from the localStorage and dispatch it. That felt like a sweet solution – whenever I needed to store some state value to the local storage, all I needed is to use StorableAction instead of Action and name the key.

My questions are:

  1. would you say it is a proper implementation of store effects, or am I bending the separation of concerns principal?
  2. Now I’ve come to a scenario in which I need to store a value to the local storage that is actually not needed in the state (I only use it in one component). That brings up a conflict – should I use the same mechanism I created, or store to the local storage directly (which will cause a duplication, when localStorage is being managed both in state level and component level). What’s better?

Thanks!

terminology – Is there a name for this kind of mini-game? (cursor moves on a bar, press key in part of the bar to win)

Today I played a game which has a mini-game in it, basically it looks like this:

here’s a bar:

----------=====----------

and a cursor moves back and forth on it:

-|--------=====----------  ( cursor "|" moves in this direction -> )

-----|----=====----------

----------===|=----------

----------=====---------|  ( when the cursor reaches the end, it goes back <-)

If I hit a key when the cursor is on the specific part of the bar (which I used the “=” sign to represent), I win. Otherwise I lose.

This kind of mini-game is pretty common as I’ve seen many variant of it in a lot of games, yet I don’t know the name of it. Does it have a name? What’s the origin of it?