now.sh | Pipeable bash script that prints current time | Command Line Interface library
kandi X-RAY | now.sh Summary
kandi X-RAY | now.sh Summary
A simple shell script that prints current date/time while waiting for an input and echoing it to the stdout. It is particularly useful with [tail] when following log files. Instead of -. where the last line is reprinted every second with current time. This gives an idea of when the last log activity was without needing to remember what the server time zone is or what the "-0800" translates to in your local time.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of now.sh
now.sh Key Features
now.sh Examples and Code Snippets
Community Discussions
Trending Discussions on now.sh
QUESTION
I have a Vue 2 pattern I was using for a common scenario: programmatically creating an instance to open a Modal/Dialog/Lightbox on dynamic content outside of a template.
In Vue 2, I found this pattern:
...ANSWER
Answered 2021-Oct-27 at 07:24Vue 3 doesn't provide a generic event bus. It can be replaced with lightweight third-party alternatives like mitt
or eventemitter3
.
A component can be mounted outside application element hierarchy with a teleport. This has been previously available in Vue 2 with third-party portal-vue
library. Modals and other screen UI elements are common use cases for it
QUESTION
I have a terminal application that is currently written in Bash, about 20,000 SLOC. One thing that I like about the way that it's set up is that it is quite modular. Different components are spread across different files, which can be executed at run time. This means that parts of the system can be "hot swapped" or updated during runtime without needing to kill the main program and re-execute it.
The disadvantage is there is a lot of database I/O, which makes it super janky since Bash is really not suited for this. Currently, it interfaces with HTTP APIs which spawn PHP.
I'd like to rewrite it natively in PHP (CLI) to cut out the middleman layer, so the application can communicate directly with the database, making maintenance much easier. One problem I've been pondering though is how to replicate the same modularity with Bash. With Bash, if I call script A, and I make a change to script B, and then I enter script B from script A (assuming it's in a conditional block somewhere, not right at the top of the file), the changes are picked up without needing to re-execute script A, since script B isn't interpreted until it gets executed.
I'm struggling to figure out how to achieve this with PHP. For instance, this will not work:
include('script.php');
The reason is that includes are all executed when the script is interpreted, not when it is executed at run time.
A similar question has been asked already, but it doesn't specifically address this aspect, just how to launch another script in general. I want to basically be able to spawn the script anew at runtime, when the application decides it should be executed. shell_exec
and passthru
seem to be all that is built into PHP that would be similar, but I'm not sure this is right since that's just spawning another system shell and doing it there, so it's not as "direct" as with Bash.
What would be the proper equivalent in PHP of this in Bash:
...ANSWER
Answered 2021-Jun-29 at 08:28Against all recommendations you could:
QUESTION
I currently retrieve my organization (family) Google Calendars via the Google Calendar API, using Python.
For reference, the credentials file used in both cases is ((...)
is redacted information)
ANSWER
Answered 2021-May-05 at 15:30The result you are getting is normal, the problem is that you are not performing Domain-Wide Delegation correctly. I come to this conclusion because of the following scenarios:
Calendar Id:
john@example.com
. If the service account has not impressed the user, it is expected that the user's calendar will not be found.Calendar Id:
primary
. If the primary calendar of the service account does not have any events, it is expected that thelist
method does not return any results.
Comparing your code with the one in the documentation, I don't see where you place config.Subject = userEmail
, as @DalmTo says. Try the following code to create the calendar service:
QUESTION
From what I can tell, redux will notify all subscribers to the store when anything in the store changes no matter if it's a subscription to a deeply nested leaf or a subscription to the top level of the state.
In an application where you follow the guiding principle:
many individual components should be connected to the store instead of just a few... [docs]
You could end up with lots of listeners and potentially performance issues?
Disclaimer: I understand that the selector functions will only cause a re-render if the result of the selector function changes. I understand that just because the listener function is evaluated, doesn't mean the subscribing component will re-render. I understand that evaluating a selector function is comparatively cheap to a react component rendering.
However, I just would like to confirm that this is indeed how redux works?
e.g. given the following example listener
...ANSWER
Answered 2021-Jan-20 at 11:28From what I can tell, redux will notify all subscribers to the store when anything in the store changes no matter if it's a subscription to a deeply nested leaf or a subscription to the top level of the state.
Yes, all subscribers are notified. But notice the difference between Redux and its React-Redux utils.
You could end up with lots of listeners and potentially performance issues?
With React-Redux you subscribe to a store (of Redux) by having a selector (useSelector
/connect
).
By default, every subscribed component in React-Redux will be rerendered if its subscribed store portion changed, to handle it you pass a selector which bailout the renders.
But for Redux:
- The notification itself handled by Redux (outside React).
- Redux doesn't handle the "deeply nested leaf" (React Context API handles it as part of React-Redux implementation) it doesn't handle locations - it just calling callbacks.
- The notifications are batched in a while loop outside the React context (optimized).
QUESTION
I'm new to front-end development and nodejs / react so please bear with me if this is a silly question.
I was trying to learn by using this open project: https://github.com/ilhammeidi/boss-lite
In the readme, it states pretty clearly on how to deploy this react project:
- Clone this project
- Install module dependencies by run this script in terminal
npm install
- After finish downloading, then run the app.
npm run dev
- Navigate to http://localhost:8080
However I cannot get even the first npm install step right on my Ubuntu 18.04:
...ANSWER
Answered 2021-Apr-14 at 18:37These errors were simply due to the packages being obsolete for your OS.
Just update them by running,
npm update --force
This will install the latest versions of these packages. This will take a while depending on your internet connection.
Then run npm start
and it works.
QUESTION
I'm new to React and I'm trying to implement this example: https://react-selectable-fast.now.sh/ I couldn't make it work, because I can't solve this error: TypeError: Cannot read property 'getClientRects' of null.
This is my code:
...index.jsx
ANSWER
Answered 2021-Feb-25 at 13:27I solved it. The problem was in SomeComponent.jsx
.
Solution:
Delete
QUESTION
I am using the library micromodal.js to handle the functionality of my (accessible) modal dialogs.
Having read recommendations about a11y best practices, I have learned that the modal should get a tabindex="-1"
in order to "trap" the tabbing user (or screen reader) in the modal dialog.
One of the modals I am using it for has scrollable content section. In order to facilitate the content to be focusable and therefore scrollable by arrow keys, I added tabindex="0"
to the section.
On mobile devices it is not the content that should be scrollable, but the whole modal.
The issue that this solution creates is: when opening the modal on smaller screens, the content is focussed first (due to tabindex of 0 being larger than tabindex of -1, I guess?) and the whole header of the modal is not visible.
The desired behavior is that the modal header is visible when it opens. How could I achieve that with still providing an accessible UX?
Code example: https://codepen.io/AstiV/pen/vYKopNZ
...ANSWER
Answered 2020-Nov-26 at 21:07First of all, you need to review carefully the difference between tabindex=0 and tabindex=-1. Setting tabindex=0 means that the element is focusable, both manually with tab key and automatically via script. Setting element to tabindex=-1 means that only a script can set focus on it, while it isn't possible to focus the element manually.
Knowing this, you should understand what you did wrong. The most obvious solution would be to focus the element with tabindex=-1 when your modal is shown. If for any reason it's much more logical to have the element with tabindex=0 focused when the modal is opened, then you may first focus the element with tabindex=-1, wait for a short while (50-100ms), and then focus the element with tabindex=0.
Concerning scroll, normally, focusing any element (with whatever tabindex or none) should automatically bring it into view it it isn't yet visible, but if is already visible then the scroll shouldn't change. So even by focusing the element with tabindex=-1 and then the one with tabindex=0, the element with tabindex=-1 should stay visible.
QUESTION
I use Black for Python, which conforms to PEP8. It removes the indentation from the second line of a two line long value string:
...ANSWER
Answered 2020-Oct-09 at 20:40The Black code style was the right place to check and you are right, it's not super clear for this use-case. I can say if you don't split the string of the value into two strings then Black will put it on one line which you may prefer. I'm not sure Black has a good way to know when it can concatenate 2 strings to one when it makes sense - see discussion here.
e.g
QUESTION
I was following this tutorial on how to build a whiteboard with react and konva and it provides an undo function for shapes but does not work for lines because lines are not added to the layer in the same way. How can I implement undo for free draw line?
EDIT:
To expand on my question, here is the relevant code:
I have a public repo that you can check out (and make a PR if that's easier).
https://github.com/ChristopherHButler/Sandbox-react-whiteboard
I have also have a demo you can try out here:
https://whiteboard-rho.now.sh/
Here is the relevant code
line component:
...ANSWER
Answered 2020-Sep-11 at 15:19If I understand this right you saying that for shapes which are added individually there is an easy 'undo' process, but for lines which use an array of points for their segments, there is no simple undo - and no code in the tutorial you are following?
I can't give you a react code sample but I can explain some of the concepts you need to code up.
The 'freehand line' in your whiteboard is created as a sequence of points. You mousedown and the first point is noted, then you move the mouse and on each movemove event that fires the current mouse position is added to the end of the array. By the time you complete the line and mouseup fires, you have thrown multiple points into the line array.
In the Konvajs line tutorial it states:
To define the path of the line you should use points property. If you have three points with x and y coordinates you should define points property as: [x1, y1, x2, y2, x3, y3].
[Because...] Flat array of numbers should work faster and use less memory than array of objects.
So - your line points are added as separate values into the line.points array.
Now lets think about undo - you are probably there already but I'll write it out anyway - to undo a single segment of the line you need to erase the last 2 entries in the array. To erase the entire line - well you can use the standard shape.remove() or shape.destroy() methods.
In the following snippet the two buttons link to code to 'undo' lines. The 'Undo by segment' button shows how to pop the last two entries in the line.points array to remove a segment of the line, and the 'Undo by line' button removes entire lines. This is not a react example specifically, but you will in the end create something very close to this in your react case.
QUESTION
I found out that I could use Python to create a serverless function inside a Next.js project. Once deployed to Vercel, it will get converted into a serverless function.
I went through the docs and found a simple example that outputs the date:
...ANSWER
Answered 2020-Sep-05 at 16:18After going over the FAQs. I found an entry named Unmatched Function Pattern, it states:
the functions property uses a glob pattern for each key. This pattern must match Serverless Function source files within the
api
directory.
It also mentions:
if you'd like to use a Serverless Function that isn't written with Node.js in combination with Next.js, you can place it in the
api
directory (provided by the platform), sincepages/api
(provided by Next.js) only supports JavaScript.
I think that this needs to be clarified a bit. There is indeed an default api
folder when you bootstrap a Next.js project with create-next-app
, but it's created inside the pages
directory.
If you follow the example they give, you might just go ahead and create a serverless function in a supported language (other than JavaScript) inside the pages/api
directory and wonder why Vercel doesn't pick it up when you deploy.
In short, if you're using another language to write a serverless function inside a Next.js project. Be sure to place it inside an api
folder that sits in the root directory of the project (if there's none, create one).
Thanks to @evgenifotia for the suggestion, it pointed me in the right direction and helped me solve this issue.
Note: You can only have a single api
directory that houses serverless functions. Either you have a pages/api
directory or a api
directory in the root folder, having both in a single project is not supported.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install now.sh
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page